Fix new services implementation 2
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user