Skip to content

[FIX] pms_api_rest: keep folio-level pricelist on folio modification#103

Open
DarioLodeiros wants to merge 1 commit into
16.0from
16.0-fix-api-folio-pricelist-on-modification
Open

[FIX] pms_api_rest: keep folio-level pricelist on folio modification#103
DarioLodeiros wants to merge 1 commit into
16.0from
16.0-fix-api-folio-pricelist-on-modification

Conversation

@DarioLodeiros

Copy link
Copy Markdown
Member

On folio modification through the external API (PUT /folios/external), OTAs send the pricelist at folio level while the reservation payload may omit it. update_folio_values never wrote folio.pricelist_id and wrapper_reservations only read the reservation-level pricelistId, so reservations re-created by a modification kept the original (stale) pricelist instead of the rate sent in the modification (e.g. a booking switched to a non-refundable rate stayed flexible).

Fix

  • Update folio.pricelist_id on modification when the incoming folio-level pricelist changes.
  • Use the folio-level pricelist as a fallback for reservations that don't carry their own pricelistId, symmetric with the create flow.

Reproduced from real API request logs of an OTA modification.

On folio modification through the external API (PUT /folios/external),
OTAs send the pricelist at folio level while the reservation payload may
omit it. update_folio_values never wrote folio.pricelist_id and
wrapper_reservations only read the reservation-level pricelistId, so
reservations re-created by a modification kept the original (stale)
pricelist instead of the rate sent in the modification (e.g. a booking
switched to a non-refundable rate stayed flexible).

Update the folio pricelist when it changes and use the folio-level
pricelist as a fallback for reservations that don't carry their own,
symmetric with the create flow.
@github-actions

Copy link
Copy Markdown

Diff Coverage

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

  • pms_api_rest/services/pms_folio_service.py (16.7%): Missing lines 2323,2327,2531,2534,2539

Summary

  • Total: 6 lines
  • Missing: 5 lines
  • Coverage: 16%

pms_api_rest/services/pms_folio_service.py

Lines 2319-2331

  2319             self.get_language(pms_folio_info.language)
  2320             and self.get_language(pms_folio_info.language) != folio.lang
  2321         ):
  2322             folio_vals.update({"lang": self.get_language(pms_folio_info.language)})
! 2323         if (
  2324             pms_folio_info.pricelistId
  2325             and folio.pricelist_id.id != pms_folio_info.pricelistId
  2326         ):
! 2327             folio_vals.update({"pricelist_id": pms_folio_info.pricelistId})
  2328         reservations_vals = []
  2329         if pms_folio_info.reservations:
  2330             reservations_vals = self.wrapper_reservations(
  2331                 folio, pms_folio_info.reservations, pms_folio_info.pricelistId

Lines 2527-2543

  2527             # OTAs send the pricelist at folio level on modifications, while the
  2528             # reservation payload may omit it. Fall back to the folio pricelist so
  2529             # reservations re-created by a modification keep the right rate instead
  2530             # of the stale one (symmetric with the create flow).
! 2531             reservation_pricelist_id = (
  2532                 info_reservation.pricelistId or folio_pricelist_id
  2533             )
! 2534             if reservation_pricelist_id:
  2535                 if new_res or (
  2536                     proposed_reservation.pricelist_id.id != reservation_pricelist_id
  2537                     and proposed_reservation.state in ["draft", "confirm"]
  2538                 ):
! 2539                     vals.update({"pricelist_id": reservation_pricelist_id})
  2540             board_service_id = self.get_board_service_room_type_id(
  2541                 info_reservation.roomTypeId,
  2542                 folio.pms_property_id.id,
  2543                 info_reservation.boardServiceId,

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