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

  1. 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.
  2. 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.
  3. 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.
  4. 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

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.