Repository navigation
fix(bookings): link catering and equipment to native room bookings - #545
Conversation
With `app.events.use_bookings` on, the meeting form created its catering orders and equipment requests with `?event_id=<booking id>`. staff-api resolves that against calendar event metadata, refused the order with 422 "error linking booking to event", and the room booking was rolled back, so neither could be ordered on a native room booking. Link them by `parent_id` instead, which staff-api reads as an integer, and look existing linked bookings up without the `event_id` filter. The asset path already had a native branch keyed on `from_booking`; the meeting form passes an event whose flag is `from_bookings`, so honour both.
|
Deployment failed for project frontend-templates with the following error: Learn More: https://vercel.com/placeos?upgradeToPro=build-rate-limit |
|
The 1. Equipment edit deletes asset bookings of other bookings (data loss)
For a native booking, the "existing bookings" query sends Effects:
I reproduced the delete with a temporary unit test: a native edit with Fix: keep only the bookings linked to this parent, and remove the const bookings = (await queryBookings({ ... })).filter(
(_) => !native || _.extension_data?.parent_id === id,
);2. Native linked-booking lookup only finds the current user's bookings
For a native event, the query has no Fix: for native events, read the children from const existing = event.from_bookings
? (event.linked_bookings || [])
.filter((_) => _.booking_type === type)
.map((_) => new Booking(_ as any))
: await linkedBookingsForEvent(event, type);A smaller fix is to add Also update the doc comment at lines 750-753. It says the API ignores the period. That is not true for native events. 3. Rollback of a new native booking calls the events API
When a child booking fails on a new booking, 4. Type casts for
|
Address review on #545: - Asset requests of a native booking are filtered by `extension_data.parent_id`, so an edit no longer removes or ignores asset bookings of the host's other bookings. Drop the `booking_id` query, which staff-api ignores - Read the children of a native booking from `linked_bookings`, so a delegate or admin edit updates them instead of creating duplicates - Remove a new native room booking with `removeBooking` when a child booking fails, not the events API - Type `parent_id` on the create path and drop the `any` casts Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
Fixed in 3d44184.
All 17 affected apps build except Fixes by Claude Opus 5.5 in Claude Code (T3 Code). |
What was broken
With
app.events.use_bookingson, a room booking is a staff-api booking rather than a calendar event. The meeting form still created its catering orders and equipment requests with?event_id=<booking id>, which staff-api resolves against calendar event metadata, so every order was refused:The room booking was then rolled back, so catering and equipment could not be ordered on a native room booking at all. staff-api has supported linking a child booking to its parent through
parent_idsince 2023.The asset path already had a native branch, but it keyed on
from_bookingwhile the meeting form passes aCalendarEventwhose flag isfrom_bookings.Change
createBookingsForEvent: for a native event, sendparent_id(as an integer, which is what staff-api reads) and noevent_idorical_uidquery; look existing linked bookings up without theevent_idfiltervalidateAssetRequestsForResource: treatfrom_bookingslikefrom_booking, and sendparent_idas an integerUnit tests added in
libs/bookingsandlibs/assets. The #497 e2e specs ROOM-22 (catering) and ROOM-24 (equipment) pass against this change.