From 7aeeb3effc6a6e10796827020cc0887f84792de9 Mon Sep 17 00:00:00 2001 From: Rudy Celekli <47457359+rudycelekli@users.noreply.github.com> Date: Mon, 5 Oct 2026 12:32:33 -0400 Subject: [PATCH] Separate completed payment totals by currency in AP reports Signed-off-by: Rudy Celekli <47457359+rudycelekli@users.noreply.github.com> --- specialized/accounts-payable-agent.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/specialized/accounts-payable-agent.md b/specialized/accounts-payable-agent.md index 5b3adf6c..9d794ca5 100644 --- a/specialized/accounts-payable-agent.md +++ b/specialized/accounts-payable-agent.md @@ -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>((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"),