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

from ..core.unchecked_base_model import UncheckedBaseModel
import typing
from .measurement_unit import MeasurementUnit
import pydantic
from ..core.pydantic_utilities import IS_PYDANTIC_V2


class OrderQuantityUnit(UncheckedBaseModel):
    """
    Contains the measurement unit for a quantity and a precision that
    specifies the number of digits after the decimal point for decimal quantities.
    """

    measurement_unit: typing.Optional[MeasurementUnit] = pydantic.Field(default=None)
    """
    A [MeasurementUnit](entity:MeasurementUnit) that represents the
    unit of measure for the quantity.
    """

    precision: typing.Optional[int] = pydantic.Field(default=None)
    """
    For non-integer quantities, represents the number of digits after the decimal point that are
    recorded for this quantity.
    
    For example, a precision of 1 allows quantities such as `"1.0"` and `"1.1"`, but not `"1.01"`.
    
    Min: 0. Max: 5.
    """

    catalog_object_id: typing.Optional[str] = pydantic.Field(default=None)
    """
    The catalog object ID referencing the
    [CatalogMeasurementUnit](entity:CatalogMeasurementUnit).
    
    This field is set when this is a catalog-backed measurement unit.
    """

    catalog_version: typing.Optional[int] = pydantic.Field(default=None)
    """
    The version of the catalog object that this measurement unit references.
    
    This field is set when this is a catalog-backed measurement unit.
    """

    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
