New alert system and panel de control page

This commit is contained in:
Urtzi Alfaro
2025-11-27 15:52:40 +01:00
parent 1a2f4602f3
commit e902419b6e
178 changed files with 20982 additions and 6944 deletions

View File

@@ -36,6 +36,10 @@ import structlog
from app.models.inventory import Ingredient, Stock, StockMovement, StockMovementType
# Add shared path for demo utilities
sys.path.insert(0, str(Path(__file__).parent.parent.parent.parent))
from shared.utils.demo_dates import BASE_REFERENCE_DATE
# Configure logging
structlog.configure(
processors=[
@@ -51,9 +55,6 @@ logger = structlog.get_logger()
DEMO_TENANT_SAN_PABLO = uuid.UUID("a1b2c3d4-e5f6-47a8-b9c0-d1e2f3a4b5c6")
DEMO_TENANT_LA_ESPIGA = uuid.UUID("b2c3d4e5-f6a7-48b9-c0d1-e2f3a4b5c6d7")
# Base reference date for demo data (all relative dates calculated from this)
BASE_REFERENCE_DATE = datetime(2025, 1, 15, 12, 0, 0, tzinfo=timezone.utc)
# Daily consumption rates (kg/day) - aligned with procurement seed script
# Used to create realistic stock levels that trigger appropriate PO scenarios
DAILY_CONSUMPTION_RATES = {
@@ -196,7 +197,14 @@ async def create_stock_batches_for_ingredient(
# CRITICAL DEMO SCENARIO: Create consumption-aware stock levels
# This creates realistic scenarios that trigger intelligent PO reasoning
critical_low_stock_skus = ["HAR-T55-001", "LEV-SEC-001", "MAN-SAL-001"]
# DASHBOARD SHOWCASE: Critical low stock scenarios for realistic alert demonstration
# These will trigger automatic alert generation by the inventory service
critical_low_stock_skus = [
"HAR-T55-001", # Harina Tipo 55 - URGENT: Will run out in <18h, triggers delivery overdue scenario
"LEV-SEC-001", # Levadura (Yeast) - TODAY: Recommend ordering today
"MAN-SAL-001", # Mantequilla (Butter) - For croissant production batch at risk
"CHO-NEG-001" # Chocolate Negro - For chocolate cake batch at risk in 5 hours
]
is_critical_low = ingredient.sku in critical_low_stock_skus
# Calculate target total stock using consumption-aware logic