AI Insights: a daily Claude-generated wage cost briefing covering month-to-date pace vs budget, prior-month/prior-year comparison, rota-vs-actual variance by department, a rota-informed forecast to month-end, employee-level anomalies, and wage cost as a % of revenue. Runs on a configurable daily schedule or on demand, gated by a manual 5-minute rate limit and a daily token budget. Uses the Anthropic key configured centrally in Portal → Settings → Integrations. Also includes the rota-vs-repeat-pattern forecast method (published/ draft rota tiers with same-weekday fallback) already built into the Weekly/Monthly views, and adds a .gitignore for node_modules/dist. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
13 lines
563 B
JavaScript
13 lines
563 B
JavaScript
import { getConfig } from '../db.js'
|
|
|
|
export async function fcFetch(path) {
|
|
const apiKey = await getConfig('forecasting_api_key')
|
|
const baseUrl = (await getConfig('forecasting_url')) || 'http://10.10.10.113:3080'
|
|
if (!apiKey) throw new Error('Forecasting API key not configured — add it in Settings')
|
|
const res = await fetch(`${baseUrl}/forecasting/api/public${path}`, {
|
|
headers: { 'X-API-Key': apiKey },
|
|
signal: AbortSignal.timeout(15000),
|
|
})
|
|
if (!res.ok) throw new Error(`Forecasting API ${res.status} — ${path}`)
|
|
return res.json()
|
|
}
|