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".
This commit is contained in:
Adam Moussa 2026-04-10 17:31:27 -04:00
parent 33cd9759b4
commit 3b8c201444

View file

@ -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)