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

@@ -7,9 +7,11 @@ use Carbon\CarbonPeriod;
class WorkingDaysCalculator
{
public const TIMEZONE = 'America/New_York';
public static function calculate(string $month, array $holidays = []): int
{
$start = Carbon::createFromFormat('Y-m', $month)->startOfMonth();
$start = Carbon::createFromFormat('Y-m', $month, self::TIMEZONE)->startOfMonth();
$end = $start->copy()->endOfMonth();
return self::getWorkingDaysInRange($start->toDateString(), $end->toDateString(), $holidays);
@@ -17,7 +19,10 @@ class WorkingDaysCalculator
public static function getWorkingDaysInRange(string $start, string $end, array $holidays = []): int
{
$period = CarbonPeriod::create(Carbon::create($start), Carbon::create($end));
$period = CarbonPeriod::create(
Carbon::create($start, self::TIMEZONE),
Carbon::create($end, self::TIMEZONE)
);
$holidayLookup = array_flip($holidays);
$workingDays = 0;
@@ -34,7 +39,7 @@ class WorkingDaysCalculator
public static function isWorkingDay(string $date, array $holidays = []): bool
{
$carbonDate = Carbon::create($date);
$carbonDate = Carbon::create($date, self::TIMEZONE);
if ($carbonDate->isWeekend()) {
return false;
@@ -46,4 +51,9 @@ class WorkingDaysCalculator
return true;
}
public static function isWeekend(string $date): bool
{
return Carbon::create($date, self::TIMEZONE)->isWeekend();
}
}