Commit graph

17 commits

Author SHA1 Message Date
c19460ecb3 Fix timesheet sync overwriting future rota dates with empty data
Pull timesheets was writing source='timesheet' rows for future dates
(no clock-in data yet), giving ? / 0.00h and preventing rota sync
from ever healing those dates.

Three-part fix:
- Backend runTimesheetSync: cap end date to today before looping
- Frontend syncTimesheetData: cap end date to today before calling API
- Backend runRotaSync: only skip timesheet-sourced dates that are <= today,
  so any future dates accidentally marked as timesheet are self-healed
  next time rota sync runs

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-23 12:08:36 +00:00
ffefa1914f Scope manual sync buttons to current view dates only
Sync rota and pull timesheets now operate on the 7-day view window rather
than rolling default windows — reduces API calls and allows backdating.
Cron job still uses rolling defaults via runRotaSync()/runTimesheetSync().

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-22 20:08:43 +00:00
9bfd14a082 Add timesheet sync: pull actual hours, daily cron, per-cell source indicators
- fetchTimesheetShifts: hits /api/v2/shifts, subtracts breaks, carries PENDING/APPROVED status
- syncJobs.js: shared runRotaSync/runTimesheetSync logic used by routes and cron
- Rota sync now skips dates already marked source='timesheet'
- POST /api/workforce/sync-timesheets: on-demand pull of last 7 days actual hours
- Daily 6am cron: rota sync then timesheet sync, each logged independently
- upsertWorkforceShifts now writes source per row (workforce or timesheet)
- Frontend: Pull timesheets button alongside Sync rota button
- Clock icon on timesheet cells — amber for PENDING, green for APPROVED
- Both buttons disabled while either sync is in progress

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-22 18:25:02 +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
1a8d8d9a2b Show muted icons on intermediate rota footer rows
vs Booked, with Recurring Tasks, and with Pickup now show ⚠/✓/✗
in muted grey using the same amber thresholds as the final row,
giving a quick visual cue without the coloured emphasis.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-22 13:41:07 +00:00
fee388db4c Fix week navigation using ref to eliminate stale closure entirely
Previous wsArg approach still suffered from useCallback memoisation
interacting with React batching — loadAll could fire with the render-
before-last week start. Switch to weekStartRef (written before every
loadAll call and on every render) so loadAll always reads the live
value regardless of when the memoised function was created.

Also removes unused putWarningThresholds import (added externally).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-22 13:35:34 +00:00
f1ba176195 Debounce date input loads to prevent mid-type API calls
Typing a date manually (e.g. "21") fires onChange on each keystroke,
so "2" would trigger a load for the 2nd before "21" was complete.
Added a 600ms debounce on the week-start and since-date inputs so the
load only fires after the user stops typing.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-22 12:59:26 +00:00
0b63543e1f Fix date selector loading stale week — pass new dates directly to loadAll
`loadAll` captured `weekStart` in a stale closure when called via
`setTimeout`. Selecting a date would show the correct value in the input
but load data for the previously-shown week. Replaced all deferred
`setTimeout(() => loadAll(true), 0)` calls with direct `loadAll(true, newDate)`
calls, passing the updated date as an explicit argument.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-22 12:26:35 +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
e7975db4a3 Show hours to 2 decimal places (0.75h instead of 0.8h)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-02 15:43:40 +00:00
74d8951fe2 Center D/S/A values and header in their column
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-02 15:28:34 +00:00
087553054e Move booking delta ticker above occupied count in Rooms cell
▲/▼ indicators relate to occupied rooms, not D/S/A breakdown,
so move them to the top of the Rooms cell in both CatRows and TotalRows.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-02 15:04:55 +00:00
97e99735ce Summary table: stronger day borders, weekend bg, and WP-accurate tooltips
- 2px left border on Rooms th/td marks each day boundary clearly
- Saturday/Sunday columns get a subtle blue-tinted background
- Occupied number shows pickup-change context + prior week stats on hover
- '+' pickup button shows prior week line (matching original WP plugin logic)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-02 14:44:35 +00:00
31fd73ce1e Summary table: split Rooms and D/S/A into separate columns per day
Match the original WP plugin layout — left cell has occupied count, vac,
and pickup controls; right cell has departs/stays/arrivals stacked
vertically, right-aligned, with delta indicators above them.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-02 14:34:21 +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