[FIX] connector_pms_wubook: keep per-room occupancy on same-type multi-room Booking reservations#100
Open
DarioLodeiros wants to merge 1 commit into
Open
[FIX] connector_pms_wubook: keep per-room occupancy on same-type multi-room Booking reservations#100DarioLodeiros wants to merge 1 commit into
DarioLodeiros wants to merge 1 commit into
Conversation
…i-room Booking reservations When a Booking.com reservation has several rooms of the SAME room type, all booked_rooms share the same room_id. _reorg_folio_data stored the occupancy/children in dicts keyed by room_id, so those rooms collapsed to a single entry and the per-room min() left every room with the lowest guest count (e.g. two rooms with 1 and 2 adults were both imported as 1). Read the authoritative per-room guest counts directly from each booked_room's ancillary (guests_adults / guests_children) instead of the room_id-keyed dict. The change is confined to the id_channel == 2 (Booking.com) branch, so all other channels keep the previous behaviour. Add a regression test covering a same-room-type two-room booking.
Diff CoverageDiff: origin/16.0...HEAD, staged and unstaged changes
Summary
connector_pms_wubook/models/pms_folio/adapter.pyLines 277-286 277 # type they share room_id, so these dicts collapse to a single
278 # entry and can no longer hold per-room guest counts. The
279 # Booking.com branch below overrides them with the authoritative
280 # per-room ancillary data.
! 281 occupancy = occupancies_d.get(room_id)
! 282 children = occupancies_d_children.get(room_id)
283 if id_channel == 2: # Booking.com
284 # Board services can be included in the rate
285 # plan and detected by the WuBook API
286 detected_board = value.get("ancillary", {}).get("Detected Board")Lines 290-301 290 # room_id-keyed dict, which collapses rooms of the same type
291 # (e.g. 2 rooms with 1 and 2 adults would both end up as 1).
292 guests_adults = room.get("ancillary", {}).get("guests_adults")
293 if guests_adults:
! 294 occupancy = guests_adults
295 guests_children = room.get("ancillary", {}).get("guests_children")
296 if guests_children:
! 297 children = guests_children
298 if id_channel == 43: # AirBnb
299 # Add commission in price
300 self.apply_gross_prices_airbnb(
301 room=room, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A Booking.com reservation that books several rooms of the same room type was imported with the wrong number of guests: every room ended up with the lowest per-room guest count. For example, a booking of two rooms — one for 1 adult and one for 2 adults — was imported as 1 adult in both rooms.
Root cause
In
_reorg_folio_data(connector_pms_wubook/models/pms_folio/adapter.py) the per-roomoccupancy/childrenare stored in dicts keyed byroom_id. When severalbooked_roomsshare the sameroom_id(rooms of the same room type), those dicts collapse to a single entry and the per-room counts are lost. For Booking.com the code then ranoccupancies_d[room_id] = min(occupancies_d[room_id], guests_adults)while iterating each room, so the single shared entry ended at the minimum across all rooms.Fix
Booking.com already returns the authoritative per-room guest counts in each
booked_room'sancillary(guests_adults/guests_children). Read them directly into per-room local variables instead of theroom_id-keyed dict. The change is confined to theid_channel == 2(Booking.com) branch, so every other channel keeps the previous behaviour.Tests
Adds a regression test (
TestPmsFolioOccupancy.test_reorg_multiroom_same_type_keeps_per_room_occupancy) covering a two-room, same-room-type Booking reservation with 1 and 2 adults, asserting each reservation (and its lines) keeps its own occupancy and children.Notes
The underlying
room_id-keyed collapse can in principle affect any channel that books multiple rooms of the same type with different occupancy, but only Booking.com provides per-room data to reconstruct it; other channels are intentionally left unchanged.