Status: Accepted (in force). Reconstructed from implementation.

Context

A payroll run reads from many tables (paygrades, allowances, statutory benefits, tax reliefs, payroll changes, exemptions, absences, exits, requests, reversals) and computes derived amounts for every employee. For large companies that's thousands of employees × dozens of joins per run.

Decision

Do the computation in T-SQL stored procedures and functions inside the tenant database. C# (PayrollService, AdminPayrollsService) only validates input, manages workflow, calls the SP, and reads results back. Procs (spPrepareRegularPayroll, spSubmitRegularPayroll, …) and functions (fnCalculateTaxAmount, fnCalculateProratedAmount, fnCalculateGrossFromNetAmount, …) hold the math.

Consequences

Good:

Bad / costs:

Alternatives considered

Verify