mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-29 14:08:11 +00:00
Merge pull request #856 from Tria-plc/alpha
Payment discrepancy paid amount update
This commit is contained in:
@@ -956,13 +956,11 @@ export class ReportsService {
|
|||||||
let rows = bookings.map(b => {
|
let rows = bookings.map(b => {
|
||||||
const pi = b.paymentIntent!;
|
const pi = b.paymentIntent!;
|
||||||
const actualMinor = b.seats.reduce((s, seat) => s + (seat.fareMinor ?? 0), 0);
|
const actualMinor = b.seats.reduce((s, seat) => s + (seat.fareMinor ?? 0), 0);
|
||||||
const paidMinor = Math.round(pi.amountMinor);
|
// pi.amountMinor is a Float in full currency units — convert to cents once
|
||||||
const varianceMinor = actualMinor - paidMinor;
|
const paidMinorCents = Math.round(pi.amountMinor * 100);
|
||||||
|
|
||||||
const isPackage = !!(b as any).package;
|
const isPackage = !!(b as any).package;
|
||||||
const effectiveActualMinor = isPackage ? actualMinor * 2 : actualMinor;
|
const effectiveActualMinor = isPackage ? actualMinor * 2 : actualMinor;
|
||||||
// actualMinor is in cents; paidMinor (PaymentIntent.amountMinor) is a Float in full units — convert to cents before comparing
|
|
||||||
const paidMinorCents = Math.round(paidMinor * 100);
|
|
||||||
const effectiveVarianceMinor = effectiveActualMinor - paidMinorCents;
|
const effectiveVarianceMinor = effectiveActualMinor - paidMinorCents;
|
||||||
|
|
||||||
const breakdown = b.seats.map(s => ({
|
const breakdown = b.seats.map(s => ({
|
||||||
@@ -984,7 +982,7 @@ export class ReportsService {
|
|||||||
destination: b.schedule.destinationStation.name,
|
destination: b.schedule.destinationStation.name,
|
||||||
phone: b.passenger?.user?.phone ?? (b as any).contactPhone ?? '—',
|
phone: b.passenger?.user?.phone ?? (b as any).contactPhone ?? '—',
|
||||||
actualMinor: effectiveActualMinor,
|
actualMinor: effectiveActualMinor,
|
||||||
paidMinor,
|
paidMinor: paidMinorCents,
|
||||||
varianceMinor: effectiveVarianceMinor,
|
varianceMinor: effectiveVarianceMinor,
|
||||||
breakdown,
|
breakdown,
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user