Fix new services implementation 2

This commit is contained in:
Urtzi Alfaro
2025-08-14 13:26:59 +02:00
parent 262b3dc9c4
commit 0951547e92
39 changed files with 1203 additions and 917 deletions

View File

@@ -160,6 +160,14 @@ class Ingredient(Base):
def to_dict(self) -> Dict[str, Any]:
"""Convert model to dictionary for API responses"""
# Map to response schema format - use ingredient_category as primary category
category = None
if self.ingredient_category:
category = self.ingredient_category.value
elif self.product_category:
# For finished products, we could map to a generic category
category = "other"
return {
'id': str(self.id),
'tenant_id': str(self.tenant_id),
@@ -167,6 +175,7 @@ class Ingredient(Base):
'sku': self.sku,
'barcode': self.barcode,
'product_type': self.product_type.value if self.product_type else None,
'category': category, # Map to what IngredientResponse expects
'ingredient_category': self.ingredient_category.value if self.ingredient_category else None,
'product_category': self.product_category.value if self.product_category else None,
'subcategory': self.subcategory,