Fix voucher pdf

This commit is contained in:
Roba Boru
2026-07-13 21:42:53 +03:00
parent 87f530f1de
commit e2cc9772e6

View File

@@ -437,8 +437,11 @@ interface VoucherData {
}
export const generateVoucherPDF = async (booking: VoucherData): Promise<void> => {
// The settled payment amount, when available, is shown exactly as returned by the API
// (no /100, no per-passenger split) on every passenger's voucher — see fareIsMajorUnits.
// The amount shown is always a single raw field straight from the API — the settled
// 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 settledCurrency = booking.payment?.currency;
const useSettledAmount = settledAmountMinor != null && !!settledCurrency;
@@ -465,7 +468,7 @@ export const generateVoucherPDF = async (booking: VoucherData): Promise<void> =>
status: booking.status,
outboundSchedule: { ...booking.schedule, seatClass: p.seat?.seatClass },
isRoundTrip: false,
fareMinor: useSettledAmount ? settledAmountMinor! : Math.round(booking.totalMinor / booking.passengers.length),
fareMinor: useSettledAmount ? settledAmountMinor! : booking.totalMinor,
currency: voucherCurrency,
fareIsMajorUnits: useSettledAmount,
createdAt: booking.createdAt,