Improve frontend panel de control

This commit is contained in:
Urtzi Alfaro
2025-11-20 22:10:16 +01:00
parent 80298b61b2
commit 2ee94fb4b1
9 changed files with 117 additions and 74 deletions

View File

@@ -390,15 +390,30 @@ class DashboardService:
# Calculate urgency based on required delivery date
urgency = self._calculate_po_urgency(po)
# Get reasoning_data or create default
reasoning_data = po.get("reasoning_data") or {
"type": "low_stock_detection",
"parameters": {
"supplier_name": po.get('supplier_name', 'Unknown'),
"product_names": ["Items"],
"days_until_stockout": 7
# Get reasoning_data or create intelligent fallback from PO items
reasoning_data = po.get("reasoning_data")
if not reasoning_data:
# Extract product names from PO line items for better UX
product_names = []
items = po.get("items", [])
for item in items[:5]: # Limit to first 5 items for readability
product_name = item.get("product_name") or item.get("name")
if product_name:
product_names.append(product_name)
# If no items or product names found, use generic fallback
if not product_names:
product_names = ["Items"]
# Create fallback reasoning_data
reasoning_data = {
"type": "low_stock_detection",
"parameters": {
"supplier_name": po.get('supplier_name', 'Unknown'),
"product_names": product_names,
"days_until_stockout": 7
}
}
}
# Get reasoning type and convert to i18n key
reasoning_type = reasoning_data.get('type', 'inventory_replenishment')