# 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.ach_holder_type import AchHolderType
from ...types.ach_sec_code import AchSecCode
from ...types.batch_number import BatchNumber
from ...types.bill_data import BillData
from ...types.billing_fee_detail import BillingFeeDetail
from ...types.chargeback_id import ChargebackId
from ...types.datetime_nullable import DatetimeNullable
from ...types.dbaname import Dbaname
from ...types.device_id import DeviceId
from ...types.entrypage_id import EntrypageId
from ...types.external_paypoint_id import ExternalPaypointId
from ...types.external_processor_information import ExternalProcessorInformation
from ...types.fee_amount import FeeAmount
from ...types.ip_address import IpAddress
from ...types.legalname import Legalname
from ...types.netamountnullable import Netamountnullable
from ...types.operation import Operation
from ...types.order_id import OrderId
from ...types.org_parent_name import OrgParentName
from ...types.orgid import Orgid
from ...types.payor_id import PayorId
from ...types.paypoint_id import PaypointId
from ...types.pending_fee_amount import PendingFeeAmount
from ...types.query_c_fee_transaction import QueryCFeeTransaction
from ...types.query_payment_data import QueryPaymentData
from ...types.query_response_data import QueryResponseData
from ...types.query_transaction_events import QueryTransactionEvents
from ...types.query_transaction_payor_data import QueryTransactionPayorData
from ...types.refund_id import RefundId
from ...types.retrieval_id import RetrievalId
from ...types.returned_id import ReturnedId
from ...types.risk_action import RiskAction
from ...types.risk_action_code import RiskActionCode
from ...types.risk_flagged import RiskFlagged
from ...types.risk_flagged_on import RiskFlaggedOn
from ...types.risk_reason import RiskReason
from ...types.risk_status import RiskStatus
from ...types.source import Source
from ...types.split_funding import SplitFunding


