mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-29 21:08:12 +00:00
Extend seat hold time if booking created
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* Single source of truth for how long a PENDING_PAYMENT booking has to be paid for,
|
||||
* shared by TasksService (which auto-cancels bookings past this deadline) and
|
||||
* SeatsService (which extends the seat hold to cover exactly this window when a
|
||||
* booking/PNR is created — without this, the seat hold reverted to its original
|
||||
* short seat-selection TTL and could expire mid-payment, letting a second customer
|
||||
* grab the same seat).
|
||||
*/
|
||||
|
||||
/** Maximum time (hours) a passenger has to pay after booking. */
|
||||
export const MAX_PAYMENT_HOURS = 2;
|
||||
/** Minutes before departure: cutoff for new bookings and payment deadline. */
|
||||
export const CUTOFF_MINUTES = 30;
|
||||
|
||||
/**
|
||||
* payment_deadline = MIN(booking_time + 2h, departure_time - 30min)
|
||||
*/
|
||||
export function computePaymentDeadline(createdAt: Date, departureAt: Date): Date {
|
||||
const maxDeadline = new Date(createdAt.getTime() + MAX_PAYMENT_HOURS * 60 * 60 * 1000);
|
||||
const cutoffDeadline = new Date(departureAt.getTime() - CUTOFF_MINUTES * 60 * 1000);
|
||||
return maxDeadline < cutoffDeadline ? maxDeadline : cutoffDeadline;
|
||||
}
|
||||
Reference in New Issue
Block a user