The employer and broker API routes were never named in the path
classifier, so they fell through to its admin-only default and the
proxy rejected a site manager with a bare {"error":"Not allowed"}
before the route handler ran. The handler's own site scoping was
always correct — it just never got the chance to apply.
- classify /api/employers as dashboard and map it to the workforce
module, mirroring /api/employees
- let the site dropdown be chosen when adding an employer; only a
rename freezes the site, which preserves assignment history
- cover the rename path, which had no route test, and the proxy
gate for the site-manager role
3.2 KiB
Workforce employers and brokers
On Workforce → Workers, open Actions → Manage employers/brokers to see the site-based list. Choose Add new, enter a name, select a permitted site, and save. Names are unique within each site. Editing an employer changes its name; its site stays fixed to preserve assignment history.
Who can manage employers and brokers: admins and site managers alike, but each only for the sites they have access to. A site manager sees and manages their own sites' employers and brokers, and cannot see or rename another site's. A site manager cannot move an employer to another site — the site is fixed on rename, and a new employer is created on the site chosen in the form. Office users with the Workforce module manage employers for the sites they are assigned to.
Worker assignments are read-only in the roster and worker profile. Use Edit to open the editing sheet, choose an employer/broker or Unassigned, set Effective from, and explicitly save. Cancel and closing the sheet discard changes.
The first assignment can be backdated to when the worker started with that employer. Later assignments must start on or after the most recent assignment date. Dates before a worker's first assignment remain unassigned. A same-day correction changes attribution from that date, while retaining the previous revision in assignment history.
Workers and Timesheets have All employers, Unassigned, and named employer filters. On Workers, open Filters to see employer, type, position and inactive-worker controls. Active filters appear as removable labels; Clear all also clears search. CSV and QR badge exports are available under Actions. The timesheet matrix opens with the selected site and employer; preview and CSV/PDF downloads use the employer assigned on each work date. A period spanning a broker change includes only that broker's matching dates. All-employer exports include all workers and hours.
Database setup
Run python3 scripts/pb-add-employers.py using the configured PocketBase credentials. It creates server-only employers and employee_employer_assignments collections, verifies their fields and indexes, and leaves existing workers and timesheets untouched. Re-running verifies the existing schema. Deployment must run this before serving the updated app.
Assignments append immutable revisions. A unique worker/site/revision index rejects competing writes, and an expected latest assignment ID rejects stale editing sheets. All reads and writes respect workforce and site access.
Add a worker
Choose Actions → Add new worker. Enter their full name and unique employee number, choose an allowed site and worker type, and optionally enter a position, hourly rate and employer/broker. The current site is selected automatically. When viewing all sites, choose one explicitly if multiple sites are available. Employer choices follow the selected site.
If assigning an employer, set its effective date. The worker and initial employer assignment save in one transaction. Add worker opens their profile, including their QR badge. New workers start active. Blank hourly rates are stored as zero and can be set later. Cancel and closing the form discard changes.