Commit Graph

95 Commits

Author SHA1 Message Date
Claude
be8cb20b18 fix: Replace all remaining hardcoded English reasoning with structured codes
This commit removes the last hardcoded English text from reasoning fields
across all backend services, completing the i18n implementation.

Changes by service:

Safety Stock Calculator (safety_stock_calculator.py):
- CALC:STATISTICAL_Z_SCORE - Statistical calculation with Z-score
- CALC:ADVANCED_VARIABILITY - Advanced formula with demand and lead time variability
- CALC:FIXED_PERCENTAGE - Fixed percentage of lead time demand
- All calculation methods now use structured codes with pipe-separated parameters

Price Forecaster (price_forecaster.py):
- PRICE_FORECAST:DECREASE_EXPECTED - Price expected to decrease
- PRICE_FORECAST:INCREASE_EXPECTED - Price expected to increase
- PRICE_FORECAST:HIGH_VOLATILITY - High price volatility detected
- PRICE_FORECAST:BELOW_AVERAGE - Current price below average (buy opportunity)
- PRICE_FORECAST:STABLE - Price stable, normal schedule
- All forecasts include relevant parameters (change_pct, days, etc.)

Optimization Utils (shared/utils/optimization.py):
- EOQ:BASE - Economic Order Quantity base calculation
- EOQ:MOQ_APPLIED - Minimum order quantity constraint applied
- EOQ:MAX_APPLIED - Maximum order quantity constraint applied
- TIER_PRICING:CURRENT_TIER - Current tier pricing
- TIER_PRICING:UPGRADED - Upgraded to higher tier for savings
- All optimizations include calculation parameters

Format: All codes use pattern "CATEGORY:TYPE|param1=value|param2=value"
This allows frontend to parse and translate with parameters while maintaining
technical accuracy for logging and debugging.

Frontend can now translate ALL reasoning codes across the entire system.
2025-11-07 19:00:00 +00:00
Claude
ddc4928d78 feat: Implement structured reasoning_data generation for i18n support
Implemented proper reasoning data generation for purchase orders and
production batches to enable multilingual dashboard support.

Backend Strategy:
- Generate structured JSON with type codes and parameters
- Store only reasoning_data (JSONB), not hardcoded text
- Frontend will translate using i18n libraries

Changes:
1. Created shared/schemas/reasoning_types.py
   - Defined reasoning types for POs and batches
   - Created helper functions for common reasoning patterns
   - Supports multiple reasoning types (low_stock, forecast_demand, etc.)

2. Production Service (services/production/app/services/production_service.py)
   - Generate reasoning_data when creating batches from forecast
   - Include parameters: product_name, predicted_demand, current_stock, etc.
   - Structure supports frontend i18n interpolation

3. Procurement Service (services/procurement/app/services/procurement_service.py)
   - Implemented actual PO creation (was placeholder before!)
   - Groups requirements by supplier
   - Generates reasoning_data based on context (low_stock vs forecast)
   - Creates PO items automatically

Example reasoning_data:
{
  "type": "low_stock_detection",
  "parameters": {
    "supplier_name": "Harinas del Norte",
    "product_names": ["Flour Type 55", "Flour Type 45"],
    "days_until_stockout": 3,
    "current_stock": 45.5,
    "required_stock": 200
  },
  "consequence": {
    "type": "stockout_risk",
    "severity": "high",
    "impact_days": 3
  }
}

Frontend will translate:
- EN: "Low stock detected for Harinas del Norte. Stock runs out in 3 days."
- ES: "Stock bajo detectado para Harinas del Norte. Se agota en 3 días."
- CA: "Estoc baix detectat per Harinas del Norte. S'esgota en 3 dies."

