# 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 .ach_holder_type import AchHolderType
from .ach_sec_code import AchSecCode
from .batch_number import BatchNumber
from .bill_data import BillData
from .datetime_nullable import DatetimeNullable
from .dbaname import Dbaname
from .device import Device
from .entrypage_id import EntrypageId
from .entrypointfield import Entrypointfield
from .external_processor_information import ExternalProcessorInformation
from .fee_amount import FeeAmount
from .legalname import Legalname
from .netamountnullable import Netamountnullable
from .operation import Operation
from .order_id import OrderId
from .org_parent_name import OrgParentName
from .orgid import Orgid
from .payor_id import PayorId
from .pending_fee_amount import PendingFeeAmount
from .query_c_fee_transaction import QueryCFeeTransaction
from .query_payment_data import QueryPaymentData
from .query_response_data import QueryResponseData
from .query_transaction_events import QueryTransactionEvents
from .query_transaction_payor_data import QueryTransactionPayorData
from .refund_id import RefundId
from .returned_id import ReturnedId
from .source import Source
from .split_funding import SplitFunding


class TransactionQueryRecords(UniversalBaseModel):
    ach_holder_type: typing_extensions.Annotated[
        typing.Optional[AchHolderType], FieldMetadata(alias="AchHolderType")
    ] = None
    ach_sec_code: typing_extensions.Annotated[typing.Optional[AchSecCode], FieldMetadata(alias="AchSecCode")] = None
    batch_amount: typing_extensions.Annotated[typing.Optional[float], FieldMetadata(alias="BatchAmount")] = (
        pydantic.Field(default=None)
    )
    """
    Batch amount.
    """

    batch_number: typing_extensions.Annotated[typing.Optional[BatchNumber], FieldMetadata(alias="BatchNumber")] = None
    cfee_transactions: typing_extensions.Annotated[
        typing.Optional[typing.List[QueryCFeeTransaction]], FieldMetadata(alias="CfeeTransactions")
    ] = pydantic.Field(default=None)
    """
    Service Fee or sub-charge transaction associated to the main transaction.
    """

    connector_name: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="ConnectorName")] = (
        pydantic.Field(default=None)
    )
    """
    Connector used for transaction.
    """

    customer: typing_extensions.Annotated[
        typing.Optional[QueryTransactionPayorData], FieldMetadata(alias="Customer")
    ] = None
    device_id: typing_extensions.Annotated[typing.Optional[Device], FieldMetadata(alias="DeviceId")] = None
    entrypage_id: typing_extensions.Annotated[typing.Optional[EntrypageId], FieldMetadata(alias="EntrypageId")] = None
    external_processor_information: typing_extensions.Annotated[
        typing.Optional[ExternalProcessorInformation], FieldMetadata(alias="ExternalProcessorInformation")
    ] = None
    fee_amount: typing_extensions.Annotated[typing.Optional[FeeAmount], FieldMetadata(alias="FeeAmount")] = None
    gateway_trans_id: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="GatewayTransId")] = (
        pydantic.Field(default=None)
    )
    """
    Internal identifier used for processing.
    """

    invoice_data: typing_extensions.Annotated[typing.Optional[BillData], FieldMetadata(alias="InvoiceData")] = None
    method: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="Method")] = pydantic.Field(
        default=None
    )
    """
    Payment method used: card, ach, or wallet.
    """

    net_amount: typing_extensions.Annotated[typing.Optional[Netamountnullable], FieldMetadata(alias="NetAmount")] = (
        pydantic.Field(default=None)
    )
    """
    Net amount paid.
    """

    operation: typing_extensions.Annotated[typing.Optional[Operation], FieldMetadata(alias="Operation")] = None
    order_id: typing_extensions.Annotated[typing.Optional[OrderId], FieldMetadata(alias="OrderId")] = None
    org_id: typing_extensions.Annotated[typing.Optional[Orgid], FieldMetadata(alias="OrgId")] = pydantic.Field(
        default=None
    )
    """
    ID of immediate parent organization.
    """

    parent_org_name: typing_extensions.Annotated[
        typing.Optional[OrgParentName], FieldMetadata(alias="ParentOrgName")
    ] = None
    payment_data: typing_extensions.Annotated[typing.Optional[QueryPaymentData], FieldMetadata(alias="PaymentData")] = (
        None
    )
    payment_trans_id: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="PaymentTransId")] = (
        pydantic.Field(default=None)
    )
    """
    Unique Transaction ID.
    """

    payor_id: typing_extensions.Annotated[typing.Optional[PayorId], FieldMetadata(alias="PayorId")] = None
    paypoint_dbaname: typing_extensions.Annotated[typing.Optional[Dbaname], FieldMetadata(alias="PaypointDbaname")] = (
        pydantic.Field(default=None)
    )
    """
    Paypoint's DBA name.
    """

    paypoint_entryname: typing_extensions.Annotated[
        typing.Optional[Entrypointfield], FieldMetadata(alias="PaypointEntryname")
    ] = pydantic.Field(default=None)
    """
    Paypoint's entryname.
    """

    paypoint_id: typing_extensions.Annotated[typing.Optional[int], FieldMetadata(alias="PaypointId")] = pydantic.Field(
        default=None
    )
    """
    InternalId for paypoint.
    """

    paypoint_legalname: typing_extensions.Annotated[
        typing.Optional[Legalname], FieldMetadata(alias="PaypointLegalname")
    ] = pydantic.Field(default=None)
    """
    Paypoint's legal name.
    """

    pending_fee_amount: typing_extensions.Annotated[
        typing.Optional[PendingFeeAmount], FieldMetadata(alias="PendingFeeAmount")
    ] = None
    refund_id: typing_extensions.Annotated[typing.Optional[RefundId], FieldMetadata(alias="RefundId")] = None
    response_data: typing_extensions.Annotated[
        typing.Optional[QueryResponseData], FieldMetadata(alias="ResponseData")
    ] = None
    returned_id: typing_extensions.Annotated[typing.Optional[ReturnedId], FieldMetadata(alias="ReturnedId")] = None
    schedule_reference: typing_extensions.Annotated[typing.Optional[int], FieldMetadata(alias="ScheduleReference")] = (
        pydantic.Field(default=None)
    )
    """
    Reference to the subscription that originated the transaction.
    """

    settlement_status: typing_extensions.Annotated[typing.Optional[int], FieldMetadata(alias="SettlementStatus")] = (
        pydantic.Field(default=None)
    )
    """
    Settlement status for transaction. See [the docs](/developers/references/money-in-statuses#payment-funding-status) for a full reference.
    """

    source: typing_extensions.Annotated[typing.Optional[Source], FieldMetadata(alias="Source")] = None
    split_funding_instructions: typing_extensions.Annotated[
        typing.Optional[SplitFunding], FieldMetadata(alias="splitFundingInstructions")
    ] = None
    total_amount: typing_extensions.Annotated[typing.Optional[float], FieldMetadata(alias="TotalAmount")] = (
        pydantic.Field(default=None)
    )
    """
    Transaction total amount (including service fee or sub-charge)
    """

    transaction_events: typing_extensions.Annotated[
        typing.Optional[typing.List[QueryTransactionEvents]], FieldMetadata(alias="TransactionEvents")
    ] = pydantic.Field(default=None)
    """
    Events associated with this transaction.
    """

    transaction_time: typing_extensions.Annotated[
        typing.Optional[DatetimeNullable], FieldMetadata(alias="TransactionTime")
    ] = pydantic.Field(default=None)
    """
    Transaction date and time, in UTC.
    """

    trans_additional_data: typing_extensions.Annotated[
        typing.Optional[typing.Optional[typing.Any]], FieldMetadata(alias="TransAdditionalData")
    ] = None
    trans_status: typing_extensions.Annotated[typing.Optional[int], FieldMetadata(alias="TransStatus")] = (
        pydantic.Field(default=None)
    )
    """
    Status of transaction. See [the docs](/developers/references/money-in-statuses#money-in-transaction-status) for a full reference.
    """

    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
