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

import datetime as dt
import typing

import pydantic
from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
from .invoice_needs_attention_object_on_hold import InvoiceNeedsAttentionObjectOnHold
from .invoice_needs_attention_object_payment_status import InvoiceNeedsAttentionObjectPaymentStatus
from .invoice_needs_attention_object_type import InvoiceNeedsAttentionObjectType


class InvoiceNeedsAttentionObject(UniversalBaseModel):
    id: str = pydantic.Field()
    """
    Unique invoice identifier in UUID v4 format
    """

    reference_number: typing.Optional[str] = pydantic.Field(default=None)
    """
    Invoice number from vendor
    """

    vendor: typing.Optional[str] = pydantic.Field(default=None)
    """
    Vendor name
    """

    location: typing.Optional[str] = pydantic.Field(default=None)
    """
    Location name
    """

    invoice_date: typing.Optional[str] = pydantic.Field(default=None)
    """
    Date invoice was issued
    """

    due_date: typing.Optional[str] = pydantic.Field(default=None)
    """
    Payment due date
    """

    total_amount: typing.Optional[float] = pydantic.Field(default=None)
    """
    Total invoice amount
    """

    total_tax: typing.Optional[float] = pydantic.Field(default=None)
    """
    Total tax amount
    """

    currency: typing.Optional[str] = pydantic.Field(default=None)
    """
    Currency code (ISO 4217)
    """

    outstanding_balance: typing.Optional[float] = pydantic.Field(default=None)
    """
    Remaining unpaid amount
    """

    type: typing.Optional[InvoiceNeedsAttentionObjectType] = pydantic.Field(default=None)
    """
    Type of invoice document
    """

    status: str = pydantic.Field()
    """
    Invoice processing status (processing, incomplete, approved, archived)
    """

    payment_status: InvoiceNeedsAttentionObjectPaymentStatus = pydantic.Field()
    """
    Payment status (paid, partial, unpaid)
    """

    purchase_order: typing.Optional[str] = pydantic.Field(default=None)
    """
    Associated purchase order number
    """

    created_at: dt.datetime = pydantic.Field()
    """
    Timestamp when invoice was created
    """

    approved_date: typing.Optional[dt.datetime] = pydantic.Field(default=None)
    """
    Date when invoice was approved
    """

    exported_date: typing.Optional[dt.datetime] = pydantic.Field(default=None)
    """
    Date when invoice was exported
    """

    posting_date: typing.Optional[str] = pydantic.Field(default=None)
    """
    Date when invoice was posted
    """

    error: typing.Optional[str] = pydantic.Field(default=None)
    """
    Processing error message if invoice has issues
    """

    has_unmatched_items: typing.Optional[bool] = pydantic.Field(default=None)
    """
    Whether invoice has unmatched line items
    """

    on_hold: typing.Optional[InvoiceNeedsAttentionObjectOnHold] = pydantic.Field(default=None)
    """
    Hold status information
    """

    attention_reason: typing.Optional[str] = pydantic.Field(default=None)
    """
    Specific reason why this invoice needs attention
    """

    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