Next steps:
- Remove TEXT fields (reasoning, consequence) from models
- Update dashboard service to use reasoning_data
- Create frontend i18n translation keys
- Update dashboard components to translate dynamically
2025-11-07 18:16:44 +00:00
Urtzi Alfaro
3ad093d38b Fix orchestrator issues 2025-11-05 22:54:14 +01:00
Urtzi Alfaro
394ad3aea4 Improve AI logic 2025-11-05 13:34:56 +01:00
Urtzi Alfaro
5adb0e39c0 Improve the frontend 5 2025-11-02 20:24:44 +01:00
Urtzi Alfaro
269d3b5032 Add user delete process 2025-10-31 11:54:19 +01:00
Urtzi Alfaro
63f5c6d512 Improve the frontend 3 2025-10-30 21:08:07 +01:00
Urtzi Alfaro
36217a2729 Improve the frontend 2 2025-10-29 06:58:05 +01:00
Urtzi Alfaro
858d985c92 Improve the frontend modals 2025-10-27 16:33:26 +01:00
Urtzi Alfaro
61376b7a9f Improve the frontend and fix TODOs 2025-10-24 13:05:04 +02:00
Urtzi Alfaro
07c33fa578 Improve the frontend and repository layer 2025-10-23 07:44:54 +02:00
Urtzi Alfaro
8d30172483 Improve the frontend 2025-10-21 19:50:07 +02:00
Urtzi Alfaro
05da20357d Improve teh securty of teh DB 2025-10-19 19:22:37 +02:00
Urtzi Alfaro
312e36c893 Update requirements and insfra versions 2025-10-17 23:09:40 +02:00
Urtzi Alfaro
7e089b80cf Improve public pages 2025-10-17 18:14:28 +02:00
Urtzi Alfaro
d4060962e4 Improve demo seed 2025-10-17 07:31:14 +02:00
Urtzi Alfaro
dbb48d8e2c Improve the sales import 2025-10-15 21:09:42 +02:00
Urtzi Alfaro
8f9e9a7edc Add role-based filtering and imporve code 2025-10-15 16:12:49 +02:00
Urtzi Alfaro
96ad5c6692 Refactor datetime and timezone utils 2025-10-12 23:16:04 +02:00
Urtzi Alfaro
7556a00db7 Improve the demo feature of the project 2025-10-12 18:47:33 +02:00
Urtzi Alfaro
b420af32c5 REFACTOR production scheduler 2025-10-09 18:01:24 +02:00
Urtzi Alfaro
3c689b4f98 REFACTOR external service and improve websocket training 2025-10-09 14:11:02 +02:00
Urtzi Alfaro
7c72f83c51 REFACTOR ALL APIs fix 1 2025-10-07 07:15:07 +02:00
Urtzi Alfaro
38fb98bc27 REFACTOR ALL APIs 2025-10-06 15:27:01 +02:00
Urtzi Alfaro
dc8221bd2f Add DEMO feature to the project 2025-10-03 14:09:34 +02:00
Urtzi Alfaro
c9d8d1d071 Fix onboarding process not getting the subcription plan 2025-10-01 21:56:38 +02:00
Urtzi Alfaro
016742d63f Fix startup issues 2025-10-01 12:17:59 +02:00
Urtzi Alfaro
2eeebfc1e0 Fix Alembic issue 2025-10-01 11:24:06 +02:00
Urtzi Alfaro
7cc4b957a5 Fix DB issue 2s 2025-09-30 21:58:10 +02:00
Urtzi Alfaro
ec6bcb4c7d Add migration services 2025-09-30 08:12:45 +02:00
Urtzi Alfaro
befcc126b0 Refactor all main.py 2025-09-29 13:13:12 +02:00
Urtzi Alfaro
4777e59e7a Add base kubernetes support final fix 4 2025-09-29 07:54:25 +02:00
Urtzi Alfaro
3816383760 Add base kubernetes support final 2025-09-28 13:54:28 +02:00
Urtzi Alfaro
b95ecf1c53 Add base kubernetes support 5 2025-09-27 22:55:42 +02:00
Urtzi Alfaro
222f945466 Add base kubernetes support 2 2025-09-27 12:10:43 +02:00
Urtzi Alfaro
a27f159e24 Fix few issues 2025-09-26 12:12:17 +02:00
Urtzi Alfaro
cf4405b771 Fix production deadlock 2025-09-25 21:00:40 +02:00
Urtzi Alfaro
89b75bd7af Support subcription payments 2025-09-25 14:30:47 +02:00
Urtzi Alfaro
7892c5a739 Add improved production UI 3 2025-09-23 19:24:22 +02:00
Urtzi Alfaro
4ae8e14e55 Add improved production UI 2025-09-23 12:49:35 +02:00
Urtzi Alfaro
e1b3184413 Add subcription level filtering 2025-09-21 13:27:50 +02:00
Urtzi Alfaro
d18c64ce6e Create the frontend receipes page to use real API 2025-09-19 21:39:04 +02:00
Urtzi Alfaro
d61056df33 Add supplier and imporve inventory frontend 2025-09-18 23:32:53 +02:00
Urtzi Alfaro
ae77a0e1c5 Improve the inventory page 3 2025-09-18 08:06:32 +02:00
Urtzi Alfaro
dcb3ce441b Improve the inventory page 2025-09-17 16:06:30 +02:00
Urtzi Alfaro
23e088dcb4 Add frontend procurement implementation 2 2025-09-09 17:40:57 +02:00
Urtzi Alfaro
0faaa25e58 Start integrating the onboarding flow with backend 3 2025-09-04 23:19:53 +02:00
Urtzi Alfaro
5077a45a25 Add procurement management logic 2025-08-23 19:47:08 +02:00
Urtzi Alfaro
b7eb4888a6 Update frontend 2025-08-23 16:30:45 +02:00
Urtzi Alfaro
a214617815 Add new alert architecture to forecasting 2025-08-23 15:48:32 +02:00