wages/backend
jtricerolph dd04b50fda Fix two root causes of timesheet figure overcount
1. Weekly fetch step (not per-day): timesheets/on/{date} returns the
   whole weekly period for any date in that week, so fetching 30 days
   counted each weekly timesheet ~7x. Now fetches one date per 7-day
   step from 'to' backwards (PBI pattern), deduplicates by timesheet.id,
   and filters shifts by sh.date to the requested window.

2. Filter by user.report_department_id not shift.department_id: shared
   departments (HR, Management, etc.) have a single location assignment
   (No 4) but staff from all hotels clock into them. Filtering by the
   employee's HOME department (report_department_id) correctly isolates
   No 4 staff. Mirrors the PBI model join: timesheet → user →
   report_department_id → department.location_id → hotel.

Both fixes applied to syncActuals and compareEndpoints diagnostic.
Target: B.cost = WF "Timesheet exc. leave inc. allowances" (~£51k June).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-23 14:11:14 +00:00
..
src Fix two root causes of timesheet figure overcount 2026-07-23 14:11:14 +00:00
Dockerfile Initial scaffold: wages app 2026-07-23 09:03:52 +00:00
package.json Initial scaffold: wages app 2026-07-23 09:03:52 +00:00