mirror of
https://github.com/Sea-Haven-Industries/payments-dashboard.git
synced 2026-10-01 18:33:12 +00:00
Merge returned into outstanding, exclude voided/cancelled payments
This commit is contained in:
parent
44a6cd1b63
commit
8e262c3b88
1 changed files with 7 additions and 5 deletions
|
|
@ -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),
|
||||
],
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue