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

from ..core.unchecked_base_model import UncheckedBaseModel
import typing
import pydantic
from .order_return_line_item import OrderReturnLineItem
from .order_return_service_charge import OrderReturnServiceCharge
from .order_return_tax import OrderReturnTax
from .order_return_discount import OrderReturnDiscount
from .order_return_tip import OrderReturnTip
from .order_rounding_adjustment import OrderRoundingAdjustment
from .order_money_amounts import OrderMoneyAmounts
from ..core.pydantic_utilities import IS_PYDANTIC_V2


class OrderReturn(UncheckedBaseModel):
    """
    The set of line items, service charges, taxes, discounts, tips, and other items being returned in an order.
    """

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

    source_order_id: typing.Optional[str] = pydantic.Field(default=None)
    """
    An order that contains the original sale of these return line items. This is unset
    for unlinked returns.
    """

    return_line_items: typing.Optional[typing.List[OrderReturnLineItem]] = pydantic.Field(default=None)
    """
    A collection of line items that are being returned.
    """

    return_service_charges: typing.Optional[typing.List[OrderReturnServiceCharge]] = pydantic.Field(default=None)
    """
    A collection of service charges that are being returned.
    """

    return_taxes: typing.Optional[typing.List[OrderReturnTax]] = pydantic.Field(default=None)
    """
    A collection of references to taxes being returned for an order, including the total
    applied tax amount to be returned. The taxes must reference a top-level tax ID from the source
    order.
    """

    return_discounts: typing.Optional[typing.List[OrderReturnDiscount]] = pydantic.Field(default=None)
    """
    A collection of references to discounts being returned for an order, including the total
    applied discount amount to be returned. The discounts must reference a top-level discount ID
    from the source order.
    """

    return_tips: typing.Optional[typing.List[OrderReturnTip]] = pydantic.Field(default=None)
    """
    A collection of references to tips being returned for an order.
    """

    rounding_adjustment: typing.Optional[OrderRoundingAdjustment] = pydantic.Field(default=None)
    """
    A positive or negative rounding adjustment to the total value being returned. Adjustments are commonly
    used to apply cash rounding when the minimum unit of the account is smaller than the lowest
    physical denomination of the currency.
    """

    return_amounts: typing.Optional[OrderMoneyAmounts] = pydantic.Field(default=None)
    """
    An aggregate monetary value being returned by this return entry.
    """

    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
