Merged in fix/refactor-currency-display (pull request #3434)

fix(SW-3616): Handle EuroBonus point type everywhere

* Add tests to formatPrice

* formatPrice

* More work replacing config with api points type

* More work replacing config with api points type

* More fixing with currency

* maybe actually fixed it

* Fix MyStay

* Clean up

* Fix comments

* Merge branch 'master' into fix/refactor-currency-display

* Fix calculateTotalPrice for EB points + SF points + cash


Approved-by: Joakim Jäderberg
This commit is contained in:
Anton Gunnarsson
2026-01-15 09:32:17 +00:00
parent c61ddaf94d
commit 16fbdb7ae0
59 changed files with 729 additions and 282 deletions

View File

@@ -1,4 +1,5 @@
import { CurrencyEnum } from "@scandic-hotels/common/constants/currency"
import { PointType } from "@scandic-hotels/common/constants/pointType"
import { RateTypeEnum } from "@scandic-hotels/common/constants/rateType"
import { logger } from "@scandic-hotels/common/logger"
@@ -19,11 +20,7 @@ function add(...nums: (number | string | undefined)[]) {
}, 0)
}
export function getRoomPrice(
roomRate: Product,
isMember: boolean,
pointsCurrency?: CurrencyEnum
) {
export function getRoomPrice(roomRate: Product, isMember: boolean) {
if (isMember && "member" in roomRate && roomRate.member) {
let publicRate
if (
@@ -167,23 +164,25 @@ export function getRoomPrice(
perNight: {
requested: undefined,
local: {
currency: pointsCurrency ?? CurrencyEnum.POINTS,
currency: CurrencyEnum.POINTS,
price: roomRate.redemption.localPrice.pointsPerStay,
additionalPrice:
roomRate.redemption.localPrice.additionalPricePerStay,
additionalPriceCurrency:
roomRate.redemption.localPrice.currency ?? undefined,
pointsType: roomRate.redemption.localPrice.pointsType,
},
},
perStay: {
requested: undefined,
local: {
currency: pointsCurrency ?? CurrencyEnum.POINTS,
currency: CurrencyEnum.POINTS,
price: roomRate.redemption.localPrice.pointsPerStay,
additionalPrice:
roomRate.redemption.localPrice.additionalPricePerStay,
additionalPriceCurrency:
roomRate.redemption.localPrice.currency ?? undefined,
pointsType: roomRate.redemption.localPrice.pointsType,
},
},
}
@@ -410,17 +409,18 @@ type RedemptionRoom = BasePriceCalculationRoom & {
localPrice: {
pointsPerStay: number
additionalPricePerStay: number
pointsType: PointType
currency?: CurrencyEnum
}
}
}
}
export function getRedemptionPrice(
rooms: RedemptionRoom[],
nights: number,
pointsCurrency?: CurrencyEnum
) {
export function getRedemptionPrice(rooms: RedemptionRoom[], nights: number) {
// We can assume that all rooms have the same pointsType
const pointsType =
rooms[0]?.roomRate.redemption.localPrice.pointsType || PointType.SCANDIC
return rooms.reduce<Price>(
(total, room) => {
const redemption = room.roomRate.redemption
@@ -444,8 +444,9 @@ export function getRedemptionPrice(
},
{
local: {
currency: pointsCurrency ?? CurrencyEnum.POINTS,
currency: CurrencyEnum.POINTS,
price: 0,
pointsType,
},
requested: undefined,
}
@@ -580,8 +581,7 @@ export function getTotalPrice(
| VoucherRoom
)[],
isMember: boolean,
nights: number,
pointsCurrency?: CurrencyEnum
nights: number
) {
const corporateChequeRooms = rooms.filter(
(x): x is CorporateCheckRoom => "corporateCheque" in x.roomRate
@@ -594,7 +594,7 @@ export function getTotalPrice(
(x): x is RedemptionRoom => "redemption" in x.roomRate
)
if (redemptionRooms.length > 0) {
return getRedemptionPrice(redemptionRooms, nights, pointsCurrency)
return getRedemptionPrice(redemptionRooms, nights)
}
const voucherRooms = rooms.filter(