Files
data-entry-app/backend/app/schemas/product.py
T

77 lines
2.5 KiB
Python
Raw Normal View History

2026-04-25 20:43:37 +12:00
from datetime import datetime
from pydantic import BaseModel, ConfigDict, Field
class ProductCreate(BaseModel):
2026-05-10 09:46:07 +12:00
model_config = ConfigDict(extra="forbid")
client_name: str = Field(min_length=1, max_length=255)
item_id: str | None = Field(default=None, max_length=128)
name: str = Field(min_length=1, max_length=255)
2026-04-25 20:43:37 +12:00
mix_id: int
sale_type: str = "standard"
own_bag: bool = False
2026-05-10 09:46:07 +12:00
visible: bool = True
unit_of_measure: str = Field(default="20kg bag", min_length=1, max_length=64)
2026-04-25 20:43:37 +12:00
items_per_pallet: int = Field(default=50, gt=0)
2026-05-10 09:46:07 +12:00
bagging_process: str | None = Field(default=None, max_length=128)
2026-04-25 20:43:37 +12:00
distributor_margin: float | None = Field(default=None, gt=0, lt=1)
wholesale_margin: float | None = Field(default=None, gt=0, lt=1)
2026-05-10 09:46:07 +12:00
notes: str | None = Field(default=None, max_length=2000)
2026-04-25 20:43:37 +12:00
class ProductUpdate(BaseModel):
2026-05-10 09:46:07 +12:00
model_config = ConfigDict(extra="forbid")
client_name: str | None = Field(default=None, min_length=1, max_length=255)
item_id: str | None = Field(default=None, max_length=128)
name: str | None = Field(default=None, min_length=1, max_length=255)
2026-04-25 20:43:37 +12:00
mix_id: int | None = None
sale_type: str | None = None
own_bag: bool | None = None
2026-05-10 09:46:07 +12:00
visible: bool | None = None
unit_of_measure: str | None = Field(default=None, min_length=1, max_length=64)
2026-04-25 20:43:37 +12:00
items_per_pallet: int | None = Field(default=None, gt=0)
2026-05-10 09:46:07 +12:00
bagging_process: str | None = Field(default=None, max_length=128)
2026-04-25 20:43:37 +12:00
distributor_margin: float | None = Field(default=None, gt=0, lt=1)
wholesale_margin: float | None = Field(default=None, gt=0, lt=1)
2026-05-10 09:46:07 +12:00
notes: str | None = Field(default=None, max_length=2000)
2026-04-25 20:43:37 +12:00
class ProductRead(BaseModel):
id: int
tenant_id: str
client_name: str
item_id: str | None
name: str
mix_id: int
mix_name: str
sale_type: str
own_bag: bool
2026-05-10 09:46:07 +12:00
visible: bool
2026-04-25 20:43:37 +12:00
unit_of_measure: str
items_per_pallet: int
bagging_process: str | None
distributor_margin: float | None
wholesale_margin: float | None
notes: str | None
created_at: datetime
model_config = ConfigDict(from_attributes=True)
class ProductCostBreakdown(BaseModel):
product_id: int
product_name: str
2026-04-27 21:53:36 +12:00
client_name: str
mix_name: str
2026-04-25 20:43:37 +12:00
cleaned_product_cost: float
grading_cost: float
bagging_cost: float
cracking_cost: float
bag_cost: float
freight_cost: float
finished_product_delivered: float
distributor_price: float | None
wholesale_price: float | None
warnings: list[str]
inputs: dict[str, object]