# 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 .query_payout_transaction_records_item import QueryPayoutTransactionRecordsItem
from .query_payout_transaction_summary import QueryPayoutTransactionSummary


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

    from payabli import (
        BillPayOutData,
        PaymentDetail,
        QueryPayoutTransaction,
        QueryPayoutTransactionRecordsItem,
        QueryPayoutTransactionRecordsItemPaymentData,
        QueryPayoutTransactionSummary,
        QueryTransactionEvents,
        VendorQueryRecord,
    )

    QueryPayoutTransaction(
        records=[
            QueryPayoutTransactionRecordsItem(
                batch_number="BT-2024321",
                bills=[BillPayOutData()],
                card_token="CardToken",
                check_number="12345",
                comments="Deposit for materials",
                created_at=datetime.datetime.fromisoformat(
                    "2022-07-01 15:00:01+00:00",
                ),
                entry_name="d193cf9a46",
                events=[QueryTransactionEvents()],
                external_paypoint_id="Paypoint-100",
                fee_amount=10.25,
                gateway="TSYS",
                id_out=236,
                last_updated=datetime.datetime.fromisoformat(
                    "2022-07-01 15:00:01+00:00",
                ),
                net_amount=3762.87,
                parent_org_name="PropertyManager Pro",
                payment_data=QueryPayoutTransactionRecordsItemPaymentData(
                    payment_details=PaymentDetail(
                        total_amount=100.0,
                    ),
                ),
                payment_id="12345678910",
                payment_method="ach",
                payment_status="Processed",
                paypoint_dbaname="Sunshine Gutters",
                paypoint_legalname="Sunshine Services, LLC",
                source="api",
                status=1,
                total_amount=110.25,
                vendor=VendorQueryRecord(
                    additional_data={
                        "key1": {"key": "value"},
                        "key2": {"key": "value"},
                        "key3": {"key": "value"},
                    },
                    created_date=datetime.datetime.fromisoformat(
                        "2022-07-01 15:00:01+00:00",
                    ),
                ),
            )
        ],
        summary=QueryPayoutTransactionSummary(
            total_pages=391,
            total_records=7803,
            total_amount=21435.95,
            total_net_amount=21435.95,
            total_paid=1,
            total_paid_amount=4.0,
            total_canceled=1743,
            total_canceled_amount=4515.0,
            total_captured=138,
            total_captured_amount=542.0,
            total_authorized=4139,
            total_authorized_amount=11712.35,
            total_processing=1780,
            total_processing_amount=4660.6,
            total_open=2,
            total_open_amount=2.0,
            total_on_hold=0,
            total_on_hold_amount=0.0,
            page_size=20,
        ),
    )
    """

    records: typing_extensions.Annotated[
        typing.Optional[typing.List[QueryPayoutTransactionRecordsItem]], FieldMetadata(alias="Records")
    ] = None
    summary: typing_extensions.Annotated[
        typing.Optional[QueryPayoutTransactionSummary], FieldMetadata(alias="Summary")
    ] = 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
