# 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 .batch_number import BatchNumber
from .dbaname import Dbaname
from .general_events import GeneralEvents
from .legalname import Legalname
from .paypoint_id import PaypointId
from .transfer_bank_account import TransferBankAccount
from .transfer_identifier import TransferIdentifier
from .transfer_message import TransferMessage


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

    from payabli import GeneralEvents, Transfer, TransferBankAccount

    Transfer(
        transfer_id=79851,
        paypoint_id=705,
        batch_number="split_705_gp_11-16-2024",
        batch_currency="USD",
        batch_records=1,
        transfer_identifier="bbcbfed7-e535-45fe-8d62-000000",
        batch_id=111430,
        paypoint_entry_name="47ae3de37",
        paypoint_legal_name="Gruzya Outdoor Outfitters LLC",
        paypoint_dba_name="Gruzya Outdoor Outfitters",
        paypoint_logo="https://example.com/logo.png",
        parent_org_name="Pilgrim Planner",
        parent_org_id=12345,
        parent_org_logo="https://example.com/parent-logo.png",
        external_paypoint_id="ext-12345",
        bank_account=TransferBankAccount(
            account_number="****1234",
            routing_number="123456789",
        ),
        transfer_date="2024-11-17T08:20:07.288+00:00",
        processor="gp",
        transfer_status=2,
        gross_amount=1029.0,
        charge_back_amount=25.0,
        returned_amount=0.0,
        hold_amount=0.0,
        released_amount=0.0,
        billing_fees_amount=0.0,
        third_party_paid_amount=0.0,
        adjustments_amount=0.0,
        net_transfer_amount=1004.0,
        events_data=[
            GeneralEvents(
                description="Transfer Created",
                event_time=datetime.datetime.fromisoformat(
                    "2024-11-16 08:15:33.436000+00:00",
                ),
                source="worker",
            )
        ],
        messages=[],
    )
    """

    transfer_id: typing_extensions.Annotated[int, FieldMetadata(alias="transferId")] = pydantic.Field()
    """
    The transfer ID.
    """

    paypoint_id: typing_extensions.Annotated[PaypointId, FieldMetadata(alias="paypointId")]
    batch_number: typing_extensions.Annotated[BatchNumber, FieldMetadata(alias="batchNumber")]
    batch_currency: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="batchCurrency")] = (
        pydantic.Field(default=None)
    )
    """
    The currency of the batch, either USD or CAD.
    """

    batch_records: typing_extensions.Annotated[typing.Optional[int], FieldMetadata(alias="batchRecords")] = (
        pydantic.Field(default=None)
    )
    """
    Number of records in the batch.
    """

    transfer_identifier: typing_extensions.Annotated[TransferIdentifier, FieldMetadata(alias="transferIdentifier")]
    batch_id: typing_extensions.Annotated[int, FieldMetadata(alias="batchId")] = pydantic.Field()
    """
    The ID of the batch the transfer belongs to.
    """

    paypoint_entry_name: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="paypointEntryName")] = (
        pydantic.Field(default=None)
    )
    """
    The paypoint entry name.
    """

    paypoint_legal_name: typing_extensions.Annotated[
        typing.Optional[Legalname], FieldMetadata(alias="paypointLegalName")
    ] = pydantic.Field(default=None)
    """
    The paypoint legal name.
    """

    paypoint_dba_name: typing_extensions.Annotated[typing.Optional[Dbaname], FieldMetadata(alias="paypointDbaName")] = (
        pydantic.Field(default=None)
    )
    """
    The paypoint DBA name.
    """

    paypoint_logo: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="paypointLogo")] = (
        pydantic.Field(default=None)
    )
    """
    The paypoint logo URL.
    """

    parent_org_name: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="parentOrgName")] = (
        pydantic.Field(default=None)
    )
    """
    The parent organization name.
    """

    parent_org_id: typing_extensions.Annotated[typing.Optional[int], FieldMetadata(alias="parentOrgId")] = (
        pydantic.Field(default=None)
    )
    """
    The parent organization ID.
    """

    parent_org_logo: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="parentOrgLogo")] = (
        pydantic.Field(default=None)
    )
    """
    The parent organization logo URL.
    """

    external_paypoint_id: typing_extensions.Annotated[
        typing.Optional[str], FieldMetadata(alias="externalPaypointId")
    ] = pydantic.Field(default=None)
    """
    The external paypoint ID.
    """

    bank_account: typing_extensions.Annotated[
        typing.Optional[TransferBankAccount], FieldMetadata(alias="bankAccount")
    ] = pydantic.Field(default=None)
    """
    Bank account information for the transfer.
    """

    transfer_date: typing_extensions.Annotated[str, FieldMetadata(alias="transferDate")] = pydantic.Field()
    """
    Date when the transfer occurred.
    """

    processor: str = pydantic.Field()
    """
    The payment processor used for the transfer.
    """

    transfer_status: typing_extensions.Annotated[int, FieldMetadata(alias="transferStatus")] = pydantic.Field()
    """
    The current status of the transfer.
    """

    gross_amount: typing_extensions.Annotated[float, FieldMetadata(alias="grossAmount")] = pydantic.Field()
    """
    Gross batch is the total amount of the payments grouped in the batch. This amount includes service fees.
    """

    charge_back_amount: typing_extensions.Annotated[float, FieldMetadata(alias="chargeBackAmount")] = pydantic.Field()
    """
    Amount of chargebacks to be deducted from batch.
    """

    returned_amount: typing_extensions.Annotated[float, FieldMetadata(alias="returnedAmount")] = pydantic.Field()
    """
    Amount of ACH returns to be deducted from batch.
    """

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

    released_amount: typing_extensions.Annotated[float, FieldMetadata(alias="releasedAmount")] = pydantic.Field()
    """
    Amount of previously held funds that have been released after a risk review.
    """

    billing_fees_amount: typing_extensions.Annotated[float, FieldMetadata(alias="billingFeesAmount")] = pydantic.Field()
    """
    Amount of charges and fees applied for services and transactions.
    """

    third_party_paid_amount: typing_extensions.Annotated[float, FieldMetadata(alias="thirdPartyPaidAmount")] = (
        pydantic.Field()
    )
    """
    Amount of 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[float, FieldMetadata(alias="adjustmentsAmount")] = pydantic.Field()
    """
    Amount of corrections applied to Billing & Fees charges.
    """

    net_transfer_amount: typing_extensions.Annotated[float, FieldMetadata(alias="netTransferAmount")] = pydantic.Field()
    """
    The net transfer amount after all deductions and additions.
    """

    events_data: typing_extensions.Annotated[
        typing.Optional[typing.List[GeneralEvents]], FieldMetadata(alias="eventsData")
    ] = pydantic.Field(default=None)
    """
    List of events associated with the transfer.
    """

    messages: typing.Optional[typing.List[TransferMessage]] = pydantic.Field(default=None)
    """
    List of messages related to the transfer.
    """

    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
