mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-29 22:18:12 +00:00
intercity fix
This commit is contained in:
@@ -614,6 +614,26 @@ export class BookingBatchService implements OnModuleInit {
|
||||
|
||||
const linked =
|
||||
await this.trainScheduleBookingsRepository.existsForBooking(bookingId);
|
||||
// Intercity is allocated MANUALLY: payment secures the ride, staff then
|
||||
// place it on whichever same-route train suits (intercity panel). Unpin
|
||||
// from the train it reserved against — that train may be the wrong one by
|
||||
// the time it departs — and return it to the waiting pool as PAID.
|
||||
if (!linked && booking.tradeDirection === "DOMESTIC" && !booking.isGovernment) {
|
||||
await this.dataSource.getRepository(Booking).update(bookingId, {
|
||||
trainScheduleId: null,
|
||||
schedulingStatus: "ELIGIBLE",
|
||||
paymentDeadline: null,
|
||||
} as never);
|
||||
this.logger.log(
|
||||
`[BATCH] intercity ${booking.reference ?? bookingId} PAID — awaiting manual placement by staff`,
|
||||
);
|
||||
void this.completeTrackingMilestones(bookingId, [
|
||||
"FREIGHT_PAYMENT_PENDING",
|
||||
"FREIGHT_PAYMENT_SETTLED",
|
||||
]);
|
||||
this.notifyBoardChanged(booking.trainScheduleId, "intercity_paid_unplaced");
|
||||
return;
|
||||
}
|
||||
if (!linked) {
|
||||
if (await this.holdIfWagonShort(booking.trainScheduleId, booking)) return;
|
||||
await this.allocate(booking.trainScheduleId, booking, "paid");
|
||||
@@ -3143,6 +3163,19 @@ export class BookingBatchService implements OnModuleInit {
|
||||
this.notifyBoardChanged(scheduleId, 'intercity_accepted');
|
||||
return;
|
||||
}
|
||||
// Manual placement of an ALREADY-PAID intercity booking: payment landed
|
||||
// earlier (and unpinned it back to the pool) — staff are now choosing its
|
||||
// train, so link directly. No new pay window; wagon assignment stays with
|
||||
// staff in the workspace.
|
||||
if (booking.paymentStatus === 'PAID' || booking.status === 'PAID') {
|
||||
await this.dataSource
|
||||
.getRepository(Booking)
|
||||
.update(booking.id, { trainScheduleId: scheduleId });
|
||||
booking.trainScheduleId = scheduleId;
|
||||
await this.allocate(scheduleId, booking, 'paid');
|
||||
this.notifyBoardChanged(scheduleId, 'intercity_accepted');
|
||||
return;
|
||||
}
|
||||
await this.reserve(booking, scheduleId);
|
||||
this.armSettle(scheduleId);
|
||||
this.notifyBoardChanged(scheduleId, 'intercity_accepted');
|
||||
@@ -3363,7 +3396,11 @@ export class BookingBatchService implements OnModuleInit {
|
||||
`[BATCH] ALLOCATED ${booking.reference} (${reason}) to train on schedule ${scheduleId}`,
|
||||
);
|
||||
this.notifier.secured(booking, reason, scheduleId);
|
||||
void this.triggerWagonAllocation(scheduleId);
|
||||
// Intercity rides are placed on wagons BY STAFF (workspace wizard) — auto
|
||||
// wagon assignment is for the import/export batch flow only.
|
||||
if (booking.tradeDirection !== 'DOMESTIC') {
|
||||
void this.triggerWagonAllocation(scheduleId);
|
||||
}
|
||||
void this.markWagonAllocatedMilestone(booking.id);
|
||||
// Customer tracking: freight payment settled (commercial pay-window path).
|
||||
// Government allocations don't pay upfront — theirs stay pending.
|
||||
|
||||
Reference in New Issue
Block a user