mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-23 13:23:04 +00:00
keep overnight checkout planning after a later arrival
This commit is contained in:
@@ -88,7 +88,7 @@ export function assembleRoadtrip({
|
||||
spills: [],
|
||||
schedule: computeSchedule(
|
||||
d.stops.map((s) => ({
|
||||
anchor: s.time,
|
||||
anchor: s.time ?? s.checkInTime ?? null,
|
||||
dwellMinutes: s.dwellMinutes,
|
||||
departureAt: s.checkoutAt === undefined ? undefined : s.checkoutAt - d.dayNumber * 1440,
|
||||
})),
|
||||
|
||||
@@ -390,3 +390,23 @@ describe('booked checkout', () => {
|
||||
expect(plan.chains[0]!.schedule.entries[1]!.arrival).toBe('14:00');
|
||||
});
|
||||
});
|
||||
|
||||
it('keeps checkout when the drive arrives after suggested check-in', () => {
|
||||
const stops = [
|
||||
stop(1, { time: '07:00', dwellMinutes: 60 }),
|
||||
stop(2, { checkInTime: '09:11', checkoutAt: 2 * 1440 + 600 }),
|
||||
stop(3),
|
||||
];
|
||||
const plan = calculate(stops, [72.5, 29]);
|
||||
expect(plan.issue).toBeNull();
|
||||
expect(plan.chains[0]!.schedule.entries[1]!.arrival).toBe('09:13');
|
||||
expect(plan.chains[1]!.stops.at(-1)!.placeId).toBe(3);
|
||||
expect(plan.chains[1]!.schedule.entries.at(-1)!.arrival).toBe('10:29');
|
||||
});
|
||||
|
||||
it('waits for check-in without treating it as a fixed appointment', () => {
|
||||
const plan = calculate([stop(1), stop(2, { checkInTime: '15:00', checkoutAt: 2 * 1440 + 600 }), stop(3)], [60, 29]);
|
||||
expect(plan.issue).toBeNull();
|
||||
expect(plan.chains[0]!.schedule.entries[1]!.arrival).toBe('15:00');
|
||||
expect(plan.chains[1]!.schedule.entries.at(-1)!.arrival).toBe('10:29');
|
||||
});
|
||||
|
||||
@@ -182,6 +182,7 @@ export function planDayWindow(
|
||||
time: null,
|
||||
dwellMinutes: 0,
|
||||
checkoutAt: undefined,
|
||||
checkInTime: undefined,
|
||||
stopType: null,
|
||||
fillPercent: null,
|
||||
automaticNight: { phase: 'end', fromDayNumber: number, position, manual: targets.has(number) },
|
||||
@@ -273,6 +274,7 @@ export function planDayWindow(
|
||||
const target = targets.get(number);
|
||||
if (target !== undefined && target < position) return failed('conflict');
|
||||
if (pin !== null) clock = pin;
|
||||
if (pin === null && number === day.dayNumber) clock = Math.max(clock, parseClock(stop.checkInTime) ?? 0);
|
||||
append(stop, clock);
|
||||
previous = stop;
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ export function spillChains(plan: PlanDay[], quietDays: QuietDay[], legFor: LegL
|
||||
const legs = routed.map((l) => l?.seg);
|
||||
const schedule = computeSchedule(
|
||||
d.stops.map((s) => ({
|
||||
anchor: s.time,
|
||||
anchor: s.time ?? s.checkInTime ?? null,
|
||||
dwellMinutes: s.dwellMinutes,
|
||||
departureAt: s.checkoutAt === undefined ? undefined : s.checkoutAt - d.dayNumber * 1440,
|
||||
})),
|
||||
|
||||
@@ -19,6 +19,7 @@ export interface RoadtripStop {
|
||||
|
||||
dwellMinutes: number | null;
|
||||
checkoutAt?: number;
|
||||
checkInTime?: string | null;
|
||||
endDay?: boolean;
|
||||
|
||||
legMode: string | null;
|
||||
|
||||
Reference in New Issue
Block a user