← back to Filemaker Mcp
scripts/post-mtd-correction.mjs
28 lines
// One-shot: post the July 2026 MTD correction to Slack #new-order.
// The 4:30 report on 2026-07-28 undercounted MTD (query-window bug, now fixed
// in sales-summary.mjs). This re-states the corrected figure in-channel.
// node scripts/post-mtd-correction.mjs
import { loadEnv } from '../lib/fm-script-helpers.js';
loadEnv(import.meta.url);
const token = process.env.SLACK_BOT_TOKEN;
const CHANNEL = process.env.SALES_SUMMARY_CHANNEL || 'C06D9C2PG1K'; // #new-order
if (!token) throw new Error('SLACK_BOT_TOKEN not set.');
const text =
'*🔧 Correction — Month-to-date (July 2026)*\n\n' +
'The earlier 4:30 summary undercounted month-to-date due to a query-window bug ' +
'(it summed only the trailing 10 days, dropping Jul 1–17). Corrected figures:\n\n' +
'📈 *Month-to-date — booked (July 2026):* ~80 orders · $26,526.23~ → *250 orders · $67,373.33*\n\n' +
'_Bug fixed; tomorrow’s automatic 4:30 report will be correct. Last-24h and quote figures were unaffected._';
const res = await fetch('https://slack.com/api/chat.postMessage', {
method: 'POST',
headers: { Authorization: `Bearer ${token}`, 'Content-Type': 'application/json; charset=utf-8' },
body: JSON.stringify({ channel: CHANNEL, text, unfurl_links: false }),
});
const j = await res.json();
if (!j.ok) throw new Error(`Slack post failed: ${j.error}`);
console.log(`✓ Correction posted to ${CHANNEL} (ts ${j.ts})`);