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,
|
getAdditionalPrice,
|
||||||
getCorporateChequePrice,
|
getCorporateChequePrice,
|
||||||
getRedemptionPrice,
|
getRedemptionPrice,
|
||||||
getRegularPrice,
|
|
||||||
getRequestedAdditionalPrice,
|
getRequestedAdditionalPrice,
|
||||||
getTotalPrice,
|
getTotalPrice,
|
||||||
|
getTotalRegularPrice,
|
||||||
getVoucherPrice,
|
getVoucherPrice,
|
||||||
} from "./priceCalculations"
|
} from "./priceCalculations"
|
||||||
|
|
||||||
@@ -1269,11 +1269,11 @@ describe("getVoucherPrice", () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe("getRegularPrice", () => {
|
describe("getTotalRegularPrice", () => {
|
||||||
it("returns price 0 for empty rooms", () => {
|
it("returns price 0 for empty rooms", () => {
|
||||||
const isMember = false
|
const isMember = false
|
||||||
const nights = 1
|
const nights = 1
|
||||||
const result = getRegularPrice([], isMember, nights)
|
const result = getTotalRegularPrice([], isMember, nights)
|
||||||
|
|
||||||
expect(result).toEqual({
|
expect(result).toEqual({
|
||||||
local: {
|
local: {
|
||||||
@@ -1289,7 +1289,7 @@ describe("getRegularPrice", () => {
|
|||||||
const isMember = false
|
const isMember = false
|
||||||
const nights = 2
|
const nights = 2
|
||||||
const guest = { join: false }
|
const guest = { join: false }
|
||||||
const result = getRegularPrice(
|
const result = getTotalRegularPrice(
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
adults: 1,
|
adults: 1,
|
||||||
@@ -1334,7 +1334,7 @@ describe("getRegularPrice", () => {
|
|||||||
const isMember = true
|
const isMember = true
|
||||||
const nights = 2
|
const nights = 2
|
||||||
const guest = { join: false }
|
const guest = { join: false }
|
||||||
const result = getRegularPrice(
|
const result = getTotalRegularPrice(
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
adults: 1,
|
adults: 1,
|
||||||
@@ -1369,7 +1369,7 @@ describe("getRegularPrice", () => {
|
|||||||
local: {
|
local: {
|
||||||
currency: CurrencyEnum.SEK,
|
currency: CurrencyEnum.SEK,
|
||||||
price: 0,
|
price: 0,
|
||||||
regularPrice: 100,
|
regularPrice: 0,
|
||||||
},
|
},
|
||||||
requested: undefined,
|
requested: undefined,
|
||||||
})
|
})
|
||||||
@@ -1379,7 +1379,7 @@ describe("getRegularPrice", () => {
|
|||||||
const isMember = true
|
const isMember = true
|
||||||
const nights = 2
|
const nights = 2
|
||||||
const guest = { join: false }
|
const guest = { join: false }
|
||||||
const result = getRegularPrice(
|
const result = getTotalRegularPrice(
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
adults: 1,
|
adults: 1,
|
||||||
@@ -1417,7 +1417,7 @@ describe("getRegularPrice", () => {
|
|||||||
const isMember = false
|
const isMember = false
|
||||||
const nights = 2
|
const nights = 2
|
||||||
const guest = { join: false }
|
const guest = { join: false }
|
||||||
const result = getRegularPrice(
|
const result = getTotalRegularPrice(
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
adults: 1,
|
adults: 1,
|
||||||
@@ -1455,7 +1455,7 @@ describe("getRegularPrice", () => {
|
|||||||
const isMember = false
|
const isMember = false
|
||||||
const nights = 2
|
const nights = 2
|
||||||
const guest = { join: false }
|
const guest = { join: false }
|
||||||
const result = getRegularPrice(
|
const result = getTotalRegularPrice(
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
adults: 1,
|
adults: 1,
|
||||||
@@ -1500,7 +1500,7 @@ describe("getRegularPrice", () => {
|
|||||||
const isMember = false
|
const isMember = false
|
||||||
const nights = 2
|
const nights = 2
|
||||||
const guest = { join: false }
|
const guest = { join: false }
|
||||||
const result = getRegularPrice(
|
const result = getTotalRegularPrice(
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
adults: 1,
|
adults: 1,
|
||||||
@@ -1554,7 +1554,7 @@ describe("getRegularPrice", () => {
|
|||||||
const isMember = false
|
const isMember = false
|
||||||
const nights = 2
|
const nights = 2
|
||||||
const guest = { join: false }
|
const guest = { join: false }
|
||||||
const result = getRegularPrice(
|
const result = getTotalRegularPrice(
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
adults: 1,
|
adults: 1,
|
||||||
@@ -1597,7 +1597,7 @@ describe("getRegularPrice", () => {
|
|||||||
const isMember = false
|
const isMember = false
|
||||||
const nights = 2
|
const nights = 2
|
||||||
const guest = { join: false }
|
const guest = { join: false }
|
||||||
const result = getRegularPrice(
|
const result = getTotalRegularPrice(
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
adults: 1,
|
adults: 1,
|
||||||
@@ -1649,7 +1649,7 @@ describe("getRegularPrice", () => {
|
|||||||
it("calculates prices for multi-room", () => {
|
it("calculates prices for multi-room", () => {
|
||||||
const isMember = true
|
const isMember = true
|
||||||
const nights = 2
|
const nights = 2
|
||||||
const result = getRegularPrice(
|
const result = getTotalRegularPrice(
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
adults: 1,
|
adults: 1,
|
||||||
@@ -1660,7 +1660,7 @@ describe("getRegularPrice", () => {
|
|||||||
public: {
|
public: {
|
||||||
localPrice: {
|
localPrice: {
|
||||||
pricePerNight: 100,
|
pricePerNight: 100,
|
||||||
pricePerStay: 0,
|
pricePerStay: 200,
|
||||||
regularPricePerStay: 100,
|
regularPricePerStay: 100,
|
||||||
currency: CurrencyEnum.SEK,
|
currency: CurrencyEnum.SEK,
|
||||||
},
|
},
|
||||||
@@ -1684,7 +1684,7 @@ describe("getRegularPrice", () => {
|
|||||||
public: {
|
public: {
|
||||||
localPrice: {
|
localPrice: {
|
||||||
pricePerNight: 75,
|
pricePerNight: 75,
|
||||||
pricePerStay: 0,
|
pricePerStay: 150,
|
||||||
regularPricePerStay: 75,
|
regularPricePerStay: 75,
|
||||||
currency: CurrencyEnum.SEK,
|
currency: CurrencyEnum.SEK,
|
||||||
},
|
},
|
||||||
@@ -1708,7 +1708,7 @@ describe("getRegularPrice", () => {
|
|||||||
local: {
|
local: {
|
||||||
currency: CurrencyEnum.SEK,
|
currency: CurrencyEnum.SEK,
|
||||||
price: 90,
|
price: 90,
|
||||||
regularPrice: 265,
|
regularPrice: 440,
|
||||||
},
|
},
|
||||||
requested: undefined,
|
requested: undefined,
|
||||||
})
|
})
|
||||||
@@ -1717,7 +1717,7 @@ describe("getRegularPrice", () => {
|
|||||||
it("returns unknown price for room without public and member rate", () => {
|
it("returns unknown price for room without public and member rate", () => {
|
||||||
const isMember = false
|
const isMember = false
|
||||||
const nights = 1
|
const nights = 1
|
||||||
const result = getRegularPrice(
|
const result = getTotalRegularPrice(
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
adults: 1,
|
adults: 1,
|
||||||
|
|||||||
@@ -479,7 +479,7 @@ type RegularRoomRequestedPrice = {
|
|||||||
pricePerStay: number
|
pricePerStay: number
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getRegularPrice(
|
export function getTotalRegularPrice(
|
||||||
rooms: RegularPriceCalculationRoom[],
|
rooms: RegularPriceCalculationRoom[],
|
||||||
isMember: boolean,
|
isMember: boolean,
|
||||||
nights: number
|
nights: number
|
||||||
@@ -539,13 +539,13 @@ export function getRegularPrice(
|
|||||||
useMemberRate: !!useMemberRate,
|
useMemberRate: !!useMemberRate,
|
||||||
regularMemberPrice: memberRate
|
regularMemberPrice: memberRate
|
||||||
? {
|
? {
|
||||||
pricePerStay: memberRate.localPrice.pricePerNight,
|
pricePerStay: memberRate.localPrice.pricePerStay,
|
||||||
regularPricePerStay: memberRate.localPrice.regularPricePerStay,
|
regularPricePerStay: memberRate.localPrice.regularPricePerStay,
|
||||||
}
|
}
|
||||||
: undefined,
|
: undefined,
|
||||||
regularPublicPrice: publicRate
|
regularPublicPrice: publicRate
|
||||||
? {
|
? {
|
||||||
pricePerStay: publicRate.localPrice.pricePerNight,
|
pricePerStay: publicRate.localPrice.pricePerStay,
|
||||||
regularPricePerStay: publicRate.localPrice.regularPricePerStay,
|
regularPricePerStay: publicRate.localPrice.regularPricePerStay,
|
||||||
}
|
}
|
||||||
: undefined,
|
: undefined,
|
||||||
@@ -609,7 +609,7 @@ export function getTotalPrice(
|
|||||||
"member" in x.roomRate || "public" in x.roomRate
|
"member" in x.roomRate || "public" in x.roomRate
|
||||||
)
|
)
|
||||||
if (regularRooms.length > 0) {
|
if (regularRooms.length > 0) {
|
||||||
return getRegularPrice(regularRooms, isMember, nights)
|
return getTotalRegularPrice(regularRooms, isMember, nights)
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.warn(
|
logger.warn(
|
||||||
|
|||||||
Reference in New Issue
Block a user