fix(SW-3616): Handle EuroBonus point type everywhere * Add tests to formatPrice * formatPrice * More work replacing config with api points type * More work replacing config with api points type * More fixing with currency * maybe actually fixed it * Fix MyStay * Clean up * Fix comments * Merge branch 'master' into fix/refactor-currency-display * Fix calculateTotalPrice for EB points + SF points + cash Approved-by: Joakim Jäderberg
52 lines
1.3 KiB
TypeScript
52 lines
1.3 KiB
TypeScript
"use client"
|
|
import { useIntl } from "react-intl"
|
|
|
|
import { CurrencyEnum } from "@scandic-hotels/common/constants/currency"
|
|
import { formatPrice } from "@scandic-hotels/common/utils/numberFormatting"
|
|
|
|
import { calculateVat } from "../../../../utils/SelectRate"
|
|
import RegularRow from "./Regular"
|
|
|
|
import type { Price } from "../../../../types/price"
|
|
|
|
interface VatProps {
|
|
totalPrice: Price
|
|
vat: number
|
|
}
|
|
|
|
const noVatCurrencies = [
|
|
CurrencyEnum.CC,
|
|
CurrencyEnum.POINTS,
|
|
CurrencyEnum.Voucher,
|
|
CurrencyEnum.Unknown,
|
|
]
|
|
|
|
export default function VatRow({ totalPrice, vat }: VatProps) {
|
|
const intl = useIntl()
|
|
|
|
if (noVatCurrencies.includes(totalPrice.local.currency)) {
|
|
return null
|
|
}
|
|
|
|
const { vatAmount, priceExclVat } = calculateVat(totalPrice.local.price, vat)
|
|
|
|
return (
|
|
<>
|
|
<RegularRow
|
|
label={intl.formatMessage({
|
|
id: "booking.priceExcludingVat",
|
|
defaultMessage: "Price excluding VAT",
|
|
})}
|
|
value={formatPrice(intl, priceExclVat, totalPrice.local.currency)}
|
|
/>
|
|
<RegularRow
|
|
label={intl.formatMessage(
|
|
{ id: "priceDetails.VAT", defaultMessage: "VAT {vat}%" },
|
|
{ vat }
|
|
)}
|
|
value={formatPrice(intl, vatAmount, totalPrice.local.currency)}
|
|
/>
|
|
</>
|
|
)
|
|
}
|