# 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 .catalog_allowance_object_allowance_type import CatalogAllowanceObjectAllowanceType
from .catalog_allowance_object_target_type import CatalogAllowanceObjectTargetType


class CatalogAllowanceObject(UniversalBaseModel):
    """
    Catalog allowance object for standalone list endpoint
    """

    id: str = pydantic.Field()
    """
    Unique identifier
    """

    catalog_entry_id: str = pydantic.Field()
    """
    Associated catalog entry ID (prefixed with cte_)
    """

    ottimate_company_id: int = pydantic.Field()
    """
    Company ID
    """

    ottimate_location_id: typing.Optional[int] = pydantic.Field(default=None)
    """
    Location ID
    """

    allowance_type: CatalogAllowanceObjectAllowanceType = pydantic.Field()
    """
    Type of allowance
    """

    amount: str = pydantic.Field()
    """
    Allowance amount (decimal string)
    """

    unit_allowance: typing.Optional[str] = pydantic.Field(default=None)
    """
    Unit allowance amount (decimal string)
    """

    target: int = pydantic.Field()
    """
    Target code (10=company, 15=location_group, 20=location)
    """

    target_type: typing.Optional[CatalogAllowanceObjectTargetType] = pydantic.Field(default=None)
    """
    Human-readable target type
    """

    start_date: dt.datetime = pydantic.Field()
    """
    Start date
    """

    end_date: typing.Optional[dt.datetime] = pydantic.Field(default=None)
    """
    End date
    """

    reference_id: typing.Optional[str] = pydantic.Field(default=None)
    """
    Unique key
    """

    created_date: typing.Optional[dt.datetime] = pydantic.Field(default=None)
    """
    Record creation date
    """

    last_modified_date: typing.Optional[dt.datetime] = pydantic.Field(default=None)
    """
    Record last modified date
    """

    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
