Debug: expose full raw booking in debug-room; fix guest name extraction

- debug-room now returns full raw NewBook booking objects so all
  field names are visible for diagnosis
- guest_name extraction also tries guests[0].firstname+lastname
  (original PHP plugin pattern), not just guests[0].guest_name

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
jtricerolph 2026-07-04 13:24:24 +00:00
parent d0e80c2484
commit 5f3e52d8a6

View file

@ -44,7 +44,11 @@ function filterBookingData(booking, canSeeGuest, canSeeRate, canSeeAllNotes, vis
if (canSeeGuest) {
const guests = booking.guests || []
out.guest_name = guests[0]?.guest_name || booking.guest_name || booking.account_for_name || null
const g0 = guests[0]
const fromGuests = g0
? (g0.guest_name || [g0.firstname, g0.lastname].filter(Boolean).join(' ') || null)
: null
out.guest_name = fromGuests || booking.guest_name || booking.account_for_name || null
}
if (canSeeRate) {
@ -119,13 +123,7 @@ export async function roomRoutes(app) {
site: { id: siteId, name: site.site_name, fields: Object.keys(site) },
booking_id_fields: idFields,
total_bookings_fetched: bookings.length,
matching_bookings: siteBookings.map(b => {
const out = {}
for (const f of ['booking_id', 'booking_status', 'booking_arrival', 'booking_departure', ...idFields]) {
out[f] = b[f]
}
return out
}),
matching_bookings: siteBookings,
classified: {
flow_type: classified.flow_type,
spans_previous: classified.spans_previous,