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

import typing

import pydantic
import typing_extensions
from ...core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
from ...core.serialization import FieldMetadata
from ...types.accounting_field import AccountingField
from ...types.additional_data_string import AdditionalDataString
from ...types.bill_approvals import BillApprovals
from ...types.bill_events import BillEvents
from ...types.bill_id import BillId
from ...types.billitems import Billitems
from ...types.billstatus import Billstatus
from ...types.comments import Comments
from ...types.created_at import CreatedAt
from ...types.datenullable import Datenullable
from ...types.dbaname import Dbaname
from ...types.documents_ref import DocumentsRef
from ...types.entity_id import EntityId
from ...types.entrypointfield import Entrypointfield
from ...types.external_paypoint_id import ExternalPaypointId
from ...types.frequency import Frequency
from ...types.last_modified import LastModified
from ...types.legalname import Legalname
from ...types.org_parent_id import OrgParentId
from ...types.org_parent_name import OrgParentName
from ...types.paylink_id import PaylinkId
from ...types.terms import Terms
from ...types.transaction_out_query_record import TransactionOutQueryRecord
from ...types.vendor_data_response import VendorDataResponse


class BillResponseData(UniversalBaseModel):
    id_bill: typing_extensions.Annotated[typing.Optional[BillId], FieldMetadata(alias="IdBill")] = None
    bill_number: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="BillNumber")] = pydantic.Field(
        default=None
    )
    """
    Unique identifier for the bill.
    """

    net_amount: typing_extensions.Annotated[typing.Optional[float], FieldMetadata(alias="NetAmount")] = pydantic.Field(
        default=None
    )
    """
    Net amount owed in bill.
    """

    discount: typing_extensions.Annotated[typing.Optional[float], FieldMetadata(alias="Discount")] = pydantic.Field(
        default=None
    )
    """
    Bill discount amount.
    """

    total_amount: typing_extensions.Annotated[typing.Optional[float], FieldMetadata(alias="TotalAmount")] = (
        pydantic.Field(default=None)
    )
    """
    Total amount for the bill.
    """

    bill_date: typing_extensions.Annotated[typing.Optional[Datenullable], FieldMetadata(alias="BillDate")] = (
        pydantic.Field(default=None)
    )
    """
    Date of bill. Accepted formats: YYYY-MM-DD, MM/DD/YYYY
    """

    due_date: typing_extensions.Annotated[typing.Optional[Datenullable], FieldMetadata(alias="DueDate")] = (
        pydantic.Field(default=None)
    )
    """
    Due Date of bill. Accepted formats: YYYY-MM-DD, MM/DD/YYYY
    """

    comments: typing_extensions.Annotated[typing.Optional[Comments], FieldMetadata(alias="Comments")] = None
    batch_number: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="BatchNumber")] = (
        pydantic.Field(default=None)
    )
    """
    The batch number that the bill belongs to.
    """

    bill_items: typing_extensions.Annotated[typing.Optional[Billitems], FieldMetadata(alias="BillItems")] = (
        pydantic.Field(default=None)
    )
    """
    Array of `LineItems` contained in bill.
    """

    mode: typing_extensions.Annotated[typing.Optional[int], FieldMetadata(alias="Mode")] = pydantic.Field(default=None)
    """
    Bill mode: value `0` for single/one-time bills, `1` for scheduled bills.
    """

    payment_method: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="PaymentMethod")] = (
        pydantic.Field(default=None)
    )
    """
    Payment method used for the bill.
    """

    payment_id: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="PaymentId")] = pydantic.Field(
        default=None
    )
    """
    Payment ID associated with the bill.
    """

    accounting_field_1: typing_extensions.Annotated[
        typing.Optional[AccountingField], FieldMetadata(alias="AccountingField1")
    ] = None
    accounting_field_2: typing_extensions.Annotated[
        typing.Optional[AccountingField], FieldMetadata(alias="AccountingField2")
    ] = None
    terms: typing_extensions.Annotated[typing.Optional[Terms], FieldMetadata(alias="Terms")] = None
    source: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="Source")] = pydantic.Field(
        default=None
    )
    """
    The source of the bill, such as "API" or "UI".
    """

    additional_data: typing_extensions.Annotated[
        typing.Optional[AdditionalDataString], FieldMetadata(alias="AdditionalData")
    ] = None
    vendor: typing_extensions.Annotated[typing.Optional[VendorDataResponse], FieldMetadata(alias="Vendor")] = None
    status: typing_extensions.Annotated[typing.Optional[Billstatus], FieldMetadata(alias="Status")] = None
    created_at: typing_extensions.Annotated[typing.Optional[CreatedAt], FieldMetadata(alias="CreatedAt")] = None
    end_date: typing_extensions.Annotated[typing.Optional[Datenullable], FieldMetadata(alias="EndDate")] = (
        pydantic.Field(default=None)
    )
    """
    End date for scheduled bills. Applied only in `Mode` = 1.
    """

    last_updated: typing_extensions.Annotated[typing.Optional[LastModified], FieldMetadata(alias="LastUpdated")] = None
    frequency: typing_extensions.Annotated[typing.Optional[Frequency], FieldMetadata(alias="Frequency")] = (
        pydantic.Field(default=None)
    )
    """
    Frequency for scheduled bills. Applied only in `Mode` = 1.
    """

    transaction: typing_extensions.Annotated[
        typing.Optional[TransactionOutQueryRecord], FieldMetadata(alias="Transaction")
    ] = pydantic.Field(default=None)
    """
    MoneyOut transaction associated to the bill
    """

    bill_events: typing_extensions.Annotated[typing.Optional[BillEvents], FieldMetadata(alias="billEvents")] = None
    bill_approvals: typing_extensions.Annotated[
        typing.Optional[BillApprovals], FieldMetadata(alias="billApprovals")
    ] = None
    paypoint_legalname: typing_extensions.Annotated[
        typing.Optional[Legalname], FieldMetadata(alias="PaypointLegalname")
    ] = None
    paypoint_dbaname: typing_extensions.Annotated[typing.Optional[Dbaname], FieldMetadata(alias="PaypointDbaname")] = (
        None
    )
    parent_org_id: typing_extensions.Annotated[typing.Optional[OrgParentId], FieldMetadata(alias="ParentOrgId")] = None
    parent_org_name: typing_extensions.Annotated[
        typing.Optional[OrgParentName], FieldMetadata(alias="ParentOrgName")
    ] = None
    paypoint_entryname: typing_extensions.Annotated[
        typing.Optional[Entrypointfield], FieldMetadata(alias="PaypointEntryname")
    ] = None
    paylink_id: typing_extensions.Annotated[typing.Optional[PaylinkId], FieldMetadata(alias="paylinkId")] = None
    documents_ref: typing_extensions.Annotated[typing.Optional[DocumentsRef], FieldMetadata(alias="DocumentsRef")] = (
        pydantic.Field(default=None)
    )
    """
    Object with the attached documents.
    """

    external_paypoint_id: typing_extensions.Annotated[
        typing.Optional[ExternalPaypointId], FieldMetadata(alias="externalPaypointID")
    ] = None
    lot_number: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="LotNumber")] = pydantic.Field(
        default=None
    )
    """
    Lot number of the bill.
    """

    entity_id: typing_extensions.Annotated[typing.Optional[EntityId], FieldMetadata(alias="EntityID")] = None

    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
