fix: always use totalPrice to display roomCharge
This commit is contained in:
@@ -273,7 +273,7 @@ export function getRoomPrice(roomRate: RoomRate, isMember: boolean) {
|
||||
}
|
||||
|
||||
export function getTotalPrice(roomRates: RoomRate[], isMember: boolean) {
|
||||
return roomRates.reduce<Price>(
|
||||
const totalPrice = roomRates.reduce<Price>(
|
||||
(total, roomRate, idx) => {
|
||||
const isMainRoom = idx === 0
|
||||
let rate
|
||||
@@ -320,6 +320,52 @@ export function getTotalPrice(roomRates: RoomRate[], isMember: boolean) {
|
||||
requested: undefined,
|
||||
}
|
||||
)
|
||||
|
||||
if (totalPrice.local.regularPrice) {
|
||||
const totalPriceWithRegularPrice = roomRates.reduce(
|
||||
(total, roomRate, idx) => {
|
||||
const isMainRoom = idx === 0
|
||||
let rate
|
||||
if (isMainRoom && isMember && "member" in roomRate && roomRate.member) {
|
||||
rate = roomRate.member
|
||||
} else if ("public" in roomRate && roomRate.public) {
|
||||
rate = roomRate.public
|
||||
}
|
||||
|
||||
if (!rate) {
|
||||
return total
|
||||
}
|
||||
|
||||
if (rate.localPrice.regularPricePerStay) {
|
||||
total.local.regularPrice =
|
||||
total.local.regularPrice + rate.localPrice.regularPricePerStay
|
||||
} else {
|
||||
total.local.regularPrice =
|
||||
total.local.regularPrice + rate.localPrice.pricePerStay
|
||||
}
|
||||
|
||||
return total
|
||||
},
|
||||
{
|
||||
...totalPrice,
|
||||
local: {
|
||||
...totalPrice.local,
|
||||
regularPrice: 0,
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
if (
|
||||
totalPriceWithRegularPrice.local.price ===
|
||||
totalPriceWithRegularPrice.local.regularPrice
|
||||
) {
|
||||
totalPriceWithRegularPrice.local.regularPrice = 0
|
||||
}
|
||||
|
||||
return totalPriceWithRegularPrice
|
||||
}
|
||||
|
||||
return totalPrice
|
||||
}
|
||||
|
||||
export function calculateVoucherPrice(roomRates: RoomRate[]) {
|
||||
|
||||
Reference in New Issue
Block a user