Игорь Надеин
69402567e3
feat(procurement): add budget control and alerts
Budget Model Enhancements:
- Add reserved_amount property (sum of pending requests)
- Add available_amount property (remaining - reserved)
- Add _quarter_months() helper method
API Endpoints:
- Add /budgets/my-department/ endpoint for user's department budget
- Add /stats/overview/ for procurement statistics
- Add /stats/by-department/ for department-level statistics
- Register ProcurementStatsViewSet in urls.py
Budget Alerts:
- Add _check_budget_alert() method in ProcurementRequestViewSet
- Send notifications when budget < 20% (low) or < 10% (critical)
- Alerts sent to department head via NotificationService
Serializers:
- Add reserved_amount, available_amount to BudgetSerializer
- Add BudgetDetailSerializer with pending_requests list
Permissions:
- Fix led_departments → headed_departments in BudgetViewSet
- Allow my_department endpoint for all authenticated users
Tests:
- Add test_budget.py with 11 new tests
- TestBudgetReservedAmount (3 tests)
- TestBudgetMyDepartmentEndpoint (3 tests)
- TestProcurementStatsEndpoints (4 tests)
- TestBudgetAlerts (1 test)
All 52 procurement tests passing:
✅ 20/20 Model tests
✅ 12/12 API tests
✅ 9/9 Workflow tests
✅ 11/11 Budget tests (NEW)
2025-12-09 10:19:24 +03:00
..
2025-12-09 09:41:26 +03:00
2025-09-09 17:55:15 +03:00
2025-11-29 16:41:03 +03:00
2025-12-05 16:18:11 +03:00
2025-12-03 12:50:10 +03:00
2025-11-30 11:20:05 +03:00
2025-12-05 13:07:57 +03:00
2025-12-08 13:29:53 +03:00
2025-12-09 09:41:26 +03:00
2025-12-05 10:56:23 +03:00
2025-11-20 09:00:55 +03:00
2025-07-30 08:15:53 +03:00
2025-11-20 09:00:55 +03:00
2025-11-20 09:00:55 +03:00
2025-12-03 12:50:10 +03:00
2025-12-09 10:19:24 +03:00
2025-12-03 12:59:12 +03:00
2025-12-05 14:53:52 +03:00
2025-09-11 17:56:33 +03:00
2025-12-08 13:37:20 +03:00
2025-12-08 14:24:40 +03:00
2025-12-09 10:19:24 +03:00
2025-07-30 08:15:53 +03:00
2025-10-28 08:54:38 +03:00
2025-12-01 14:19:58 +03:00
2025-12-01 14:19:58 +03:00
2025-11-29 16:41:03 +03:00
2025-12-02 14:44:48 +03:00
2025-11-20 18:52:29 +03:00
2025-12-01 14:19:58 +03:00
2025-10-28 08:54:38 +03:00
2025-12-01 14:19:58 +03:00
2025-12-01 14:19:58 +03:00
2025-12-02 17:39:09 +03:00
2025-10-28 08:54:38 +03:00
2025-10-28 08:54:38 +03:00
2025-11-20 09:00:55 +03:00
2025-09-03 17:17:44 +03:00
2025-11-20 18:52:29 +03:00
2025-11-20 09:00:55 +03:00
2025-07-30 08:15:53 +03:00
2025-12-01 14:19:58 +03:00
2025-12-01 14:19:58 +03:00
2025-12-08 14:17:06 +03:00
2025-12-09 09:41:26 +03:00
2025-11-20 18:52:29 +03:00
2025-12-01 14:19:58 +03:00
2025-12-01 14:19:58 +03:00
2025-10-28 08:54:38 +03:00
2025-12-03 07:21:25 +03:00
2025-11-21 12:57:01 +03:00
2025-12-02 17:39:09 +03:00
2025-11-20 18:52:29 +03:00
2025-11-30 12:25:19 +03:00
2025-12-05 16:25:17 +03:00
2025-11-30 12:25:19 +03:00
2025-11-21 15:46:02 +03:00
2025-12-05 16:18:45 +03:00
2025-12-05 16:18:45 +03:00
2025-12-01 14:19:58 +03:00
2025-12-03 13:48:31 +03:00
2025-11-20 18:52:29 +03:00
2025-11-20 18:52:29 +03:00
2025-11-20 18:52:29 +03:00
2025-12-01 14:19:58 +03:00
2025-12-02 17:39:09 +03:00
2025-12-02 17:39:09 +03:00
2025-11-21 13:35:38 +03:00
2025-12-01 14:19:58 +03:00
2025-12-03 07:21:25 +03:00
2025-12-03 07:21:25 +03:00
2025-12-01 14:19:58 +03:00