Separate completed payment totals by currency in AP reports

Signed-off-by: Rudy Celekli <47457359+rudycelekli@users.noreply.github.com>
This commit is contained in:
Rudy Celekli
2026-10-05 12:32:33 -04:00
parent 83294689da
commit 7aeeb3effc
+10 -1
View File
@@ -164,8 +164,17 @@ const summary = await payments.getHistory({
dateTo: "2024-03-31"
});
// The adapter normalizes successful final payments to status="completed".
// Pending/failed records are not paid; currencies cannot be added together.
const paidByCurrency = summary
.filter(p => p.status === "completed")
.reduce<Record<string, number>>((totals, p) => {
totals[p.currency] = (totals[p.currency] ?? 0) + p.amount;
return totals;
}, {});
const report = {
totalPaid: summary.reduce((sum, p) => sum + p.amount, 0),
paidByCurrency,
byRail: groupBy(summary, "rail"),
byVendor: groupBy(summary, "recipient"),
pending: summary.filter(p => p.status === "pending"),