ccnl_engine¶
The package root holds the common path: the facade, the request and plan types, the results the facade returns, the errors and the versions. Every other public name lives in one of the four namespaces: see API reference.
Entry point¶
ccnl_engine.PayrollEngine
¶
Unified entry point for Italian CCNL payroll computation.
Pass explicit repository and policies arguments to inject custom
knowledge and policy data, useful for testing or air-gapped deployments.
Call :meth:bundled to create an engine backed by the package-bundled
data.
The mode sets the payability policy of every result (see
:class:~ccnl_engine.assurance.policies.EngineMode):
"simulation" (the default) reports ruleset readiness, while
"operational" also blocks payment from any ruleset that is not
production. Both modes compute the same amounts.
Example::
from datetime import date
from ccnl_engine import (
Employment, EmployerProfile, Headcount, PayrollEngine,
PayrollRun, PeriodInput,
)
from ccnl_engine.inputs import Permanent
engine = PayrollEngine.bundled()
result = engine.calculate_period(PeriodInput(
run=PayrollRun.regular(2026, 1),
payment_date=date(2026, 1, 28),
employment=Employment(
ccnl_id="metalmeccanico-federmeccanica",
level_code="C3",
contract_type=Permanent(),
),
employer=EmployerProfile(headcount=Headcount(50)),
))
print(result.is_payable, result.period_net)
for ruleset in result.rulesets:
print(ruleset.id, ruleset.readiness)
mode
property
¶
Payability policy of the results of this engine.
bundled(*, mode='simulation')
classmethod
¶
Create an engine backed by the package-bundled knowledge data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mode
|
EngineMode | Mode
|
|
'simulation'
|
Returns:
| Name | Type | Description |
|---|---|---|
A |
PayrollEngine
|
class: |
PayrollEngine
|
policy JSON files. The resolver is loaded once and cached on |
|
PayrollEngine
|
the instance. |
list_contracts(family=None)
¶
Return the contracts of the repository, of family when given.
Returns:
| Type | Description |
|---|---|
tuple[ContractSummary, ...]
|
One summary per CCNL, sorted by |
list_levels(ccnl_id)
¶
Return the levels of one CCNL, each code as Employment takes it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ccnl_id
|
str
|
Slug or CNEL code; an unknown one raises
|
required |
Returns:
| Type | Description |
|---|---|
tuple[LevelSummary, ...]
|
One summary per level, in the order of the CCNL data. |
inspect_ruleset(ccnl_id)
¶
Return the identity, hash, readiness and confidence of a CCNL.
A run of the same CCNL reports the same assurance in
result.rulesets, so a caller can check readiness before
calculating.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ccnl_id
|
str
|
Slug (e.g. |
required |
Returns:
| Type | Description |
|---|---|
RulesetAssurance
|
The assurance of the CCNL ruleset. |
A ccnl_id that matches no CCNL of the repository raises
:class:~ccnl_engine.errors.UnknownCcnlError.
calculate_period(request)
¶
Compute a single payroll run.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
PeriodInput
|
The run, its payment date, the employment, the employer, the facts of the run, the prior-year facts and the opening state. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
The |
PeriodResult
|
class: |
PeriodResult
|
assurance and payability, issues, decisions, amounts, closing |
|
PeriodResult
|
state, pay items, ledger entries and capability report. |
calculate_competence_year(plan)
¶
Compute every run of a competence year, in payment order.
The common case: twelve months and the extra months of the CCNL,
each paid on the plan's payment day or date. The runs paid in the
year settle its conguaglio on the last of them; a run paid in the
next tax year (December paid after 12 January) opens it. See
:func:~ccnl_engine.year.competence.services.calculate_competence_year.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
plan
|
CompetenceYearPlan
|
The year, the employment, the employer, the prior-year facts, the facts per run, an optional calendar override, the payment day and dates, and the opening state. |
required |
Returns:
| Type | Description |
|---|---|
CompetenceYearResult
|
One result per run and the annual totals; |
CompetenceYearResult
|
|
A calendar override that drops or lowers an extra month the CCNL
grants, or does not match its reason, raises
:class:~ccnl_engine.errors.InvalidInputError.
calculate_tax_year(plan)
¶
Compute every payment cashed in a tax year, in payment order.
The payments of the competence years of plan attributed to its
tax year, late payments of an earlier competence year included; the
conguaglio falls on the last one. See
:func:~ccnl_engine.year.tax_year.services.calculate_tax_year.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
plan
|
TaxYearPlan
|
The tax year, its competence years and its opening state. |
required |
Returns:
| Type | Description |
|---|---|
TaxYearResult
|
One result per payment computed, the payments of the year and |
TaxYearResult
|
the conguaglio; |
close_tax_year(closing_state)
staticmethod
¶
Open the next tax year from the closing state of the last run.
See :func:~ccnl_engine.year.tax_year.closing.rules.close_tax_year.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
closing_state
|
PeriodState
|
|
required |
Returns:
| Type | Description |
|---|---|
PeriodState
|
The opening state of the next tax year: a fresh tax year state |
PeriodState
|
and the obligations still running. |
import_opening_balances(balances)
staticmethod
¶
Return the state that opens a run after another provider's totals.
The one way to start from totals the engine did not compute: a mid-year takeover, the INPS base of the worker's other employers of the year, the competence runs of an earlier tax year a late December follows, or recoveries still running. The totals are verified against the payments that produced them.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
balances
|
OpeningBalances
|
The totals, payments and obligations to import. |
required |
Returns:
| Type | Description |
|---|---|
PeriodState
|
The opening state, bound to |
Modes¶
PayrollEngine.bundled(mode=...) sets the payability policy of every result;
both modes compute the same amounts. EngineMode is in
ccnl_engine.inputs.
| Mode | Payable when |
|---|---|
simulation (default) |
No blocker. Ruleset readiness is reported in result.rulesets, not enforced. |
operational |
No blocker, and every ruleset that tracks readiness is production with a verified confidence and a review_due not before the payment date. Otherwise the result carries one ruleset_not_production blocker per such ruleset (detail: the ruleset id), and the amounts stay inspectable. |
An operational engine returns a result with blockers rather than refusing
before the calculation: the amounts, the other blockers and the readiness of
every ruleset remain visible, and a year aggregates its runs as in
simulation. Readiness is tracked for CCNL rulesets only, so today the
operational gate is the CCNL tier; tax, INPS and surtax rulesets report
readiness = None and never raise it. A run whose CCNL has no ruleset
identity fails closed with the detail no_ruleset_tracks_readiness.
Requests and plans¶
calculate_period takes a PeriodInput, calculate_competence_year a
CompetenceYearPlan and calculate_tax_year a TaxYearPlan of competence
years. They group the facts by owner and are validated when built;
import_opening_balances takes the OpeningBalances of another provider:
| Model | Holds |
|---|---|
Employment |
CCNL slug, level, contract type, category, EmploymentPeriod, weekly and full-time WeeklyHours (Decimal, e.g. 37.5), WorkPattern (vertical or mixed part time), SeniorityFact, roles, ContributionHistory (IVS massimale eligibility), sector (None means unknown), PensionFundEnrolment or NoPensionFund (None means unknown) |
EmployerProfile |
Headcount (required, no size is assumed) and activity (None means unknown) |
PriorYearTaxFacts |
prior-year employment income and the regimes waived in writing, read by every substitute-tax regime and the PdR |
CurrentYearTaxFacts |
income of the tax year beyond this employment, the main dwelling excluded, with its date and IncomeEstimateQuality; the Art. 12 family deductions add it to the employment income (None means unknown, a blocker when a dependent is entitled) |
PeriodFacts |
events, contributable hours, region and Belfiore code, family composition, dependent children of one run |
The other facts these types take are in ccnl_engine.inputs,
the work events in ccnl_engine.events.
ccnl_engine.PeriodInput
dataclass
¶
Input of one payroll run.
Attributes:
| Name | Type | Description |
|---|---|---|
run |
PayrollRun
|
The run: its month, year and kind. |
payment_date |
date
|
Date the run is paid. Selects the tax year
(:class: |
employment |
Employment
|
Contract, level and worker facts. |
employer |
EmployerProfile
|
The employer. Required: its headcount selects the INPS rate tier. |
facts |
PeriodFacts
|
Facts of the run. Defaults to a run with no event and no surtax jurisdiction. |
prior_year |
PriorYearTaxFacts
|
Prior-year income and waivers. Defaults to unknown income and no waiver. |
current_year |
CurrentYearTaxFacts | None
|
Income of the tax year beyond this employment, which
the family deductions add to the employment income of the year
to get the reddito complessivo, and the INPS base of the other
employments of the year. |
opening_state |
PeriodState
|
State entering the run, with the history of the
employment. The default
:meth: |
planned_payments |
tuple[PaymentId, ...] | None
|
Payments of the same tax year still planned after
this one, in payment order, when they differ from the CCNL
standard calendar. |
Raises:
| Type | Description |
|---|---|
InvalidInputError
|
When a field is not of its type, a regular run
falls outside the employment, the payment precedes the run month,
or |
calculation_request(*, extra_month_accrual=None, extra_month_settlements=None, withholding_schedule=None, uncovered_runs=())
¶
Map this input to the request of the period calculation.
The only mapping from the public input to the internal request, used by both the single-run and the year calculation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
extra_month_accrual
|
ExtraMonthAccrual | None
|
Rateo of an extra-month run, supplied by the year calculation. |
None
|
extra_month_settlements
|
tuple[ExtraMonthAccrual, ...] | None
|
Ratei liquidated on this run because the
employment ends before their payment month, supplied by the
year calculation. |
None
|
withholding_schedule
|
WithholdingSchedule | None
|
Withholding slots of the tax year.
|
None
|
uncovered_runs
|
tuple[PayrollRunId, ...]
|
Runs of the year the year calculation left out because the bundle holds no pay rules on their date. |
()
|
Returns:
| Type | Description |
|---|---|
PeriodCalculationRequest
|
The validated request. |
ccnl_engine.PeriodFacts
dataclass
¶
Facts that hold in one payroll run.
Attributes:
| Name | Type | Description |
|---|---|---|
contributable_hours |
ContributableHours | None
|
Hours worked and paid in the run that are subject to INPS contributions. Required for domestic CCNLs. |
ordinary_hours_worked |
ContributableHours | None
|
Ordinary hours actually worked in the month,
sickness, ferie, permits, festività and other paid absences
left out: the hours a CCNL with |
commission_average |
Decimal | None
|
On a tredicesima or quattordicesima run of a
level paid by commission, the monthly average of the
commissions of the twelve months before (Commercio protocollo
operatori di vendita art. 15); the engine pays its twelfths
with those of the fixed part. |
commission_fixed_part |
Decimal | None
|
Monthly fixed part, full time, agreed in
writing with a worker paid by commission (Commercio art. 217);
it replaces the paga base of the level, and a regular run tops
it and the commissions of the month up to the CCNL minimum.
|
hourly_pay_elements |
Decimal | None
|
Sum of additional hourly remuneration elements
applicable to contractual hourly pay, excluding monthly elements
already in monthly pay. |
paid_holiday_days |
PaidHolidayDays | None
|
Caller-stated eligible holidays in this run, distinct
from hours worked; |
presence_days |
int | None
|
Days actually present at work in this month; |
site_presence_days |
int | None
|
Of those days, days actually present at the
contractual work site; |
events |
tuple[WorkEvent, ...]
|
Variable work events of the run (overtime, absences,
bonuses, supplements), each one of the
:data: |
regione |
str | None
|
ISO 3166-2:IT region code for the regional surtax, e.g.
|
comune_belfiore |
str | None
|
Belfiore code for the municipal surtax, e.g.
|
meal_benefit_days |
int | None
|
Days verified as eligible for an electronic
contractual meal voucher (including the employer's canteen and
shift conditions). |
family_composition |
FamilyComposition | None
|
Dependents for the Art. 12 TUIR deductions.
|
Raises:
| Type | Description |
|---|---|
InvalidInputError
|
When a field is not of its type, an event is not a work event, or a surtax code is malformed. |
ccnl_engine.PayrollRun
dataclass
¶
Identity and classification of one payroll computation.
Attributes:
| Name | Type | Description |
|---|---|---|
run_kind |
RunKind
|
Classification of the run type:
|
month |
int
|
Calendar month (1-12) of the run. |
year |
int
|
Year of the run month. The tax year follows from the payment
date (:class: |
sequence |
int
|
Number of the run among the runs of its kind and month,
from 1. Above 1 only for a second or later adjustment run of
the month (:meth: |
run_id |
str
|
Unique, deterministic identifier derived from year, month,
kind and sequence, e.g. |
identifier
property
¶
Typed identifier of the run; str() of it is :attr:run_id.
of(run_id)
classmethod
¶
Return the run run_id identifies.
Returns:
| Name | Type | Description |
|---|---|---|
A |
PayrollRun
|
class: |
regular(year, month)
classmethod
¶
Create a regular monthly run for the given year and month.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
year
|
int
|
Year of the run month. |
required |
month
|
int
|
Calendar month (1-12). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
A |
PayrollRun
|
class: |
PayrollRun
|
deterministic |
thirteenth(year, payment_month)
classmethod
¶
Create a tredicesima run paid in the given calendar month.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
year
|
int
|
Year of the run month. |
required |
payment_month
|
int
|
Calendar month in which the tredicesima is paid. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
A |
PayrollRun
|
class: |
fourteenth(year, payment_month)
classmethod
¶
Create a quattordicesima run paid in the given calendar month.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
year
|
int
|
Year of the run month. |
required |
payment_month
|
int
|
Calendar month in which the quattordicesima is paid. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
A |
PayrollRun
|
class: |
adjustment(year, month, sequence=1)
classmethod
¶
Create an adjustment run correcting a run of the given month.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
year
|
int
|
Year of the run month. |
required |
month
|
int
|
Calendar month (1-12) of the run corrected. |
required |
sequence
|
int
|
Number of the adjustment within the month: 1 for the first, 2 for a second correction of the same month, and so on. Each closes once. |
1
|
Returns:
| Name | Type | Description |
|---|---|---|
A |
PayrollRun
|
class: |
ccnl_engine.Employment
dataclass
¶
The employment relationship: contract, level and worker facts.
Facts are validated on construction: a wrong type or an impossible
combination raises :class:~ccnl_engine.errors.InvalidInputError.
Attributes:
| Name | Type | Description |
|---|---|---|
ccnl_id |
str
|
CCNL slug or CNEL code; ambiguous or unknown ids raise
:class: |
level_code |
str
|
Contractual level code, e.g. |
contract_type |
Permanent | Apprentice | FixedTerm
|
Permanent, fixed term or apprentice; determines NASpI surcharge and the art. 13 TUIR deduction minimum. |
category |
WorkerCategory | None
|
Worker category, accepting string values. |
employment_period |
EmploymentPeriod | None
|
Start and optional end of the employment. |
level_started_on |
date | None
|
Entry date for time-limited levels (Confetra 6J). |
weekly_hours |
WeeklyHours | None
|
Contracted weekly hours, required for domestic CCNLs (INPS
bracket); below |
full_time_weekly_hours |
WeeklyHours | None
|
Full-time weekly hours, at least |
full_time_week_days |
int | None
|
Working days of the full-time week, 5 or 6; a CCNL
that sets the daily pay by the week (Pulizia art. 34: 22 or 26) uses
it. |
qualifying_shifts |
bool | None
|
Whether the worker is in a rotation of 15 or more
weekly shifts with nights (a day worker: |
rota |
Rota | None
|
Rota of a security guard ( |
work_pattern |
WorkPattern | None
|
Vertical or mixed part time: the hours of each day of the week,
summing to |
weekly_rest_day |
Weekday
|
Day of the week of the weekly rest, Sunday unless stated (L. 370/1934 art. 3); a CCNL that pays a holiday falling on the rest day pays it on this day. A rest day that rotates is not modelled. |
seniority |
SeniorityFact | None
|
Recognised seniority, aged by the engine to each run. |
roles |
frozenset[str] | None
|
Role codes for contractual allowances and legacy holiday clauses
( |
contribution_history |
ContributionHistory | None
|
First enrolment in a mandatory pension scheme and
contributory option, which set whether the IVS massimale applies. |
sector |
EmploymentSector | None
|
Private or public sector of the employment, for the regimes restricted
to one sector. |
pension_fund |
PensionFundEnrolment | NoPensionFund | None
|
Enrolment in a complementary pension fund of the CCNL, or
:class: |
tfr_fund |
TfrFundBalance | None
|
TFR fund at 31 December of the year before the run, the base of the
revaluation at 31 December (art. 2120 c. 4 c.c.). |
tfr_treasury_fund |
bool | None
|
Whether the TFR not paid to a pension fund is paid to the
Fondo Tesoreria INPS (L. 296/2006 art. 1 c. 756): the employer is obliged by
its size and the worker is not excluded (DM 30 gennaio 2007 art. 1 cc. 5-8).
|
holiday_company_offset |
Decimal | None
|
Company holiday compensation already paid for the
eligible former-worker holidays of this month. Zero states no offset;
|
una_tantum_reduced_months |
Decimal | None
|
Full-time months of the period of an una tantum
lost to unpaid absences, part time and agreed reductions of hours; zero
states none, |
prior_extra_month_amount |
Decimal | None
|
Annual extra remuneration month(s) already received
beyond the thirteenth at the contract's entry, excluding merit bonuses,
as a full monthly amount before accrual proration; zero for none,
|
erc_amount |
Decimal | None
|
Annual Elemento di Raccordo Contrattuale of the CCNL grafici
editoriali (renewal of 19 January 2021), frozen in December 2020; zero when
the worker has none. It is paid with the tredicesima, by its months, and
sets the Byblos employer rate (1.4% with one, 1.9% without). |
public_end_of_service |
PublicEndOfService | None
|
End-of-service regime of a public employee (TFS, TFR at
INPS or TFR at the employer), which sets the contributions to INPS Gestione
Dipendenti Pubblici and whether the run accrues the TFR. |
individual_elements |
tuple[IndividualElement, ...]
|
Pay elements agreed with the worker above the CCNL minimum (superminimo, assegno ad personam), each with its own code, as a tuple. |
personal_withholdings |
tuple[PersonalWithholding, ...]
|
Garnishments and salary assignments notified to the
employer, each a :class: |
fund_opt_ins |
frozenset[str] | None
|
Codes of the contractual funds whose optional worker share
the worker pays (Alimentari FASA from 2029; FIA unless waived in
writing); an empty set for none. |
tax_returns |
tuple[Form730Settlement, ...]
|
The 730-4 statements the employer received, which the
payslips settle (:mod: |
contribution_exemption |
ContributionExemption | None
|
The exemption of the employer contributions
(:mod: |
Raises:
| Type | Description |
|---|---|
InvalidInputError
|
When a field is not of its type, a role or fund code
is not a non-blank string, |
check_seniority_in(year, month)
¶
Reject a seniority whose recognised service starts after a month.
The run of the month ages :attr:seniority to it; checking on the
input rejects a seniority that cannot be aged to the first run
before any calculation, with
:class:~ccnl_engine.errors.InvalidInputError.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
year
|
int
|
Year of the competence month of the run. |
required |
month
|
int
|
Competence month of the run, 1-12. |
required |
ccnl_engine.EmployerProfile
dataclass
¶
The employer of the worker being paid.
The only employer model of the payroll pipeline. The INPS classification of the employer follows from the CCNL, unless the CCNL is applied by employers of more than one INPS sector: then the employer states its sector.
Attributes:
| Name | Type | Description |
|---|---|---|
headcount |
Headcount
|
Employer headcount, used to select the INPS contribution tier. Required: no size is assumed. |
activity |
EmployerActivity | None
|
Activity of the employer, for the regimes that exclude
some activities. |
public_life_insurance |
bool | None
|
Whether a public employer enrols its staff in
the Assicurazione Sociale Vita (ex ENPDEP): every "ente dotato di
personalità giuridica di diritto pubblico" except the State, the
Province, the Comuni and the enti di assistenza e beneficenza
(INPS circ. 104/2014). |
fis_reduction |
bool | None
|
Whether an employer of the fondo di integrazione
salariale with on average up to five employees has its rate cut
by 40% for not having applied for the assegno di integrazione
salariale in the last twenty-four months (D.Lgs. 148/2015 art. 29
c. 8-bis). |
cigs_indotto |
bool | None
|
Whether a craft firm with more than fifteen employees
works in the indotto of a firm with the prevailing management
influence, owing the CIGS contribution (D.Lgs. 148/2015 art. 20
c. 1 lett. b, art. 23 c. 1). |
provincial_pay_element |
bool | None
|
Whether a provincial pay element of the CCNL
(a terzo elemento provinciale) is in force where the worker
works, replacing the national element the CCNL pays only in its
absence (Commercio Art. 215). |
second_level_premium |
bool | None
|
Whether the employer has company or
territorial bargaining with economic content (a premio per
obiettivi, di risultato) that replaces the element the CCNL owes
in its absence (Unionalimentari: elemento di garanzia
retributiva; metalmeccanici: elemento perequativo). |
subsector |
str | None
|
Sub-sector of the CCNL the employer belongs to, by the
code its time-supplement bands name (Alimentari art. 31:
|
agricultural_zone |
AgriculturalZone | None
|
Zone of the land of an agricultural employer,
which cuts its INPS contributions by 68% in a zona svantaggiata
and 75% in a zona particolarmente svantaggiata (INPS circ.
43/2026 par. 7). |
inps_sector |
TaxSector | None
|
INPS sector of the classification of the employer (art.
49 L. 88/1989), by the activity it carries out: a CCNL applied
by employers of more than one sector (Logistica: an autotrasporto
firm is industria, a spedizioniere terziario) lists them in
|
sickness_window_counting |
bool
|
Whether the employer counts the comporto over the window its CCNL offers as an alternative (ABI Art. 66 c. 2: the 48 months before the last day of absence) instead of each illness; raises on a CCNL that offers none. |
solidarity_fund_covered |
bool | None
|
Whether this employer is within the scope
of the agreement's solidarity fund. |
contractual_funds |
frozenset[str] | None
|
Codes of the health and bilateral funds of the
CCNL the employer pays ( |
patron_saint_day |
str | None
|
Local patron saint holiday as |
legacy_section_applicable |
bool | None
|
Whether the employer belongs to a legacy
section of the CCNL carried forward from a previous agreement.
|
permit_carryover |
bool | None
|
How the employer settles the permits not taken
within their year, on a CCNL that leaves the choice
( |
flexibility_programme_month |
int | None
|
Month (1-12) the yearly programme of
flexible hours starts (Studi art. 92); |
inail_rate |
Decimal | None
|
The INAIL rate applied to the employer's position, per
mille, from the INAIL basi di calcolo of the year (art. 29 DPR
1124/1965): the run accrues the premium on its contribution
base. |
second_level_rates |
tuple[SecondLevelRate, ...]
|
The supplements of the employer's agreement
(:class: |
Raises:
| Type | Description |
|---|---|
InvalidInputError
|
When |
ccnl_engine.Headcount
dataclass
¶
Employer headcount used to select INPS contribution tiers.
At least one: the worker being paid is an employee of the employer.
Attributes:
| Name | Type | Description |
|---|---|---|
value |
int
|
Number of employees, |
Raises:
| Type | Description |
|---|---|
InvalidInputError
|
When |
ccnl_engine.CompetenceYearPlan
dataclass
¶
The runs of one competence year, their facts and when each is paid.
The runs follow from the calendar and the employment period: the twelve
months and the extra months of :attr:year. Each run takes its
:class:PeriodFacts from :attr:periods and, when it has no entry,
from :attr:default_facts. Each run is paid on :attr:payment_day of
its own month unless :attr:payment_dates says otherwise; the payment
date sets the tax year of the run (TUIR art. 51 c. 1), so December paid
on 13 January of the next year is income of the next tax year.
Attributes:
| Name | Type | Description |
|---|---|---|
year |
int
|
The competence year of the runs. |
employment |
Employment
|
Contract, level and worker facts. |
employer |
EmployerProfile
|
The employer. Required: its headcount selects the INPS rate tier. |
prior_year |
PriorYearTaxFacts
|
Prior-year income and waivers. Defaults to unknown income and no waiver. |
current_year |
CurrentYearTaxFacts | None
|
Income beyond this employment of the tax year of the
runs, read by the family deductions; runs paid in another tax
year ignore it. Its INPS base of other employments counts
toward the massimale of the runs of the same competence year.
|
periods |
RunKeyed[PeriodFacts]
|
Facts per run, keyed by run id ( |
default_facts |
PeriodFacts
|
Facts of every run without an entry in
:attr: |
calendar_override |
CalendarOverride | None
|
A calendar that replaces the CCNL standard one,
with its reason. |
payment_day |
int
|
Day of the run month on which a run is paid, 1-28,
unless :attr: |
payment_dates |
RunKeyed[date]
|
Payment date per run, keyed like :attr: |
employment_changes |
tuple[EmploymentChange, ...]
|
Changes of level, weekly hours or category
during :attr: |
opening_state |
PeriodState | None
|
State the first run opens with, read by
|
Raises:
| Type | Description |
|---|---|
InvalidInputError
|
When a field is not of its type, a key of
:attr: |
facts_by_run
property
¶
Entries of :attr:periods keyed by run id, e.g. "2026-03-regular".
dated_runs
property
¶
Run ids :attr:payment_dates names.
employment_for(run)
¶
Return the employment of run.
Returns:
| Type | Description |
|---|---|
Employment
|
attr: |
facts_for(run)
¶
Return the facts of run.
Returns:
| Type | Description |
|---|---|
PeriodFacts
|
The entry of :attr: |
PeriodFacts
|
attr: |
ccnl_engine.TaxYearPlan
dataclass
¶
Every payment of one tax year, drawn from its competence years.
The payments of the tax year are the runs of :attr:competence_years
whose payment date falls in :attr:tax_year under the cassa allargata
rule (paid by 12 January for a period of the year before: that year),
plus the payments already closed in :attr:opening_state. They are
computed in order of payment date, ties in run order. The conguaglio
(art. 23 c. 3 DPR 600/1973) falls on the last payment of the tax year:
a late December paid on 13 January comes before the standard runs, a
late payment in July among them, one paid after the tredicesima after
them, and the conguaglio follows in every case.
Attributes:
| Name | Type | Description |
|---|---|---|
tax_year |
int
|
The tax year. |
competence_years |
tuple[CompetenceYearPlan, ...]
|
Plans of the competence years paid in the tax
year, at most one per year, none after :attr: |
opening_state |
PeriodState | None
|
State the first payment opens with: |
current_year |
CurrentYearTaxFacts | None
|
Income of :attr: |
Raises:
| Type | Description |
|---|---|
InvalidInputError
|
When a field is not of its type, there is no
competence year, two plans share a year, a plan is of a year
after :attr: |
Year calendar¶
CompetenceYearPlan derives the calendar from the CCNL when calendar_override is
omitted. A different calendar is accepted only as a validated
CalendarOverride.
Results¶
What a result says about its own reliability (assurance, blockers,
decisions, the capability report) is described in
ccnl_engine.results.
ccnl_engine.PeriodResult
dataclass
¶
Result of one period-first payroll calculation.
Attributes:
| Name | Type | Description |
|---|---|---|
period_id |
PeriodId
|
The competence period, identical to the request. |
payment_date |
date
|
Payment date, identical to the request. |
period_gross |
Decimal
|
Contractual gross entitlement for this period (sum of CASH_EARNINGS ledger entries). This is the theoretical wage the worker is entitled to before absence deductions. |
period_net |
Decimal
|
Net pay for this period only. |
period_employer_cost |
Decimal
|
Employer cost net of unpaid absences:
|
unpaid_absence_deduction |
Decimal
|
Sum of EMPLOYEE_DEDUCTIONS ledger entries. Represents wages not paid due to unpaid absences or sickness. Zero when no absences are present. |
closing_state |
PeriodState
|
State after closing this period: the tax year state
and the obligations. Pass as |
pay_items |
tuple[PayItem, ...]
|
All pay items produced for this period. |
ledger_entries |
tuple[LedgerEntry, ...]
|
All ledger entries posted for this period. |
contribution_breakdown |
ContributionBreakdown
|
Per-component INPS breakdown for audit and compliance tracing. |
benefit_breakdown |
BenefitBreakdown
|
Per-axis fringe/welfare benefit breakdown for audit and cost-centre reporting. |
capability_report |
CapabilityReport
|
Gaps between the capability catalog and what the run executed, with the provenance of the rules each capability read and the values the caller supplied. |
issues |
tuple[CalculationIssue, ...]
|
Conditions that lower the reliability of this result, in the order they were raised. Empty when every capability decided from known rules and facts. |
decisions |
tuple[CalculationDecision, ...]
|
What the capabilities that record a decision decided in this run, e.g. the eligibility of a pay item for a preferential tax regime, in the order they were taken. |
rulesets |
tuple[RulesetAssurance, ...]
|
Assurance of the rulesets the run read: the CCNL, and each tax, INPS and surtax ruleset a payable rule came from, with identity, hash, readiness and confidence. |
mode |
EngineMode
|
Payability policy of the engine that produced the result;
|
limitations |
tuple[ModelLimitation, ...]
|
Model limitations that concern the run (see
:class: |
extra_months |
tuple[ExtraMonthProgress, ...]
|
Ratei maturati of each extra month by the end of the
month of a regular or termination run
(:class: |
Whether the amounts can be paid is :attr:is_payable: the net pay
(:attr:is_net_pay_payable) and the employer cost
(:attr:is_employer_cost_complete) both reliable. Why not is
:attr:blockers; all come from :attr:assurance.
assurance
property
¶
Assurance derived from what the run recorded and the mode.
It is derived on access, so an issue added to the result later (e.g. a partial month of a year) is reflected.
leave_balances
property
¶
Leave balances after the run, per bucket and year of accrual.
Each :class:~ccnl_engine.leave.balance.models.LeaveBalance gives
the days of ferie or the hours of a permit bucket accrued, taken,
paid and left (accrued, taken, paid, residual); they
are those the closing state carries to the next run.
paid_gross
property
¶
Gross actually paid: period_gross less the unpaid absences.
period_gross is the contractual pay of the period with the
earnings of its events (sick pay included) before the deduction of
the days not paid; this is what the payslip pays as gross.
progressives
property
¶
The progressivi of the tax year, the INPS base, TFR and ratei.
is_payable
property
¶
Whether nothing blocks the amounts of this result.
is_net_pay_payable
property
¶
Whether no blocker leaves the net pay of this result unreliable.
is_employer_cost_complete
property
¶
Whether no blocker leaves the employer cost of this result short.
blockers
property
¶
Every reason the amounts of this result cannot be paid.
payslip_lines(voci=None)
¶
Return the payslip of the run as lines.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
voci
|
Mapping[str, str] | None
|
The provider's voce code by engine code. |
None
|
Returns:
| Type | Description |
|---|---|
PayslipLine
|
One line per earning or deduction of the ledger: the competenze |
...
|
less the trattenute are :attr: |
remittance_summary()
¶
Return the tax and credit amounts of the run by F24 codice tributo.
IRPEF withheld, surtax, substitute and separate taxes, credits paid
and recovered, IRPEF refunded and recoveries carried for lack of
pay, one line per account and code (see
:func:~ccnl_engine.ledger.remittance.models.remittance_summary).
Returns:
| Type | Description |
|---|---|
tuple[RemittanceLine, ...]
|
The lines of the run, uncoded ones included. |
ccnl_engine.CompetenceYearResult
dataclass
¶
Bases: PaymentsResult
Results of the runs of one competence year, in payment order.
The runs paid in the competence year come first and the last of them settles the conguaglio of that tax year, which is then closed; the runs paid in the next tax year (a December paid after 12 January) follow and open it.
Attributes:
| Name | Type | Description |
|---|---|---|
year |
int
|
The competence year. |
calendar |
WorkCalendar
|
The calendar the year ran on: the CCNL standard calendar, or the accepted override. |
calendar_override |
CalendarOverride | None
|
The override that replaced the standard calendar,
with its reason and note, or |
next_opening_state
property
¶
State to open the next competence year with.
close_tax_year() of :attr:closing_state when the last payment
settled its tax year; otherwise the closing state itself, a state
of the next tax year that already holds the late payments.
ccnl_engine.TaxYearResult
dataclass
¶
Bases: PaymentsResult
Results of every payment of one tax year, in payment order.
Attributes:
| Name | Type | Description |
|---|---|---|
tax_year |
int
|
The tax year. |
payments |
tuple[PaymentId, ...]
|
Every payment of the tax year in payment order: those the opening state had already closed, then those computed. |
The assurance of a competence or tax year is incremental: assurance,
is_payable, blockers and rulesets assess the payments computed by the
call, listed in assessed_payments. A payment the opening state already
closed (a resumed or retried plan, a late December carried in from the
previous competence year) is vouched for by the result of the call that
computed it. A call that computed no payment assessed nothing: it is not
payable, with missing evidence and a rule_source_weak blocker (and in
operational mode a ruleset_not_production blocker).
A competence or tax year does not compute a run whose competence date has
no base salary of the CCNL level in the bundle. The run is listed in
uncovered_runs as an UncoveredRun (its payment, the fields of the
MissingRuleError it would raise, and that error as error) and adds a run_not_computed blocker
whose detail is the run id; the other runs are computed on a withholding
schedule without it, so the year is partial and not payable. A year in
which no run has a base salary raises the MissingRuleError of its first
run.
Errors¶
Every error is exported at the root: see Errors.