# 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 LineItem(UniversalBaseModel):
    item_categories: typing_extensions.Annotated[
        typing.Optional[typing.List[typing.Optional[str]]],
        FieldMetadata(alias="itemCategories"),
        pydantic.Field(alias="itemCategories", description="Array of tags classifying item or product."),
    ] = None
    item_commodity_code: typing_extensions.Annotated[
        typing.Optional[ItemCommodityCode],
        FieldMetadata(alias="itemCommodityCode"),
        pydantic.Field(alias="itemCommodityCode"),
    ] = None
    item_cost: typing_extensions.Annotated[
        float,
        FieldMetadata(alias="itemCost"),
        pydantic.Field(alias="itemCost", description="Item or product price per unit."),
    ]
    item_description: typing_extensions.Annotated[
        typing.Optional[ItemDescription],
        FieldMetadata(alias="itemDescription"),
        pydantic.Field(alias="itemDescription"),
    ] = None
    item_mode: typing_extensions.Annotated[
        typing.Optional[int],
        FieldMetadata(alias="itemMode"),
        pydantic.Field(
            alias="itemMode",
            description="Internal class of item or product: value '0' is only for invoices, '1' for bills, and '2' is common for both.",
        ),
    ] = None
    item_product_code: typing_extensions.Annotated[
        typing.Optional[ItemProductCode],
        FieldMetadata(alias="itemProductCode"),
        pydantic.Field(alias="itemProductCode"),
    ] = None
    item_product_name: typing_extensions.Annotated[
        typing.Optional[ItemProductName],
        FieldMetadata(alias="itemProductName"),
        pydantic.Field(alias="itemProductName"),
    ] = None
    item_qty: typing_extensions.Annotated[
        int, FieldMetadata(alias="itemQty"), pydantic.Field(alias="itemQty", description="Quantity of item or product.")
    ]
    item_unit_of_measure: typing_extensions.Annotated[
        typing.Optional[ItemUnitofMeasure],
        FieldMetadata(alias="itemUnitOfMeasure"),
        pydantic.Field(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
