mirror of
https://github.com/Sea-Haven-Industries/payments-dashboard.git
synced 2026-09-30 21:43:11 +00:00
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:
parent
df14849dbb
commit
6c9727eb75
1 changed files with 12 additions and 2 deletions
|
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue