Commit graph

28 commits

Author SHA1 Message Date
3a068ece23 Add vs Prev column to monthly table; weekly two-row cards + vs PY + vs Prev Wk
Monthly: fetches previous month actuals; adds % delta vs prior month full
alongside existing vs PY column in the dept breakdown table.

Weekly: expanded 14-day actuals fetch (prev+current week) so prior-week
per-dept data is available for both forecast and comparison. Two-row summary
cards for current week (WTD actuals + full-week forecast). Past weeks keep
single-row layout. Dept table gains vs PY and vs Prev Wk delta columns;
budget columns use WTD pro-rata for current week, 7-day proportion for past.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-23 12:59:14 +00:00
27f9190dc5 Add vs PY % delta column to monthly dept breakdown table
Shows (actual_mtd - PY_MTD) / PY_MTD for current month rows,
(actual - PY_full) / PY_full for past months. Red if wages up vs PY,
green if down. Total row uses same basis. Matches department by ID
against pyDepts so departments with no PY data show —.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-23 12:44:17 +00:00
5b243b3ef8 Yesterday cutoff for actuals; two-row monthly summary cards
Both Weekly and Monthly now cut off actuals at yesterday (not today) to avoid
partial clockins and open timesheets skewing the WTD/MTD figures and % net sales.
PY comparison periods also cap at the equivalent yesterday for fair comparison.

Monthly rota forecast removed — all future days use prior-week same-day actuals
from yesterday back, which is more reliable than partially-published future rotas.

Monthly summary cards split into two rows for current month:
  Row 1 (MTD to yesterday): Actual MTD · Budget pro-rata · % Budget MTD · % Net Sales MTD
  Row 2 (Full month):       Forecast EOM · Monthly Budget · % Budget (Forecast) · % Net Sales (OTB)
Net sales fetched for full month so row 2 % net sales uses OTB forecast revenue.
Past months show one row (full month actuals only).

Weekly: budget pro-rata now counts days Monday to yesterday for current week;
dept totals filtered to yesterday for current week.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-23 12:36:42 +00:00
d04cd1e82c Monthly view: rota boundary, EOM PY card, % Budget headline; backfill 25 months
Rota forecasting: only trust Workforce rota for the current Mon–Sun week —
beyond that use prior-week actuals to avoid incomplete next-week rotas
deflating the EOM forecast.

% vs Budget cards (Weekly + Monthly): show as coloured headline number
(green/amber/red) instead of small pct-badge chip, matching other cards.

Forecast EOM: PY sub-label shows full prior-year month total + % delta,
replacing the static "rota + prior-week actual" note once PY data exists.
Achieves this by fetching the full PY month rather than MTD-capped range,
then deriving both MTD (for Actual MTD card) and full-month (for EOM card).

