Commit graph

11 commits

Author SHA1 Message Date
69720b778a Fix workforce sync: split 35-day window into 7-day API chunks
Workforce schedules API enforces a hard 7-day limit per request.
Split the rolling window into up to 5 weekly chunks, fetch each
sequentially, then merge by staff id before pivoting to per-date rows.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-22 14:22:32 +00:00
18e24efbeb Add sync error logging, extend error flash, fix unload saves
- Log workforce sync errors to backend stdout so they appear in docker logs
- Extend error flash from 5s to 15s so errors are readable
- Replace sendBeacon (POST-only) with keepalive fetch (PUT) on unload —
  sendBeacon was hitting 404s on all three unload saves

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-22 14:19:38 +00:00
c7066521ff Rework workforce sync to per-date storage with rolling window
Replaces the single workforce_rota config snapshot (which was overwritten
on each sync, losing data when switching weeks) with a workforce_daily_shifts
table keyed by date. Sync now covers a rolling today-7 to today+28 window
unconditionally — no date params needed. Each date's record carries a
synced_at timestamp so the UI shows the age of the oldest date in view.
Mid-week viewing works naturally since data is stored per date not per week.
source column reserved for future timesheet replacement of past dates.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-22 14:06:56 +00:00
75ac7591d2 Add 5-tier warning thresholds to staff rota footer
Replaces the 2-row (vs Booked / vs with Pickup) footer with a progressive 5-row breakdown:
- Total Available (unchanged)
- vs Booked — plain diff, room cleaning only
- with Recurring Tasks — plain diff, adds recurring tasks
- with Pickup — plain diff, adds pickup hours
- with Adjustments — bold coloured final row with configurable thresholds

New 5-tier icon system: red ⚠ / amber ⚠ / green ✓ / amber ✗ / red ✗, with defaults of
4h / 1h / 1h / 2h spare or short. Thresholds are editable in Settings.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-22 13:38:46 +00:00
1a5de8d3fc Remove break deductions from shift hours — show raw on-site time
The planner needs to know who is available and for how long (scheduling),
not paid hours after payroll deductions. Workforce was returning explicit
break data for some shifts (e.g. a 30-min break on a 12:00–14:00 shift),
causing those hours to display short. Strip all break logic and use raw
start→finish duration.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-21 15:50:33 +00:00
e0b0f2f275 Fix shift hours overcounting automatic breaks + add version-check banner
Workforce's automatic_break_length is a payroll deduction setting, not a
scheduling field — applying it when no explicit breaks are present was silently
shortening all shifts (e.g. a 2h shift showing as 1.5h). Now only deducts
explicit break records from s.breaks. Also adds BUILD_VERSION to /health and
an UpdateBanner that prompts staff to reload when a new deploy lands.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-21 15:30:17 +00:00
e4e6958ff9 Gate planner config write endpoints with requireCap('planner')
Six PUT /api/config/* routes were missing per-route capability checks —
any authenticated hk-planner user could modify staff, time requirements,
pickup data, tasks, adjustments, and last-reviewed regardless of their cap.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-13 09:24:55 +00:00
c0b1d2a62e Move general tasks + time reqs to Settings; add date adjustments
- Rename 'Category Settings' to 'Settings' (nav, page title, component)
- Move Recurring General Tasks and Time Requirements editing to Settings page
- Planner still loads both for calcRequired calculations
- Add date-specific Adjustments section to Planner: per-date +/- hour
  offsets keyed by YYYY-MM-DD (non-recurring); feed into Required Hours total
- Adjustments row shown in Required Hours tfoot when non-zero

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-07 21:11:21 +00:00
b803b01ae1 Add Workforce rota integration to HK Planner
Pulls HK staff shifts from Workforce.com API into the staff rota section.
Rota rows (read-only, WF badge, times+hours per day) appear above manual rows;
manual name inputs get a datalist populated from WF staff. Sync triggered via
button with stale-week detection. Dept selection stored per-app in CategorySettings.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-07 20:47:09 +00:00
135f1f6cf0 Add CalendarClock icon, planner/settings capabilities
- backend/src/auth.js: extract caps from JWT (planner/settings), hasCap/requireCap
- backend/src/routes/config.js: gate categories + test-connection on requireCap('settings')
- frontend/src/types.ts: add caps[] to User, export can() helper
- frontend/src/App.tsx: gate /settings route on can(user, 'settings')
- frontend/src/components/Layout.tsx: gate nav item on can(user, 'settings')

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-02 14:29:58 +00:00
4abae5eda1 Initial commit: HK Planner app
Housekeeping workload and hours planning app — port of the WP hotel
housekeeping hours calculator plugin. 7-day occupancy planner with
Newbook PMS integration, staff rota, time requirements, and pickup tracking.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-02 09:24:14 +00:00