Fix enum mismatch: Update Python enums and seed data to match database uppercase values

- Fixed ProductType enum values from lowercase to uppercase (INGREDIENT, FINISHED_PRODUCT)
- Fixed UnitOfMeasure enum values from lowercase/abbreviated to uppercase (KILOGRAMS, LITERS, etc.)
- Fixed IngredientCategory enum values from lowercase to uppercase (FLOUR, YEAST, etc.)
- Fixed ProductCategory enum values from lowercase to uppercase (BREAD, CROISSANTS, etc.)
- Updated seed data files to use correct uppercase enum values
- Fixed hardcoded enum references throughout the codebase
- This resolves the InvalidTextRepresentationError when inserting inventory data

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
Urtzi Alfaro
2025-12-13 16:49:04 +01:00
parent e116ac244c
commit 10c779858a
7 changed files with 1354 additions and 47 deletions

View File

@@ -1069,14 +1069,14 @@ class InventoryService:
ingredient_create = IngredientCreate(
name=ingredient_data.get('name'),
product_type=ingredient_data.get('type', 'finished_product'),
unit_of_measure=ingredient_data.get('unit', 'units'),
product_type=ingredient_data.get('type', 'FINISHED_PRODUCT'),
unit_of_measure=ingredient_data.get('unit', 'UNITS'),
low_stock_threshold=ingredient_data.get('current_stock', 0),
reorder_point=max(ingredient_data.get('reorder_point', 1),
ingredient_data.get('current_stock', 0) + 1),
average_cost=ingredient_data.get('cost_per_unit', 0.0),
ingredient_category=ingredient_data.get('category') if ingredient_data.get('type') == 'ingredient' else None,
product_category=ingredient_data.get('category') if ingredient_data.get('type') == 'finished_product' else None
ingredient_category=ingredient_data.get('category') if ingredient_data.get('type') == 'INGREDIENT' else None,
product_category=ingredient_data.get('category') if ingredient_data.get('type') == 'FINISHED_PRODUCT' else None
)
ingredient = await repository.create_ingredient(ingredient_create, tenant_id)