2.8 KiB
US-MGN-008-005-002: Alertas de Desviación Presupuestaria
RF Asociado: RF-MGN-008-001 Módulo: MGN-008 - Contabilidad Analítica Epic: Presupuestos Analíticos Prioridad: P2 Story Points: 2 Sprint: Sprint 19 Estado: Ready for Development Fecha: 2025-11-24
User Story
Como gerente, Quiero recibir alertas automáticas cuando el gasto real exceda el presupuesto, Para tomar acciones correctivas a tiempo.
Descripción Detallada
Sistema monitorea continuamente:
- Presupuesto vs Real por cuenta analítica
- Threshold configurable (ej: alertar al 80%, 100%, 120%)
- Notificaciones vía email y in-app
Ejemplo:
- Proyecto A: Presupuesto $60K, Real $54K (90%)
- Alerta: "Proyecto A ha alcanzado el 90% del presupuesto"
Criterios de Aceptación
Escenario 1: Alerta al 80%
Dado que Proyecto A tiene presupuesto $60K, threshold=80%, Cuando gasto real alcanza $48K (80%), Entonces sistema envía alerta al gerente del proyecto.
Escenario 2: Alerta al exceder 100%
Dado que presupuesto es $60K, Cuando gasto real alcanza $61K (101.7%), Entonces sistema envía alerta crítica "Presupuesto excedido".
Escenario 3: Configurar thresholds
Dado que soy gerente, Cuando configuro thresholds: 80%, 100%, 120%, Entonces sistema envía alertas en cada umbral.
Escenario 4: Dashboard de desviaciones
Dado que múltiples proyectos tienen desviaciones, Cuando accedo a dashboard, Entonces veo widget "Proyectos en riesgo" con % de ejecución.
Reglas de Negocio
- RN-1: Alertas se envían solo una vez por umbral.
- RN-2: Thresholds configurables por cuenta analítica.
- RN-3: Alertas vía email + notificación in-app.
Tareas Técnicas
Backend
- Service:
BudgetAlertService.checkBudgets()(cron job) - Service:
BudgetAlertService.calculateVariance(account) - Service:
BudgetAlertService.sendAlert(user, account, variance) - Cron: Ejecutar cada hora
- Unit tests
Frontend
- Componente:
BudgetAlertsWidget.tsx(dashboard) - Página:
BudgetThresholdsConfigPage.tsx - Notificaciones in-app
Database
- Tabla:
analytics.budget_alerts(account_id, threshold, triggered_at) - Tabla:
analytics.budget_thresholds(account_id, thresholds[])
Estimación Detallada
| Tarea | Horas |
|---|---|
| Backend | 1 |
| Frontend | 0.5 |
| Testing | 0.5 |
| TOTAL | 2 horas = 2 SP |
Definition of Done
- Alertas funcionan automáticamente
- Thresholds configurables
- Notificaciones se envían
- Tests >80%
- QA/PO aprobado