Files
geMoldInsight/src/api/inventory/schemas/product_schemas.py
T
2026-04-09 23:15:56 +08:00

62 lines
1.2 KiB
Python

from pydantic import BaseModel
from typing import Optional, List
from datetime import datetime
class ProductCreate(BaseModel):
sku: str
name: str
description: Optional[str] = None
category: Optional[str] = None
unit: str = "件"
item_type: str = "finished"
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
item_type: str
cost_price: float
sale_price: float
min_stock: int
max_stock: int
material_cost: float = 0
is_active: bool
created_at: datetime
class Config:
from_attributes = True
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]