# This file was auto-generated by Fern from our API Definition.

from ...core.pydantic_utilities import UniversalBaseModel
from .contract_recurrence_id import ContractRecurrenceId
from .contract_id import ContractId
import pydantic
from .contract_invoice_schema import ContractInvoiceSchema
import typing
from ...invoice_types.types.invoice_id import InvoiceId
import datetime as dt
from ...core.pydantic_utilities import IS_PYDANTIC_V2


class ContractRecurrenceResponse(UniversalBaseModel):
    """
    Examples
    --------
    import datetime

    from mercoa.contract_types import (
        ContractInvoiceLineItemSchema,
        ContractInvoiceSchema,
        ContractRecurrenceResponse,
    )

    ContractRecurrenceResponse(
        id="cntrec_0b2d48a7-38e8-44e1-9abc-95e0e67eb484",
        contract_id="cnt_3bd62b69-3835-433e-829f-4388a2e46c41",
        rrule="DTSTART:20250201T000000ZRRULE:FREQ=MONTHLY;INTERVAL=1;BYMONTHDAY=1",
        justification="Monthly recurring fee billed in advance on the 1st of each month",
        filtered_contract_summary="Contract Start Date: January 29, 2025\nParties to the Agreement:\n- Provider (Vendor): [Vendor Name] - Client (Payer): [Client Name]\nFees and Payment Terms:\n- Monthly Recurring Fee: \\$20.00 - Payment Schedule: Fees are payable in advance on the 1st day of each month. - First Payment Date: February 1, 2025 - Payment Method: Via credit card to the account designated by Provider. - Payment Due Date: Payment is due 5 days after the invoice date.\n",
        invoice_schema=ContractInvoiceSchema(
            line_items=[
                ContractInvoiceLineItemSchema(
                    name="Monthly Subscription Service Fee",
                    unit_price=20.0,
                    currency="USD",
                    quantity=1.0,
                )
            ],
        ),
        created_invoice_ids=["in_8545a84e-a45f-41bf-bdf1-33b42a55812c"],
        created_at=datetime.datetime.fromisoformat(
            "2025-01-29 00:00:00+00:00",
        ),
        updated_at=datetime.datetime.fromisoformat(
            "2025-01-29 00:00:00+00:00",
        ),
    )
    """

    id: ContractRecurrenceId
    contract_id: ContractId = pydantic.Field(alias="contractId")
    rrule: str = pydantic.Field()
    """
    RFC 5545 RRULE string
    """

    justification: str = pydantic.Field()
    """
    Natural language justification for the recurrence
    """

    filtered_contract_summary: str = pydantic.Field(alias="filteredContractSummary")
    """
    Natural language summary of the contract, filtered to only include information relevant to the recurrence
    """

    invoice_schema: ContractInvoiceSchema = pydantic.Field(alias="invoiceSchema")
    """
    Schema of the invoices to be created by this recurrence
    """

    created_invoice_ids: typing.List[InvoiceId] = pydantic.Field(alias="createdInvoiceIds")
    """
    IDs of invoices created by the recurrence
    """

    created_at: dt.datetime = pydantic.Field(alias="createdAt")
    updated_at: dt.datetime = pydantic.Field(alias="updatedAt")

    if IS_PYDANTIC_V2:
        model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True)  # type: ignore # Pydantic v2
    else:

        class Config:
            frozen = True
            smart_union = True
            extra = pydantic.Extra.allow