class TransferDetailRecord(UniversalBaseModel):
    transfer_detail_id: typing_extensions.Annotated[typing.Optional[int], FieldMetadata(alias="transferDetailId")] = (
        pydantic.Field(default=None)
    )
    """
    Unique identifier for the transfer detail record
    """

    transfer_id: typing_extensions.Annotated[typing.Optional[int], FieldMetadata(alias="transferId")] = pydantic.Field(
        default=None
    )
    """
    The ID of the transfer this detail belongs to
    """

    transaction_id: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="transactionId")] = (
        pydantic.Field(default=None)
    )
    """
    The transaction ID in Payabli's system
    """

    transaction_number: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="transactionNumber")] = (
        pydantic.Field(default=None)
    )
    """
    External transaction reference number
    """

    type: typing.Optional[str] = pydantic.Field(default=None)
    """
    The transaction type (credit or debit)
    """

    category: typing.Optional[str] = pydantic.Field(default=None)
    """
    A field used to categorize the transaction details. Values include: auth, decline, refund, adj, cb, split
    """

    gross_amount: typing_extensions.Annotated[typing.Optional[float], FieldMetadata(alias="grossAmount")] = (
        pydantic.Field(default=None)
    )
    """
    The gross amount of the transaction
    """

    charge_back_amount: typing_extensions.Annotated[typing.Optional[float], FieldMetadata(alias="chargeBackAmount")] = (
        pydantic.Field(default=None)
    )
    """
    Chargeback amount deducted from transaction
    """

    returned_amount: typing_extensions.Annotated[typing.Optional[float], FieldMetadata(alias="returnedAmount")] = (
        pydantic.Field(default=None)
    )
    """
    ACH return amount deducted from transaction
    """

    refund_amount: typing_extensions.Annotated[typing.Optional[float], FieldMetadata(alias="refundAmount")] = (
        pydantic.Field(default=None)
    )
    """
    Refund amount deducted from transaction
    """

    hold_amount: typing_extensions.Annotated[typing.Optional[float], FieldMetadata(alias="holdAmount")] = (
        pydantic.Field(default=None)
    )
    """
    Amount being held for fraud or risk concerns
    """

    released_amount: typing_extensions.Annotated[typing.Optional[float], FieldMetadata(alias="releasedAmount")] = (
        pydantic.Field(default=None)
    )
    """
    Previously held funds that have been released after a risk review
    """

    billing_fees_amount: typing_extensions.Annotated[
        typing.Optional[float], FieldMetadata(alias="billingFeesAmount")
    ] = pydantic.Field(default=None)
    """
    Charges applied for transactions and services
    """

    third_party_paid_amount: typing_extensions.Annotated[
        typing.Optional[float], FieldMetadata(alias="thirdPartyPaidAmount")
    ] = pydantic.Field(default=None)
    """
    Payments captured in the batch cycle that are deposited separately. For example,  checks or cash payments recorded in the batch but not deposited via Payabli,  or card brands making a direct transfer in certain situations.
    """

    adjustments_amount: typing_extensions.Annotated[
        typing.Optional[float], FieldMetadata(alias="adjustmentsAmount")
    ] = pydantic.Field(default=None)
    """
    Corrections applied to Billing & Fees charges
    """

    net_transfer_amount: typing_extensions.Annotated[
        typing.Optional[float], FieldMetadata(alias="netTransferAmount")
    ] = pydantic.Field(default=None)
    """
    The net amount after all deductions
    """

    split_funding_amount: typing_extensions.Annotated[
        typing.Optional[float], FieldMetadata(alias="splitFundingAmount")
    ] = pydantic.Field(default=None)
    """
    Total amount directed to split funding destinations
    """

    billing_fees_details: typing_extensions.Annotated[
        typing.Optional[typing.List[BillingFeeDetail]], FieldMetadata(alias="billingFeesDetails")
    ] = None
    parent_org_name: typing_extensions.Annotated[
        typing.Optional[OrgParentName], FieldMetadata(alias="ParentOrgName")
    ] = None
    paypoint_dbaname: typing_extensions.Annotated[typing.Optional[Dbaname], FieldMetadata(alias="PaypointDbaname")] = (
        None
    )
    paypoint_legalname: typing_extensions.Annotated[
        typing.Optional[Legalname], FieldMetadata(alias="PaypointLegalname")
    ] = None
    paypoint_entryname: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="PaypointEntryname")] = (
        pydantic.Field(default=None)
    )
    """
    The paypoint's entryname
    """

    payment_trans_id: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="PaymentTransId")] = (
        pydantic.Field(default=None)
    )
    """
    The transaction ID for the payment
    """

    connector_name: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="ConnectorName")] = (
        pydantic.Field(default=None)
    )
    """
    The payment connector used to process the transaction
    """

    external_processor_information: typing_extensions.Annotated[
        typing.Optional[ExternalProcessorInformation], FieldMetadata(alias="ExternalProcessorInformation")
    ] = None
    gateway_trans_id: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="GatewayTransId")] = (
        pydantic.Field(default=None)
    )
    """
    Internal identifier used for processing
    """

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

    batch_number: typing_extensions.Annotated[typing.Optional[BatchNumber], FieldMetadata(alias="BatchNumber")] = None
    batch_amount: typing_extensions.Annotated[typing.Optional[float], FieldMetadata(alias="BatchAmount")] = (
        pydantic.Field(default=None)
    )
    """
    The amount of the batch
    """

    payor_id: typing_extensions.Annotated[typing.Optional[PayorId], FieldMetadata(alias="PayorId")] = pydantic.Field(
        default=None
    )
    """
    Unique ID for customer linked to the transaction
    """

    payment_data: typing_extensions.Annotated[typing.Optional[QueryPaymentData], FieldMetadata(alias="PaymentData")] = (
        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.
    """

    paypoint_id: typing_extensions.Annotated[typing.Optional[PaypointId], FieldMetadata(alias="PaypointId")] = 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)
    """

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

    fee_amount: typing_extensions.Annotated[typing.Optional[FeeAmount], FieldMetadata(alias="FeeAmount")] = None
    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.
    """

    operation: typing_extensions.Annotated[typing.Optional[Operation], FieldMetadata(alias="Operation")] = None
    response_data: typing_extensions.Annotated[
        typing.Optional[QueryResponseData], FieldMetadata(alias="ResponseData")
    ] = None
    source: typing_extensions.Annotated[typing.Optional[Source], FieldMetadata(alias="Source")] = None
    schedule_reference: typing_extensions.Annotated[typing.Optional[int], FieldMetadata(alias="ScheduleReference")] = (
        pydantic.Field(default=None)
    )
    """
    Reference to the subscription or schedule that originated the transaction
    """

    org_id: typing_extensions.Annotated[typing.Optional[Orgid], FieldMetadata(alias="OrgId")] = None
    refund_id: typing_extensions.Annotated[typing.Optional[RefundId], FieldMetadata(alias="RefundId")] = None
    returned_id: typing_extensions.Annotated[typing.Optional[ReturnedId], FieldMetadata(alias="ReturnedId")] = None
    chargeback_id: typing_extensions.Annotated[typing.Optional[ChargebackId], FieldMetadata(alias="ChargebackId")] = (
        None
    )
    retrieval_id: typing_extensions.Annotated[typing.Optional[RetrievalId], FieldMetadata(alias="RetrievalId")] = None
    trans_additional_data: typing_extensions.Annotated[
        typing.Optional[typing.Optional[typing.Any]], FieldMetadata(alias="TransAdditionalData")
    ] = pydantic.Field(default=None)
    """
    Additional transaction data
    """

    invoice_data: typing_extensions.Annotated[typing.Optional[BillData], FieldMetadata(alias="invoiceData")] = (
        pydantic.Field(default=None)
    )
    """
    Associated invoice data
    """

    entrypage_id: typing_extensions.Annotated[typing.Optional[EntrypageId], FieldMetadata(alias="EntrypageId")] = None
    external_paypoint_id: typing_extensions.Annotated[
        typing.Optional[ExternalPaypointId], FieldMetadata(alias="externalPaypointID")
    ] = None
    is_validated_ach: typing_extensions.Annotated[typing.Optional[bool], FieldMetadata(alias="IsValidatedACH")] = (
        pydantic.Field(default=None)
    )
    """
    Indicates whether the ACH account has been validated
    """

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

    customer: typing_extensions.Annotated[
        typing.Optional[QueryTransactionPayorData], FieldMetadata(alias="Customer")
    ] = None
    split_funding_instructions: typing_extensions.Annotated[
        typing.Optional[SplitFunding], FieldMetadata(alias="splitFundingInstructions")
    ] = None
    cfee_transactions: typing_extensions.Annotated[
        typing.Optional[typing.List[QueryCFeeTransaction]], FieldMetadata(alias="CfeeTransactions")
    ] = None
    transaction_events: typing_extensions.Annotated[
        typing.Optional[typing.List[QueryTransactionEvents]], FieldMetadata(alias="TransactionEvents")
    ] = None
    pending_fee_amount: typing_extensions.Annotated[
        typing.Optional[PendingFeeAmount], FieldMetadata(alias="PendingFeeAmount")
    ] = None
    risk_flagged: typing_extensions.Annotated[typing.Optional[RiskFlagged], FieldMetadata(alias="RiskFlagged")] = None
    risk_flagged_on: typing_extensions.Annotated[
        typing.Optional[RiskFlaggedOn], FieldMetadata(alias="RiskFlaggedOn")
    ] = None
    risk_status: typing_extensions.Annotated[typing.Optional[RiskStatus], FieldMetadata(alias="RiskStatus")] = None
    risk_reason: typing_extensions.Annotated[typing.Optional[RiskReason], FieldMetadata(alias="RiskReason")] = None
    risk_action: typing_extensions.Annotated[typing.Optional[RiskAction], FieldMetadata(alias="RiskAction")] = None
    risk_action_code: typing_extensions.Annotated[
        typing.Optional[RiskActionCode], FieldMetadata(alias="RiskActionCode")
    ] = None
    device_id: typing_extensions.Annotated[typing.Optional[DeviceId], FieldMetadata(alias="DeviceId")] = None
    ach_sec_code: typing_extensions.Annotated[typing.Optional[AchSecCode], FieldMetadata(alias="AchSecCode")] = None
    ach_holder_type: typing_extensions.Annotated[
        typing.Optional[AchHolderType], FieldMetadata(alias="AchHolderType")
    ] = None
    ip_address: typing_extensions.Annotated[typing.Optional[IpAddress], FieldMetadata(alias="IpAddress")] = None
    is_same_day_ach: typing_extensions.Annotated[typing.Optional[bool], FieldMetadata(alias="IsSameDayACH")] = (
        pydantic.Field(default=None)
    )
    """
    Indicates if this was a same-day ACH transaction.
    """

    wallet_type: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="WalletType")] = pydantic.Field(
        default=None
    )
    """
    Type of wallet used for the transaction (if applicable)
    """

    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
