mirror of
https://github.com/Sea-Haven-Industries/payments-dashboard.git
synced 2026-09-30 06:33:11 +00:00
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:
parent
33cd9759b4
commit
3b8c201444
1 changed files with 13 additions and 2 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue