date params
This commit is contained in:
@@ -15,8 +15,12 @@ const { pool } = require('./src/config/database');
|
|||||||
|
|
||||||
const DRY_RUN = process.argv.includes('--dry-run');
|
const DRY_RUN = process.argv.includes('--dry-run');
|
||||||
|
|
||||||
const START_DATE = '2025-01-01';
|
function argVal(flag) {
|
||||||
const END_DATE = '2025-12-31';
|
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;
|
const PAGE_SIZE = 500;
|
||||||
|
|
||||||
// ─── Helpers ──────────────────────────────────────────────────────────
|
// ─── Helpers ──────────────────────────────────────────────────────────
|
||||||
@@ -62,7 +66,9 @@ async function queryAll(entity, where) {
|
|||||||
// ─── Main ─────────────────────────────────────────────────────────────
|
// ─── Main ─────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
(async () => {
|
(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)
|
// 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');
|
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 ──
|
// ── 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(`Total QBO invoices queried: ${qboInvoices.length}`);
|
||||||
console.log(`Imported: ${stats.imported} (${stats.lineItems} line items)`);
|
console.log(`Imported: ${stats.imported} (${stats.lineItems} line items)`);
|
||||||
console.log(`Skipped (duplicate): ${stats.skippedDuplicate}`);
|
console.log(`Skipped (duplicate): ${stats.skippedDuplicate}`);
|
||||||
|
|||||||
Reference in New Issue
Block a user