Tutorial: Singapore payroll run
Purpose
Section titled “Purpose”Orient developers on the custom payroll stack (Singapore: CPF, SHG, SDL, etc.) built on ERPNext Payroll Entry, Salary Slip, Employee, Salary Component.
Standard ERPNext objects
Section titled “Standard ERPNext objects”- Payroll Entry — batch run for employees in a period
- Salary Slip — per-employee payslip document
- Salary Component — earnings and deductions
Custom code entry points
Section titled “Custom code entry points”| Layer | Location |
|---|---|
| Hooks registration | leekimerp/hooks.py — doc_events for Salary Slip, Employee, Payroll Entry, Salary Component |
| Calculation scripts | leekimerp/scripts/salary_slip.py, salary_component.py, payroll_entry.py, employee.py |
| Hook methods | leekimerp/hook_methods.py |
Validation chain (conceptual)
Section titled “Validation chain (conceptual)”See the diagram on Payroll & HR — Salary Slip validate runs setup_payment_days → … → calculate_cpf_v2 → … → recalculate_net_pay.
DocType reference
Section titled “DocType reference”- Payroll & HR category — settings DocTypes (
Singapore Payroll Settings,Lee Kim Payroll Settings, etc.)
Related pages
Section titled “Related pages”Verification checklist (Singapore payroll)
Section titled “Verification checklist (Singapore payroll)”Run on staging with anonymized employees where possible.
| Step | Check |
|---|---|
| 1 | Payroll Entry for a small cohort (1–3 employees) with known salary structures. |
| 2 | Open each Salary Slip — verify gross, CPF employee/employer, net pay against spreadsheet expectations. |
| 3 | Confirm SHG/SDL and other components match configured Salary Components for the period. |
| 4 | Submit payroll; verify GL impact (if your process posts journals) matches finance sign-off rules. |
| 5 | Error Log clean during run; scheduler not stalled. |
Edge cases to test periodically
Section titled “Edge cases to test periodically”| Case | Why it matters |
|---|---|
| New hire mid-period | Proration and payment days logic |
| Resigned employee last month | Cessation rules and component stops |
| CPF ceiling | cpf_ow_ceiling and related settings — see payroll-hr DocTypes |
| Retro adjustments | Custom salary lines and validation hooks |
When payroll numbers disagree
Section titled “When payroll numbers disagree”- Compare Salary Slip JSON (export) vs Salary Component breakdown in Desk.
- Step through
scripts/salary_slip.pyvalidation order —validatechain is order-sensitive. - Check hooks on Employee / Salary Structure Assignment for overrides.
- Document outcome in an ADR if business rules change.
Related
Section titled “Related”- Known issues & roadmap — payroll technical debt
- Test evidence & CI