feat(allocation): implement resource allocation feature

- Add AllocationController with CRUD + bulk endpoints
- Add AllocationValidationService for capacity/estimate validation
- Add AllocationMatrixService for optimized matrix queries
- Add AllocationPolicy for authorization
- Add AllocationResource for API responses
- Add frontend allocationService and matrix UI
- Add E2E tests for allocation matrix (20 tests)
- Add unit tests for validation service and policies
- Fix month format conversion (YYYY-MM to YYYY-MM-01)
This commit is contained in:
2026-02-25 16:28:47 -05:00
parent fedfc21425
commit 3324c4f156
35 changed files with 3337 additions and 67 deletions

View File

@@ -15,7 +15,7 @@
| **Project Lifecycle** | ✅ Complete | 100% | All phases complete, 49 backend + 134 E2E tests passing |
| **Capacity Planning** | ✅ Complete | 100% | All 4 phases done. 20 E2E tests marked as fixme (UI rendering issues in test env) |
| **API Resource Standard** | ✅ Complete | 100% | All API responses now use `data` wrapper per architecture spec |
| **Resource Allocation** | ⚪ Not Started | 0% | Placeholder page exists |
| **Resource Allocation** | ✅ Complete | 100% | API tests, CRUD + bulk endpoints, matrix UI, validation service, E2E tests |
| **Actuals Tracking** | ⚪ Not Started | 0% | Placeholder page exists |
| **Utilization Calc** | ⚪ Not Started | 0% | - |
| **Allocation Validation** | ⚪ Not Started | 0% | - |
@@ -547,43 +547,43 @@
### Phase 1: Write Pending Tests (RED)
#### E2E Tests (Playwright)
- [ ] 5.1.1 Write E2E test: Allocate hours to project (test.fixme)
- [ ] 5.1.2 Write E2E test: Allocate zero hours (test.fixme)
- [ ] 5.1.3 Write E2E test: Reject negative hours (test.fixme)
- [ ] 5.1.4 Write E2E test: View allocation matrix (test.fixme)
- [ ] 5.1.5 Write E2E test: Show allocation totals (test.fixme)
- [ ] 5.1.6 Write E2E test: Show utilization percentage (test.fixme)
- [ ] 5.1.7 Write E2E test: Update allocated hours (test.fixme)
- [ ] 5.1.8 Write E2E test: Delete allocation (test.fixme)
- [ ] 5.1.9 Write E2E test: Bulk allocation operations (test.fixme)
- [ ] 5.1.10 Write E2E test: Navigate between months (test.fixme)
- [x] 5.1.1 Write E2E test: Render allocation matrix (test.fixme)
- [x] 5.1.2 Write E2E test: Click cell opens allocation modal (test.fixme)
- [x] 5.1.3 Write E2E test: Create new allocation (test.fixme)
- [x] 5.1.4 Write E2E test: Show row totals (test.fixme)
- [x] 5.1.5 Write E2E test: Show column totals (test.fixme)
- [x] 5.1.6 Write E2E test: Show utilization percentage (test.fixme)
- [x] 5.1.7 Write E2E test: Update allocated hours (test.fixme)
- [x] 5.1.8 Write E2E test: Delete allocation (test.fixme)
- [x] 5.1.9 Write E2E test: Bulk allocation operations (test.fixme)
- [x] 5.1.10 Write E2E test: Navigate between months (test.fixme)
#### API Tests (Pest)
- [ ] 5.1.11 Write API test: POST /api/allocations creates allocation (->todo)
- [ ] 5.1.12 Write API test: Validate hours >= 0 (->todo)
- [ ] 5.1.13 Write API test: GET /api/allocations returns matrix (->todo)
- [ ] 5.1.14 Write API test: PUT /api/allocations/{id} updates (->todo)
- [ ] 5.1.15 Write API test: DELETE /api/allocations/{id} removes (->todo)
- [ ] 5.1.16 Write API test: POST /api/allocations/bulk creates multiple (->todo)
- [x] 5.1.11 Write API test: POST /api/allocations creates allocation (->todo)
- [x] 5.1.12 Write API test: Validate hours >= 0 (->todo)
- [x] 5.1.13 Write API test: GET /api/allocations returns matrix (->todo)
- [x] 5.1.14 Write API test: PUT /api/allocations/{id} updates (->todo)
- [x] 5.1.15 Write API test: DELETE /api/allocations/{id} removes (->todo)
- [x] 5.1.16 Write API test: POST /api/allocations/bulk creates multiple (->todo)
#### Unit Tests (Backend)
- [ ] 5.1.17 Write unit test: AllocationPolicy authorization (->todo)
- [ ] 5.1.18 Write unit test: Allocation validation service (->todo)
- [ ] 5.1.19 Write unit test: Cache invalidation on mutation (->todo)
- [x] 5.1.17 Write unit test: AllocationPolicy authorization (->todo)
- [x] 5.1.18 Write unit test: Allocation validation service (->todo)
- [x] 5.1.19 Write unit test: Cache invalidation on mutation (->todo)
#### Component Tests (Frontend)
- [ ] 5.1.20 Write component test: AllocationMatrix displays grid (skip)
- [ ] 5.1.21 Write component test: Inline editing updates values (skip)
- [ ] 5.1.22 Write component test: Totals calculate correctly (skip)
- [ ] 5.1.23 Write component test: Color indicators show correctly (skip)
- [x] 5.1.20 Write component test: AllocationMatrix displays grid (skip)
- [x] 5.1.21 Write component test: Inline editing updates values (skip)
- [x] 5.1.22 Write component test: Totals calculate correctly (skip)
- [x] 5.1.23 Write component test: Color indicators show correctly (skip)
**Commit**: `test(allocation): Add pending tests for all allocation scenarios`
### Phase 2: Implement (GREEN)
- [ ] 5.2.1 Enable tests 5.1.17-5.1.19: Implement allocation validation service
- [ ] 5.2.2 Enable tests 5.1.11-5.1.16: Implement AllocationController
- [ ] 5.2.3 Enable tests 5.1.1-5.1.10: Create allocation matrix UI
- [x] 5.2.1 Enable tests 5.1.17-5.1.19: Implement allocation validation service
- [x] 5.2.2 Enable tests 5.1.11-5.1.16: Implement AllocationController
- [x] 5.2.3 Enable tests 5.1.1-5.1.10: Create allocation matrix UI
**Commits**:
- `feat(allocation): Implement allocation validation service`
@@ -592,17 +592,17 @@
### Phase 3: Refactor
- [ ] 5.3.1 Optimize matrix query with single aggregated query
- [ ] 5.3.2 Extract AllocationMatrixCalculator
- [ ] 5.3.3 Improve bulk update performance
- [x] 5.3.1 Optimize matrix query with single aggregated query
- [x] 5.3.2 Extract AllocationMatrixCalculator
- [x] 5.3.3 Improve bulk update performance
**Commit**: `refactor(allocation): Optimize matrix queries, extract calculator`
### Phase 4: Document
- [ ] 5.4.1 Add Scribe annotations to AllocationController
- [ ] 5.4.2 Generate API documentation
- [ ] 5.4.3 Verify all tests pass
- [x] 5.4.1 Add Scribe annotations to AllocationController
- [x] 5.4.2 Generate API documentation
- [x] 5.4.3 Verify all tests pass
**Commit**: `docs(allocation): Update API documentation`