Implement client-side validation for container and bul

This commit is contained in:
Marshal
2026-07-09 08:13:20 +00:00
parent c6198a4c62
commit f736523afd
8 changed files with 140 additions and 26 deletions

View File

@@ -2503,6 +2503,32 @@ export class BookingBatchService implements OnModuleInit {
}
}
/**
* A reservation on this schedule still has time left to pay.
*
* The PAYMENT phase ends a hair BEFORE its own reservations do: `paymentPhaseEndsAt`
* is stamped when the phase starts, then `reserve()` gives each booking
* `now + paymentWindow` a few hundred milliseconds later, one booking at a time. So
* the first settle after the phase deadline finds every reservation still in date,
* expires nothing, reports `anySettled = false`, runs no top-up — and the caller
* concludes the cycle out from under customers who still had time to pay. The next
* tick then expires them with no cycle left to promote the waiting list into.
*
* Callers must not conclude the cycle while this returns true.
*/
async hasLiveReservations(scheduleId: string): Promise<boolean> {
const reserved =
await this.bookingsRepository.findReservedForSchedule(scheduleId);
const now = Date.now();
return reserved.some(
(b) =>
b.paymentStatus !== "PAID" &&
b.status !== "PAID" &&
b.paymentDeadline != null &&
b.paymentDeadline.getTime() > now,
);
}
/** No wagon slots left for allocated + reserved bookings. */
async isScheduleFull(scheduleId: string): Promise<boolean> {
const schedule =