# 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 .item_commodity_code import ItemCommodityCode
from .item_description import ItemDescription
from .item_product_code import ItemProductCode
from .item_product_name import ItemProductName
from .item_unitof_measure import ItemUnitofMeasure


class BillItem(UniversalBaseModel):
    item_categories: typing_extensions.Annotated[
        typing.Optional[typing.List[typing.Optional[str]]], FieldMetadata(alias="itemCategories")
    ] = pydantic.Field(default=None)
    """
    Array of tags classifying item or product.
    """

    item_commodity_code: typing_extensions.Annotated[
        typing.Optional[ItemCommodityCode], FieldMetadata(alias="itemCommodityCode")
    ] = None
    item_cost: typing_extensions.Annotated[float, FieldMetadata(alias="itemCost")] = pydantic.Field()
    """
    Item or product price per unit.
    """

    item_description: typing_extensions.Annotated[
        typing.Optional[ItemDescription], FieldMetadata(alias="itemDescription")
    ] = None
    item_mode: typing_extensions.Annotated[typing.Optional[int], FieldMetadata(alias="itemMode")] = pydantic.Field(
        default=None
    )
    """
    Internal class of item or product: value '0' is only for invoices , '1' for bills and, '2' common for both.
    """

    item_product_code: typing_extensions.Annotated[
        typing.Optional[ItemProductCode], FieldMetadata(alias="itemProductCode")
    ] = None
    item_product_name: typing_extensions.Annotated[
        typing.Optional[ItemProductName], FieldMetadata(alias="itemProductName")
    ] = None
    item_qty: typing_extensions.Annotated[typing.Optional[int], FieldMetadata(alias="itemQty")] = pydantic.Field(
        default=None
    )
    """
    Quantity of item or product.
    """

    item_tax_amount: typing_extensions.Annotated[typing.Optional[float], FieldMetadata(alias="itemTaxAmount")] = (
        pydantic.Field(default=None)
    )
    """
    Tax amount applied to item or product.
    """

    item_tax_rate: typing_extensions.Annotated[typing.Optional[float], FieldMetadata(alias="itemTaxRate")] = (
        pydantic.Field(default=None)
    )
    """
    Tax rate applied to item or product.
    """

    item_total_amount: typing_extensions.Annotated[typing.Optional[float], FieldMetadata(alias="itemTotalAmount")] = (
        pydantic.Field(default=None)
    )
    """
    Total amount in item or product.
    """

    item_unit_of_measure: typing_extensions.Annotated[
        typing.Optional[ItemUnitofMeasure], FieldMetadata(alias="itemUnitOfMeasure")
    ] = None

    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
