Fix issues 4

This commit is contained in:
Urtzi Alfaro
2025-08-17 15:21:10 +02:00
parent cafd316c4b
commit f33f5d242a
6 changed files with 255 additions and 45 deletions

View File

@@ -10,7 +10,7 @@ from pydantic import BaseModel, Field, validator
from typing import Generic, TypeVar
from enum import Enum
from app.models.inventory import UnitOfMeasure, IngredientCategory, StockMovementType
from app.models.inventory import UnitOfMeasure, IngredientCategory, StockMovementType, ProductType, ProductCategory
T = TypeVar('T')
@@ -32,11 +32,12 @@ class InventoryBaseSchema(BaseModel):
# ===== INGREDIENT SCHEMAS =====
class IngredientCreate(InventoryBaseSchema):
"""Schema for creating ingredients"""
name: str = Field(..., max_length=255, description="Ingredient name")
"""Schema for creating ingredients and finished products"""
name: str = Field(..., max_length=255, description="Product name")
product_type: ProductType = Field(ProductType.INGREDIENT, description="Type of product (ingredient or finished_product)")
sku: Optional[str] = Field(None, max_length=100, description="SKU code")
barcode: Optional[str] = Field(None, max_length=50, description="Barcode")
category: IngredientCategory = Field(..., description="Ingredient category")
category: Optional[str] = Field(None, description="Product category (ingredient or finished product category)")
subcategory: Optional[str] = Field(None, max_length=100, description="Subcategory")
description: Optional[str] = Field(None, description="Ingredient description")
brand: Optional[str] = Field(None, max_length=100, description="Brand name")
@@ -83,11 +84,12 @@ class IngredientCreate(InventoryBaseSchema):
class IngredientUpdate(InventoryBaseSchema):
"""Schema for updating ingredients"""
name: Optional[str] = Field(None, max_length=255, description="Ingredient name")
"""Schema for updating ingredients and finished products"""
name: Optional[str] = Field(None, max_length=255, description="Product name")
product_type: Optional[ProductType] = Field(None, description="Type of product (ingredient or finished_product)")
sku: Optional[str] = Field(None, max_length=100, description="SKU code")
barcode: Optional[str] = Field(None, max_length=50, description="Barcode")
category: Optional[IngredientCategory] = Field(None, description="Ingredient category")
category: Optional[str] = Field(None, description="Product category")
subcategory: Optional[str] = Field(None, max_length=100, description="Subcategory")
description: Optional[str] = Field(None, description="Ingredient description")
brand: Optional[str] = Field(None, max_length=100, description="Brand name")
@@ -122,13 +124,14 @@ class IngredientUpdate(InventoryBaseSchema):
class IngredientResponse(InventoryBaseSchema):
"""Schema for ingredient API responses"""
"""Schema for ingredient and finished product API responses"""
id: str
tenant_id: str
name: str
product_type: ProductType
sku: Optional[str]
barcode: Optional[str]
category: IngredientCategory
category: Optional[str] # Will be populated from ingredient_category or product_category
subcategory: Optional[str]
description: Optional[str]
brand: Optional[str]