mirror of
https://github.com/msitarzewski/agency-agents.git
synced 2026-10-10 04:35:07 +00:00
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:
@@ -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"),
|
||||
|
||||
Reference in New Issue
Block a user