refactor(stock): make expired reservations terminal

This commit is contained in:
2026-08-25 15:58:41 -03:00
parent d612b7a118
commit f6f138e180
9 changed files with 164 additions and 33 deletions

View File

@@ -76,6 +76,20 @@ class ExpireStockReservationsService
return $summary;
}
public function expireIfOverdue(int $reservationId): bool
{
/** @var StockReservation|null $reservation */
$reservation = StockReservation::query()->find($reservationId);
if ($reservation?->status === StockReservation::STATUS_EXPIRED) {
return true;
}
if (! $this->isOverdue($reservation)) {
return false;
}
return $this->expireReservation($reservationId) !== null;
}
/** @return 'purchases'|'cart_reservations'|'orphan_reservations'|null */
private function expireReservation(int $reservationId): ?string
{