Skip to content

A complete AI agency at your fingertips - From frontend wizards to Reddit community ninjas, from whimsy injectors to reality checkers. Each agent is a specialized expert with personality, processes, and proven deliverables.

Shell

Separate completed payment totals by currency in AP reports

Rudy Celekli7aeeb3effc6a
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<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"),