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

from ..core.unchecked_base_model import UncheckedBaseModel
import typing
import pydantic
from .order_line_item_tax_type import OrderLineItemTaxType
from .money import Money
from .order_line_item_tax_scope import OrderLineItemTaxScope
from ..core.pydantic_utilities import IS_PYDANTIC_V2


class OrderReturnTax(UncheckedBaseModel):
    """
    Represents a tax being returned that applies to one or more return line items in an order.

    Fixed-amount, order-scoped taxes are distributed across all non-zero return line item totals.
    The amount distributed to each return line item is relative to that item’s contribution to the
    order subtotal.
    """

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

    source_tax_uid: typing.Optional[str] = pydantic.Field(default=None)
    """
    The tax `uid` from the order that contains the original tax charge.
    """

    catalog_object_id: typing.Optional[str] = pydantic.Field(default=None)
    """
    The catalog object ID referencing [CatalogTax](entity:CatalogTax).
    """

    catalog_version: typing.Optional[int] = pydantic.Field(default=None)
    """
    The version of the catalog object that this tax references.
    """

    name: typing.Optional[str] = pydantic.Field(default=None)
    """
    The tax's name.
    """

    type: typing.Optional[OrderLineItemTaxType] = pydantic.Field(default=None)
    """
    Indicates the calculation method used to apply the tax.
    See [OrderLineItemTaxType](#type-orderlineitemtaxtype) for possible values
    """

    percentage: typing.Optional[str] = pydantic.Field(default=None)
    """
    The percentage of the tax, as a string representation of a decimal number.
    For example, a value of `"7.25"` corresponds to a percentage of 7.25%.
    """

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

    scope: typing.Optional[OrderLineItemTaxScope] = pydantic.Field(default=None)
    """
    Indicates the level at which the `OrderReturnTax` applies. For `ORDER` scoped
    taxes, Square generates references in `applied_taxes` on all
    `OrderReturnLineItem`s. For `LINE_ITEM` scoped taxes, the tax is only applied to
    `OrderReturnLineItem`s with references in their `applied_discounts` field.
    See [OrderLineItemTaxScope](#type-orderlineitemtaxscope) for possible values
    """

    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
