Room planner: fix next-bracket visibility and vacant room misdetection
Extend booking fetch window to day-after-tomorrow so tomorrow-arriving bookings appear in nextBooking lookups (some NewBook regions exclude arrivals exactly on period_to date, causing right brackets to not render). Add booking_site_id fallback in site-ID matching so bookings are found correctly even when NewBook returns booking_site_id instead of site_id in the booking object (was causing some rooms to show as vacant). Remove category debug logging (no longer needed). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
cbfec7d591
commit
916dc50390
2 changed files with 12 additions and 12 deletions
|
|
@ -23,12 +23,18 @@ export function toTimeStr(dt) {
|
|||
return t || null
|
||||
}
|
||||
|
||||
// Match a booking to a site ID. NewBook sometimes uses booking_site_id instead of site_id.
|
||||
function siteMatches(b, siteId) {
|
||||
const bid = String(b.site_id || b.booking_site_id || '')
|
||||
return bid === String(siteId)
|
||||
}
|
||||
|
||||
// Find all bookings for a given site on a specific date.
|
||||
// A booking occupies a site on viewDate if: arrival <= viewDate < departure
|
||||
// (departure date is the check-out day, so the room is vacated on that morning)
|
||||
export function bookingsForSiteOnDate(bookings, siteId, viewDate) {
|
||||
return bookings.filter(b => {
|
||||
if (String(b.site_id) !== String(siteId)) return false
|
||||
if (!siteMatches(b, siteId)) return false
|
||||
const arrival = toDateStr(b.booking_arrival)
|
||||
const departure = toDateStr(b.booking_departure)
|
||||
if (!arrival || !departure) return false
|
||||
|
|
@ -39,7 +45,7 @@ export function bookingsForSiteOnDate(bookings, siteId, viewDate) {
|
|||
// Find the departing booking for a site on viewDate (departure_date === viewDate)
|
||||
export function departingBookingForSite(bookings, siteId, viewDate) {
|
||||
return bookings.find(b =>
|
||||
String(b.site_id) === String(siteId) &&
|
||||
siteMatches(b, siteId) &&
|
||||
toDateStr(b.booking_departure) === viewDate
|
||||
) ?? null
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue