Add supplier and imporve inventory frontend

This commit is contained in:
Urtzi Alfaro
2025-09-18 23:32:53 +02:00
parent ae77a0e1c5
commit d61056df33
40 changed files with 2022 additions and 629 deletions

View File

@@ -61,13 +61,6 @@ class IngredientCreate(InventoryBaseSchema):
is_perishable: bool = Field(False, description="Is perishable")
allergen_info: Optional[Dict[str, Any]] = Field(None, description="Allergen information")
@validator('storage_temperature_max')
def validate_temperature_range(cls, v, values):
if v is not None and 'storage_temperature_min' in values and values['storage_temperature_min'] is not None:
if v <= values['storage_temperature_min']:
raise ValueError('Max temperature must be greater than min temperature')
return v
@validator('reorder_point')
def validate_reorder_point(cls, v, values):
if 'low_stock_threshold' in values and v <= values['low_stock_threshold']:
@@ -147,6 +140,7 @@ class IngredientResponse(InventoryBaseSchema):
class StockCreate(InventoryBaseSchema):
"""Schema for creating stock entries"""
ingredient_id: str = Field(..., description="Ingredient ID")
supplier_id: Optional[str] = Field(None, description="Supplier ID")
batch_number: Optional[str] = Field(None, max_length=100, description="Batch number")
lot_number: Optional[str] = Field(None, max_length=100, description="Lot number")
supplier_batch_ref: Optional[str] = Field(None, max_length=100, description="Supplier batch reference")
@@ -181,9 +175,16 @@ class StockCreate(InventoryBaseSchema):
shelf_life_days: Optional[int] = Field(None, gt=0, description="Batch-specific shelf life in days")
storage_instructions: Optional[str] = Field(None, description="Batch-specific storage instructions")
@validator('storage_temperature_max')
def validate_temperature_range(cls, v, values):
min_temp = values.get('storage_temperature_min')
if v is not None and min_temp is not None and v <= min_temp:
raise ValueError('Max temperature must be greater than min temperature')
return v
class StockUpdate(InventoryBaseSchema):
"""Schema for updating stock entries"""
supplier_id: Optional[str] = Field(None, description="Supplier ID")
batch_number: Optional[str] = Field(None, max_length=100, description="Batch number")
lot_number: Optional[str] = Field(None, max_length=100, description="Lot number")
supplier_batch_ref: Optional[str] = Field(None, max_length=100, description="Supplier batch reference")
@@ -226,6 +227,7 @@ class StockResponse(InventoryBaseSchema):
id: str
tenant_id: str
ingredient_id: str
supplier_id: Optional[str]
batch_number: Optional[str]
lot_number: Optional[str]
supplier_batch_ref: Optional[str]