mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-09-09 08:18:20 +00:00
Implement consolidated booking handling and UI updates for shared wagons
This commit is contained in:
@@ -993,12 +993,14 @@ export class BookingTransitionService {
|
||||
|
||||
// Export is FCFS: fail the accept up-front (409) when no export train on the
|
||||
// booking's day still has capacity — nothing below runs and the request stays
|
||||
// pending for staff to move/decline.
|
||||
// pending for staff to move/decline. (For a consolidated pair this is a rough
|
||||
// solo pre-check; the real combined-capacity reservation happens after the
|
||||
// booking is FULLY_EXECUTED, once both partners are ready.)
|
||||
const isExportTrain =
|
||||
booking.tradeDirection === "EXPORT" && !isRoadService(booking.serviceType);
|
||||
const exportScheduleId = isExportTrain
|
||||
? await this.bookingBatchService.pickExportSchedule(booking)
|
||||
: null;
|
||||
if (isExportTrain) {
|
||||
await this.bookingBatchService.pickExportSchedule(booking);
|
||||
}
|
||||
|
||||
const invoice = await this.invoiceService.ensureInvoiceForBooking(booking);
|
||||
this.logger.log(
|
||||
@@ -1023,11 +1025,12 @@ export class BookingTransitionService {
|
||||
lockedAt: booking.lockedAt ?? now,
|
||||
} as never);
|
||||
|
||||
if (exportScheduleId) {
|
||||
if (isExportTrain) {
|
||||
// FCFS: reserve the slot and send the payment notification immediately;
|
||||
// paid → auto-allocated by the settle/paid pipeline.
|
||||
// paid → auto-allocated by the settle/paid pipeline. Consolidated bookings
|
||||
// only reserve once both partners are FULLY_EXECUTED (handled inside).
|
||||
const fresh = await this.bookingsService.findById(booking.id);
|
||||
await this.bookingBatchService.reserveExportBooking(fresh, exportScheduleId);
|
||||
await this.bookingBatchService.acceptExportBooking(fresh);
|
||||
} else if (booking.tradeDirection === "IMPORT") {
|
||||
// Import bookings wait for their booking-day window cycle — the batch runs
|
||||
// after staff document review, never at accept time.
|
||||
|
||||
Reference in New Issue
Block a user