From 3b8c2014449c519d357e80b55f58e35ec6b12cb2 Mon Sep 17 00:00:00 2001 From: Adam Moussa <166072409+amoussa1229@users.noreply.github.com> Date: Fri, 10 Apr 2026 17:31:27 -0400 Subject: [PATCH] Add ACH auto-clear and expanded cancel status list ACH payments auto-marked as Cleared when send date has passed. Cancel statuses expanded to include "canceled" and "marked as void". --- src/processPaymentCsv.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/processPaymentCsv.js b/src/processPaymentCsv.js index cc67469..8d1b9ba 100644 --- a/src/processPaymentCsv.js +++ b/src/processPaymentCsv.js @@ -54,7 +54,7 @@ export const handler = async (event) => { return isNaN(num) ? 0 : num; }; - const cancelStatuses = ["voided", "cancelled"]; + const cancelStatuses = ["voided", "cancelled", "canceled", "marked as void"]; const newChecks = []; const cancelChecks = []; @@ -63,7 +63,18 @@ export const handler = async (event) => { for (const row of normalizedRows) { const checkNumber = (row["Check Number"] || "").trim(); const method = (row["Method"] || "").trim(); - const status = (row["Status"] || "").trim(); + let status = (row["Status"] || "").trim(); + const sendOn = (row["Send Payment On"] || "").trim(); + + // ACH payments clear automatically on their send date + if (method === "ACH" && !cancelStatuses.includes(status.toLowerCase())) { + const sendDate = toISODate(sendOn); + const today = new Date().toISOString().slice(0, 10); + if (sendDate && sendDate <= today) { + status = "Cleared"; + } + } + const pk = `payment#${checkNumber}`; // Check if record already exists (for detecting new vs updated)