mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-30 02:58:11 +00:00
Implement client-side validation for container and bul
This commit is contained in:
@@ -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 =
|
||||
|
||||
Reference in New Issue
Block a user