v1.2 scaffold
This commit is contained in:
@@ -0,0 +1 @@
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
from datetime import datetime
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, Field
|
||||
|
||||
|
||||
class MixIngredientCreate(BaseModel):
|
||||
raw_material_id: int
|
||||
quantity_kg: float = Field(gt=0)
|
||||
notes: str | None = None
|
||||
|
||||
|
||||
class MixIngredientUpdate(BaseModel):
|
||||
quantity_kg: float | None = Field(default=None, gt=0)
|
||||
notes: str | None = None
|
||||
|
||||
|
||||
class MixIngredientRead(BaseModel):
|
||||
id: int
|
||||
raw_material_id: int
|
||||
raw_material_name: str
|
||||
quantity_kg: float
|
||||
cost_per_kg: float | None
|
||||
line_cost: float | None
|
||||
notes: str | None
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
|
||||
|
||||
class MixCreate(BaseModel):
|
||||
client_name: str
|
||||
name: str
|
||||
status: str = "draft"
|
||||
version: int = 1
|
||||
notes: str | None = None
|
||||
ingredients: list[MixIngredientCreate]
|
||||
|
||||
|
||||
class MixUpdate(BaseModel):
|
||||
client_name: str | None = None
|
||||
name: str | None = None
|
||||
status: str | None = None
|
||||
version: int | None = None
|
||||
notes: str | None = None
|
||||
|
||||
|
||||
class MixRead(BaseModel):
|
||||
id: int
|
||||
tenant_id: str
|
||||
client_name: str
|
||||
name: str
|
||||
status: str
|
||||
version: int
|
||||
notes: str | None
|
||||
created_at: datetime
|
||||
ingredients: list[MixIngredientRead]
|
||||
total_mix_kg: float
|
||||
total_mix_cost: float
|
||||
mix_cost_per_kg: float | None
|
||||
warnings: list[str]
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
from datetime import datetime
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, Field
|
||||
|
||||
|
||||
class ProductCreate(BaseModel):
|
||||
client_name: str
|
||||
item_id: str | None = None
|
||||
name: str
|
||||
mix_id: int
|
||||
sale_type: str = "standard"
|
||||
own_bag: bool = False
|
||||
unit_of_measure: str = "20kg bag"
|
||||
items_per_pallet: int = Field(default=50, gt=0)
|
||||
bagging_process: str | None = None
|
||||
distributor_margin: float | None = Field(default=None, gt=0, lt=1)
|
||||
wholesale_margin: float | None = Field(default=None, gt=0, lt=1)
|
||||
notes: str | None = None
|
||||
|
||||
|
||||
class ProductUpdate(BaseModel):
|
||||
client_name: str | None = None
|
||||
item_id: str | None = None
|
||||
name: str | None = None
|
||||
mix_id: int | None = None
|
||||
sale_type: str | None = None
|
||||
own_bag: bool | None = None
|
||||
unit_of_measure: str | None = None
|
||||
items_per_pallet: int | None = Field(default=None, gt=0)
|
||||
bagging_process: str | None = None
|
||||
distributor_margin: float | None = Field(default=None, gt=0, lt=1)
|
||||
wholesale_margin: float | None = Field(default=None, gt=0, lt=1)
|
||||
notes: str | None = None
|
||||
|
||||
|
||||
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
|
||||
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
|
||||
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]
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
from datetime import date, datetime
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, Field
|
||||
|
||||
|
||||
class RawMaterialPriceVersionCreate(BaseModel):
|
||||
market_value: float = Field(gt=0)
|
||||
waste_percentage: float = Field(ge=0, default=0.0)
|
||||
effective_date: date
|
||||
status: str = "active"
|
||||
notes: str | None = None
|
||||
|
||||
|
||||
class RawMaterialPriceVersionRead(RawMaterialPriceVersionCreate):
|
||||
id: int
|
||||
created_at: datetime
|
||||
loss_cost: float
|
||||
cost_per_unit: float
|
||||
cost_per_kg: float
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
|
||||
|
||||
class RawMaterialCreate(BaseModel):
|
||||
name: str
|
||||
supplier: str | None = None
|
||||
unit_of_measure: str
|
||||
kg_per_unit: float = Field(gt=0)
|
||||
status: str = "active"
|
||||
notes: str | None = None
|
||||
initial_price: RawMaterialPriceVersionCreate
|
||||
|
||||
|
||||
class RawMaterialUpdate(BaseModel):
|
||||
supplier: str | None = None
|
||||
unit_of_measure: str | None = None
|
||||
kg_per_unit: float | None = Field(default=None, gt=0)
|
||||
status: str | None = None
|
||||
notes: str | None = None
|
||||
|
||||
|
||||
class RawMaterialRead(BaseModel):
|
||||
id: int
|
||||
tenant_id: str
|
||||
name: str
|
||||
supplier: str | None
|
||||
unit_of_measure: str
|
||||
kg_per_unit: float
|
||||
status: str
|
||||
notes: str | None
|
||||
created_at: datetime
|
||||
current_price: RawMaterialPriceVersionRead | None
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
from datetime import datetime
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, Field
|
||||
|
||||
from app.schemas.product import ProductCostBreakdown
|
||||
|
||||
|
||||
class ScenarioCreate(BaseModel):
|
||||
name: str
|
||||
description: str | None = None
|
||||
overrides: dict = Field(default_factory=dict)
|
||||
|
||||
|
||||
class ScenarioRead(BaseModel):
|
||||
id: int
|
||||
name: str
|
||||
status: str
|
||||
description: str | None
|
||||
overrides: dict
|
||||
created_at: datetime
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
|
||||
|
||||
class ScenarioRunResponse(BaseModel):
|
||||
scenario: ScenarioRead
|
||||
results: list[ProductCostBreakdown]
|
||||
Reference in New Issue
Block a user