fix: check if absence is cancellable in expiry check instead

Approved & pending absences can be cancelled. Initial actionability check only accounts for pending absences. Fixes issue where expired absences wouldn't be ended.

Signed-off-by: miguel456 <me@nogueira.codes>
This commit is contained in:
2022-11-19 03:05:55 +00:00
parent 228750e1c3
commit 0941023aef

View File

@@ -167,12 +167,16 @@ class AbsenceService
return $absence->delete(); return $absence->delete();
} }
/**
public function endExpired() * End all expired absences in the application
* @return void
*/
public function endExpired(): void
{ {
foreach (Absence::all() as $absence) foreach (Absence::all() as $absence)
{ {
if (!Carbon::parse($absence->predicted_end)->isFuture() && $absence->isActionable()) { // tell the absence we want to check for cancelability
if (!Carbon::parse($absence->predicted_end)->isFuture() && $absence->isActionable(true)) {
$this->endAbsence($absence); $this->endAbsence($absence);
} }
} }