imporve features

This commit is contained in:
Urtzi Alfaro
2025-11-14 07:23:56 +01:00
parent 9bc048d360
commit a8d8828935
32 changed files with 5436 additions and 271 deletions

View File

@@ -227,9 +227,9 @@ class InventoryAlertService(BaseAlertService, AlertServiceMixin):
"""Process expiring items for a tenant"""
try:
# Group by urgency
expired = [i for i in items if i['days_to_expiry'] <= 0]
urgent = [i for i in items if 0 < i['days_to_expiry'] <= 2]
warning = [i for i in items if 2 < i['days_to_expiry'] <= 7]
expired = [i for i in items if i['days_until_expiry'] <= 0]
urgent = [i for i in items if 0 < i['days_until_expiry'] <= 2]
warning = [i for i in items if 2 < i['days_until_expiry'] <= 7]
# Process expired products (urgent alerts)
if expired:
@@ -257,7 +257,7 @@ class InventoryAlertService(BaseAlertService, AlertServiceMixin):
'name': item['name'],
'stock_id': str(item['stock_id']),
'quantity': float(item['current_quantity']),
'days_expired': abs(item['days_to_expiry'])
'days_expired': abs(item['days_until_expiry'])
} for item in expired
]
}
@@ -270,12 +270,12 @@ class InventoryAlertService(BaseAlertService, AlertServiceMixin):
'type': 'urgent_expiry',
'severity': 'high',
'title': f'⏰ Caducidad Urgente: {item["name"]}',
'message': f'{item["name"]} caduca en {item["days_to_expiry"]} día(s). Usar prioritariamente.',
'message': f'{item["name"]} caduca en {item["days_until_expiry"]} día(s). Usar prioritariamente.',
'actions': ['Usar inmediatamente', 'Promoción especial', 'Revisar recetas', 'Documentar'],
'metadata': {
'ingredient_id': str(item['id']),
'stock_id': str(item['stock_id']),
'days_to_expiry': item['days_to_expiry'],
'days_to_expiry': item['days_until_expiry'],
'quantity': float(item['current_quantity'])
}
}, item_type='alert')