Fix past-departure room cards incorrectly merging with prior night
A past-departure record only marks that a checkout happened on the viewed date — it never occupied the night before, so it must not merge with the previous card the way a booking still actively occupying viewDate would. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
parent
db38b586d5
commit
16c70f5ba4
1 changed files with 9 additions and 1 deletions
|
|
@ -89,6 +89,10 @@ export function classifyRoom(site, allBookings, viewDate, yesterday, tomorrow, o
|
|||
// Determine flow type
|
||||
let flowType = 'vacant'
|
||||
|
||||
// True when primaryBooking is a historical depart-only record (set below) rather
|
||||
// than a booking that actually occupies viewDate — the room was vacant that night.
|
||||
let isPastDepartureRecord = false
|
||||
|
||||
if (primaryBooking) {
|
||||
const status = (primaryBooking.booking_status || '').toLowerCase()
|
||||
if (status === 'blocked') {
|
||||
|
|
@ -113,6 +117,7 @@ export function classifyRoom(site, allBookings, viewDate, yesterday, tomorrow, o
|
|||
} else if (effectiveDeparting && opts.past) {
|
||||
primaryBooking = effectiveDeparting
|
||||
flowType = 'depart'
|
||||
isPastDepartureRecord = true
|
||||
}
|
||||
|
||||
const arrivalDate = primaryBooking ? toDateStr(primaryBooking.booking_arrival) : null
|
||||
|
|
@ -158,7 +163,10 @@ export function classifyRoom(site, allBookings, viewDate, yesterday, tomorrow, o
|
|||
flow_type: flowType,
|
||||
booking: primaryBooking,
|
||||
|
||||
spans_previous: isVacantFlow
|
||||
// A past-departure record only marks that a checkout happened on viewDate — it
|
||||
// never occupied the night before viewDate, so it must not merge with the prior
|
||||
// card the way a booking that's still actively occupying viewDate would.
|
||||
spans_previous: (isVacantFlow || isPastDepartureRecord)
|
||||
? prevVacant
|
||||
: !!primaryBooking && !!arrivalDate && arrivalDate < viewDate,
|
||||
spans_next: isVacantFlow ? nextVacant : spansNext,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue