← back to Filemaker Mcp
invoicing: require client account number before any invoice (client-account-first) + stop creating the duplicate per-SKU 'second invoice'
a19a17d1030b886ace0dced20998a4f44df75343 · 2026-07-03 08:57:14 -0700 · Steve
Files touched
Diff
commit a19a17d1030b886ace0dced20998a4f44df75343
Author: Steve <steve@designerwallcoverings.com>
Date: Fri Jul 3 08:57:14 2026 -0700
invoicing: require client account number before any invoice (client-account-first) + stop creating the duplicate per-SKU 'second invoice'
---
lib/sync-core.js | 27 ++++++++++++++++++---------
1 file changed, 18 insertions(+), 9 deletions(-)
diff --git a/lib/sync-core.js b/lib/sync-core.js
index c92e49f..09ebf75 100644
--- a/lib/sync-core.js
+++ b/lib/sync-core.js
@@ -90,16 +90,25 @@ export async function syncOrder(order, { commit = true } = {}) {
clientAction = 'would-create';
}
- // 2) invoice
- const { createInvoiceForOrder, createSkuRecords } = await import('./invoice.js');
- const inv = await createInvoiceForOrder(order, accountNumber, { commit });
-
- // 2b) one no-$ per-SKU tracking record (DW SKU field) for every order
- let skuRecs = null;
- if (commit) {
- try { skuRecs = await createSkuRecords(order, accountNumber, mapped.fields['Company'], { commit }); }
- catch (e) { skuRecs = { error: e.message }; }
+ // 2) invoice — HARD RULES (Steve 2026-07-03):
+ // (a) CLIENT-ACCOUNT-FIRST: no invoice may be created without a client account
+ // first. Only a client account number can BEGIN an invoice. If we could not
+ // resolve/create an account number above, DO NOT create the invoice.
+ // (b) NO SECOND INVOICE: the per-SKU tracking records (createSkuRecords) that
+ // duplicated the SKU number are removed — not needed.
+ if (commit && !String(accountNumber || '').trim()) {
+ return {
+ orderNumber: mapped.orderNumber,
+ action: 'skipped',
+ reason: 'no client account number — invoice not created (client-account-first rule)',
+ client: clientAction,
+ company: mapped.fields['Company'],
+ email: mapped.fields['Email address'],
+ };
}
+ const { createInvoiceForOrder } = await import('./invoice.js');
+ const inv = await createInvoiceForOrder(order, accountNumber, { commit });
+ const skuRecs = null; // second invoice (per-SKU tracking records) intentionally removed
// 3) Slack alert (only on real commit)
let slack = null;
← 83d8494 chore: macstudio3 migration — reconcile from mac2 + repoint
·
back to Filemaker Mcp
·
add read-only dup-invoice audit: group by Cust PO, split dou 6a8406b →