mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-29 18:48:11 +00:00
Fix voucher pdf
This commit is contained in:
@@ -437,8 +437,11 @@ interface VoucherData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const generateVoucherPDF = async (booking: VoucherData): Promise<void> => {
|
export const generateVoucherPDF = async (booking: VoucherData): Promise<void> => {
|
||||||
// The settled payment amount, when available, is shown exactly as returned by the API
|
// The amount shown is always a single raw field straight from the API — the settled
|
||||||
// (no /100, no per-passenger split) on every passenger's voucher — see fareIsMajorUnits.
|
// payment amount when available, otherwise the booking total — never a derived value
|
||||||
|
// (previously this fell back to Math.round(totalMinor / passengers.length), which
|
||||||
|
// doesn't correspond to any real field and could disagree with what was actually
|
||||||
|
// charged). Same value on every passenger's voucher; no /100, no per-passenger split.
|
||||||
const settledAmountMinor = booking.payment?.amountMinor;
|
const settledAmountMinor = booking.payment?.amountMinor;
|
||||||
const settledCurrency = booking.payment?.currency;
|
const settledCurrency = booking.payment?.currency;
|
||||||
const useSettledAmount = settledAmountMinor != null && !!settledCurrency;
|
const useSettledAmount = settledAmountMinor != null && !!settledCurrency;
|
||||||
@@ -465,7 +468,7 @@ export const generateVoucherPDF = async (booking: VoucherData): Promise<void> =>
|
|||||||
status: booking.status,
|
status: booking.status,
|
||||||
outboundSchedule: { ...booking.schedule, seatClass: p.seat?.seatClass },
|
outboundSchedule: { ...booking.schedule, seatClass: p.seat?.seatClass },
|
||||||
isRoundTrip: false,
|
isRoundTrip: false,
|
||||||
fareMinor: useSettledAmount ? settledAmountMinor! : Math.round(booking.totalMinor / booking.passengers.length),
|
fareMinor: useSettledAmount ? settledAmountMinor! : booking.totalMinor,
|
||||||
currency: voucherCurrency,
|
currency: voucherCurrency,
|
||||||
fareIsMajorUnits: useSettledAmount,
|
fareIsMajorUnits: useSettledAmount,
|
||||||
createdAt: booking.createdAt,
|
createdAt: booking.createdAt,
|
||||||
|
|||||||
Reference in New Issue
Block a user