Files
geMoldInsight/src/api/inventory/schemas/product_schemas.py
T

62 lines
1.2 KiB
Python
Raw Normal View History

2026-03-08 22:58:25 +08:00
from pydantic import BaseModel
2026-03-15 22:50:38 +08:00
from typing import Optional, List
2026-03-08 22:58:25 +08:00
from datetime import datetime
class ProductCreate(BaseModel):
sku: str
name: str
description: Optional[str] = None
category: Optional[str] = None
unit: str = "件"
2026-03-15 22:50:38 +08:00
item_type: str = "finished"
2026-03-08 22:58:25 +08:00
cost_price: float = 0
sale_price: float = 0
min_stock: int = 0
max_stock: int = 1000
class ProductResponse(BaseModel):
id: int
sku: str
name: str
description: Optional[str]
category: Optional[str]
unit: str
2026-03-15 22:50:38 +08:00
item_type: str
2026-03-08 22:58:25 +08:00
cost_price: float
sale_price: float
min_stock: int
max_stock: int
2026-03-15 22:50:38 +08:00
material_cost: float = 0
2026-03-08 22:58:25 +08:00
is_active: bool
created_at: datetime
class Config:
from_attributes = True
2026-03-15 22:50:38 +08:00
class ProductMaterialItemUpdate(BaseModel):
material_id: int
quantity: float
class ProductBOMUpdate(BaseModel):
items: List[ProductMaterialItemUpdate]
class ProductMaterialItemResponse(BaseModel):
material_id: int
material_sku: str
material_name: str
quantity: float
unit_cost: float
line_cost: float
class ProductBOMResponse(BaseModel):
product_id: int
product_name: str
total_material_cost: float
items: List[ProductMaterialItemResponse]