mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-09-08 05:25:41 +00:00
Fix paid minor calculation
This commit is contained in:
@@ -59,8 +59,8 @@ interface DiscrepancyReport {
|
|||||||
|
|
||||||
// ── Helpers ───────────────────────────────────────────────────────────────────
|
// ── Helpers ───────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
function fmtMoney(minor: number, currency: string) {
|
function fmtMoney(amount: number, currency: string) {
|
||||||
return `${currency} ${(minor / 100).toLocaleString('en-US', { minimumFractionDigits: 2 })}`;
|
return `${currency} ${amount.toLocaleString('en-US', { minimumFractionDigits: 2 })}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function exportCsv(rows: DiscrepancyRow[]) {
|
function exportCsv(rows: DiscrepancyRow[]) {
|
||||||
@@ -77,9 +77,9 @@ function exportCsv(rows: DiscrepancyRow[]) {
|
|||||||
new Date(r.departureAt).toLocaleString('en-GB', { dateStyle: 'medium', timeStyle: 'short' }),
|
new Date(r.departureAt).toLocaleString('en-GB', { dateStyle: 'medium', timeStyle: 'short' }),
|
||||||
r.seatType,
|
r.seatType,
|
||||||
r.coachNumber ?? '—',
|
r.coachNumber ?? '—',
|
||||||
`${r.actualCurrency} ${(r.actualMinor / 100).toFixed(2)}`,
|
`${r.actualCurrency} ${r.actualMinor.toFixed(2)}`,
|
||||||
`${r.paidCurrency} ${(r.paidMinor / 100).toFixed(2)}`,
|
`${r.paidCurrency} ${r.paidMinor.toFixed(2)}`,
|
||||||
`${r.balanceCurrency} ${(r.balanceMinor / 100).toFixed(2)}`,
|
`${r.balanceCurrency} ${r.balanceMinor.toFixed(2)}`,
|
||||||
].map(v => `"${String(v).replace(/"/g, '""')}"`).join(','));
|
].map(v => `"${String(v).replace(/"/g, '""')}"`).join(','));
|
||||||
|
|
||||||
const csv = [headers.join(','), ...lines].join('\n');
|
const csv = [headers.join(','), ...lines].join('\n');
|
||||||
@@ -275,24 +275,6 @@ export default function PaymentDiscrepancyPage() {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{/* Summary — date-range mode, only when there are results */}
|
|
||||||
{data && !isSearchMode && !data.notFound && data.total > 0 && (
|
|
||||||
<div className="flex flex-wrap gap-6 rounded-xl border px-5 py-4 bg-red-50 dark:bg-red-950/20 border-red-200 dark:border-red-800">
|
|
||||||
<div className="flex flex-col">
|
|
||||||
<span className="text-2xl font-bold text-red-700 dark:text-red-300">{data.total}</span>
|
|
||||||
<span className="text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wide">Underpaid bookings</span>
|
|
||||||
</div>
|
|
||||||
{data.totalBalanceEtbMinor > 0 && (
|
|
||||||
<div className="flex flex-col">
|
|
||||||
<span className="text-2xl font-bold text-red-700 dark:text-red-300">
|
|
||||||
{fmtMoney(data.totalBalanceEtbMinor, 'ETB')}
|
|
||||||
</span>
|
|
||||||
<span className="text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wide">Total outstanding (ETB)</span>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{/* Table */}
|
{/* Table */}
|
||||||
{rows.length > 0 && (
|
{rows.length > 0 && (
|
||||||
<div className="bg-white dark:bg-gray-900 border border-gray-200 dark:border-gray-700 rounded-xl overflow-hidden">
|
<div className="bg-white dark:bg-gray-900 border border-gray-200 dark:border-gray-700 rounded-xl overflow-hidden">
|
||||||
|
|||||||
Reference in New Issue
Block a user