# This file was auto-generated by Fern from our API Definition.

from ..core.unchecked_base_model import UncheckedBaseModel
import typing
import pydantic
from .money import Money
from ..core.pydantic_utilities import IS_PYDANTIC_V2


class OrderLineItemAppliedTax(UncheckedBaseModel):
    """
    Represents an applied portion of a tax to a line item in an order.

    Order-scoped taxes automatically include the applied taxes in each line item.
    Line item taxes must be referenced from any applicable line items.
    The corresponding applied money is automatically computed, based on the
    set of participating line items.
    """

    uid: typing.Optional[str] = pydantic.Field(default=None)
    """
    A unique ID that identifies the applied tax only within this order.
    """

    tax_uid: str = pydantic.Field()
    """
    The `uid` of the tax for which this applied tax represents. It must reference
    a tax present in the `order.taxes` field.
    
    This field is immutable. To change which taxes apply to a line item, delete and add a new
    `OrderLineItemAppliedTax`.
    """

    applied_money: typing.Optional[Money] = pydantic.Field(default=None)
    """
    The amount of money applied by the tax to the line item.
    """

    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
