<aside> 📋
Copied from Payroll — technical / engineering documentation. Relevant source sections are reproduced below; the original remains unchanged. Source qualifications and verification notes still apply. Screenshots and attachments remain available in the original page.
</aside>
The repository now includes Stored procedures (index + full SQL dumps) — a full dump of 398 stored procedures with their CREATE PROCEDURE text. This resolves most of the ⚠️ VERIFY items elsewhere in this doc that were previously inferred. This section is a navigation aid: find the SP, jump to its body.
| SP | Lines | Body location | Purpose |
|---|---|---|---|
spPrepareRegularPayroll |
10,444 | line 33569 | Regular payroll preview run. The single biggest piece of code in the system. See §6c for its internal phases. |
spSubmitRegularPayroll |
10,453 | line 97207 | Commit a prepared regular payroll. Mirrors spPrepareRegularPayroll structurally but writes to permanent tables (PayrollItems instead of TempPayrollItems). |
spPrepareOffcyclePayroll |
6,671 | line 25020 | Off-cycle (mid-month bonus, project payment) preview. |
spPrepareOnDemandPayroll |
1,836 | line 31691 | On-demand allowance disbursement (e.g. data allowance for everyone in a department). |
spPreparePayroll |
42 | line 33527 | Master dispatcher — routes to the type-specific Prepare SP based on PayrollTypeId. |
spSubmitPayroll |
42 | line 97165 | Master dispatcher — routes to type-specific Submit SP. |
spRollbackPayrollPreview |
(small) | line 69083 | Wipes TempPayrollItems • TempPayrollItemSummaries for a payroll. Called when an admin re-prepares after edits. |
| SP | Lines | Body location | Purpose |
|---|---|---|---|
spProcessSalaryChangeRetros |
1,156 | line 53573 | The cursor-driven retro algorithm. Walks every month from CompensationEffectiveDate to today, finds the active paygrade for each month from EmployeePaygradeHistories, computes the difference between historical pay and current pay, materialises into #tmpPersonRetroAndSalaryChangePayments. See §19 deep dive. |
spProcessCompensationChangeRetros |
1,175 | line 44988 | Sibling retro path for one-off compensation changes. |
spProcessAllowanceChangeRetros |
975 | line 44013 | Retro for allowance-only changes (vs full paygrade swap). |
spProcessConfirmationRetros |
⚠️ check | grep | Retros triggered by employee confirmation (post-probation). |
| SP | Lines | Body location | Purpose |
|---|---|---|---|
spProcessMonthlyAllowances |
(medium) | grep | Monthly recurring allowance computation for IsAmortized = 1 allowances. |
spProcessLeaveAllowanceInLieu |
(medium) | grep | Pays out unused leave entitlement as a cash allowance (typical for end-of-year balances). |
spProcessRentalAndHosAllowance |
(medium) | grep | Rental + house-owner subsidy allowance processing. |
spProcessRetirementAllowances |
(medium) | grep | Retirement-year allowances (final-month gratuity, etc.). |
spApplyRentReliefToPaygradeRR |
(medium) | line 1009 | TA25-specific. Recomputes paygrade gross + effective tax rate + allowance/statutory amounts when an employee has a Rent record (TA25 introduced rent as a tax-deductible item for PAYE). Returns three result sets (paygrade / allowances / statutory benefits). |
| SP | Lines | Body location | Purpose |
|---|---|---|---|
spProcessPaymentInLieuOfNotice |
203 | line 51084 | Computes the per-paygrade statutory-benefit / allowance / tax breakdown when a PILON PayrollChange is being processed. Calls helpers below. |
spGetPilonPaygradeStatutoryBenefitDeductionAmountFromPaygradeStatutoryBenefitId |
(small) | grep | Helper: per-stat-benefit deduction amount. |
spGetPilonPaygradeStatutoryBenefitContributionAmountFromPaygradeStatutoryBenefitId |
(small) | grep | Helper: per-stat-benefit employer contribution. |
spGetPilonTaxableAmountFromPaygradeIdAndAmount |
(small) | grep | Helper: taxable PILON amount calculation. |
spGetPilonTaxAmountFromPaygradeIdAndTaxableAmount |
(small) | grep | Helper: PILON tax from taxable amount, with rent relief plumbed in. |
fnGetPilonPaygradeAllowanceAmountFromPercentage |
(small) | function | Helper: scales a percentage allowance to PILON amount. |
spProcessPaymentFromPastPayroll |
203 | line 50881 | Sibling: process a "back-pay" PayrollChange that points at a past payroll cycle (the "Payment from past payroll" path). |
spReviewEmployeeRequest)| SP | Lines | Body location | Purpose |
|---|---|---|---|
spProcessEmployeeExit |
(small) | line 47818 | Final-state exit processing — typically called by scheduler when an approved future-dated exit reaches its effective date. |
spProcessEmployeeRedeployment |
(small) | line 47888 | Same for future-dated redeployments. |
spProcessEmployeeSuspension |
(small) | line 47981 | Same for suspensions. |
spProcessEmployeeViolationTrigger |
(small) | grep | Process violation-policy-triggered actions (e.g. auto-deduct on N infractions). |
| SP | Lines | Body location | Purpose |
|---|---|---|---|
spReviewPayroll |
202 | line 68155 | Approve/decline a Payroll. Status transitions for PayrollStatusId. |
spReviewPayrollChange |
191 | line 68357 | Approve/decline a PayrollChange. |
spReviewPaymentSchedule |
(small) | line 67969 | Approve/decline a PaymentSchedule. |
spReviewEmployeeRequest |
966 | line 66193 | Documented in ‣. |
ReviewStepsCount, NextReviewEntityId, WorkflowStepsCount columns on EmployeeRequests, Payrolls, PayrollChanges, EmployeeAbsences, etc. is invisible to this dump. Same for any triggers on AspNetUserRoles, Persons, etc.fnGetRetroDatesBetween, fnGetMonthsTillDecember, fnGetMonthRange, fnGetMatchingPaygradeIdFromEmployeePaygradeHistory, fnGetLastDayOfMonth, fnGetWorkedDaysTillEndOfMonth are referenced from spProcessSalaryChangeRetros but their bodies are not in the dump. They are inline-table or scalar functions deployed alongside the SPs.fnCalculateTaxAmount, fnCalculateGrossFromNetAmount, fnCalculateGrossFromNetAndTaxAmount, fnCalculateEffectiveTaxRate, fnCalculateProratedAmount — still external. These are the most-asked-for pieces. ⚠️ Engineering must dump these into a sibling file (pade_tax_functions.md).
⚠️ Action item: extend the catalog dump to include INFORMATION_SCHEMA.ROUTINES for all function types (not just procedures) plus all triggers, and refresh quarterly. The current dump is procedures-only.