Panly API docsstaging

Screens / Payroll

Payroll

Needs `payroll.manage` (the owner's; PAN-65, PAN-70, PAN-72, PAN-76, PAN-80, PAN-83). Tabs: Shifts, Pay runs, Employees, and on desktop Settings. Shifts: one week at a time (Monday to Sunday, no future weeks) with active employees plus inactive ones who have shifts that week, hours and estimated pay for hourly staff; open shifts show Open with End shift, and a week covered by a paid run reads as paid with View run. Log shift and the edit sheet check future times, a paid day and an overlap with that employee's shifts before saving. A shift with locked_reason payroll shows a lock and offers no edit or delete. Employees: Add employee and Edit (PAN-76: name, pay type and rate, role, dates), and Deactivate after a confirm. Pay runs: newest first. New pay run (Last week, This week, This month or custom dates; refused in the app when a run already covers part of the dates) shows the estimate the server returns from POST /v1/payroll-runs/preview and the open_shifts_count (PAN-80, PAN-83); the run is created with period_start, period_end and an optional frequency. A draft run can be deleted (PAN-72) after a confirm. Run detail lists each employee's hours, days worked, gross, deductions and net. Mark paid asks for Paid on (today by default, never in the future, not before the period starts) and adds the payroll expense. The payroll settings (salary proration, work days, standard hours per day, frequency) have their own page at /payroll/settings on a phone.

App routes
/payroll
Access
payroll.manage
Screen code
lib/screens/payroll/payroll_page.dart
lib/screens/payroll/payroll_controller.dart
lib/screens/payroll/payroll_bindings.dart
lib/screens/payroll/payroll_copy.dart
lib/screens/payroll/payroll_drafts.dart
lib/screens/payroll/widgets/shifts_table.dart
lib/screens/payroll/widgets/employee_shifts_card.dart
lib/screens/payroll/widgets/edit_shift_sheet.dart
lib/screens/payroll/widgets/delete_shift_dialog.dart
lib/screens/payroll/widgets/paid_week_banner.dart
lib/screens/payroll/widgets/runs_list.dart
lib/screens/payroll/widgets/run_detail.dart
lib/screens/payroll/widgets/new_run_sheet.dart
lib/screens/payroll/widgets/mark_paid_sheet.dart
lib/screens/payroll/widgets/employees_list.dart
lib/domain/payroll/payroll_rules.dart
lib/domain/payroll/payroll_models.dart
lib/data/repositories/payroll_repository.dart
lib/core/navigation/nav_catalog.dart
lib/screens/payroll/widgets/employee_sheet.dart
lib/screens/payroll/widgets/deactivate_employee_dialog.dart
lib/screens/payroll/widgets/delete_run_dialog.dart
lib/screens/payroll/widgets/payroll_settings_form.dart
lib/screens/payroll/widgets/log_shift_page.dart
Source
elmermj/panly-app @ pre-staging-test (72aaffd)

API calls (15)

CallWhy the screen makes itWhere in the app code
GET /v1/employees
List employees
Every page (limit 100) on open, pull-to-refresh, Retry and coming back to the tab: name, pay type, rate, is_active, hired_on and role lib/screens/payroll/payroll_controller.dart:160
lib/domain/usecases/payroll/payroll_usecase.dart:13
lib/data/repositories/payroll_repository.dart:17
lib/data/repositories/payroll_repository.dart:134
POST /v1/employees
Create employee
Add employee (PAN-76). Not idempotent: never retried by the app itself lib/screens/payroll/payroll_controller.dart:406
lib/domain/usecases/payroll/payroll_usecase.dart:15
lib/data/repositories/payroll_repository.dart:23
PATCH /v1/employees/{employeeId}
Update employee
Edit employee, and Deactivate or Reactivate (is_active): the pay fields always, role, dates and is_active only when they changed lib/screens/payroll/payroll_controller.dart:407
lib/screens/payroll/payroll_controller.dart:429
lib/domain/usecases/payroll/payroll_usecase.dart:19
lib/data/repositories/payroll_repository.dart:29
GET /v1/employees/{employeeId}/shifts
List shifts of an employee
Shifts tab: every employee's shifts for the week (from, to), in parallel, reading locked_reason. Also, when Mark paid is refused because of open shifts, the run's employees' shifts are read to list the ones still open lib/screens/payroll/payroll_controller.dart:184
lib/screens/payroll/payroll_controller.dart:579
lib/domain/usecases/payroll/payroll_usecase.dart:24
lib/data/repositories/payroll_repository.dart:36
POST /v1/employees/{employeeId}/shifts
Start/record a shift
Log shift: started_at, plus ended_at unless the shift is still open. Sent once, never retried by itself
409 shift_overlap and shift_locked show the app's own text (payroll_copy.dart:18); a 422 on employee_id or ended_at names that problem.
lib/screens/payroll/widgets/log_shift_page.dart:155
lib/screens/payroll/payroll_controller.dart:337
lib/domain/usecases/payroll/payroll_usecase.dart:27
lib/data/repositories/payroll_repository.dart:46
PATCH /v1/shifts/{shiftId}
Edit or end a shift
Edit shift or End shift: only the changed started_at and ended_at (End shift prefills ended_at with now); nothing is sent when nothing changed
Not offered for a locked shift (locked_reason payroll, payroll_controller.dart:195). 409 shift_overlap and shift_locked show the app's own text.
lib/screens/payroll/widgets/edit_shift_sheet.dart:105
lib/screens/payroll/payroll_controller.dart:361
lib/domain/usecases/payroll/payroll_usecase.dart:30
lib/data/repositories/payroll_repository.dart:53
DELETE /v1/shifts/{shiftId}
Delete a shift
Delete shift from the edit sheet, after a confirm dialog; the week reloads
Not offered for a locked shift. 409 shift_locked shows "These hours are in a paid pay run, so they can't be changed."
lib/screens/payroll/payroll_page.dart:367
lib/screens/payroll/payroll_controller.dart:380
lib/domain/usecases/payroll/payroll_usecase.dart:35
lib/data/repositories/payroll_repository.dart:58
GET /v1/payroll-runs
List payroll runs
Every page: the Pay runs tab (newest first), the paid-week banner, the paid-day check before saving a shift and the overlap check in New pay run lib/screens/payroll/payroll_controller.dart:205
lib/domain/usecases/payroll/payroll_usecase.dart:40
lib/data/repositories/payroll_repository.dart:62
lib/data/repositories/payroll_repository.dart:134
POST /v1/payroll-runs
Create draft payroll run
New pay run: period_start and period_end, plus frequency only when the sheet overrides the business setting; the new draft opens
409 payroll_period_overlap shows "There's already a pay run for part of these dates." The app reads hours_worked, gross_pay, deductions and net_pay per entry.
lib/screens/payroll/widgets/new_run_sheet.dart:199
lib/screens/payroll/payroll_controller.dart:507
lib/domain/usecases/payroll/payroll_usecase.dart:44
lib/data/repositories/payroll_repository.dart:78
POST /v1/payroll-runs/preview
Preview a payroll run (no writes)
New pay run: what a run for the chosen dates would contain (per-employee hours, gross, deductions, net and open_shifts_count). Owner only, writes nothing; asked again when the dates or frequency change and a stale answer is dropped
409 payroll_period_overlap and the 422s are the same as on create; the figures stay empty and the error shows on the sheet.
lib/screens/payroll/widgets/new_run_sheet.dart:23
lib/screens/payroll/payroll_controller.dart:492
lib/domain/usecases/payroll/payroll_usecase.dart:48
lib/data/repositories/payroll_repository.dart:90
POST /v1/payroll-runs/{payrollRunId}/pay
Pay run: creates one Manpower (opex) expense
Mark paid: paid_on from the sheet, with an Idempotency-Key made when the sheet opens and reused on every try. The run in the answer replaces the one shown (paying can recalculate it), then the runs and the week reload so the locks show
409 conflict (already paid) reads the run again and counts as success.
lib/screens/payroll/widgets/mark_paid_sheet.dart:158
lib/screens/payroll/payroll_controller.dart:539
lib/domain/usecases/payroll/payroll_usecase.dart:70
lib/data/repositories/payroll_repository.dart:77
GET /v1/payroll-runs/{payrollRunId}
Get payroll run with entries
Read the run again after Mark paid answered 409 conflict, or when the pay answer had no run in it lib/screens/payroll/payroll_controller.dart:554
lib/domain/usecases/payroll/payroll_usecase.dart:42
lib/data/repositories/payroll_repository.dart:127
lib/data/repositories/payroll_repository.dart:70
DELETE /v1/payroll-runs/{payrollRunId}
Delete draft payroll run
Delete a draft run (PAN-72) from the run detail, after the confirm dialog; the runs reload
409 payroll_run_paid: the run is read again (it is paid now) and the app says so.
lib/screens/payroll/payroll_page.dart:342
lib/screens/payroll/payroll_controller.dart:602
lib/domain/usecases/payroll/payroll_usecase.dart:52
lib/data/repositories/payroll_repository.dart:100
GET /v1/payroll-settings
Get payroll settings
On open (owner): the settings the sheets and the work-days label use (salary proration, work days, standard hours, frequency, next period suggestion). A failure keeps the last settings and the sheets fall back to the defaults lib/screens/payroll/payroll_controller.dart:107
lib/domain/usecases/payroll/payroll_usecase.dart:59
lib/data/repositories/payroll_repository.dart:104
PATCH /v1/payroll-settings
Update payroll settings
Save the Settings tab (desktop): only the changed fields, never empty lib/screens/payroll/widgets/payroll_settings_form.dart:93
lib/screens/payroll/payroll_controller.dart:139
lib/domain/usecases/payroll/payroll_usecase.dart:61
lib/data/repositories/payroll_repository.dart:112

Each call links to its operation in the API reference. Code locations are file:line in panly-app at 72aaffd, listed from the screen down to the line that sends the request.