← back to Filemaker Mcp
scripts/bump-grs-wq-price.mjs
42 lines
// Raise Retail Price by 20% on the recent WallQuest specialty-grasscloth WALLPAPER
// masters (Series=GRS, vid=WQ, JS Pattern 300001..300078 — today's batch only, NOT the
// legacy GRS backlog). new = round(current * 1.20, 2). Skips records with no numeric price.
// Idempotent guard: writes a marker? No — price bumps are NOT self-idempotent, so this is
// deliberately scoped + dry-run-by-default. Run it ONCE with --apply.
//
// node bump-grs-wq-price.mjs # DRY-RUN (prints old -> new)
// node bump-grs-wq-price.mjs --apply # commit
import * as fm from '../src/fm-client.js';
const APPLY = process.argv.includes('--apply');
const FACTOR = 1.20;
const DB = 'WALLPAPER';
const LAYOUT = '*List Wallpapers - Full View';
const sleep = ms => new Promise(r => setTimeout(r, ms));
const round2 = n => Math.round((n + Number.EPSILON) * 100) / 100;
async function main() {
const res = await fm.findRecords(DB, LAYOUT,
{ Series: 'GRS', vid: 'WQ', 'JS Pattern': '300001...300078' },
{ limit: 500 });
const recs = res.records || [];
console.log(`Batch: ${recs.length} GRS/WQ records (JS 300001..300078) · +${Math.round((FACTOR-1)*100)}% · ${APPLY ? 'APPLY' : 'DRY-RUN'}\n`);
let ok = 0, skip = 0, fail = 0;
for (const rec of recs) {
const fd = rec.fieldData;
const sku = fd['combo sku'];
const cur = parseFloat(fd['Retail Price']);
if (!isFinite(cur) || cur <= 0) { skip++; console.log(` SKIP ${sku} (no price: "${fd['Retail Price']}")`); continue; }
const next = round2(cur * FACTOR);
if (!APPLY) { if (ok < 80) console.log(` ${sku} ${cur} -> ${next}`); ok++; continue; }
try {
await fm.updateRecord(DB, LAYOUT, rec.recordId, { 'Retail Price': next }, { dryRun: false });
ok++; if (ok % 20 === 0) console.log(` ...updated ${ok}`);
await sleep(120);
} catch (e) { fail++; console.error(` FAIL ${sku}: ${e.fmCode || e.message}`); await sleep(400); }
}
console.log(`\n${APPLY ? 'Updated' : 'Planned'}=${ok} skippedNoPrice=${skip} fail=${fail}`);
}
main().catch(e => { console.error(e); process.exit(1); });