Fix BoA CashPro API rejection when CSV has >100 checks

BoA check-issues endpoint has a 100-item limit per call. Large Stampli
exports were failing with error 10102. Batch submissions into chunks of
100 for both add_Issue and cancel_Issue actions.
This commit is contained in:
Adam Moussa 2026-05-07 19:02:58 -04:00
parent df14849dbb
commit 6c9727eb75

View file

@ -275,12 +275,22 @@ export const handler = async (event) => {
return data;
};
const BOA_BATCH_SIZE = 100;
const submitInBatches = async (items, action) => {
for (let i = 0; i < items.length; i += BOA_BATCH_SIZE) {
const batch = items.slice(i, i + BOA_BATCH_SIZE);
console.log(`BoA ${action} batch ${Math.floor(i / BOA_BATCH_SIZE) + 1}: ${batch.length} items`);
await submitToBoA(batch, action);
}
};
if (newChecks.length) {
await submitToBoA(newChecks, "add_Issue");
await submitInBatches(newChecks, "add_Issue");
}
if (cancelChecks.length) {
await submitToBoA(cancelChecks, "cancel_Issue");
await submitInBatches(cancelChecks, "cancel_Issue");
}
}