← back to Filemaker Mcp

scripts/probe-line2.mjs

28 lines

// Probe: what does "line 2 used" contain on real invoices that have a line 2?
import { readFileSync } from 'node:fs';
import { fileURLToPath } from 'node:url';
import { dirname, join } from 'node:path';
const __dir = dirname(fileURLToPath(import.meta.url));
for (const line of readFileSync(join(__dir, '..', '.env'), 'utf8').split('\n')) {
  const m = line.match(/^([A-Z_]+)=(.*)$/);
  if (m && !process.env[m[1]]) process.env[m[1]] = m[2];
}
const fm = await import('../src/fm-client.js');

const { records } = await fm.findRecords('invoice', 'Order Detail', { 'DETAIL 1(2)': '*', 'Invoice': '>=100000' }, { limit: 5, sort: [{ fieldName: 'Invoice', sortOrder: 'descend' }] });
console.log('matches:', records.length);
for (const r of records) {
  const f = r.fieldData;
  console.log(JSON.stringify({
    Invoice: f['Invoice'],
    'line 2 used': f['line 2 used'],
    'Q1(2)': f['Q1(2)'], 'DETAIL 1(2)': f['DETAIL 1(2)'], 'NET 1(2)': f['NET 1(2)'], 'TOTAL 1(2)': f['TOTAL 1(2)'],
    'MERCHANDISE TOTAL': f['MERCHANDISE TOTAL(1)'] ?? f['MERCHANDISE TOTAL'],
    'merch tot2': f['merch tot2'],
    'SALES TAX YN(1)': f['SALES TAX YN(1)'],
    'NET DUE 2': f['NET DUE 2'],
    'PAID ON ACCOUNT': f['PAID ON ACCOUNT'],
    'SHIPPING  HANDLING': f['SHIPPING  HANDLING'],
  }, null, 1));
}