fix(roadtrip): keep a booked night out of the day list, and off the traveller's stops

Three things the first pass got wrong.

A stop a booking puts on the day is for road trip mode, which needs the
hotel in the driving chain. The day planner already shows that booking as
its own overnight block, so the row there would be the same hotel twice.
It is hidden in Days whatever the service-stop switch says, and the switch
goes back to meaning what it says: the petrol stations the traveller added.

Cancelling a night from the road trip popup took the stop with it. That
control means "this is a pause now, not a night", and the stop sits
mid-drive where re-adding it would land it at the end of the day. The
booking now hands the stop over instead of deleting it.

Moving a booking whose stop belongs to the traveller put a second one on
the new day and left the first behind, which is the duplicate this change
exists to remove. Only a booking's own stop moves now. Stays booked before
this shipped get theirs from the migration, not from the next edit they
happen to receive.
This commit is contained in:
Maurice
2026-09-13 01:42:40 +02:00
parent 462a208fdf
commit edf0538260
7 changed files with 110 additions and 24 deletions
@@ -729,19 +729,22 @@ describe('the day stop a booking implies', () => {
expect(mirror).toEqual({ created: null, removed: [], stamped: null });
});
it('ACC-030 a stay booked before any of this existed picks up its stop on the next save', () => {
// The deliberate alternative to rewriting everybody finished trips in a migration:
// the booking reaches the route the moment somebody opens it and saves.
it('ACC-030 a stay whose stop belongs to the traveller does not get a second one', () => {
const { user } = createUser(testDb);
const trip = createTrip(testDb, user.id);
const day = createDay(testDb, trip.id);
const second = createDay(testDb, trip.id);
const place = createPlace(testDb, trip.id, { name: 'Hotel Adlon' });
const old = createDayAccommodation(testDb, trip.id, place.id, day.id, day.id) as any;
// The road trip books a night on a place it put on the day first, so the stop is
// the traveller's and the booking owns nothing.
createDayAssignment(testDb, day.id, place.id);
const stay = createDayAccommodation(testDb, trip.id, place.id, day.id, day.id) as any;
const existing = svc.getAccommodation(old.id, trip.id)!;
svc.updateAccommodation(old.id, existing, { check_in: '15:00' });
const existing = svc.getAccommodation(stay.id, trip.id)!;
svc.updateAccommodation(stay.id, existing, { start_day_id: second.id, end_day_id: second.id });
expect(stopsOn(day.id)).toEqual([expect.objectContaining({ place_id: place.id, accommodation_id: old.id })]);
expect(stopsOn(second.id)).toEqual([]);
expect(stopsOn(day.id)).toEqual([expect.objectContaining({ place_id: place.id, accommodation_id: null })]);
});
it('ACC-031 cancelling a booking takes back its own stop and leaves the other one', () => {