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
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user