[object Object]

← back to Filemaker Mcp

test: smoke-invoice-b — dry-run regression for SKU-on-line + money-on-first (choice B)

35cf4d35309f14ddbf147676623f44b6f749fefc · 2026-08-04 11:09:05 -0700 · Steve

Replaces the stale test-real-units.mjs (referenced a removed moneyRecordLines field).
Asserts DETAIL shows the real SKU (not 'Samples'), all money rides the first line,
and every other SKU is a $0 stub. Covers the single-sample + multi-sample cases that
regressed (orders 32759 / 32760).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

Files touched

Diff

commit 35cf4d35309f14ddbf147676623f44b6f749fefc
Author: Steve <steve@designerwallcoverings.com>
Date:   Tue Aug 4 11:09:05 2026 -0700

    test: smoke-invoice-b — dry-run regression for SKU-on-line + money-on-first (choice B)
    
    Replaces the stale test-real-units.mjs (referenced a removed moneyRecordLines field).
    Asserts DETAIL shows the real SKU (not 'Samples'), all money rides the first line,
    and every other SKU is a $0 stub. Covers the single-sample + multi-sample cases that
    regressed (orders 32759 / 32760).
    Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---
 scripts/smoke-invoice-b.mjs | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/scripts/smoke-invoice-b.mjs b/scripts/smoke-invoice-b.mjs
new file mode 100644
index 0000000..065c0cb
--- /dev/null
+++ b/scripts/smoke-invoice-b.mjs
@@ -0,0 +1,37 @@
+import { createInvoiceForOrder } from '../lib/invoice.js';
+
+const cases = [
+  { label: '32759-like — SINGLE sample (was broken → "Samples")',
+    order: { order_number: 999759, total_tax: 0,
+      customer: { first_name: 'Elizabeth', last_name: 'Comstock' },
+      shipping_address: { company: '', address1: '4911 Dartford Pl', city: 'Granite Bay', province_code: 'CA', zip: '95746', country_code: 'US' },
+      shipping_lines: [{ title: 'Free Shipping', price: '0' }],
+      line_items: [ { sku: 'DWWM-14847-Sample', name: 'Sand', price: '4.25', quantity: 1, variant_title: 'Sample' } ] } },
+  { label: '32760-like — 3 samples (money on FIRST only)',
+    order: { order_number: 999760, total_tax: 0,
+      customer: { first_name: 'joyce', last_name: 'eaton' },
+      shipping_address: { company: '', address1: '2104 Monticello', city: 'Springdale', province_code: 'AR', zip: '72762', country_code: 'US' },
+      shipping_lines: [{ title: 'UPS Ground', price: '0' }],
+      line_items: [
+        { sku: 'DWPN-100258-Sample', name: 'Astor Basketball', price: '4.25', quantity: 1, variant_title: 'Sample' },
+        { sku: 'DWPR-427799-Sample', name: 'Vintage Lipstick', price: '4.25', quantity: 1, variant_title: 'Sample' },
+        { sku: 'DWPN-100195-Sample', name: 'Barbuda Brazen', price: '4.25', quantity: 1, variant_title: 'Sample' },
+      ] } },
+];
+
+let pass = true;
+for (const { label, order } of cases) {
+  const r = await createInvoiceForOrder(order, 'TEST-ACCT', { commit: false });
+  const L = r.moneyLine;
+  console.log(`\n=== ${label} ===`);
+  console.log(`  MONEY line 1 : DETAIL="${L.detail}"  Q=${L.qty}  NET=$${L.price}  ext=$${L.ext}`);
+  console.log(`  $0 stubs     : ${r.stubRecords.length ? r.stubRecords.map(s=>`${s.sku}($${s.dollars})`).join(', ') : '(none)'}`);
+  console.log(`  merch total  : $${r.merch}  invoices=${r.invoiceCount}`);
+  const okSku   = L.detail !== 'Samples' && /^[A-Za-z]+-?\d+/.test(L.detail);
+  const okMoney = Math.abs(L.ext - r.merch) < 0.001;             // all money on the first line
+  const okStubs = r.stubRecords.every(s => s.dollars === 0);      // rest are $0
+  console.log(`  ASSERT: SKU-on-line=${okSku?'PASS':'FAIL'}  money-on-first=${okMoney?'PASS':'FAIL'}  stubs-$0=${okStubs?'PASS':'FAIL'}`);
+  if (!(okSku && okMoney && okStubs)) pass = false;
+}
+console.log(`\n==== SMOKE TEST ${pass ? 'PASS ✅' : 'FAIL ❌'} ====`);
+process.exit(pass ? 0 : 1);

← 0a0ebba invoice(B): real SKU on every line (not 'Samples') + atomic  ·  back to Filemaker Mcp  ·  wallpaper: prefix-agnostic UNIQUE-number mfr fallback so Sho d32c199 →