Backfill depth: 13 → 25 months so past months in Rolling 12 have PY wage
data available (viewing Dec 2024 needs Dec 2023 = 19 months ago).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-23 12:08:13 +00:00
a75aceb6e7 Mobile responsive layout — bottom nav + table scroll
- Hide sidebar on mobile (≤640px), show fixed bottom nav bar instead
- Cards get overflow-x: auto so wide tables scroll horizontally
- Summary grid forces 2-column on mobile
- Reduce content padding to 12px, clear 68px for bottom nav
- Summary card values shrink to 18px on mobile

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-23 11:58:14 +00:00
c6166f31d0 Batch net-sales requests in ≤365-day chunks — forecasting API 422s at 396 days 2026-07-23 11:52:05 +00:00
92400dbcec Show budget % as delta (+/-) from 100% across all views 2026-07-23 11:48:38 +00:00
bbc9a23da0 Fix budget CSV import — handle quoted fields, Aug-25 month format, currency symbols 2026-07-23 11:41:12 +00:00
95103280c3 Fix employee name lookup — use name field not first_name/last_name; remove temp logs 2026-07-23 11:33:45 +00:00
6661189127 Fix getUserNameMap location filter; fix detail cost filter to match aggregate 2026-07-23 11:32:28 +00:00
cf0cd0a5e4 Temp: log user fields + shift status cost breakdown 2026-07-23 11:31:03 +00:00
5372111f52 Add per-employee dept breakdown via modal popup
Stores per-employee shift costs in wage_actuals_detail (APPROVED shifts
only). Sync fetches employee name map from /api/v2/users alongside dept
names. Clicking any dept row in Weekly or Monthly opens a modal showing
Employee · Shifts · Cost · % of Dept, fetched on demand.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-23 11:02:11 +00:00
91936ab131 Remove temp shift sample log 2026-07-23 10:57:50 +00:00
21391d4122 Temp: log raw shift sample for field inspection 2026-07-23 10:55:54 +00:00
f9916cc3fd Add collapsed PY dept breakdown table below weekly/monthly tables
Stores full PY department breakdown from already-fetched pyActRes.
A toggle button (collapsed by default) expands an inline table showing
PY wages per dept, % of PY total, and % of PY net sales. Label adapts
to PY WTD / PY MTD for current partial periods.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-23 10:25:04 +00:00
a857eb6177 Add PY(TD) sub-label to % of Net Sales summary card
Shows prior year equivalent % (wages/net sales) as a sub-label under the
current period value — labelled PY WTD/MTD for current partial periods,
PY for complete past periods.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-23 10:16:47 +00:00
44a7caa937 Fair PYTD comparison for current week/month
Weekly: cap pyToStr at elapsed days (not full Mon-Sun), and filter
py_sales to past days only — both give WTD vs WTD. Labels show
'PY WTD' for current week, 'PY' for complete past weeks.

Monthly: pyToStr already capped at same day-of-month; salesTo already
capped at today. Labels now show 'PY MTD' for current month, 'PY' for
complete past months.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-23 10:11:09 +00:00
dc1a14a070 PY wages/sales as sub-labels not separate cards
Show PY value + % change as a subtitle line under the period card,
same pattern as the original PY sales sub-label.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-23 10:06:09 +00:00
1d7cb229e4 Add PY wages/sales cards + dept % of total column
- Weekly/Monthly: PY Wages summary card (fetches equivalent week/month last year)
- Weekly/Monthly: PY Net Sales as its own card (was a sub-label, now prominent)
- Weekly/Monthly: dept table gains '% of Total' column
- Monthly: PY comparison caps at same day-of-month for fair PYTD comparison

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-23 10:01:16 +00:00
605feaab4e Batch scheduled sync in 7-day chunks (API limit is 7 days)
Schedules endpoint has same 7-day limit as shifts. The 14-day forward
window was being fetched in one call — split into two 7-day batches.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-23 09:54:09 +00:00
793e97dbbb Fix week date range off-by-one in BST timezone
toISOString() returns UTC — in BST (UTC+1) dates computed from new Date()
land one day early. Replace with local date components via fmt()/localStr().
Affects Weekly, Monthly, Rolling12Weeks, Rolling12Months.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-23 09:48:46 +00:00
3e1851fa6d Add department budget % allocation
- Budgets page: new dept split section with % inputs, equal-split button, save
- Weekly/Monthly: per-dept budget column using dept pcts from actuals response
- Backend: dept_budget_pcts in ALLOWED_KEYS; actuals returns dept_pcts map;
  budgets route adds GET /dept-config + PUT /dept-pcts endpoints

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-23 09:43:39 +00:00
f97772cb72 Fix Monthly net sales range + chart data; Budgets year nav + CSV upload 2026-07-23 09:25:51 +00:00
4d6e53a1f8 Fix rolling sync: batch actuals in 7-day chunks (API limit 31 days) 2026-07-23 09:18:15 +00:00
46201c6592 Fix Weekly: store week as string to prevent useCallback infinite loop 2026-07-23 09:15:11 +00:00
fc92bcd897 Fix POST without body: only set Content-Type when body present 2026-07-23 09:10:55 +00:00
32318aa63f Fix TS errors: vite/client types + recharts Tooltip formatter signature 2026-07-23 09:07:34 +00:00
2e0592eb90 Initial scaffold: wages app
Full wage cost reporting app — weekly/monthly views, rolling 12-week/12-month
history, budget management, Workforce API sync with SSE backfill, net sales
via forecasting public API, department filter, CSV export.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-23 09:03:52 +00:00