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:
@@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user