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

import typing_extensions
import typing_extensions
import typing
from ..types.inventory_state import InventoryState
from .money import MoneyParams
from .source_application import SourceApplicationParams
from .inventory_adjustment_group import InventoryAdjustmentGroupParams


class InventoryAdjustmentParams(typing_extensions.TypedDict):
    """
    Represents a change in state or quantity of product inventory at a
    particular time and location.
    """

    id: typing_extensions.NotRequired[str]
    """
    A unique ID generated by Square for the
    `InventoryAdjustment`.
    """

    reference_id: typing_extensions.NotRequired[typing.Optional[str]]
    """
    An optional ID provided by the application to tie the
    `InventoryAdjustment` to an external
    system.
    """

    from_state: typing_extensions.NotRequired[InventoryState]
    """
    The [inventory state](entity:InventoryState) of the related quantity
    of items before the adjustment.
    See [InventoryState](#type-inventorystate) for possible values
    """

    to_state: typing_extensions.NotRequired[InventoryState]
    """
    The [inventory state](entity:InventoryState) of the related quantity
    of items after the adjustment.
    See [InventoryState](#type-inventorystate) for possible values
    """

    location_id: typing_extensions.NotRequired[typing.Optional[str]]
    """
    The Square-generated ID of the [Location](entity:Location) where the related
    quantity of items is being tracked.
    """

    catalog_object_id: typing_extensions.NotRequired[typing.Optional[str]]
    """
    The Square-generated ID of the
    [CatalogObject](entity:CatalogObject) being tracked.
    """

    catalog_object_type: typing_extensions.NotRequired[typing.Optional[str]]
    """
    The [type](entity:CatalogObjectType) of the [CatalogObject](entity:CatalogObject) being tracked. 
    
    The Inventory API supports setting and reading the `"catalog_object_type": "ITEM_VARIATION"` field value. 
    In addition, it can also read the `"catalog_object_type": "ITEM"` field value that is set by the Square Restaurants app.
    """

    quantity: typing_extensions.NotRequired[typing.Optional[str]]
    """
    The number of items affected by the adjustment as a decimal string.
    Can support up to 5 digits after the decimal point.
    """

    total_price_money: typing_extensions.NotRequired[MoneyParams]
    """
    The total price paid for goods associated with the
    adjustment. Present if and only if `to_state` is `SOLD`. Always
    non-negative.
    """

    occurred_at: typing_extensions.NotRequired[typing.Optional[str]]
    """
    A client-generated RFC 3339-formatted timestamp that indicates when
    the inventory adjustment took place. For inventory adjustment updates, the `occurred_at`
    timestamp cannot be older than 24 hours or in the future relative to the
    time of the request.
    """

    created_at: typing_extensions.NotRequired[str]
    """
    An RFC 3339-formatted timestamp that indicates when the inventory adjustment is received.
    """

    source: typing_extensions.NotRequired[SourceApplicationParams]
    """
    Information about the application that caused the
    inventory adjustment.
    """

    employee_id: typing_extensions.NotRequired[typing.Optional[str]]
    """
    The Square-generated ID of the [Employee](entity:Employee) responsible for the
    inventory adjustment.
    """

    team_member_id: typing_extensions.NotRequired[typing.Optional[str]]
    """
    The Square-generated ID of the [Team Member](entity:TeamMember) responsible for the
    inventory adjustment.
    """

    transaction_id: typing_extensions.NotRequired[str]
    """
    The Square-generated ID of the [Transaction](entity:Transaction) that
    caused the adjustment. Only relevant for payment-related state
    transitions.
    """

    refund_id: typing_extensions.NotRequired[str]
    """
    The Square-generated ID of the [Refund](entity:Refund) that
    caused the adjustment. Only relevant for refund-related state
    transitions.
    """

    purchase_order_id: typing_extensions.NotRequired[str]
    """
    The Square-generated ID of the purchase order that caused the
    adjustment. Only relevant for state transitions from the Square for Retail
    app.
    """

    goods_receipt_id: typing_extensions.NotRequired[str]
    """
    The Square-generated ID of the goods receipt that caused the
    adjustment. Only relevant for state transitions from the Square for Retail
    app.
    """

    adjustment_group: typing_extensions.NotRequired[InventoryAdjustmentGroupParams]
    """
    An adjustment group bundling the related adjustments of item variations through stock conversions in a single inventory event.
    """
