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:
parent
c7ec19b74e
commit
a0874484a3
2 changed files with 9 additions and 8 deletions
|
|
@ -52,9 +52,9 @@ export function departingBookingForSite(bookings, siteId, viewDate) {
|
|||
|
||||
// Classify a site's booking state for a given view date.
|
||||
// Returns a rich descriptor used to build the room card.
|
||||
// opts.future: viewDate is after the real today. A day-card represents that
|
||||
// night, so a morning-only departure doesn't occupy it — 'depart' is a live
|
||||
// operational state (checkout tracking) that only applies to today/past.
|
||||
// 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 historical
|
||||
// record that only applies when reviewing past dates.
|
||||
export function classifyRoom(site, allBookings, viewDate, yesterday, tomorrow, opts = {}) {
|
||||
const siteId = String(site.site_id)
|
||||
|
||||
|
|
@ -110,7 +110,7 @@ export function classifyRoom(site, allBookings, viewDate, yesterday, tomorrow, o
|
|||
flowType = 'stopover'
|
||||
}
|
||||
}
|
||||
} else if (effectiveDeparting && !opts.future) {
|
||||
} else if (effectiveDeparting && opts.past) {
|
||||
primaryBooking = effectiveDeparting
|
||||
flowType = 'depart'
|
||||
}
|
||||
|
|
|
|||
|
|
@ -116,8 +116,8 @@ export async function roomRoutes(app) {
|
|||
|
||||
const siteBookings = bookings.filter(matchFn)
|
||||
|
||||
const future = viewDate > new Date().toISOString().slice(0, 10)
|
||||
const classified = classifyRoom(site, bookings, viewDate, yesterday, tomorrow, { future })
|
||||
const past = viewDate < new Date().toISOString().slice(0, 10)
|
||||
const classified = classifyRoom(site, bookings, viewDate, yesterday, tomorrow, { past })
|
||||
|
||||
return {
|
||||
view_date: viewDate, yesterday, tomorrow,
|
||||
|
|
@ -199,14 +199,15 @@ export async function roomRoutes(app) {
|
|||
}
|
||||
|
||||
// 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 = []
|
||||
for (const site of sites) {
|
||||
const catId = String(site.site_category_id ?? site.category_id ?? site.category?.id ?? '')
|
||||
const isExcluded = excludedCategories.includes(catId)
|
||||
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
|
||||
const catOrderOverride = settingsCatOrder[catId]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue