# 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 .purchase_order_summary_status import PurchaseOrderSummaryStatus


class PurchaseOrderSummary(UniversalBaseModel):
    id: str
    external_id: typing.Optional[str] = pydantic.Field(default=None)
    """
    External unique identifier for idempotent operations
    """

    po_number: typing.Optional[str] = pydantic.Field(default=None)
    """
    PO number (client-provided, mandatory)
    """

    status: PurchaseOrderSummaryStatus
    ottimate_location_id: typing.Optional[int] = None
    ottimate_company_id: typing.Optional[int] = None
    date: typing.Optional[str] = None
    erp_vendor_id: typing.Optional[str] = pydantic.Field(default=None)
    """
    External vendor identifier from ERP system
    """

    erp_vendor_name: typing.Optional[str] = pydantic.Field(default=None)
    """
    Vendor name from ERP system
    """

    total_amount: typing.Optional[float] = None
    created_date: typing.Optional[dt.datetime] = None
    last_modified_date: typing.Optional[dt.datetime] = None
    custom_fields: typing.Optional[typing.Dict[str, typing.Any]] = pydantic.Field(default=None)
    """
    Custom fields configured for this company's purchase orders
    """

    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
