mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-30 00:38:11 +00:00
chore: update package overrides in pnpm-workspace.yaml for dependencies
This commit is contained in:
@@ -1182,13 +1182,23 @@ export class TrainSchedulingService {
|
||||
? new Date(new Date(schedule.scheduledArrivalDate).getTime() + deltaMs)
|
||||
: undefined;
|
||||
|
||||
// PRE_WINDOW only: the stamped open/close were derived from the old
|
||||
// departure and the window hasn't opened yet, so re-derive them from the
|
||||
// schedule's own rule snapshot against the new date (joining the target
|
||||
// day's route group timeline when one exists, exactly like
|
||||
// updateScheduleDate). Mid/post-window schedules keep their timeline.
|
||||
// PRE_WINDOW: the stamped open/close were derived from the old departure
|
||||
// and the window hasn't opened yet, so re-derive them from the schedule's
|
||||
// own rule snapshot against the new date (joining the target day's route
|
||||
// group timeline when one exists, exactly like updateScheduleDate).
|
||||
//
|
||||
// DONE: the window already finished (e.g. the close offset hit and then the
|
||||
// train was moved to a later departure). The window must follow the new
|
||||
// departure, so it REOPENS: re-derive open/close the same way, reset the
|
||||
// phase to PRE_WINDOW and clamp a past open into the present so the tick
|
||||
// opens it immediately. A FULL train stays closed — there is nothing left
|
||||
// to sell — and so does one whose re-derived window would already be over.
|
||||
//
|
||||
// Mid-window phases (OPEN/DOC_REVIEW/PAYMENT) keep their running timeline.
|
||||
const reopenFromDone =
|
||||
schedule.windowPhase === 'DONE' && schedule.bookingWindowStatus !== 'FULL';
|
||||
const windowFields =
|
||||
schedule.windowPhase === 'PRE_WINDOW'
|
||||
schedule.windowPhase === 'PRE_WINDOW' || reopenFromDone
|
||||
? await (async () => {
|
||||
const merged = effectiveWindowConfig(
|
||||
schedule,
|
||||
@@ -1207,12 +1217,33 @@ export class TrainSchedulingService {
|
||||
schedule.destinationStationId,
|
||||
departure,
|
||||
);
|
||||
return anchor
|
||||
? this.groupWindowFieldsFrom(anchor, departure)
|
||||
: {
|
||||
windowOpensAt: times.windowOpensAt,
|
||||
windowClosesAt: times.windowClosesAt,
|
||||
};
|
||||
if (anchor) {
|
||||
// groupWindowFieldsFrom copies the anchor's live phase and
|
||||
// deadlines, so a DONE train joining a live group re-enters the
|
||||
// group's cycle directly — no extra reset needed.
|
||||
return this.groupWindowFieldsFrom(anchor, departure);
|
||||
}
|
||||
if (!reopenFromDone) {
|
||||
return {
|
||||
windowOpensAt: times.windowOpensAt,
|
||||
windowClosesAt: times.windowClosesAt,
|
||||
};
|
||||
}
|
||||
const now = new Date();
|
||||
const windowOpensAt =
|
||||
times.windowOpensAt < now ? now : times.windowOpensAt;
|
||||
if (times.windowClosesAt.getTime() <= windowOpensAt.getTime()) {
|
||||
return {}; // no window fits before the new departure — stay closed
|
||||
}
|
||||
return {
|
||||
windowOpensAt,
|
||||
windowClosesAt: times.windowClosesAt,
|
||||
windowPhase: 'PRE_WINDOW',
|
||||
bookingWindowStatus: 'CLOSED',
|
||||
docReviewCompletedAt: null,
|
||||
docReviewEndsAt: null,
|
||||
paymentPhaseEndsAt: null,
|
||||
};
|
||||
})()
|
||||
: {};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user