Today/future depart-only rooms show as vacant, not depart

'Depart' flow is now exclusively a past-date historical record. On today
and future dates a room with only a morning checkout and no new arrival
classifies as vacant — the room IS free for tonight regardless of the
11am checkout. The departed booking's status still drives the left bracket
colour and the checkout time still appears in the sliver for late checkouts.

B2B rooms (depart + new arrival on the same day) are unaffected.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
jtricerolph 2026-07-08 13:59:05 +00:00
parent c7ec19b74e
commit a0874484a3
2 changed files with 9 additions and 8 deletions

View file

@ -52,9 +52,9 @@ export function departingBookingForSite(bookings, siteId, viewDate) {
// Classify a site's booking state for a given view date. // Classify a site's booking state for a given view date.
// Returns a rich descriptor used to build the room card. // Returns a rich descriptor used to build the room card.
// opts.future: viewDate is after the real today. A day-card represents that // opts.past: viewDate is strictly before the real today. A day-card represents that
// night, so a morning-only departure doesn't occupy it — 'depart' is a live // night, so a morning-only departure doesn't occupy it — 'depart' is a historical
// operational state (checkout tracking) that only applies to today/past. // record that only applies when reviewing past dates.
export function classifyRoom(site, allBookings, viewDate, yesterday, tomorrow, opts = {}) { export function classifyRoom(site, allBookings, viewDate, yesterday, tomorrow, opts = {}) {
const siteId = String(site.site_id) const siteId = String(site.site_id)
@ -110,7 +110,7 @@ export function classifyRoom(site, allBookings, viewDate, yesterday, tomorrow, o
flowType = 'stopover' flowType = 'stopover'
} }
} }
} else if (effectiveDeparting && !opts.future) { } else if (effectiveDeparting && opts.past) {
primaryBooking = effectiveDeparting primaryBooking = effectiveDeparting
flowType = 'depart' flowType = 'depart'
} }

View file

@ -116,8 +116,8 @@ export async function roomRoutes(app) {
const siteBookings = bookings.filter(matchFn) const siteBookings = bookings.filter(matchFn)
const future = viewDate > new Date().toISOString().slice(0, 10) const past = viewDate < new Date().toISOString().slice(0, 10)
const classified = classifyRoom(site, bookings, viewDate, yesterday, tomorrow, { future }) const classified = classifyRoom(site, bookings, viewDate, yesterday, tomorrow, { past })
return { return {
view_date: viewDate, yesterday, tomorrow, view_date: viewDate, yesterday, tomorrow,
@ -199,14 +199,15 @@ export async function roomRoutes(app) {
} }
// Classify each site // Classify each site
const future = viewDate > new Date().toISOString().slice(0, 10) const serverToday = new Date().toISOString().slice(0, 10)
const past = viewDate < serverToday
const rooms = [] const rooms = []
for (const site of sites) { for (const site of sites) {
const catId = String(site.site_category_id ?? site.category_id ?? site.category?.id ?? '') const catId = String(site.site_category_id ?? site.category_id ?? site.category?.id ?? '')
const isExcluded = excludedCategories.includes(catId) const isExcluded = excludedCategories.includes(catId)
if (isExcluded && hideExcluded) continue if (isExcluded && hideExcluded) continue
const classified = classifyRoom(site, bookings, viewDate, yesterday, tomorrow, { future }) const classified = classifyRoom(site, bookings, viewDate, yesterday, tomorrow, { past })
// Override category_order with settings value if available // Override category_order with settings value if available
const catOrderOverride = settingsCatOrder[catId] const catOrderOverride = settingsCatOrder[catId]