From 96b4e5a2544b6684c6b6c5dd9bb1de1188c04bd2 Mon Sep 17 00:00:00 2001 From: Bianca Widstam Date: Fri, 19 Dec 2025 08:19:19 +0000 Subject: [PATCH] Merged in fix/BOOK-584-strikethrough-regulare-price (pull request #3374) fix(BOOK-584): multiple nights did not show strikethrough price, wrong calculation for regular price per stay * fix(BOOK-548): multiple nights did not show strikethrough price, wrong calculation for regular price per stay * fix(BOOK-584): fix test, regularPrice first compare with pricePerStay Approved-by: Anton Gunnarsson --- .../enter-details/priceCalculations.test.ts | 34 +++++++++---------- .../stores/enter-details/priceCalculations.ts | 8 ++--- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/packages/booking-flow/lib/stores/enter-details/priceCalculations.test.ts b/packages/booking-flow/lib/stores/enter-details/priceCalculations.test.ts index 21533d488..de04ad939 100644 --- a/packages/booking-flow/lib/stores/enter-details/priceCalculations.test.ts +++ b/packages/booking-flow/lib/stores/enter-details/priceCalculations.test.ts @@ -7,9 +7,9 @@ import { getAdditionalPrice, getCorporateChequePrice, getRedemptionPrice, - getRegularPrice, getRequestedAdditionalPrice, getTotalPrice, + getTotalRegularPrice, getVoucherPrice, } from "./priceCalculations" @@ -1269,11 +1269,11 @@ describe("getVoucherPrice", () => { }) }) -describe("getRegularPrice", () => { +describe("getTotalRegularPrice", () => { it("returns price 0 for empty rooms", () => { const isMember = false const nights = 1 - const result = getRegularPrice([], isMember, nights) + const result = getTotalRegularPrice([], isMember, nights) expect(result).toEqual({ local: { @@ -1289,7 +1289,7 @@ describe("getRegularPrice", () => { const isMember = false const nights = 2 const guest = { join: false } - const result = getRegularPrice( + const result = getTotalRegularPrice( [ { adults: 1, @@ -1334,7 +1334,7 @@ describe("getRegularPrice", () => { const isMember = true const nights = 2 const guest = { join: false } - const result = getRegularPrice( + const result = getTotalRegularPrice( [ { adults: 1, @@ -1369,7 +1369,7 @@ describe("getRegularPrice", () => { local: { currency: CurrencyEnum.SEK, price: 0, - regularPrice: 100, + regularPrice: 0, }, requested: undefined, }) @@ -1379,7 +1379,7 @@ describe("getRegularPrice", () => { const isMember = true const nights = 2 const guest = { join: false } - const result = getRegularPrice( + const result = getTotalRegularPrice( [ { adults: 1, @@ -1417,7 +1417,7 @@ describe("getRegularPrice", () => { const isMember = false const nights = 2 const guest = { join: false } - const result = getRegularPrice( + const result = getTotalRegularPrice( [ { adults: 1, @@ -1455,7 +1455,7 @@ describe("getRegularPrice", () => { const isMember = false const nights = 2 const guest = { join: false } - const result = getRegularPrice( + const result = getTotalRegularPrice( [ { adults: 1, @@ -1500,7 +1500,7 @@ describe("getRegularPrice", () => { const isMember = false const nights = 2 const guest = { join: false } - const result = getRegularPrice( + const result = getTotalRegularPrice( [ { adults: 1, @@ -1554,7 +1554,7 @@ describe("getRegularPrice", () => { const isMember = false const nights = 2 const guest = { join: false } - const result = getRegularPrice( + const result = getTotalRegularPrice( [ { adults: 1, @@ -1597,7 +1597,7 @@ describe("getRegularPrice", () => { const isMember = false const nights = 2 const guest = { join: false } - const result = getRegularPrice( + const result = getTotalRegularPrice( [ { adults: 1, @@ -1649,7 +1649,7 @@ describe("getRegularPrice", () => { it("calculates prices for multi-room", () => { const isMember = true const nights = 2 - const result = getRegularPrice( + const result = getTotalRegularPrice( [ { adults: 1, @@ -1660,7 +1660,7 @@ describe("getRegularPrice", () => { public: { localPrice: { pricePerNight: 100, - pricePerStay: 0, + pricePerStay: 200, regularPricePerStay: 100, currency: CurrencyEnum.SEK, }, @@ -1684,7 +1684,7 @@ describe("getRegularPrice", () => { public: { localPrice: { pricePerNight: 75, - pricePerStay: 0, + pricePerStay: 150, regularPricePerStay: 75, currency: CurrencyEnum.SEK, }, @@ -1708,7 +1708,7 @@ describe("getRegularPrice", () => { local: { currency: CurrencyEnum.SEK, price: 90, - regularPrice: 265, + regularPrice: 440, }, requested: undefined, }) @@ -1717,7 +1717,7 @@ describe("getRegularPrice", () => { it("returns unknown price for room without public and member rate", () => { const isMember = false const nights = 1 - const result = getRegularPrice( + const result = getTotalRegularPrice( [ { adults: 1, diff --git a/packages/booking-flow/lib/stores/enter-details/priceCalculations.ts b/packages/booking-flow/lib/stores/enter-details/priceCalculations.ts index aa6b9b445..c105a12c8 100644 --- a/packages/booking-flow/lib/stores/enter-details/priceCalculations.ts +++ b/packages/booking-flow/lib/stores/enter-details/priceCalculations.ts @@ -479,7 +479,7 @@ type RegularRoomRequestedPrice = { pricePerStay: number } -export function getRegularPrice( +export function getTotalRegularPrice( rooms: RegularPriceCalculationRoom[], isMember: boolean, nights: number @@ -539,13 +539,13 @@ export function getRegularPrice( useMemberRate: !!useMemberRate, regularMemberPrice: memberRate ? { - pricePerStay: memberRate.localPrice.pricePerNight, + pricePerStay: memberRate.localPrice.pricePerStay, regularPricePerStay: memberRate.localPrice.regularPricePerStay, } : undefined, regularPublicPrice: publicRate ? { - pricePerStay: publicRate.localPrice.pricePerNight, + pricePerStay: publicRate.localPrice.pricePerStay, regularPricePerStay: publicRate.localPrice.regularPricePerStay, } : undefined, @@ -609,7 +609,7 @@ export function getTotalPrice( "member" in x.roomRate || "public" in x.roomRate ) if (regularRooms.length > 0) { - return getRegularPrice(regularRooms, isMember, nights) + return getTotalRegularPrice(regularRooms, isMember, nights) } logger.warn(