Status: Source-port architecture reviewed; deployment and financial/security tests remain outstanding. This chapter explains execution boundaries, not a complete tax implementation or operational permission to mutate money records.
Architecture and stores
HTTP controllers enter PayrollService/AdminPayrollsService and related configuration services. C# resolves context, validates input, orchestrates workflow, calls procedure wrappers, handles notifications/audit and reads results. The payroll arithmetic is in tenant T-SQL procedures/functions, not a formula hidden in the C# controller.
| Store |
Payroll role |
| TenantDb, per organisation |
Company-scoped compensation, payrolls/items/changes, dates, approval/recovery evidence, payment schedules, procedures and staging tables. |
| MembershipDb, shared |
Tenant connection resolution, platform reference/provider/integration configuration and error logging. |
| WarehouseDb, shared |
Denormalised analytics/read models populated by synchronisation; delayed reporting is not proof of a failed tenant write. |
JWT/context resolves OrganisationId/CompanyId and the tenant connection. Per-organisation database separation does not replace company/person row checks inside queries and mutations. Multi-currency runs and reports must keep currency scope; cross-currency conversion behaviour is unresolved.
Prepare, preview and submit
- Prepare: POST Admin/Payrolls/Prepare enters the service and ProcedureExecutionContainerRepository → spPreparePayroll/type-specific preparation. The source describes a company monitor, status guard, clearing/rebuilding TempPayrollItems/TempPayrollItemSummaries and reading configuration/eligibility inputs.
- Calculate: resolve the period-applicable grade/history, days, schedule/remittance, confirmation eligibility, allowances, statutory/relief/tax, approved changes, loans/advances, benefit/EWA obligations and reversal/outstanding balances. Roll up one employee’s lines into its summary. Group changes expand to current members.
- Preview reads: Temp endpoint families read staging; live endpoint families read committed records. Reprepare uses spRollbackPayrollPreview and rebuilds the calculation rather than a browser refresh.
- Submit: POST Admin/Payrolls/Submit → dispatcher/type-specific submit procedure. Sources describe live PayrollItems/PayrollItemSummaries, one-off-used flags, snapshots, Submitted status and review context. Approval then leads to a separate payment-schedule process.
Snapshot limits: simplified prose/RFD describes copying Temp to live; the newer catalogue describes submit procedures mirroring calculation with permanent destinations. Verify which inputs are re-read/recomputed at submit and how intervening edits/concurrency are handled. Do not guarantee a byte-identical accepted preview or call Prepare “no writes anywhere”: working columns, Clone mirrors, status/monitor and audit can change even though payroll is not submitted or paid.
Calculation stages worth locating
- Calendar/eligibility: run dates and company next-scheduled tracker; hire/exit/status overlap, exemptions, grade and schedule. Inclusive-period/working-day/fixed-day and part-time paths need boundary tests, especially first-day exit and zero-day denominators.
- Amounts/tax: helpers include fnCalculatePayrollWorkingDays, overlap/suspension functions, fnCalculateProratedAmount, fnCalculateTaxAmount and gross-up/effective-rate functions. Statutory employee deductions and employer contributions are different line/economic types.
- Per-person working state: TA25 Rent processing can mutate temporary grade/allowance/statutory results. The documented restore-to-default phase between people matters; test multi-person isolation, not just one example employee.
- Specialised runs: the newer catalogue explicitly lists spPrepareOnDemandPayroll; older “same SP or dedicated?” notes are stale uncertainty, not evidence that no dedicated processor exists. Off-cycle uses its own prepare/submit/filtering. Confirmation processors exist in the map, but the initiating event/caller and ApplicationPayrollId semantics remain unverified.
- Retros: history/audit, dormant older generic generator, processable historical PFPP, future-grade lookback and newer salary/allowance/compensation retro processors are separate mechanisms. The documented salary-change processor uses history/date functions and materialises differences; its IsRetroPaymentEnabled dispatch conflicts with blanket “flag unused” prose. Inspect deployed caller/version before asserting automatic/manual-only back-pay.
- Recoveries: carry-forward tracks original amounts versus cumulative recovery. EWA can emit zero-deducted evidence for an otherwise excluded employee. Capping priority and original-row update details remain unverified. A reversal-linked deduction must be reconciled with actual money movement before any operational clawback.
Status, approval and locking
The enum is New 1, Cancelled 2, Declined 3, Submitted 4, Approved 5, Processed 6, Processing 7. Numeric order is not chronological. Detailed lifecycle describes Processing during preparation and preview-ready returning to New; an isolated SP outline instead says “3 Prepared”. Preserve the enum and flag the contradiction—do not invent Prepared = 3.