60 lines
1.5 KiB
Python
60 lines
1.5 KiB
Python
import uuid
|
|
|
|
from decimal import Decimal
|
|
|
|
from pydantic import BaseModel, ConfigDict, Field
|
|
|
|
from . import to_camel
|
|
from .product_group import ProductGroupLink
|
|
from .stock_keeping_unit import StockKeepingUnit
|
|
|
|
|
|
class ProductLink(BaseModel):
|
|
id_: uuid.UUID = Field(...)
|
|
name: str | None = None
|
|
model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
|
|
|
|
|
|
class ProductIn(BaseModel):
|
|
name: str = Field(..., min_length=1)
|
|
description: str | None
|
|
fraction_units: str = Field(..., min_length=1)
|
|
skus: list[StockKeepingUnit]
|
|
product_group: ProductGroupLink = Field(...)
|
|
is_active: bool
|
|
is_purchased: bool
|
|
is_sold: bool
|
|
|
|
allergen: str
|
|
protein: Decimal
|
|
carbohydrate: Decimal
|
|
total_sugar: Decimal
|
|
added_sugar: Decimal
|
|
total_fat: Decimal
|
|
saturated_fat: Decimal
|
|
trans_fat: Decimal
|
|
cholestrol: Decimal
|
|
sodium: Decimal
|
|
|
|
msnf: Decimal
|
|
other_solids: Decimal
|
|
total_solids: Decimal
|
|
water: Decimal
|
|
|
|
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True)
|
|
|
|
|
|
class Product(ProductIn):
|
|
id_: uuid.UUID
|
|
code: int
|
|
is_fixture: bool
|
|
|
|
|
|
class ProductBlank(ProductIn):
|
|
name: str
|
|
fraction_units: str
|
|
skus: list[StockKeepingUnit]
|
|
product_group: ProductGroupLink | None = None # type: ignore[assignment]
|
|
is_fixture: bool
|
|
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True)
|