fix(capacity): stabilize PTO flows and calendar consistency
Make PTO creation immediately approved, add PTO deletion, and ensure cache invalidation updates individual/team/revenue capacity consistently. Harden holiday duplicate handling (422), support PTO-day availability overrides without disabling edits, and align tests plus OpenSpec artifacts with the new behavior.
This commit is contained in:
@@ -61,12 +61,11 @@ class CapacityService
|
||||
continue;
|
||||
}
|
||||
|
||||
$availability = $availabilities->get($date, 1.0);
|
||||
$isPto = in_array($date, $ptoDates, true);
|
||||
|
||||
if ($isPto) {
|
||||
$availability = 0.0;
|
||||
}
|
||||
$hasAvailabilityOverride = $availabilities->has($date);
|
||||
$availability = $hasAvailabilityOverride
|
||||
? (float) $availabilities->get($date)
|
||||
: ($isPto ? 0.0 : 1.0);
|
||||
|
||||
$details[] = [
|
||||
'date' => $date,
|
||||
@@ -198,13 +197,14 @@ class CapacityService
|
||||
|
||||
foreach ($months as $month) {
|
||||
$tags = $this->getCapacityCacheTags($month, "team_member:{$teamMemberId}");
|
||||
$key = $this->buildCacheKey($month, $teamMemberId);
|
||||
|
||||
// Always forget from array store (used in tests and as fallback)
|
||||
Cache::store('array')->forget($key);
|
||||
|
||||
if ($useRedis) {
|
||||
$this->flushCapacityTags($tags);
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->forgetCapacity($this->buildCacheKey($month, $teamMemberId));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -213,17 +213,16 @@ class CapacityService
|
||||
*/
|
||||
public function forgetCapacityCacheForMonth(string $month): void
|
||||
{
|
||||
// Always forget from array store (used in tests and as fallback)
|
||||
foreach (TeamMember::pluck('id') as $teamMemberId) {
|
||||
Cache::store('array')->forget($this->buildCacheKey($month, $teamMemberId));
|
||||
}
|
||||
Cache::store('array')->forget($this->buildCacheKey($month, 'team'));
|
||||
Cache::store('array')->forget($this->buildCacheKey($month, 'revenue'));
|
||||
|
||||
if ($this->redisAvailable()) {
|
||||
$this->flushCapacityTags($this->getCapacityCacheTags($month));
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (TeamMember::pluck('id') as $teamMemberId) {
|
||||
$this->forgetCapacity($this->buildCacheKey($month, $teamMemberId));
|
||||
}
|
||||
|
||||
$this->forgetCapacity($this->buildCacheKey($month, 'team'));
|
||||
$this->forgetCapacity($this->buildCacheKey($month, 'revenue'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user