Skip to content

[FIX] connector_pms_wubook: keep per-room occupancy on same-type multi-room Booking reservations#100

Open
DarioLodeiros wants to merge 1 commit into
16.0from
16.0-fix-wubook-multiroom-occupancy
Open

[FIX] connector_pms_wubook: keep per-room occupancy on same-type multi-room Booking reservations#100
DarioLodeiros wants to merge 1 commit into
16.0from
16.0-fix-wubook-multiroom-occupancy

Conversation

@DarioLodeiros

Copy link
Copy Markdown
Member

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-room occupancy/children are stored in dicts keyed by room_id. When several booked_rooms share the same room_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 ran occupancies_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's ancillary (guests_adults / guests_children). Read them directly into per-room local variables instead of the room_id-keyed dict. The change is confined to the id_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.

…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.
@github-actions

Copy link
Copy Markdown

Diff Coverage

Diff: origin/16.0...HEAD, staged and unstaged changes

  • connector_pms_wubook/models/pms_folio/adapter.py (0.0%): Missing lines 281-282,294,297

Summary

  • Total: 4 lines
  • Missing: 4 lines
  • Coverage: 0%

connector_pms_wubook/models/pms_folio/adapter.py

Lines 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,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant