diff --git a/import-invoices-2025.js b/import-invoices-2025.js index a1b7540..d1fdf2b 100644 --- a/import-invoices-2025.js +++ b/import-invoices-2025.js @@ -15,8 +15,12 @@ const { pool } = require('./src/config/database'); const DRY_RUN = process.argv.includes('--dry-run'); -const START_DATE = '2025-01-01'; -const END_DATE = '2025-12-31'; +function argVal(flag) { + const arg = process.argv.find(a => a.startsWith(`--${flag}=`)); + return arg ? arg.split('=')[1] : null; +} +const START_DATE = argVal('start') || '2025-01-01'; +const END_DATE = argVal('end') || '2025-12-31'; const PAGE_SIZE = 500; // ─── Helpers ────────────────────────────────────────────────────────── @@ -62,7 +66,9 @@ async function queryAll(entity, where) { // ─── Main ───────────────────────────────────────────────────────────── (async () => { - console.log(DRY_RUN ? '🔍 DRY RUN — no writes will be made\n' : '📝 LIVE IMPORT — writing to database\n'); + console.log(DRY_RUN + ? `🔍 DRY RUN — ${START_DATE} to ${END_DATE} — no writes will be made\n` + : `📝 LIVE IMPORT — ${START_DATE} to ${END_DATE} — writing to database\n`); // 1. Load customer map (QBO customer ID → local customer ID) const custRes = await pool.query('SELECT id, qbo_id, name FROM customers WHERE qbo_id IS NOT NULL'); @@ -217,7 +223,7 @@ async function queryAll(entity, where) { } // ── Summary ── - console.log(`\n=== IMPORT ${DRY_RUN ? '(DRY RUN)' : ''} SUMMARY ===`); + console.log(`\n=== IMPORT ${DRY_RUN ? '(DRY RUN)' : ''} SUMMARY — ${START_DATE} to ${END_DATE} ===`); console.log(`Total QBO invoices queried: ${qboInvoices.length}`); console.log(`Imported: ${stats.imported} (${stats.lineItems} line items)`); console.log(`Skipped (duplicate): ${stats.skippedDuplicate}`);