Merge returned into outstanding, exclude voided/cancelled payments

This commit is contained in:
Adam Moussa 2026-04-09 15:03:09 -04:00
parent 44a6cd1b63
commit 8e262c3b88

View file

@ -105,9 +105,10 @@ function buildHomeView(payments, metadata) {
// Categorize payments
const scheduled = []; // future payments not yet due
const outstanding = []; // past-due checks not yet cleared
const outstanding = []; // past-due checks not yet cleared, or returned by BoA
const cleared = []; // confirmed cleared by BoA or ACH past due date
const returned = []; // returned by BoA
const skipStatuses = ["voided", "cancelled"];
for (const p of payments) {
if (p.method !== "ACH" && p.method !== "Check") continue;
@ -115,8 +116,11 @@ function buildHomeView(payments, metadata) {
const dt = parseMDYLocal(p.send_payment_on);
if (!dt) continue;
// Skip voided/cancelled payments entirely
if (skipStatuses.includes((p.status || "").toLowerCase())) continue;
if (p.clear_status === "Returned") {
returned.push(p);
outstanding.push(p);
} else if (p.clear_status === "Cleared") {
cleared.push(p);
} else if (p.method === "ACH" && dt < today) {
@ -139,7 +143,6 @@ function buildHomeView(payments, metadata) {
scheduled.sort(byDate);
outstanding.sort(byDate);
cleared.sort(byDate);
returned.sort(byDate);
const buildSectionBlocks = (title, emoji, items) => {
const total = items.reduce((sum, p) => sum + p.amount_usd, 0);
@ -212,7 +215,6 @@ function buildHomeView(payments, metadata) {
...buildSectionBlocks("Scheduled", ":calendar:", scheduled),
...buildSectionBlocks("Outstanding", ":warning:", outstanding),
...buildSectionBlocks("Cleared", ":white_check_mark:", cleared),
...buildSectionBlocks("Returned", ":x:", returned),
],
};
}