Audience: on-call engineers, Ops, and senior Support handling Payroll incidents. Symptom → diagnosis → fix. Assumes access to the tenant's SQL Server and the app logs.

Companion: technical.md (mechanics), how-to.md (product steps), api-reference.md (endpoints).

⚠️ Safety: Payroll writes real money movement. Any direct SQL below runs against a tenant DB — confirm you are on the correct (OrganisationId, CompanyId) connection first. Prefer app endpoints over raw SQL where one exists. Take a backup/snapshot before mutating.


Return codes cheat-sheet

Payroll SPs return an int (surfaced by C# as an ApiResponseModel):

Code Meaning First move
> 0 Success (row id / affected count) —
0 No-op Check inputs; likely nothing eligible
-2 Payroll runner busy (PayrollMonitor.IsBusy = 1) See §1 Stuck run
-3 No eligible employees for this payroll See §2
-4 and below SP-specific error Read the SP + logs for that code

1. Run stuck / "Payroll runner is currently busy"

Symptom: Prepare/Submit returns -2; the UI says the runner is busy; a run sits in Processing and never advances.

Diagnosis: PayrollMonitor is a per-company lock. spPrepareRegularPayroll / spSubmitRegularPayroll set IsBusy = 1 at the top and back to 0 at the end. If the SP errored mid-run (e.g. a data issue on person 3000 of 5000 — the whole prep is one transaction and rolls back), it can leave the monitor stuck at 1 forever.

-- Is it actually stuck? UpdatedDate should be < a few minutes old in normal operation.
SELECT Id, IsBusy, LastObjectId, Details, Message, UpdatedDate
FROM PayrollMonitors;

Fix (once you've confirmed no prep is genuinely running):

UPDATE PayrollMonitors SET IsBusy = 0, Message = NULL, UpdatedDate = GETDATE();

Then re-Prepare. ⚠️ VERIFY whether a watchdog auto-resets stuck monitors — if one exists, prefer waiting for it. Never reset while a legitimate large-company prep is mid-flight.

Prevent: watch PayrollMonitor.UpdatedDate age in observability; alert if IsBusy = 1 for > N minutes.


2. Run produces no employees (-3)

Symptom: Prepare returns -3 "no eligible employees".

Check, in order: