feat: Complete backend i18n implementation with error codes and demo data

Demo Seed Scripts:
- Updated seed_demo_purchase_orders.py to use structured reasoning_data
  * Imports create_po_reasoning_low_stock and create_po_reasoning_supplier_contract
  * Generates reasoning_data with product names, stock levels, and consequences
  * Removed deprecated reasoning/consequence TEXT fields
- Updated seed_demo_batches.py to use structured reasoning_data
  * Imports create_batch_reasoning_forecast_demand and create_batch_reasoning_regular_schedule
  * Generates intelligent reasoning based on batch priority and AI assistance
  * Adds reasoning_data to all production batches

Backend Services - Error Code Implementation:
- Updated safety_stock_calculator.py with error codes
  * Replaced "Lead time or demand std dev is zero or negative" with ERROR:LEAD_TIME_INVALID
  * Replaced "Insufficient historical demand data" with ERROR:INSUFFICIENT_DATA
- Updated replenishment_planning_service.py with error codes
  * Replaced "Insufficient data for safety stock calculation" with ERROR:INSUFFICIENT_DATA
  * Frontend can now translate error codes using i18n

Demo data will now display with translatable reasoning in EN/ES/EU languages.
Backend services return error codes that frontend translates for user's language.
This commit is contained in:
Claude
2025-11-07 18:40:44 +00:00
parent 28136cf198
commit ed7db4d4f2
4 changed files with 70 additions and 29 deletions

View File

@@ -373,7 +373,7 @@ class ReplenishmentPlanningService:
lead_time_days=req.lead_time_days,
calculation_method='none',
confidence='low',
reasoning='Insufficient data for safety stock calculation'
reasoning='ERROR:INSUFFICIENT_DATA' # Error code for i18n translation
)
def _adjust_for_shelf_life(

View File

@@ -108,7 +108,7 @@ class SafetyStockCalculator:
lead_time_days=lead_time_days,
calculation_method='zero_due_to_invalid_inputs',
confidence='low',
reasoning='Lead time or demand std dev is zero or negative'
reasoning='ERROR:LEAD_TIME_INVALID' # Error code for i18n translation
)
# Safety Stock = Z × σ × √L
@@ -160,7 +160,7 @@ class SafetyStockCalculator:
lead_time_days=lead_time_days,
calculation_method='insufficient_data',
confidence='low',
reasoning='Insufficient historical demand data (need at least 2 data points)'
reasoning='ERROR:INSUFFICIENT_DATA' # Error code for i18n translation
)
# Calculate standard deviation