From 43a503b59343af0df48c047223f3af56dc6ca459 Mon Sep 17 00:00:00 2001 From: jubnl Date: Tue, 21 Apr 2026 19:51:44 +0200 Subject: [PATCH] fix(reservations): always update place_id when saving hotel accommodation When clearing the accommodation place from a hotel reservation, the update branch that runs without a place_id omitted the column from its UPDATE statement, leaving the old place linked in day_accommodations. Collapse the two branches into one that always writes place_id (null or value). --- server/src/services/reservationService.ts | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/server/src/services/reservationService.ts b/server/src/services/reservationService.ts index 0be86264..4410c36d 100644 --- a/server/src/services/reservationService.ts +++ b/server/src/services/reservationService.ts @@ -278,13 +278,8 @@ export function updateReservation(id: string | number, tripId: string | number, const { place_id: accPlaceId, start_day_id, end_day_id, check_in, check_out, confirmation: accConf } = create_accommodation; if (start_day_id && end_day_id) { if (resolvedAccId) { - if (accPlaceId) { - db.prepare('UPDATE day_accommodations SET place_id = ?, start_day_id = ?, end_day_id = ?, check_in = ?, check_out = ?, confirmation = ? WHERE id = ?') - .run(accPlaceId, start_day_id, end_day_id, check_in || null, check_out || null, accConf || confirmation_number || null, resolvedAccId); - } else { - db.prepare('UPDATE day_accommodations SET start_day_id = ?, end_day_id = ?, check_in = ?, check_out = ?, confirmation = ? WHERE id = ?') - .run(start_day_id, end_day_id, check_in || null, check_out || null, accConf || confirmation_number || null, resolvedAccId); - } + db.prepare('UPDATE day_accommodations SET place_id = ?, start_day_id = ?, end_day_id = ?, check_in = ?, check_out = ?, confirmation = ? WHERE id = ?') + .run(accPlaceId || null, start_day_id, end_day_id, check_in || null, check_out || null, accConf || confirmation_number || null, resolvedAccId); } else if (accPlaceId) { const accResult = db.prepare( 'INSERT INTO day_accommodations (trip_id, place_id, start_day_id, end_day_id, check_in, check_out, confirmation) VALUES (?, ?, ?, ?, ?, ?, ?)'