Tracing a payslip line¶
Where each total of a run is computed, from the facade to the rule, so a
wrong amount on a payslip leads to its code. Every step below is a
function you can set a breakpoint on; the decisions of the result
(result.decisions) name the rule and the inputs each one used.
The common path of every run¶
api.py:PayrollEngine.calculate_periodchecks the input and opens the decimal context of the call.period/input/services.py:period_requestturns the publicPeriodInputinto the internalPeriodCalculationRequest.period/services.py:calculate_periodruns the pipeline of the run: context, events, amounts, posting, result.period/context/request/services.py:build_contextloads the CCNL, the level and the year rules into theRunContext.period/step/services.py:run_eventsprices the events;run_amountscomputes the amounts of the run.period/step/input/services.py:amounts_inputgathers what the amounts read into_AmountsInput(pay, days, state, facts).period/amount/services.py:_compute_amountscomputes, in order, contributions, TFR, taxable income, IRPEF and surtax.
From there, by total¶
| Total | Function | Rules |
|---|---|---|
| Gross and pay items | period/step/services.py run_events, then the pay items of compensation/ |
CCNL tables of the level (agreement/), seniority (seniority/), extra months (extra_month/) |
| INPS contributions | contribution/services.py run_contributions |
contribution/rules.py, rates of the year in YearRules.inps (tier by headcount in contribution/headcount/rules.py) |
| TFR accrual | contribution/services.py tfr_accrual |
severance/ (divisor, 0.50% IVS deduction, compensation in severance/relief/services.py) |
| Taxable income | irpef/taxable/services.py |
Untaxed amounts in withholding/agent/services.py |
| IRPEF | irpef/services.py withhold_irpef, then irpef/computation/services.py compute_tax |
Brackets (irpef/rules.py), art. 13 deduction (irpef/deduction/rules.py), net IRPEF (irpef/net/rules.py), credits (tax_credit/) |
| Surtaxes | surtax/rules.py run_surtax |
Tables of surtax/stage/rules.py, conguaglio and acconto in surtax/conguaglio/rules.py |
| Net | withholding/cap/services.py run_net |
The ledger entries the posting of period/posting/services.py wrote |
| Employer cost | period/result/services.py assemble_result |
Employer contributions, TFR, funds and INAIL-free employer items of the ledger |
Reading a decision¶
A result carries one CalculationDecision per capability it decided:
capability, rule and rule_version name the rule, inputs the values
it read, reason_code why the amount is what it is. Start from the
decision of the wrong total, then open the rule it names in the table
above.