fix: always use totalPrice to display roomCharge

This commit is contained in:
Simon Emanuelsson
2025-04-16 12:41:37 +02:00
parent 1f94c581ae
commit 722d4505ba
18 changed files with 312 additions and 864 deletions

View File

@@ -36,10 +36,6 @@ export default function PriceDetails() {
return total
}
const pkgsSum =
room.roomFeatures?.reduce((total, pkg) => total + pkg.totalPrice, 0) ??
0
if (room.cheques) {
// CorporateCheque Booking
total.local.currency = CurrencyEnum.CC
@@ -54,7 +50,7 @@ export default function PriceDetails() {
total.local.price = total.local.price + room.vouchers
} else {
// Price Booking
total.local.price = total.local.price + room.roomPrice + pkgsSum
total.local.price = total.local.price + room.totalPrice
}
if (
@@ -62,7 +58,7 @@ export default function PriceDetails() {
room.roomPrice
) {
total.local.additionalPrice =
(total.local.additionalPrice || 0) + room.roomPrice + pkgsSum
(total.local.additionalPrice || 0) + room.totalPrice
total.local.additionalPriceCurrency = currency
}

View File

@@ -4,6 +4,8 @@ import {
} from "@/server/routers/hotels/schemas/packages"
import { ChildBedMapEnum } from "@/types/components/bookingWidget/enums"
import { BreakfastPackageEnum } from "@/types/enums/breakfast"
import { PackageTypeEnum } from "@/types/enums/packages"
import type { Package } from "@/types/requests/packages"
import type { Room } from "@/types/stores/booking-confirmation"
@@ -15,16 +17,20 @@ export function mapToPrice(rooms: (Room | null)[], nights: number) {
if (room.cheques) {
price = {
corporateCheque: {
additionalPricePerStay: room.roomPrice ? room.roomPrice : undefined,
currency: room.roomPrice ? room.currencyCode : undefined,
additionalPricePerStay: room.totalPrice
? room.totalPrice
: undefined,
currency: room.totalPrice ? room.currencyCode : undefined,
numberOfCheques: room.cheques,
},
}
} else if (room.roomPoints) {
price = {
redemption: {
additionalPricePerStay: room.roomPrice ? room.roomPrice : undefined,
currency: room.roomPrice ? room.currencyCode : undefined,
additionalPricePerStay: room.totalPrice
? room.totalPrice
: undefined,
currency: room.totalPrice ? room.currencyCode : undefined,
pointsPerNight: room.roomPoints / nights,
pointsPerStay: room.roomPoints,
},
@@ -40,7 +46,7 @@ export function mapToPrice(rooms: (Room | null)[], nights: number) {
regular: {
currency: room.currencyCode,
pricePerNight: room.roomPrice / nights,
pricePerStay: room.roomPrice,
pricePerStay: room.totalPrice,
},
}
}
@@ -53,7 +59,10 @@ export function mapToPrice(rooms: (Room | null)[], nights: number) {
price: room.breakfast?.unitPrice,
totalPrice: room.breakfast?.totalPrice,
},
packageType: room.breakfast?.type,
packageType:
room.breakfast?.code === BreakfastPackageEnum.REGULAR_BREAKFAST
? PackageTypeEnum.BreakfastAdult
: "",
requestedPrice: {
currency: room.breakfast?.currency,
price: room.breakfast?.unitPrice,