intercity fix

This commit is contained in:
Marshal
2026-07-31 10:50:16 +00:00
parent 74b7ee81fc
commit a64af98205
17 changed files with 1174 additions and 182 deletions

View File

@@ -330,8 +330,10 @@ export class IntercityService {
.leftJoinAndSelect('booking.destinationYard', 'destinationYard')
.where(`booking.trade_direction = 'DOMESTIC'`)
.andWhere('booking.train_schedule_id IS NULL')
// PAID = customer paid but staff have not placed it on a train yet
// (intercity allocation is manual) — it stays in the pool until they do.
.andWhere(
`((booking.is_government = false AND booking.status = 'FULLY_EXECUTED')
`((booking.is_government = false AND booking.status IN ('FULLY_EXECUTED', 'PAID'))
OR (booking.is_government = true AND booking.status = 'APPROVED'))`,
)
.orderBy('booking.is_government', 'DESC')
@@ -382,8 +384,12 @@ export class IntercityService {
if (booking.trainScheduleId) {
return 'Already assigned to a train';
}
const readyStatus = booking.isGovernment ? 'APPROVED' : 'FULLY_EXECUTED';
if (booking.status !== readyStatus) {
// Commercial: FULLY_EXECUTED opens a pay window; PAID (payment landed,
// awaiting manual placement) links straight onto the chosen train.
const readyStatuses = booking.isGovernment
? ['APPROVED']
: ['FULLY_EXECUTED', 'PAID'];
if (!readyStatuses.includes(booking.status)) {
return `Not ready to board (status ${booking.status})`;
}
if (!this.corridorOnRoute(booking, milestoneSeq)) {