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

@@ -195,4 +195,47 @@ class CapacityController extends Controller
return $this->wrapResource(new TeamMemberAvailabilityResource($entry), 201);
}
/**
* Batch Update Team Member Availability
*
* Persist multiple daily availability overrides in a single batch operation.
*
* @group Capacity Planning
*
* @bodyParam month string required The month in YYYY-MM format. Example: 2026-02
* @bodyParam updates array required Array of availability updates.
* @bodyParam updates[].team_member_id string required The team member UUID.
* @bodyParam updates[].date string required The date (YYYY-MM-DD).
* @bodyParam updates[].availability numeric required The availability value (0, 0.5, 1).
*
* @response {
* "data": {
* "saved": 12,
* "month": "2026-02"
* }
* }
*/
public function batchUpdateAvailability(Request $request): JsonResponse
{
$data = $request->validate([
'month' => 'required|date_format:Y-m',
'updates' => 'present|array',
'updates.*.team_member_id' => 'required_with:updates|exists:team_members,id',
'updates.*.date' => 'required_with:updates|date_format:Y-m-d',
'updates.*.availability' => ['required_with:updates', 'numeric', Rule::in([0, 0.5, 1])],
]);
$saved = $this->capacityService->batchUpsertAvailability(
$data['updates'],
$data['month']
);
return response()->json([
'data' => [
'saved' => $saved,
'month' => $data['month'],
],
]);
}
}