[object Object]

← back to Filemaker Mcp

invoicing: fix double-increment so per-SKU invoice numbers are consecutive (no gaps); verified live 3-invoice write test PASS

4dd914ec4cf1d95584e25f8760f50e1dbf32a2bf · 2026-07-07 09:07:27 -0700 · Steve Abrams

Files touched

Diff

commit 4dd914ec4cf1d95584e25f8760f50e1dbf32a2bf
Author: Steve Abrams <steve@designerwallcoverings.com>
Date:   Tue Jul 7 09:07:27 2026 -0700

    invoicing: fix double-increment so per-SKU invoice numbers are consecutive (no gaps); verified live 3-invoice write test PASS
---
 lib/invoice.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/invoice.js b/lib/invoice.js
index dfeb86b..a7629ab 100644
--- a/lib/invoice.js
+++ b/lib/invoice.js
@@ -132,7 +132,7 @@ export async function createInvoiceForOrder(order, accountNumber, { commit = tru
       const dup = await fm.findRecords('invoice', HDR, { 'Invoice': '==' + nextNum }, { limit: 1 }).catch(() => ({ records: [] }));
       if (dup.records.length) continue;
       const res = await fm.createRecord('invoice', HDR, { 'Invoice': String(nextNum), ...sharedHeader }, { dryRun: false }).catch(() => null);
-      if (res) { id = res.recordId; createdInv = nextNum; nextNum++; }
+      if (res) { id = res.recordId; createdInv = nextNum; } // for-loop's single nextNum++ then advances to the next free number (no gaps)
     }
     if (!id) throw new Error('could not allocate an invoice number');
 

← bd4cd95 invoicing: one record per SKU, only the FIRST carries the do  ·  back to Filemaker Mcp  ·  auto-save: 2026-07-07T09:29:44 (1 files) — scripts/watch-nex f705ac9 →