# 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_entry_object_allowances_item_allowance_type import CatalogEntryObjectAllowancesItemAllowanceType
from .catalog_entry_object_allowances_item_target_type import CatalogEntryObjectAllowancesItemTargetType


class CatalogEntryObjectAllowancesItem(UniversalBaseModel):
    """
    Catalog allowance object nested in catalog entry
    """

    id: str = pydantic.Field()
    """
    Allowance ID
    """

    allowance_type: CatalogEntryObjectAllowancesItemAllowanceType = 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[CatalogEntryObjectAllowancesItemTargetType] = pydantic.Field(default=None)
    """
    Human-readable target type
    """

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

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

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

    end_date: typing.Optional[dt.datetime] = pydantic.Field(default=None)
    """
    Allowance 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
