fix(dashboard): keep hotels out of the upcoming reservations widget

A stay covers a range rather than a moment, so one week in a hotel would hold a
slot in a six-entry widget for the whole week and push out the bookings that
actually happen on a day. The accommodation belongs to the day plan, which shows
it across its span.

They never worked here either, which is what the report is about. A hotel keeps
its dates on the linked stay, not on the reservation, so the two ways one can
exist behaved differently:

The booking form writes reservation_time = NULL and sends no day_id, so a
form-created hotel matched neither arm of the date test and was silently absent.
That is the "incomplete" half.

The accommodation panel auto-creates its booking with day_id and with the start
day's date stamped into reservation_time. That row did show, but updateAccommodation
syncs only metadata and the confirmation number to its linked bookings, so moving
the stay left the stamp untouched and the widget kept the old date. That is the
"no effect when I change the date" half.

The type test is NULL-safe: the column defaults to 'other' but nothing stops a
NULL, and a bare `type != 'hotel'` evaluates to NULL there and would have dropped
those rows from the widget instead.

Closes #1934
This commit is contained in:
Maurice
2026-08-14 13:27:23 +02:00
committed by Maurice
parent f43b56a745
commit 681fe1fee3
3 changed files with 53 additions and 2 deletions
@@ -384,6 +384,20 @@ export class ReservationsService {
* as upcoming when its own time is in the future, or — for timeless entries —
* when its day falls on or after today. Cancelled bookings are skipped.
* The default limit (6) matches the legacy inline handler.
*
* Hotels are left out on purpose (#1934). A stay covers a range rather than a
* moment, so a week in one hotel would hold a slot in a six-entry widget for
* the whole week and push out the bookings that actually happen on a day. The
* accommodation belongs to the day plan, which shows it across its span.
*
* They also never worked here. A hotel keeps its dates on the linked stay, not
* on the reservation: the booking form writes reservation_time = NULL and no
* day_id, so a form-created hotel matched neither arm of the date test and was
* invisible. The one path that did produce a visible row, the accommodation
* panel's auto-created booking, stamps the start day into reservation_time
* once and never restamps it, so moving the stay left the widget showing the
* old date. Both halves of the report come from reading a hotel's date off
* fields hotels do not use.
*/
listUpcoming(userId: number, limit = 6) {
const today = new Date().toISOString().slice(0, 10);
@@ -402,6 +416,7 @@ export class ReservationsService {
WHERE (t.user_id = ? OR tm.user_id IS NOT NULL)
AND t.is_archived = 0
AND r.status != 'cancelled'
AND COALESCE(r.type, '') != 'hotel'
AND (
(r.reservation_time IS NOT NULL AND r.reservation_time >= ?)
OR (r.reservation_time IS NULL AND d.date IS NOT NULL AND d.date >= ?)