fix: make sure calculations in booking flow are correct
This commit is contained in:
committed by
Michael Zetterberg
parent
3e0f503314
commit
a222ecfc5c
@@ -75,6 +75,9 @@ export default function PriceDetailsModal() {
|
||||
return null
|
||||
}
|
||||
|
||||
const checkInDate = dt(fromDate).format("YYYY-MM-DD")
|
||||
const checkOutDate = dt(toDate).format("YYYY-MM-DD")
|
||||
|
||||
const bookingTotal = rooms.reduce(
|
||||
(acc, room) => {
|
||||
if (room) {
|
||||
@@ -89,7 +92,7 @@ export default function PriceDetailsModal() {
|
||||
{ price: 0, priceExVat: 0, vatAmount: 0 }
|
||||
)
|
||||
|
||||
const diff = dt(toDate).diff(fromDate, "days")
|
||||
const diff = dt(checkOutDate).diff(checkInDate, "days")
|
||||
const nights = intl.formatMessage(
|
||||
{ id: "{totalNights, plural, one {# night} other {# nights}}" },
|
||||
{ totalNights: diff }
|
||||
|
||||
@@ -163,21 +163,23 @@ export default function ReceiptRoom({
|
||||
</Body>
|
||||
</div>
|
||||
) : null}
|
||||
<div className={styles.entry}>
|
||||
<Body>{intl.formatMessage({ id: "Breakfast buffet" })}</Body>
|
||||
{(room.rateDefinition.breakfastIncluded ?? room.breakfastIncluded) ? (
|
||||
<Body color="red">{intl.formatMessage({ id: "Included" })}</Body>
|
||||
) : null}
|
||||
{room.breakfast ? (
|
||||
<Body color="uiTextHighContrast">
|
||||
{formatPrice(
|
||||
intl,
|
||||
room.breakfast.totalPrice * room.adults,
|
||||
room.breakfast.currency
|
||||
)}
|
||||
</Body>
|
||||
) : null}
|
||||
</div>
|
||||
{room.breakfast || room.breakfastIncluded ? (
|
||||
<div className={styles.entry}>
|
||||
<Body>{intl.formatMessage({ id: "Breakfast buffet" })}</Body>
|
||||
{(room.rateDefinition.breakfastIncluded ?? room.breakfastIncluded) ? (
|
||||
<Body color="red">{intl.formatMessage({ id: "Included" })}</Body>
|
||||
) : null}
|
||||
{room.breakfast ? (
|
||||
<Body color="uiTextHighContrast">
|
||||
{formatPrice(
|
||||
intl,
|
||||
room.breakfast.totalPrice,
|
||||
room.breakfast.currency
|
||||
)}
|
||||
</Body>
|
||||
) : null}
|
||||
</div>
|
||||
) : null}
|
||||
</article>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import {
|
||||
type TrackingSDKPaymentInfo,
|
||||
} from "@/types/components/tracking"
|
||||
import { BreakfastPackageEnum } from "@/types/enums/breakfast"
|
||||
import { RateEnum } from "@/types/enums/rate"
|
||||
import type { Room } from "@/types/stores/booking-confirmation"
|
||||
import type { BookingConfirmation } from "@/types/trpc/routers/booking/confirmation"
|
||||
import type { RateDefinition } from "@/types/trpc/routers/hotel/roomAvailability"
|
||||
@@ -19,11 +20,11 @@ import type { Lang } from "@/constants/languages"
|
||||
function getRate(cancellationRule: RateDefinition["cancellationRule"] | null) {
|
||||
switch (cancellationRule) {
|
||||
case "CancellableBefore6PM":
|
||||
return "flex"
|
||||
return RateEnum.flex
|
||||
case "Changeable":
|
||||
return "change"
|
||||
return RateEnum.change
|
||||
case "NotCancellable":
|
||||
return "save"
|
||||
return RateEnum.save
|
||||
default:
|
||||
return "-"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user