Skip to content

ccnl_engine.inputs

Every fact a caller passes beyond the common path of the root: optional fields of Employment, EmployerProfile and PeriodFacts, tax facts, the calendar, the engine mode, the opening state and imported balances. See Opening state and imported balances for the state types.

Contract type, hours and seniority

ccnl_engine.inputs.Apprentice dataclass

Apprenticeship contract; salary is derived from CCNL apprenticeship rules.

Attributes:

Name Type Description
months_elapsed int

Months of apprenticeship service elapsed so far, >= 0. Used to look up the applicable apprenticeship_pct in the CCNL percentage track, or the under-classification level in under-classification tracks.

track str | None

Name of the CCNL apprenticeship track to apply. Required only when more than one track covers the destination level; None lets the engine select the unique applicable track.

programme ApprenticeshipProgramme

Kind of apprenticeship; a first- or third-level one is paid by the CCNL dual_apprenticeship tracks.

school_year int | None

Year of the school or training course the apprentice attends, for a CCNL that pays a first-level apprentice by it; None when not stated.

programme_months int | None

Length in months of the whole apprenticeship, for a CCNL that pays by the half of the programme or by its length; None when not stated.

hours DualHours | None

Hours of the month by kind, for a first- or third-level apprentice; on an extra-month run, the hours of the period the ratei accrue over. None when not stated.

ratei_hours DualHours | None

Hours by kind of the period the extra-month ratei accrue over, for a first- or third-level apprentice whose final settlement pays its month at hours and the ratei at these. None when not stated.

failed_title_extension_start_month int | None

First month (zero-based from contract start) of an extension following failure to obtain the qualification. None when no such extension applies. Only tracks with a rule for this outcome can pay the extension.

fixed_term bool

Whether the apprenticeship has a term, as a seasonal one may (D.Lgs. 81/2015 art. 44 c. 5); an apprenticeship is otherwise permanent (art. 41 c. 1). A CCNL that keeps the seniority increments to permanent workers pays none to it.

objective_one_area bool | None

Whether the workplace is in an Objective 1 area of Regulation (EEC) 2081/93, for a CCNL that pays its apprentices there by other percentages (Calzaturiero 2024 art. 23: "Nelle aree di cui all'obiettivo 1 [...] 70% [...] 80% [...] 90%"); None when not stated.

Raises:

Type Description
InvalidInputError

When a field has the wrong type or range.

ccnl_engine.inputs.ApprenticeshipProgramme

Bases: StrEnum

Kind of apprenticeship (D.Lgs. 81/2015 artt. 43-45).

Attributes:

Name Type Description
PROFESSIONALISING

Apprendistato professionalizzante (art. 44).

FIRST_LEVEL

Apprendistato per la qualifica e il diploma professionale, il diploma di istruzione secondaria superiore e il certificato di specializzazione tecnica superiore (art. 43).

THIRD_LEVEL

Apprendistato di alta formazione e di ricerca (art. 45).

ccnl_engine.inputs.DualHours dataclass

Hours of a first- or third-level apprentice over a stretch of time.

The pay of the stretch weighs each kind of hour by its share of the total (D.Lgs. 81/2015 art. 43 c. 7, art. 45 c. 3).

Attributes:

Name Type Description
school Decimal

Hours of training in the educational institution, which the employer does not pay.

company_training Decimal

Hours of training the employer provides.

work Decimal

Hours of work at the employer.

Raises:

Type Description
InvalidInputError

When an hour count is negative, or all are 0.

total property

Hours of the three kinds together.

ccnl_engine.inputs.FixedTerm dataclass

Fixed-term contract, which may owe the NASpI surcharge.

Attributes:

Name Type Description
renewals int | None

Renewals of the fixed-term contract with the same employer, this contract being the last, signed from 14 July 2018 (INPS circ. 121/2019 par. 2.3: earlier renewals are not counted). A prorogation of the term is not a renewal. Each renewal raises the surcharge by 0.5 points. None means not known: a run that owes the increase has a missing_fact blocker.

naspi_exclusion NaspiExclusion | None

The exclusion of c. 29 the contract falls in, :attr:NaspiExclusion.NONE when none. None means not known: a run whose sector charges the surcharge has a missing_fact blocker.

qualifying_years int | None

Consecutive calendar years, up to the year before the run, the worker worked for the employer at least the days a CCNL element asks (operai agricoli art. 54-bis: 150 days). None means not known: a run that pays such an element raises MissingRequiredFactError.

Raises:

Type Description
InvalidInputError

When renewals or qualifying_years is not a non-negative int or naspi_exclusion names no exclusion.

ccnl_engine.inputs.NaspiExclusion

Bases: StrEnum

Why the NASpI surcharge of a fixed-term contract is not charged.

Sources: L. 92/2012 art. 2 c. 28-29 and D.L. 87/2018 art. 1 c. 3, text in force on Normattiva on 7 October 2026; INPS circ. 121/2019 par. 2.2 and 2.4. Apprentices (c. 29 lett. c) are not a reason here: an apprenticeship is an :class:~ccnl_engine.employment.inputs.Apprentice contract, which never pays the surcharge. Operai agricoli (c. 3) are not a reason either: the bundle marks the categories of the sector the whole article does not apply to.

Attributes:

Name Type Description
NONE

No exclusion: the surcharge and its renewal increase apply.

REPLACEMENT

Hired to replace absent workers (c. 29 lett. a).

SEASONAL

Hired for the seasonal activities of DPR 1525/1963, or for those of the CCNLs of the provincia di Bolzano signed by 31 December 2019 (c. 29 lett. b and b-bis).

PUBLIC_ADMINISTRATION

Employed by a public administration of art. 1 c. 2 D.Lgs. 165/2001 (c. 29 lett. d).

SHORT_SERVICE

Special services of at most three days in tourism and public establishments, D.Lgs. 81/2015 art. 29 c. 2 lett. b (c. 29 lett. d-bis).

RESEARCH

Teaching or research at a private university, a public research institute, a public company promoting research or a private research body: the 1.4% applies, the renewal increase does not (D.L. 87/2018 art. 1 c. 3).

excludes_surcharge property

Whether the whole surcharge of c. 28 is not charged.

excludes_renewal_increase property

Whether the 0.5-point increase per renewal is not charged.

ccnl_engine.inputs.Permanent dataclass

Open-ended contract; entry_pay takes the entry pay of the CCNL.

ccnl_engine.inputs.WorkerCategory

Bases: StrEnum

Legal category of an employee under art. 2095 c.c.

The single category vocabulary shared by CCNL data (levels, seniority rules, employer funds), INPS contribution rules and employment facts. Values are the lowercase Italian names used in the bundled JSON.

Attributes:

Name Type Description
OPERAIO

Manual worker.

IMPIEGATO

Clerical or technical employee.

QUADRO

Middle manager (L. 190/1985).

DIRIGENTE

Executive.

ccnl_engine.inputs.EmploymentChange dataclass

New terms of the employment from a date: level, weekly hours, category.

A field left None keeps the value in force before the change. The change applies from :attr:effective_on, the first day of a month: the runs of that month and of the months after price it (see :class:~ccnl_engine.CompetenceYearPlan).

Attributes:

Name Type Description
effective_on date

First day of the new terms.

level_code str | None

New contractual level, e.g. "4"; None keeps it.

weekly_hours WeeklyHours | None

New contracted weekly hours; None keeps them. To return to full time, state the full-time hours.

category WorkerCategory | None

New worker category, or its string value; None keeps it.

Raises:

Type Description
InvalidInputError

When effective_on is not a date, a field is not of its type, level_code is blank, category names no known value, or no field changes.

applied_to(employment)

Return employment with the terms this change states.

A change of level records it on the seniority as its last promotion (:class:~ccnl_engine.seniority.inputs.SeniorityPromotion), for a CCNL that reprices the earlier increments at the next one.

Returns:

Type Description
Employment

A copy of employment, validated again: weekly hours above

Employment

the full-time hours raise InvalidInputError.

ccnl_engine.inputs.EmploymentPeriod dataclass

Start and optional end of the employment relationship.

Attributes:

Name Type Description
started_on date

First day of employment.

uninterrupted_service_started_on date | None

First day of the current uninterrupted actual service counted for service-gated awards. State the date from employer records when it differs from the hire date (for example, after a break or on a group transfer). It must exclude conventional seniority that is not actual service, unless the CCNL extends the award to it (Alimentari saccarifero, dichiarazione aggiuntiva al punto 25). None uses started_on.

ended_on date | None

Last day of employment, or None for an open-ended relationship. Must not precede started_on.

ended_by TerminationCause | None

How the employment ends, with ended_on; None when not stated (a run that needs it reports the missing fact).

just_cause bool | None

Whether a dismissal or a resignation has a just cause (art. 2119 c.c.); None when not stated or not either.

disciplinary_dismissal bool | None

Whether a dismissal is for disciplinary reasons; distinct from just cause. None when not stated.

naspi_case NaspiCase | CollectiveDismissal | None

The case of the end that changes the NASpI contribution, a collective dismissal or NaspiCase.ORDINARY; None when not stated (the contribution carries a limitation).

probation_until date | None

Last day of the periodo di prova, read by a fund that leaves out the workers on probation (FASDA, Igiene ambientale art. 65 lett. B); None when there is none or it is not stated.

permanent_incapacity bool | None

Whether the employment ends for the worker's permanent incapacity (invalidità permanente), read by a service award that settles its ratei on it (Alimentari saccarifero, punto 25); None when not stated.

Raises:

Type Description
InvalidInputError

When a date is not a date, ended_on or probation_until is before started_on, the service start is after ended_on, ended_by comes without ended_on, just_cause with a cause other than a dismissal or a resignation, disciplinary_dismissal without a dismissal, or naspi_case without its own cause.

from_dates(started_on, ended_on) classmethod

Build a period from optional dates, as supplied by callers.

Returns:

Type Description
EmploymentPeriod | None

None when neither date is given, otherwise the validated period.

Raises:

Type Description
InvalidInputError

When only ended_on is given, or when ended_on precedes started_on.

overlaps_month(year, month)

Return whether the employment covers at least one day of a month.

Parameters:

Name Type Description Default
year int

Calendar year of the month.

required
month int

Calendar month, 1-12.

required

Returns:

Type Description
bool

True when the month has at least one employed day.

covers_month(year, month)

Return whether the employment covers every day of a month.

Parameters:

Name Type Description Default
year int

Calendar year of the month.

required
month int

Calendar month, 1-12.

required

Returns:

Type Description
bool

True when the employment starts on or before the first day

bool

and does not end before the last day of the month.

span_in_month(year, month)

Return the first and last employed day of a calendar month.

Parameters:

Name Type Description Default
year int

Calendar year of the month.

required
month int

Calendar month, 1-12.

required

Returns:

Type Description
tuple[date, date] | None

(first, last) employed days of the month, inclusive; None

tuple[date, date] | None

when the employment has no day in it.

clip_start(day)

Return day, or the hire date when day precedes it.

Parameters:

Name Type Description Default
day date

A date, typically the first day of an accrual window.

required

Returns:

Type Description
date

max(day, started_on).

ccnl_engine.inputs.EmploymentSpell dataclass

Days of one employment within a tax year.

Attributes:

Name Type Description
first_day date

First day of the employment in the year.

last_day date

Last day of the employment in the year: its end, or 31 December while the end is not stated.

fixed_term bool

Whether the employment is fixed-term.

unpaid_days tuple[date, ...]

Days of the spell for which no pay at all is due (aspettativa senza assegni), in order: they leave the days of the deductions (AdE circ. 15/E/2007 par. 1.5.1).

Raises:

Type Description
InvalidInputError

When a field is not of its type, or the days are not of one year in order.

with_unpaid(days)

Return the spell with days added to its unpaid days.

Returns:

Type Description
EmploymentSpell

The spell with the days of days that fall within it.

of(period, year, *, fixed_term) classmethod

Return the spell of period in year.

Parameters:

Name Type Description Default
period EmploymentPeriod | None

The employment period; None when its start is not stated, which covers the whole year.

required
year int

The tax year.

required
fixed_term bool

Whether the employment is fixed-term.

required

Returns:

Type Description
EmploymentSpell | None

The spell, or None when the period has no day in year.

ccnl_engine.inputs.WeeklyHours dataclass

Weekly working hours, contracted or full-time.

Attributes:

Name Type Description
value Decimal

Hours per week, a :class:~decimal.Decimal > 0 and at most 168 with at most two decimal places (Decimal("37.5")).

Raises:

Type Description
InvalidInputError

When value is not a finite Decimal, is not positive, exceeds 168 or has more than two decimal places.

ccnl_engine.inputs.WorkPattern dataclass

How the contracted hours are spread over the week and the year.

A horizontal part time needs no pattern: :class:WeeklyHours below the full time scale every month. A pattern states a vertical or mixed part time (D.Lgs. 81/2015 art. 5 c. 2): the hours of each day of the week, and the months of the year the worker works. In a month the worker works the pay is the weekly-hours ratio of a horizontal part time; a month outside :attr:months pays nothing and accrues no extra-month rateo.

Attributes:

Name Type Description
weekday_hours tuple[Decimal, ...] | None

Hours worked on each day of the week, Monday first: seven Decimals in [0, 24] with at most two decimal places, at least one positive. Their sum must equal the contracted weekly_hours of the employment. None when not stated.

months frozenset[int] | None

Calendar months (1-12) the worker works, at least one. None for every month.

Raises:

Type Description
InvalidInputError

When neither field is stated, weekday_hours is not seven valid day hours or sums to zero, or months is not a non-empty frozenset of months.

weekly_hours property

Hours of the week the pattern states, None without days.

works_in(month)

Return whether the worker works in a calendar month.

Returns:

Type Description
bool

True for every month when :attr:months is not stated.

idle_days(first, last)

Return the days from first to last of the months not worked.

Returns:

Type Description
frozenset[date]

Every day of the range whose month is outside :attr:months;

frozenset[date]

empty when every month is worked or last precedes first.

ccnl_engine.inputs.Weekday

Bases: StrEnum

A day of the week, Monday first.

number property

Position of the day in the week, Monday 0 and Sunday 6.

is_day_of(day)

Return whether day falls on this day of the week.

Returns:

Type Description
bool

True when the weekday of day is this one.

ccnl_engine.inputs.Rota

Bases: StrEnum

Days of work and of rest a rota repeats.

ccnl_engine.inputs.ContributableHours dataclass

Hours worked and paid in a period that are subject to INPS contributions.

Zero is valid (a period with no paid hours).

Attributes:

Name Type Description
value Decimal

Finite :class:~decimal.Decimal number of hours, >= 0.

Raises:

Type Description
InvalidInputError

When value is not a finite Decimal or is negative.

ccnl_engine.inputs.PaidHolidayDays dataclass

Number of eligible paid holidays, including those on rest days.

The caller resolves employment span, local patron saint and any suspension; this count does not replace hours actually worked.

Attributes:

Name Type Description
value int

Nonnegative whole number of eligible holidays.

ccnl_engine.inputs.SecondLevelAgreement

Bases: StrEnum

Kind of the agreement an element comes from.

Values

COMPANY: A contratto aziendale of the employer. TERRITORIAL: A contratto territoriale (provincial or regional).

ccnl_engine.inputs.SecondLevelElement dataclass

A monthly element of a company or territorial agreement.

Attributes:

Name Type Description
code str

Lower snake case code of the element, unique within the employer, e.g. "premio_presenza"; it names the earning on the payslip.

monthly Decimal

Full-time monthly amount in EUR, above zero.

agreement SecondLevelAgreement

The kind of agreement, company or territorial.

valid_from date

First day the element is in force.

valid_until date | None

Last day it is in force, None while open.

levels tuple[str, ...]

Codes of the CCNL levels it applies to; empty for every level.

extra_months bool

Whether it is paid on the extra months of the CCNL.

tfr_relevant bool

Whether it enters the TFR base (art. 2120 c. 2 c.c., unless the agreement excludes it).

Raises:

Type Description
InvalidInputError

When a field is not of its type, monthly is not above zero, or the period ends before it starts.

applies_to(level_code, day)

Return whether the element is paid to level_code on day.

Returns:

Type Description
bool

True when the day is in its period and the level is listed,

bool

or no level is.

ccnl_engine.inputs.SecondLevelRate dataclass

The supplement of one kind of work set by a second-level agreement.

Attributes:

Name Type Description
work SupplementWork

The work it pays (night, holiday, a shift, ...).

rate Decimal

0.15 for 15% with :attr:RateUnit.PERCENTAGE, else EUR.

unit RateUnit

What the rate measures.

agreement SecondLevelAgreement

The kind of agreement, company or territorial.

valid_from date

First day the rate is in force.

valid_until date | None

Last day it is in force, None while open.

levels tuple[str, ...]

Codes of the CCNL levels it applies to; empty for every level.

hours_paid_apart bool

Whether the hours themselves are paid on top of the monthly pay (a public holiday worked: L. 260/1949 art. 5).

Raises:

Type Description
InvalidInputError

When a field is not of its type, rate is not above zero, or the period ends before it starts.

applies_to(level_code, day)

Return whether the rate prices the work of level_code on day.

Returns:

Type Description
bool

True when the day is in its period and the level is listed,

bool

or no level is.

ccnl_engine.inputs.RateUnit

Bases: StrEnum

What a second-level rate is a measure of.

Values

PERCENTAGE: A share of the hourly base of the CCNL for each hour. PER_HOUR: An amount in EUR for each hour. PER_SHIFT: An amount in EUR for each turn or day of shift.

ccnl_engine.inputs.SeniorityFact dataclass

Recognised seniority of the worker, for seniority increments.

The seniority is a fact as of a date: the engine ages it to each run. The increments and the service-gated allowances of a run use the months of service completed by the first day of its competence month, so an increment matured during a month is paid from the next one, and service starting within the month counts zero months (see :meth:months_in_month). A month is complete on the same day of the following month.

Use :meth:since when the caller knows the date the recognised seniority starts from instead of a count of months.

Attributes:

Name Type Description
months int

Completed months of recognised service on as_of, >= 0.

as_of date

Date the months are counted at.

source SenioritySource

Where the seniority was read from; a string value of :class:SenioritySource is accepted and normalized.

earned EarnedIncrements | None

The increments matured on as_of whose amount stays as matured (:class:EarnedIncrements). The runs pay that amount and add only the increments matured after as_of, priced by the CCNL table of the run, up to its maximum count. None prices every increment by that table.

promotion SeniorityPromotion | None

The last change of level (:class:SeniorityPromotion), read only by a CCNL that reprices the earlier increments at the next increment; None when the level never changed or the change is older than the last increment.

birth_date date | None

Date of birth of the worker, read only by a CCNL that counts the increments from an age (Turismo Art. 158 c. 2: from the eighteenth birthday); None counts them from the start.

career_months int | None

Completed months on as_of of the career a CCNL counts apart from the service, aged like months, read by the allowances gated on it (Farmacie Tabella C: the years in level 1 and Area Q); None reads the service months instead.

apprenticeship_months int | None

Completed months in a past apprenticeship followed by continued employment, separate from months. Zero confirms no preceding apprenticeship; None leaves the duration unknown when a CCNL requires a fractional credit.

Raises:

Type Description
InvalidInputError

When months is not a non-negative int, as_of is not a date, source names no source, earned is not :class:EarnedIncrements, promotion is not :class:SeniorityPromotion, birth_date is not a date, career_months or apprenticeship_months is not a non-negative int.

since(recognised_from, source) classmethod

Return the seniority that starts on recognised_from.

Parameters:

Name Type Description Default
recognised_from date

First day of recognised service, which may precede the hire date when the employer recognises earlier service.

required
source SenioritySource

Where the date was read from.

required

Returns:

Type Description
SeniorityFact

Zero months as of recognised_from.

months_at(day)

Return the completed months of recognised service on day.

Parameters:

Name Type Description Default
day date

The date to age the seniority to; it may precede as_of.

required

Returns:

Type Description
int

months plus the whole months from as_of to day,

int

minus them when day precedes as_of.

Raises:

Type Description
InvalidInputError

When day precedes the start of the recognised service.

months_in_month(year, month)

Return the months of service a run of a month counts.

A run counts the months completed by the first day of its month. Service that starts within the month counts zero months: the hire month of a worker whose seniority is recognised from the hire date.

Parameters:

Name Type Description Default
year int

Year of the competence month.

required
month int

Competence month, 1-12.

required

Returns:

Type Description
int

The completed months on the first day of the month, at least 0.

Raises:

Type Description
InvalidInputError

When the recognised service starts after the last day of the month.

career_months_in_month(year, month)

Return the career months a run of a month counts, if stated.

Returns:

Type Description
int | None

career_months aged to the first day of the month, at least

int | None

0; None when the career is not stated.

ccnl_engine.inputs.SeniorityPromotion dataclass

The last change of level of the worker, for the increments it reprices.

Some CCNLs reprice the increments matured before a promotion at the amounts of the new level only when the next increment matures (Turismo art. 158 c. 6: "gli importi relativi agli scatti precedenti saranno ricalcolati in base al nuovo valore al momento di maturazione del nuovo scatto"); until then they keep the amount of the level they were matured at. A :class:~ccnl_engine.CompetenceYearPlan derives it from an :class:~ccnl_engine.inputs.EmploymentChange of level; state it for a promotion before the plan or for a single run.

Attributes:

Name Type Description
effective_on date

First day of the new level.

from_level str

Level code before the change.

Raises:

Type Description
InvalidInputError

When effective_on is not a date or from_level is blank.

ccnl_engine.inputs.EarnedIncrements dataclass

Seniority increments whose amount stays as matured, not repriced.

The CCNL table prices the increments of a run (Federmeccanica art. 6: after a promotion the increments "ragguagliati agli importi previsti per la categoria di arrivo"). Some keep the amount they matured at: the increments the norme transitorie of the same article fix, or those matured under another CCNL and kept on a transfer. State them here, as the payslip prints them.

Attributes:

Name Type Description
count int

Increments matured, >= 0.

monthly Decimal

Their full-time monthly amount in EUR, >= 0.

Raises:

Type Description
InvalidInputError

When count is not a non-negative int or monthly not a non-negative Decimal.

ccnl_engine.inputs.SenioritySource

Bases: StrEnum

Where the caller read the recognised seniority from.

Attributes:

Name Type Description
EMPLOYER_RECORDS

The personnel file or the libro unico del lavoro.

PAYSLIP

A previous payslip of the same employment.

EMPLOYMENT_CONTRACT

The letter of hire, for a seniority recognised on hiring (anzianita convenzionale).

ccnl_engine.inputs.ContributionHistory dataclass

The pension history that decides whether the IVS massimale applies.

L. 335/1995 art. 2 c. 18 caps the IVS contribution base at an annual massimale (EUR 122,295 in 2026) for workers without contributions before 1 January 1996 and for those who opted for the contributory system under art. 1 c. 23. Every other worker contributes on the full base. The engine derives the eligibility from these facts; the caller never states it.

The history is the one in force for the run being computed: the engine models no effective date of a change. Pre-1996 periods credited on request to a worker hired after 1995 lift the massimale only from the month after the request (L. 208/2015 art. 1 c. 280), and the option takes effect from when it is exercised: for the runs before those dates, supply the history as it stood then.

Attributes:

Name Type Description
first_enrolled_on date

Date of the first contribution credited to any mandatory pension scheme (prima iscrizione), from the worker's contribution statement.

contributory_option bool

Whether the worker opted for the contributory system (L. 335/1995 art. 1 c. 23). Defaults to False.

Raises:

Type Description
InvalidInputError

When a field is not of its type.

ivs_ceiling_basis property

Why the massimale applies to the worker or not.

ivs_ceiling_applies property

Whether the annual IVS massimale caps the contribution base.

ccnl_engine.inputs.EmploymentSector

Bases: StrEnum

Whether the worker is employed in the private or the public sector.

Attributes:

Name Type Description
PRIVATE

Employer outside the public administrations.

PUBLIC

Public administration employer (D.Lgs. 165/2001 art. 1 c. 2).

ccnl_engine.inputs.PensionFundEnrolment dataclass

The worker's enrolment in a pension fund of the CCNL.

Enrolment is voluntary (D.Lgs. 252/2005 art. 1 c. 2), so it is a fact of the employment, never derived from the CCNL. The employer rate and its base come from the fund in CCNL.parameters.employer_funds.

Attributes:

Name Type Description
fund_code str

Code of the fund in the CCNL data, e.g. "ALIFOND".

employee_rate Decimal

Contribution the worker chose, as a fraction of the same base as the employer rate, e.g. Decimal("0.01"). It cannot be below the minimum of the CCNL when the bundle records one, except zero: a worker who confers the TFR alone, with no contribution of either side (D.Lgs. 252/2005 art. 8 c. 1).

tfr_to_fund bool

Whether the TFR accrued is paid to the fund (D.Lgs. 252/2005 art. 8 c. 1-2). Required: the choice is the worker's, and it moves the TFR out of the company.

tfr_share Decimal

The share of the TFR maturando paid to the fund, when tfr_to_fund: 1 for all of it; less for a worker enrolled in a compulsory scheme before 29 April 1993 who confers the share the agreements set, or at least 50% (D.Lgs. 252/2005 art. 8 c. 7 lett. c), c. 9-bis from 1 July 2026). The rest stays in the company or goes to the Fondo Tesoreria.

young_member bool | None

Whether the worker belongs to the members the CCNL favours for the age at enrolment (Cometa: enrolled after 5 February 2021 before turning 35), read only by a fund with a young_member_rate; None when not stated.

support_contract bool | None

Whether the worker is on a sostegno all'occupazione contract, or in the 24 months after its conversion (DMO art. 70 c. 8), read only by a fund with a support_contract_rate; None when not stated.

conventional_base Decimal | None

Monthly base the fund applies to the worker, read only by a fund on a conventional base (Previambiente: the base pay of the level at 1 January 1997, its contingenza and one scatto, e.g. 2077.84 for a quadro); None when not stated.

seniority_to_fund bool

Whether the worker opted to convert the seniority increments into fund contributions, read only by a fund with a seniority_conversion (Previambiente art. 65 lett. A) bis): not unless stated.

extra_deduction Decimal | None

The deduction above the annual cap the worker states for the tax year (D.Lgs. 252/2005 art. 8 c. 6: a worker first employed after its coming into force deducts, in the twenty years after the fifth year of membership, the room the first five years left, up to half the cap a year), at least zero; None when not stated. The withholding agent applies it to the ritenute (AdE circ. 70/E/2007).

seniority_converted_on date | None

Date of the request of a worker already in service (lett. A) bis c. 6): the increments matured by then stay in the pay, frozen, and only the later ones are converted; None for a new hire who opted at the hire (c. 1).

Raises:

Type Description
InvalidInputError

When a field is not of its type, fund_code is empty, employee_rate is outside [0, 1], or zero with no TFR conferred.

tfr_only property

Whether the worker confers the TFR alone, with no contribution.

ccnl_engine.inputs.NoPensionFund dataclass

The worker is stated not enrolled in a pension fund of the CCNL.

It is the fact Employment.pension_fund left None does not state: on every CCNL but domestic work, an unknown enrolment leaves the contributions to the fund undetermined. Whether the TFR of a worker who expressed no choice goes to the fund (D.Lgs. 252/2005 art. 8 c. 7) is for the caller to establish: the engine does not infer it.

ccnl_engine.inputs.PublicEndOfService

Bases: StrEnum

End-of-service regime of a public employee (DPCM 20 dicembre 1999).

Values

TFS: Trattamento di fine servizio (buonuscita or indennità premio di servizio) of INPS Gestione Dipendenti Pubblici: the worker pays 2.50% of the contribution base, the administration the rest. TFR_INPS: Trattamento di fine rapporto accrued notionally by INPS (art. 1 c. 6): the administration pays the whole contribution and the gross is reduced by the 2.50% the worker no longer pays (c. 3). TFR_EMPLOYER: Trattamento di fine rapporto the employer accrues and pays (art. 1 c. 6 and 8: enti pubblici non economici, enti di ricerca): no contribution to the Gestione, no reduction.

ccnl_engine.inputs.TfrFundBalance dataclass

TFR the worker has accrued with the employer at 31 December of a year.

The fund at 31 December of year, after the revaluation of that date and net of the substitute tax charged to it, less the advances paid: the TFR the next year revalues (art. 2120 c. 4 c.c.: the quota accrued in the year is excluded). It includes the part paid to the Fondo Tesoreria INPS, whose share the Fondo pays out under art. 2120 c.c. (DM 30 gennaio 2007 art. 2 c. 1), and excludes the TFR paid to a complementary pension fund.

The separate taxation of the TFR at the termination (art. 19 c. 1 TUIR) needs two more facts of the same fund: the revaluations it holds, already taxed at the substitute rate and left out of the taxable, and whether advances were paid out of it.

Attributes:

Name Type Description
year int

Year at whose 31 December the balance is struck.

amount Decimal

Balance in EUR, non-negative, with at most two decimals.

revaluations Decimal | None

Part of amount that comes from the revaluations of the past years, net of their substitute tax; None when not known.

advances Decimal | None

Advances paid out of the fund over the employment (art. 2120 c. 6 c.c.), already deducted from amount; None when not known, 0 when none was paid.

advances_taxable Decimal | None

The taxable of those advances at their separate taxation: their amount less the revaluations they held, already taxed at the substitute rate (art. 19 c. 4 TUIR); None when not known.

advances_tax Decimal | None

The IRPEF withheld on those advances, which the termination takes back in the conguaglio of art. 19 c. 4 TUIR; None when not known.

Raises:

Type Description
InvalidInputError

When year is not an int from 1900, an amount is not a non-negative Decimal in cents, revaluations exceeds amount or advances_taxable exceeds advances.

ccnl_engine.inputs.TfrQuotaYtd dataclass

TFR the runs of one competence year accrued with the employer.

The quotas of art. 2120 c. 1 c.c. net of the additional IVS of L. 297/1982, posted to the company accrual or to the Fondo Tesoreria INPS, as :class:TfrFundBalance counts them; the TFR paid to a complementary pension fund is left out. The quotas of a year enter the fund at its 31 December: until then the settlement of a termination adds them to the fund of the year before.

Attributes:

Name Type Description
year int

The competence year.

amount Decimal

Sum of the quotas of the runs of :attr:year; an adjustment run that lowers the TFR base posts a negative quota.

Raises:

Type Description
InvalidInputError

When year is not an int from 1970 to 9999 or amount is not a finite Decimal in cents.

plus(quota)

Return the quotas with quota of one more run added.

Returns:

Type Description
TfrQuotaYtd

A new record of the same year.

ccnl_engine.inputs.EmployerActivity

Bases: StrEnum

Activity of the employer, where a regime excludes some activities.

L. 199/2025 art. 1 c. 11 excludes from the night, holiday and shift substitute tax the activities of c. 18: "esercizi di somministrazione di alimenti e bevande, di cui all'articolo 5 della legge 25 agosto 1991, n. 287" and "comparto del turismo, ivi inclusi gli stabilimenti termali". Their workers receive the trattamento integrativo speciale of c. 18 instead.

Attributes:

Name Type Description
FOOD_AND_BEVERAGE_SERVICE

Somministrazione di alimenti e bevande (L. 287/1991 art. 5).

TOURISM

Comparto del turismo, other than thermal establishments.

THERMAL_ESTABLISHMENT

Stabilimenti termali.

CONSTRUCTION

Building construction (edile), including artisan firms.

STONE_WORKING

Industrial stone working, or artisan stone extraction and working linked to the quarry (D.Lgs. 148/2015 art. 10(n-o)).

STONE_WORKING_SEPARATE_WORKSHOP

Artisan stone working only in a separate workshop, excluded from CIGO by art. 10(o): "con esclusione di quelle che svolgono tale attività di lavorazione in laboratori con strutture e organizzazione distinte dalla attività di escavazione". Industrial firms under art. 10(n) are unaffected.

OTHER

Any activity not listed above.

ccnl_engine.inputs.AgriculturalZone

Bases: StrEnum

Zone of the agricultural land, for the reduced contributions.

Attributes:

Name Type Description
ORDINARY

No reduction.

DISADVANTAGED

A "zona svantaggiata": 68% less.

MOUNTAIN

A "zona particolarmente svantaggiata (ex montana)": 75% less.

ccnl_engine.inputs.TaxSector

Bases: StrEnum

INPS sector classification used to select the contribution-rate file.

ccnl_engine.inputs.TerminationCause

Bases: StrEnum

How an employment ends.

Attributes:

Name Type Description
DISMISSAL

The employer dismisses the worker (licenziamento).

RESIGNATION

The worker resigns (dimissioni).

DEATH

The worker dies.

MUTUAL_AGREEMENT

The parties agree to end it (risoluzione consensuale).

ccnl_engine.inputs.NaspiCase

Bases: StrEnum

The case of an end of employment that changes the NASpI contribution.

Attributes:

Name Type Description
ORDINARY

None of the cases below.

PROTECTED_MATERNITY

A resignation in the protected period of maternity (INPS circ. 44/2013 par. 1): owes it.

CONCILIATION

A mutual agreement before the labour office (art. 7 L. 604/1966): owes it.

TRANSFER

A mutual agreement on a transfer more than 50 km from home or 80 minutes away by public transport: owes it.

CONTRACTOR_CHANGE

A dismissal on a change of contractor followed by hiring under a social clause (L. 92/2012 art. 2 c. 34 lett. a): owes none.

SITE_CLOSURE

A dismissal in construction on the end of the works and closure of the site (c. 34 lett. b): owes none.

ccnl_engine.inputs.CollectiveDismissal dataclass

A dismissal at the end of a collective procedure (L. 223/1991 art. 4).

Attributes:

Name Type Description
union_agreement bool

Whether the declaration of redundancy was the object of a union agreement; without one the contribution is three times (L. 92/2012 art. 2 c. 35).

cigs_employer bool

Whether the employer owes the CIGS contribution (art. 23 D.Lgs. 148/2015); its rate is 82% (L. 205/2017 art. 1 c. 137).

Raises:

Type Description
InvalidInputError

When a flag is not a bool.

Family and tax facts

ccnl_engine.inputs.FamilyComposition dataclass

Caller-supplied family unit for Art. 12 TUIR deductions.

Used to compute the family deductions the employer applies as sostituto d'imposta, on the reddito complessivo of :class:~ccnl_engine.irpef.other_income.inputs.CurrentYearTaxFacts. Eligibility conditions the engine cannot verify (residency, disability certification, the dependents' own income) are taken as declared; one left unknown grants no deduction (see :class:Dependent). The children also select the fringe-benefit threshold (L. 207/2024 art. 1 c. 390).

Attributes:

Name Type Description
dependents tuple[Dependent, ...]

The dependents; a list is accepted and stored as a tuple.

sole_parent bool

True when the other parent is missing or has not recognized the children, or the children are the worker's alone, and the worker is not married or is legally separated: for the first child the spouse deduction of lett. a applies when more favourable (art. 12 c. 1 lett. c, last period).

has_any_dependent property

True when at least one dependent is declared.

ccnl_engine.inputs.Dependent dataclass

One fiscally dependent family member for Art. 12 TUIR purposes.

The caller declares the dependent and the dated interval in which the conditions it cannot verify hold (marriage, cohabitation, residency, custody); the engine derives from it, month by month, the months the deduction is due (art. 12 c. 3: "rapportate a mese e competono dal mese in cui si sono verificate a quello in cui sono cessate le condizioni richieste") and, for a child, the months of the age band.

A condition left None is unknown, never met by default: when the dependant would give right to a deduction in some month, the family deductions of the run are not determined and the run has a missing_fact blocker naming the field. A condition is read only where art. 12 makes it one: own_income and residency_eligibility for every dependant (c. 2 and c. 2-bis refer to every deduction of c. 1), cohabiting for an ascendant (c. 1 lett. d), allocation_pct for a child and an ascendant (lett. c and lett. d share the deduction; the spouse deduction of lett. a is not shared). The dependency interval has no default: None is an open end the caller states.

Attributes:

Name Type Description
relationship DependentRelationship

Relationship to the worker.

birth_date date | None

Date of birth. Required for a child: the age band of lett. c is evaluated in every month. Ignored for a spouse or an ascendant.

disabled bool

True when a disability is certified under art. 3 L. 104/1992; a child keeps the deduction from the age of 30.

own_income Decimal | None

Dependent's own reddito complessivo of the year (EUR), checked against the limit of art. 12 c. 2; None is unknown.

allocation_pct Decimal | None

Percentage of the deduction allocated to this worker (0-100): the share between the parents of lett. c, or the pro quota share of lett. d. None is unknown for a child or an ascendant; a spouse takes the whole deduction, so only None or 100 is accepted for one.

cohabiting bool | None

True when the ascendant lives with the worker (Art. 12 c. 1 lett. d post L. 207/2024); None is unknown. Not read for a spouse or a child.

residency_eligibility bool | None

True when the condition of Art. 12 c. 2-bis is met: the worker is an Italian, EU or EEA citizen, or the dependant is not resident abroad. Caller-declared, not engine-verified; None is unknown.

dependent_from date | None

First day the conditions hold; None states that they held before the tax year. Keyword only, required.

dependent_until date | None

Last day the conditions hold; None states that they have not ceased. Keyword only, required.

Raises:

Type Description
InvalidInputError

When a field is not of its type or is outside its range, a child has no birth date, a spouse is allocated less than the whole deduction, or the interval ends before it starts.

share property

Percentage of the deduction to this worker; 100 when not stated.

A child or an ascendant without a stated share has a missing fact (:attr:missing_facts) and no deduction, so the 100 is never applied to one.

missing_facts property

Conditions of art. 12 this dependant leaves unknown.

Returns:

Type Description
str

The names of the fields left None that art. 12 reads for

...

the relationship, in field order.

may_qualify(income_limit)

Return whether no stated condition excludes the deduction.

An unknown condition does not exclude it: the dependant may qualify once the fact is stated.

Parameters:

Name Type Description Default
income_limit Decimal

Own-income limit of art. 12 c. 2 for this dependant.

required

Returns:

Type Description
bool

False when residency or, for an ascendant, cohabitation is

bool

stated as not met, or the stated own income exceeds the limit.

dependency_months(year)

Return the months of year the conditions hold on some day.

Returns:

Type Description
frozenset[int]

Months 1-12 the interval touches, both ends included (c. 3).

ccnl_engine.inputs.DependentRelationship

Bases: StrEnum

Relationship category of a fiscally dependent family member.

ccnl_engine.inputs.IndividualElement dataclass

A monthly pay element agreed with the worker, above the CCNL minimum.

Attributes:

Name Type Description
code str

Lower snake case code of the element, unique within the employment, e.g. "superminimo"; it names the earning (allowance_code) on the payslip.

monthly Decimal

Full-time monthly amount in EUR on :attr:as_of, above zero.

absorbable bool

Whether the increases of the CCNL minimo absorb it (superminimo assorbibile). False keeps it whole on a renewal (assegno ad personam non assorbibile).

as_of date | None

Day on which :attr:monthly is the amount, required for an absorbable element: the increases of the minimo of the level from this day to the competence date of the run reduce it, down to zero.

extra_months bool

Whether the element is paid on the extra months of the CCNL (tredicesima, quattordicesima) too.

tfr_relevant bool

Whether the element enters the TFR base (art. 2120 c. 2 c.c.: every amount paid in connection with the employment, unless the agreement excludes it).

Raises:

Type Description
InvalidInputError

When a field is not of its type, monthly is not above zero, or an absorbable element has no as_of.

ccnl_engine.inputs.PriorYearTaxFacts dataclass

Prior-year income, written waivers and requests of the tax year.

The single source of the requirements the preferential regimes check: the premio di risultato (L. 208/2015 art. 1 c. 182, prior-year income up to 80,000 EUR), the renewal increments (L. 199/2025 art. 1 c. 7, 2025 income up to 33,000 EUR) and the night, holiday and shift supplements (L. 199/2025 art. 1 cc. 10-11, 2025 income up to 40,000 EUR). For a 2026 payment the prior year is 2025, the reference year of both L. 199/2025 regimes.

Attributes:

Name Type Description
employment_income Decimal | None

Employment income (reddito di lavoro dipendente) of the year before the tax year, in EUR, >= 0. None means not known: the PdR substitute rate is not applied and the L. 199/2025 regimes are unknown, so the result is provisional.

waived_regimes frozenset[SubstituteTaxRegime]

Regimes the worker renounced in writing; their amounts are taxed as ordinary income. String values are accepted and normalized.

shortfall_deferral ShortfallDeferralRequest | None

The worker's written request to have the IRPEF the conguaglio cannot withhold for lack of pay withheld on the payslips of the next year, with interest (art. 23 c. 3 DPR 600/1973). None: what is not withheld is communicated to the worker. Read on the conguaglio only.

foreign_taxes tuple[ForeignTaxPaid, ...]

Foreign tax paid on employment income of the tax year, one entry per State, credited at the conguaglio (art. 165 TUIR, art. 23 c. 3 DPR 600/1973). A list is accepted and stored as a tuple.

net_income_biennio tuple[Decimal, Decimal] | None

Reddito complessivo netto of the second and of the first year before the tax year, in EUR, each >= 0: the rate of the separate taxation of arrears is the one of half their sum (art. 21 cc. 1, 3 TUIR). None when not known.

special_supplement_requested bool

Whether the worker asked in writing, attesting employment_income, for the trattamento integrativo speciale of L. 199/2025 art. 1 cc. 18-20 (c. 20).

arrears_unused_deductions Decimal | None

The deductions of art. 12 and art. 13 cc. 1-2 TUIR the worker declared not used in the years of the una tantum the engine pays as arrears (art. 21 c. 4 TUIR), in EUR, >= 0. None when not declared.

pay_above_ccnl Decimal | None

The pay above the CCNL the worker received in the year before (superminimi, premi, other pay subject to contributions), in EUR, >= 0, which reduces the elemento perequativo "fino a concorrenza" (Federmeccanica art. 13). None when not stated: the run reads the individual elements and names the missing fact.

Raises:

Type Description
InvalidInputError

When employment_income is not a finite, non-negative Decimal, a waiver names no regime, shortfall_deferral is not a request, two foreign taxes name the same State, net_income_biennio is not two non-negative amounts, special_supplement_requested is not a bool, or arrears_unused_deductions or pay_above_ccnl is negative.

ccnl_engine.inputs.CurrentYearTaxFacts dataclass

Income of the tax year that enters the reddito complessivo.

The family deductions of art. 12 TUIR depend on the reddito complessivo of the worker, not on the income of this employment alone. The engine adds to its own projection of the employment income of the year:

reddito complessivo = this employment + other_employment_income
    + other_income - main_dwelling_income

The somma esente of L. 207/2024 art. 1 c. 4 adds the exempt share of the impatriati and researcher regimes (c. 9), exempt_regime_income.

Every amount is required: declaring no other income is a fact, stated with zeros (see :meth:employment_only). Without these facts the reddito complessivo is unknown, and a run whose family deductions depend on it is not payable; so is a run whose contributions could depend on the INPS base of other employments, unless the opening state states it.

Attributes:

Name Type Description
tax_year int

The tax year the income belongs to. Facts of another tax year are not used.

other_employment_income Decimal

Employment and pension income of the tax year from other employers or payers (e.g. a previous employer of the year), net of their exclusions, >= 0.

other_employment_inps_base Decimal

INPS base of the worker's other employments of :attr:tax_year, earlier or simultaneous, >= 0. It counts toward the IVS massimale and the additional 1% threshold of the runs whose competence year is :attr:tax_year, and is carried in their closing state (:class:~ccnl_engine.contribution.base.models.InpsBaseYtd).

other_income Decimal

Every other income of the tax year in the reddito complessivo (land and buildings, self-employment, rents under cedolare secca, art. 3 c. 7 D.Lgs. 23/2011), >= 0.

main_dwelling_income Decimal

Income of the main dwelling and its appurtenances included in other_income, excluded from the reddito complessivo of art. 12 (c. 4-bis), >= 0 and not above other_income.

exempt_regime_income Decimal

Exempt share of the income of the tax year under art. 44 c. 1 D.L. 78/2010 (researchers), art. 16 D.Lgs. 147/2015 or art. 5 D.Lgs. 209/2023 (impatriati), >= 0. It counts only in the reddito complessivo of the somma esente (L. 207/2024 art. 1 c. 9), not in that of the family deductions.

estimated_on date

Date the amounts were stated.

quality IncomeEstimateQuality

How the amounts are known.

prior_employers tuple[PriorEmployerIncome, ...]

Earlier employments of :attr:tax_year the worker asks the conguaglio to take in (art. 23 c. 4 DPR 600/1973), from their CU; their taxable income is part of other_employment_income and the conguaglio moves it into the tax of this employment (:mod:~ccnl_engine.irpef.prior.rules).

art15_expenses tuple[Art15Expense, ...]

The art. 15 TUIR charges of the year the employer withheld or paid under an agreement, which the conguaglio deducts (art. 23 c. 3 DPR 600/1973).

Raises:

Type Description
InvalidInputError

When a field is not of its type or in its range.

external_income property

Reddito complessivo of the year beyond this employment.

somma_esente_income property

Reddito complessivo beyond this employment for the somma esente.

L. 207/2024 art. 1 c. 9 adds the exempt share of the impatriati and researcher regimes to :attr:external_income.

employment_only(tax_year, estimated_on, quality=IncomeEstimateQuality.DECLARED) classmethod

Return the facts of a worker whose only income is this employment.

Returns:

Type Description
CurrentYearTaxFacts

Facts with every other income and the INPS base of other

CurrentYearTaxFacts

employments stated as zero.

ccnl_engine.inputs.IncomeEstimateQuality

Bases: StrEnum

How the income of :class:CurrentYearTaxFacts is known.

Attributes:

Name Type Description
CERTIFIED

Final amounts from a certification (Certificazione Unica of another employer) or from the worker's tax return.

DECLARED

The worker's declaration to the employer of the income expected in the year.

ESTIMATED

The employer's own estimate: enough for the runs of the year, not for the conguaglio, which then stays provisional.

ccnl_engine.inputs.ForeignTaxPaid dataclass

Tax paid in one foreign State on income taxed in Italy this year.

Attributes:

Name Type Description
country str

ISO 3166-1 alpha-2 code of the State, not "IT".

income Decimal

Foreign-source employment income as it entered the Italian taxable income of the tax year (the conventional pay when art. 51 c. 8-bis TUIR applies), in EUR, positive.

tax Decimal

Foreign tax paid on it "a titolo definitivo", in EUR, >= 0, within the rate of a tax treaty. Pass it already reduced as art. 165 c. 10 TUIR requires when the income entered the taxable income only in part: on the conventional pay, by the ratio of that pay to the income that would be taxable under art. 51 without c. 8-bis (circ. AdE 9/E/2015 par. 5).

earlier EarlierYearTax | None

The Italian tax of the earlier year the income entered, for a foreign tax paid on income of an earlier year; None for income of the tax year of the conguaglio.

Raises:

Type Description
InvalidInputError

When country is not an ISO code of a foreign State, or an amount is not a finite Decimal in its range.

ccnl_engine.inputs.ContributionExemption dataclass

The exemption of the employer contributions for one worker.

Attributes:

Name Type Description
measure ExemptionMeasure

The measure the employer was admitted to.

start date

The hire, or the conversion to a permanent contract, the exemption runs from.

share Decimal

The share of the contributions exempted: 0.7, or 1 with a net headcount growth (young and zes); 1 otherwise.

territorial bool

The site is in a region of DL 60/2024 art. 22 c. 3 (young: 650 EUR a month) or in the ZES unica (women: the code of the ZES).

made_permanent bool

A mothers hire made permanent: 18 months from start, the first hire.

Raises:

Type Description
InvalidInputError

When a field is not of its type, share is not 0.7 or 1, or a measure is given a fact it does not read.

ccnl_engine.inputs.ExemptionMeasure

Bases: StrEnum

The exemption measure the employer applies.

ccnl_engine.inputs.MothersExemption dataclass

The exemption of the IVS share of a working mother of three or more.

L. 213/2023 art. 1 c. 180: for the pay periods of 2024 to 2026, a mother of three or more children on a permanent contract does not pay her IVS contributions, up to 3,000 EUR a year, until the month her youngest child turns eighteen (INPS circ. 27/2024). The worker states it to the employer.

Attributes:

Name Type Description
youngest_child_born_on date

Birth day of the youngest child.

Raises:

Type Description
InvalidInputError

When the birth day is not a date.

ccnl_engine.inputs.ShortfallDeferralRequest dataclass

The worker's written authorization to defer the year-end shortfall.

Attributes:

Name Type Description
signed_on date

Date of the written request. It must fall between 1 January of the tax year and the end of February of the next one, the deadline of the conguaglio.

Raises:

Type Description
InvalidInputError

When signed_on is not a date.

check_for(tax_year)

Check that the request can defer the conguaglio of tax_year.

Raises:

Type Description
InvalidInputError

When signed_on is before the tax year or after the end of February of the next year.

ccnl_engine.inputs.SubstituteTaxRegime

Bases: StrEnum

Preferential regimes a worker can renounce in writing.

Each value is the regime_id of a bundled :class:PreferentialTaxRegime.

Attributes:

Name Type Description
RINNOVO

Contract-renewal increments (L. 199/2025 art. 1 c. 7).

NOTTE_FESTIVI_TURNI

Night, holiday and shift supplements (L. 199/2025 art. 1 cc. 10-11).

Garnishments and salary assignments

See Payroll state: garnishments and salary assignments.

ccnl_engine.inputs.PersonalWithholding dataclass

One garnishment order or salary assignment notified to the employer.

Attributes:

Name Type Description
withholding_id str

Non-blank reference of the order or contract, unique within the employment; the closing state carries what was withheld to date under it.

kind PersonalWithholdingKind

What it is withheld for; its string value is accepted.

notified_on date

Day the order or the contract was notified to the employer. It ranks the deductions: an earlier one keeps its amount and a later one takes what the combined limits leave (art. 68-70 DPR 180/1950).

starts_on date

First payment date it applies to, not before notified_on: a cessione takes effect from its notification (art. 1 DPR 180/1950).

total_due Decimal

Amount due to the creditor when the deduction starts on this payroll, above zero: the loan to repay, or the credit and costs of the order. For a deduction started on another payroll, what is left of it.

installment Decimal | None

Monthly installment of a salary assignment or a payment delegation, or monthly measure of a maintenance order, above zero; for a garnishment the monthly amount the ordinanza di assegnazione sets, needed when two garnishments of one kind share its measure (art. 553 c.p.c.), else None: the legal fraction of the net pay.

Raises:

Type Description
InvalidInputError

When a field is not of its type, starts_on precedes notified_on, total_due is not above zero, or installment is missing for a kind that states it.

ccnl_engine.inputs.PersonalWithholdingKind

Bases: StrEnum

What the employer withholds for, which sets the legal limit.

Attributes:

Name Type Description
SALARY_ASSIGNMENT

Cessione del quinto: a loan repaid by assigning up to a fifth of the net pay (art. 5 and 52 DPR 180/1950).

PAYMENT_DELEGATION

Delegazione di pagamento: a further installment the employer accepted to pay to a lender (art. 69 and 70 DPR 180/1950).

MAINTENANCE

Garnishment for maintenance (crediti alimentari), in the measure the judge authorized (art. 545 c. 3 c.p.c.).

TAX

Garnishment for taxes due to the State, the provinces or the municipalities (art. 545 c. 4 c.p.c.).

TAX_COLLECTION

Garnishment by the agente della riscossione (art. 72-ter DPR 602/1973; art. 171 D.Lgs. 33/2025 from 2027).

ORDINARY

Garnishment for any other credit (art. 545 c. 4 c.p.c.).

Calendar and engine mode

ccnl_engine.inputs.WorkCalendar dataclass

Year-level payroll calendar with extra-month schedule.

Attributes:

Name Type Description
year int

The tax year this calendar applies to.

extra_months tuple[ExtraMonthSchedule, ...]

Ordered tuple of extra-month payment schedules. A list is accepted and stored as a tuple.

Raises:

Type Description
InvalidInputError

When year is not an int from 1970, an extra month is not an :class:ExtraMonthSchedule, a kind appears twice, or a fourteenth month comes without a thirteenth.

entitlement property

Equivalent months of pay granted by this calendar.

Twelve regular months plus the max_fraction of each extra month, so a full tredicesima and half a quattordicesima give 13.5.

from_additional_months(year, additional_months, *, thirteenth_payment_month=12, fourteenth_payment_month=6) classmethod

Build a calendar from a CCNL additional_months parameter.

Accepts fractional values (e.g. Decimal("13.5")). A fractional fourteenth month is added with :attr:ExtraMonthSchedule.max_fraction set to the fractional part so the caller receives the correct partial entitlement without discarding it.

For additional_months=13 (12 regular + 1 tredicesima) this produces one :class:ExtraMonthSchedule paid in December. For additional_months=14 it produces tredicesima (December) and quattordicesima in fourteenth_payment_month (default June). For additional_months=13.5 it produces tredicesima (full) and a half quattordicesima (max_fraction=Decimal("0.5")).

Parameters:

Name Type Description Default
year int

Tax year.

required
additional_months int | Decimal | ExtraMonthEntitlement

Value from CCNL parameters (13, 13.5 or 14), as :class:ExtraMonthEntitlement, int or Decimal. Fractional parts are preserved.

required
thirteenth_payment_month int

Calendar month for the tredicesima. Defaults to December (12).

12
fourteenth_payment_month int

Calendar month for the quattordicesima. Defaults to June (6).

6

Returns:

Type Description
WorkCalendar

class:WorkCalendar with up to two extra schedules.

Raises:

Type Description
InvalidInputError

When additional_months is outside the range [12, 14], or strictly between 12 and 13: a partial tredicesima is not a supported calendar and would otherwise be dropped silently.

ccnl_engine.inputs.CalendarOverride dataclass

A calendar that replaces the CCNL standard one, with its reason.

Attributes:

Name Type Description
calendar WorkCalendar

The calendar to run instead of the standard one.

reason CalendarOverrideReason

Why the standard calendar does not apply.

note str

Free-text justification kept for audit, e.g. the CCNL article or the agreement that sets the payment month. Must not be blank.

Raises:

Type Description
InvalidInputError

When calendar is not a :class:WorkCalendar, reason is not a :class:CalendarOverrideReason or note is blank.

resolve(standard)

Validate the override against the standard calendar and return it.

Rules, compared per :class:ExtraMonthKind on max_fraction (names are free):

  • the override is for the same year as standard;
  • every extra month accrues over the 12 months ending in its payment month (accrual_window_start_month == payment_month % 12 + 1), so it pays its full fraction; a tredicesima is therefore paid in December;
  • every extra month of standard is kept with at least its fraction, whatever the reason;
  • :attr:CalendarOverrideReason.PAYMENT_MONTH: the fractions equal the standard ones, no extra month is added;
  • :attr:CalendarOverrideReason.MORE_FAVOURABLE_TREATMENT: at least one extra month is added or has a larger fraction.

Parameters:

Name Type Description Default
standard WorkCalendar

Calendar derived from the CCNL for the same year.

required

Returns:

Type Description
WorkCalendar

attr:calendar, the effective calendar of the year.

Raises:

Type Description
InvalidInputError

When any rule is broken.

ccnl_engine.inputs.CalendarOverrideReason

Bases: StrEnum

Domain reason for replacing the standard calendar of a CCNL.

The list is deliberately short. Paying the ratei monthly inside the regular pay (mensilizzazione) is real practice, but the engine does not pay ratei in regular runs, so an override that drops extra-month runs would underpay the worker; no reason allows it.

Members

PAYMENT_MONTH: The CCNL article or the employer's practice pays an extra month in a different month than the engine default (quattordicesima in June), e.g. a quattordicesima paid with the July salary. The extra months and their fractions must equal the ones the CCNL grants. MORE_FAVOURABLE_TREATMENT: An individual or company agreement grants more than the CCNL (trattamento di miglior favore, art. 2077 c.c.): an extra month the CCNL does not grant, or a larger fraction of one it grants. Every CCNL extra month must be kept at least at its CCNL fraction, and at least one must be larger or added.

ccnl_engine.inputs.EngineMode

Bases: StrEnum

Payability policy of a payroll engine.

Attributes:

Name Type Description
SIMULATION

Amounts with their assurance; readiness is reported only.

OPERATIONAL

Amounts are payable only from production rulesets.

Opening state and imported balances

ccnl_engine.inputs.PeriodState dataclass

State entering a payroll run: what is accrued and what is paid.

Pass :meth:zero for the first run of an employment. Between runs, pass the closing_state of the previous run. To open the next tax year, pass the closing state of the last run of the year to :func:~ccnl_engine.year.tax_year.closing.rules.close_tax_year: it restarts :attr:cash with its obligations and keeps :attr:accrual.

A run that opens without the history of the employment before it (a zero state after the start of the employment, or a state descending from such a run) is computed as a simulation with a missing_fact opening_state blocker, and its closing state has :attr:history_known False, so every later run of the chain blocks too. The same holds for the closing state of a conguaglio of a withholding agent computed without the worker's residence: it determines no surtax of the year and opens none of the obligations of the next. Import the balances of the previous provider, or recompute the chain with the missing facts, to restart from a known history.

A run closes once (its competence run in :attr:accrual) and is paid once (its payment in :attr:cash). The same request on the same opening state yields the same closing state; a state that already closed the run rejects it, so a retry never counts a payment twice.

Attributes:

Name Type Description
accrual EmploymentAccrualState

Competence runs closed over the employment; carried across tax years.

cash TaxCashState

Payments, YTD accounts and carried obligations of the current tax year; the payments and accounts restart every tax year.

history_known bool

Whether the state accounts for every run of the employment before it. The engine sets it False on the closing state of a run that opened without that history, or of a conguaglio without the residence; a state the caller builds states it.

Raises:

Type Description
InvalidInputError

When a field is not of its type, or a payment of :attr:cash settles a run :attr:accrual has not closed.

tax_year property

Tax year of :attr:cash; None when not yet bound to a year.

check_next(payment)

Check that payment and the run it settles can close next.

A run already closed or out of order in its competence year, or a payment that cannot close in the tax year, raises InvalidInputError.

zero() classmethod

Return the state of a new employment: no run closed, no obligation.

Returns:

Name Type Description
A PeriodState

class:PeriodState with all counters and accumulators at zero.

ccnl_engine.inputs.period_state_from_json(text)

Return the state written by :func:period_state_to_json.

A state written by another engine or knowledge-bundle version reads back: those versions stay in the text, for audit. A state of an earlier schema is migrated to the current one. A text that is not such JSON, of a schema newer than this engine or older than the first one persisted, or that names a type outside the persisted state raises :class:~ccnl_engine.errors.InvalidInputError: recompute the runs, or import the balances with :class:~ccnl_engine.balance.opening.provider.services.OpeningBalances.

Returns:

Type Description
PeriodState

The state, its invariants checked by its constructors.

ccnl_engine.inputs.period_state_to_json(state)

Return state as JSON text, with its schema, engine and bundle versions.

Returns:

Type Description
str

The JSON text of the state.

ccnl_engine.inputs.OpeningBalances dataclass

Progressive totals of a tax year computed outside the engine.

Every amount is in EUR, non-negative and with at most two decimals; an amount left None (a *_due) is not known. The totals are validated by the same rules as the state the engine produces (:class:~ccnl_engine.balance.models.PeriodState); a violation is raised as InvalidInputError. A tax-year total without the payments that produced it is rejected: it could not be told apart from the payments the engine would compute again. The INPS bases and the obligations carried from an earlier run have no default: what the previous provider determined is a fact the import states, () when there is none.

Attributes:

Name Type Description
tax_year int

Tax year of the totals.

payments tuple[PaymentId, ...]

The payments already made this tax year, in payment order (:meth:~ccnl_engine.calendar.payment.models.PaymentId.parse reads "2026-12-regular@2027-01-13"), whatever their competence year. Each must belong to tax_year; its run is closed, so it is rejected if computed again, and each takes a slot of the withholding schedule of the year but an adjustment.

competence_runs tuple[PayrollRunId, ...]

Runs closed in earlier tax years that a run still to compute must follow: with December 2026 paid on 13 January 2027, the other 2026 runs paid in 2026. Payments of tax_year go in payments, not here.

inps_bases tuple[InpsBaseYtd, ...]

Required. INPS base toward the IVS massimale per competence year: this employment's (own) and the worker's other employments of the same year (other_employers, from their CU or the worker's declaration; INPS circ. 237/2016 par. 3.1; None when not known, which blocks the runs whose contributions could depend on it), with the additional 1% IVS each withheld on it (additional_ivs, other_employers_additional_ivs). Every competence year of payments and competence_runs needs its base; import the year before too when its December is paid in tax_year.

sickness_episodes tuple[SicknessEpisode, ...]

Sickness episodes of the employment up to the last processed day, in start order: they set the waiting period, INPS days and CCNL tier of later episodes.

sickness_known_from date | None

First day from which sickness_episodes list every sick day of the employment: the first day of the employment when they list all of them. None states the episodes of tax_year only (from 1 January). A CCNL that counts the sickness of earlier years (Federmeccanica: the comporto over three years) has a missing_fact blocker when the days before it could change a sick day it pays.

gross Decimal

Contractual gross earnings paid.

taxable Decimal

IRPEF taxable income.

inps_employee Decimal

Employee INPS contributions withheld.

pension_deducted Decimal

Pension fund contributions already deducted from the taxable income (D.Lgs. 252/2005 art. 8 c. 4).

irpef_withheld Decimal

IRPEF withheld.

surtax_withheld Decimal

Regional and municipal surtax withheld.

municipal_advance_withheld Decimal

Part of surtax_withheld withheld as the municipal acconto of tax_year (D.Lgs. 360/1998 art. 1 c. 5); the conguaglio deducts it from the municipal surtax.

regional_settled Decimal

Regional surtax of tax_year a conguaglio at the end of an earlier employment of the year already withheld.

municipal_settled Decimal

Municipal saldo of tax_year withheld the same way.

fringe_value Decimal

Fringe benefit value granted (Art. 51 c. 3 TUIR).

fringe_taxed Decimal

Part of fringe_value already taxed.

pdr Decimal

Premio di Risultato taxed at the substitute rate.

trattamento_recognized Decimal

Trattamento integrativo paid.

trattamento_recovered Decimal

Trattamento integrativo already recovered.

trattamento_due Decimal | None

Annual trattamento integrativo last computed by the previous provider, None when not known.

trattamento_reason str | None

Lower snake case reason of that amount, e.g. "full_amount", None when not known.

somma_esente_recognized Decimal

Somma esente (L. 207/2024) paid.

somma_esente_recovered Decimal

Somma esente already recovered.

somma_esente_due Decimal | None

Annual somma esente last computed, or None.

somma_esente_reason str | None

Reason of that amount, or None.

ulteriore_recognized Decimal

Ulteriore detrazione (L. 207/2024 art. 1 c. 6) already applied by the withholding.

ulteriore_recovered Decimal

Ulteriore detrazione already taken back.

ulteriore_due Decimal | None

Annual ulteriore detrazione last computed, or None.

ulteriore_reason str | None

Reason of that amount, or None.

irpef_shortfall Decimal

IRPEF due on earlier runs and not yet withheld for lack of pay.

surtax_shortfall Decimal

Surtax due on earlier runs and not yet withheld.

credit_recovery_shortfall Decimal

Credit recoveries (trattamento integrativo, somma esente, installments) due on earlier runs and not yet withheld for lack of pay.

work_time_regime_used Decimal

Night, holiday and shift supplements already taxed at the substitute rate (L. 199/2025 art. 1 cc. 10-11).

recoveries tuple[RecoveryObligation, ...]

Required. Installment recoveries still running, from this tax year or an earlier one; () states that there is none.

surtax_obligations tuple[SurtaxObligation, ...]

Surtax determined by the conguaglio of an earlier tax year and not yet withheld: the regional surtax and municipal saldo of tax_year - 1 and the municipal acconto of tax_year, by the installments still to post. Required: the engine withholds no surtax the previous provider determined unless it is stated here; () states that there is none.

deferred_shortfall DeferredShortfall | None

IRPEF the conguaglio of tax_year - 1 deferred on the worker's written request (art. 23 c. 3 DPR 600/1973) and not yet withheld, None without one.

employment_spells tuple[EmploymentSpell, ...]

Days in tax_year of the employments whose income the totals hold, when they hold an earlier employment with this employer (a rehire): the art. 13 TUIR deduction counts their union. () states none: the next run adds the days of its own employment.

tfr_quotas tuple[TfrQuotaYtd, ...] | None

TFR the payments and competence runs accrued with the employer, per competence year (the quotas net of the additional IVS, posted to the company or to the Fondo Tesoreria INPS). None means not known: a termination in tax_year or earlier whose TFR the engine computes then has a missing_fact tfr_quotas blocker; the runs of the next years count their own.

leave_balances tuple[LeaveBalance, ...] | None

Balances of ferie, ROL and ex festività of the employment the previous provider kept, per bucket and year of accrual, in bucket then year order; () states that none is left. None means not known: the run that closes the employment pays no residual leave and has a missing_fact blocker.

ccnl_engine.inputs.InpsBaseYtd dataclass

INPS base of one competence year, toward the massimale and the 1% band.

Attributes:

Name Type Description
year int

The competence year.

own Decimal

INPS base of the runs of this employment of :attr:year.

other_employers Decimal | None

INPS base of the worker's other employments of :attr:year, earlier or simultaneous, as certified (CU) or declared by the worker. It counts toward the massimale and the band of the additional 1% IVS and is never contributed by this employer. None means not known: a run whose contributions could depend on it has a missing_fact blocker; 0 states that there is none.

additional_ivs Decimal

Additional 1% IVS (D.L. 384/1992 art. 3-ter) this employment withheld on the pay of :attr:year, net of what its conguagli gave back. Negative only when a conguaglio refunded more than this employment withheld, giving back what other employers withheld (INPS circ. 156/2025 par. 5).

other_employers_additional_ivs Decimal | None

Additional 1% IVS the other employments withheld on :attr:other_employers, as certified; the conguaglio deducts it from the 1% due on the year. None when not stated: with a base of other employers the conguaglio then cannot be settled (:attr:other_employers_withheld_unknown).

month int | None

Competence month of the latest run of this employment, None before the first run of :attr:year.

month_base Decimal

INPS base of the runs of this employment of :attr:month: the runs of one month share its threshold of the additional 1% IVS.

Raises:

Type Description
InvalidInputError

When a field is not of its type, an amount other than :attr:additional_ivs is negative, an amount is not finite, or :attr:month_base is not zero without a month.

other_employers_known property

Whether the base of the other employments is stated.

total property

Base of the year toward the massimale: own and other employers.

An unknown base of other employers counts as zero: the run computes on this employment alone and reports the missing fact.

additional_ivs_withheld property

Additional 1% IVS withheld on the year by every employment.

An unstated 1% of other employers counts as zero here; see :attr:other_employers_withheld_unknown.

other_employers_withheld_unknown property

Whether other employers have a base but their 1% is not stated.

stating_other_employers(amount)

Return the base with the other employers' base stated as amount.

Returns:

Type Description
InpsBaseYtd

A new base with other_employers set and every other field

InpsBaseYtd

unchanged.

base_of_month(month)

Return the INPS base this employment already declared for month.

Returns:

Type Description
Decimal

attr:month_base when month is :attr:month, else zero.

plus(amount, month, additional_ivs=_ZERO)

Return the base after a run of this employment of month.

Parameters:

Name Type Description Default
amount Decimal

INPS base of the run.

required
month int

Competence month of the run.

required
additional_ivs Decimal

Additional 1% IVS the run withheld, negative when its conguaglio gave some back.

_ZERO

Returns:

Type Description
InpsBaseYtd

A new base with own raised by amount and the base of

InpsBaseYtd

month by the same amount.

ccnl_engine.inputs.LeaveBalance dataclass

Leave of one bucket accrued in one year: accrued, taken and paid.

Attributes:

Name Type Description
bucket LeaveBucket

The bucket of leave.

year int

Calendar year the leave accrued in.

accrued_twelfths Decimal

Twelve times the days or hours accrued: the yearly entitlement of each month credited, summed.

taken_twelfths Decimal

Twelve times the days or hours taken against the balance.

settled bool

Whether the residual was paid (at the end of the employment): a settled balance has no residual left.

exact bool

Whether every month credited was computed from known facts and sourced rules; False when a month rests on an estimate (a month fraction the CCNL text does not rule on, an unknown seniority or hire date, an absence whose effect on the accrual is not stated).

Raises:

Type Description
InvalidInputError

When a field is not of its type, the year is not plausible or an amount is negative.

accrued property

Days or hours accrued: :attr:accrued_twelfths over twelve.

taken property

Days or hours taken: :attr:taken_twelfths over twelve.

residual_twelfths property

Twelve times the residual, zero once settled; negative when overdrawn.

residual property

Days or hours left: accrued less taken, zero once paid.

paid property

Days or hours paid at the settlement, zero before it.

ccnl_engine.inputs.PaymentId dataclass

Identifier of one payment: the run it pays and its payment date.

The text form is "{run_id}@{payment_date}", e.g. "2026-12-regular@2027-01-13". A run is paid once, so the run id alone identifies the payment within an employment; the date fixes the tax year the payment belongs to.

Attributes:

Name Type Description
run_id PayrollRunId

The competence run the payment settles.

payment_date date

Day the run is paid, not before the first day of the run month.

Raises:

Type Description
InvalidInputError

When a field is not of its type or the payment precedes the run month.

competence property

First day of the run month.

tax_year property

Tax year of the payment (TUIR art. 51 c. 1, cassa allargata).

is_prior_competence property

Whether the payment settles a run of a year before its tax year.

parse(text) classmethod

Parse the text form "{run_id}@{payment_date}".

Parameters:

Name Type Description Default
text str

A payment id such as "2026-12-regular@2027-01-13".

required

Returns:

Type Description
PaymentId

The typed identifier. A text that is not a well-formed

PaymentId

payment id raises

PaymentId

class:~ccnl_engine.errors.InvalidInputError.

ccnl_engine.inputs.PayrollRunId dataclass

Typed identifier of a payroll run: year, month, kind and sequence.

The text form is "{year}-{month:02d}-{kind}", e.g. "2026-12-thirteenth", as in :attr:PayrollRun.run_id. A month has at most one run of each kind, except adjustment runs: the second and later adjustments of a month carry their sequence number as a suffix, e.g. "2026-12-adjustment-2".

Attributes:

Name Type Description
year int

Year of the run month (the competence year). The tax year of the run follows from its payment date and can be later.

month int

Run month, 1-12.

kind RunKind

Kind of the run.

sequence int

Number of the run among the runs of its kind and month, from 1. Above 1 only for an adjustment run.

order_key property

Key ordering the runs as they are paid: year, month, kind rank, sequence.

payment_key property

Key of what the run pays, closed once per employment.

A regular, termination or adjustment run pays its month, an adjustment once per sequence number; a tredicesima or quattordicesima pays the extra month of its year, whatever month it is paid in: the quattordicesima of 2027 is the same entitlement paid in June or in July.

parse(text) classmethod

Parse the text form of :meth:__str__.

Parameters:

Name Type Description Default
text str

A run id such as "2026-06-fourteenth" or "2026-12-adjustment-2".

required

Returns:

Type Description
PayrollRunId

The typed identifier. A text that is not a well-formed run

PayrollRunId

id, or not in its canonical form (a "-1" or "-02"

PayrollRunId

suffix), raises

PayrollRunId

class:~ccnl_engine.errors.InvalidInputError.

ccnl_engine.inputs.RecoveryObligation dataclass

An installment recovery and the tax year of the credit it recovers.

Attributes:

Name Type Description
tax_year int

Tax year whose conguaglio found the credit not due. The installments posted in that year enter the recovered total of its :class:~ccnl_engine.balance.cash.account.models.CreditAccount; those posted in a later year are carried: they are deducted on the payslip but belong to no account of the later year.

plan RecoveryPlan

The installment plan, with the installments still to post.

post(run)

Return what run recovers and the obligation after it.

Returns:

Type Description
PostedInstallment

meth:RecoveryPlan.post of the plan and the obligation still

RecoveryObligation | None

running, None once the plan is settled.

ccnl_engine.inputs.RecoveryPlan dataclass

Structured installment plan for recovering an over-paid tax credit.

Created when the amount to recover exceeds 60 EUR, to spread the recovery over equal installments: eight for the trattamento integrativo (D.L. 3/2020 art. 1 co. 3), ten for the somma esente (L. 207/2024 art. 1 c. 7). The last installment absorbs any rounding residual so the sum is always exactly original_amount.

Attributes:

Name Type Description
kind str

Identifier for the credit being recovered, e.g. "trattamento_integrativo" or "somma_esente".

original_amount Decimal

Total amount to recover (positive).

installment_amount Decimal

Uniform per-period deduction (positive, rounded).

installments_total int

Number of periods over which the recovery runs.

installments_posted int

Number of installments already deducted.

residual property

Amount not yet recovered.

next_installment property

Amount to deduct this period.

The last installment uses the residual to absorb rounding.

post(run)

Return what run recovers of the plan.

The single rule shared by every recovered credit: the next installment on an ordinary or adjustment run, the whole residual on the final run of the employment.

Parameters:

Name Type Description Default
run InstallmentRun

The run the installment is posted on.

required

Returns:

Type Description
PostedInstallment

The amount recovered, its reason and the plan still running.

advance()

Return a plan with installments_posted incremented by one.

Returns:

Type Description
RecoveryPlan

A new :class:RecoveryPlan one period further along.

create(kind, original_amount, installments_total) classmethod

Create a fresh plan from the original recovery amount.

Parameters:

Name Type Description Default
kind str

Credit identifier.

required
original_amount Decimal

Total amount to recover (positive).

required
installments_total int

Number of periods to spread across.

required

Returns:

Name Type Description
A RecoveryPlan

class:RecoveryPlan with installments_posted=0 and

RecoveryPlan

installment_amount set to original_amount / installments_total

RecoveryPlan

rounded to two decimal places.

ccnl_engine.inputs.SurtaxComponent

Bases: StrEnum

Part of the surtax a conguaglio determines.

REGIONAL_BALANCE = 'regional_balance' class-attribute instance-attribute

Regional surtax of the tax year (it has no acconto).

MUNICIPAL_BALANCE = 'municipal_balance' class-attribute instance-attribute

Municipal surtax of the tax year less the acconto withheld in it.

MUNICIPAL_ADVANCE = 'municipal_advance' class-attribute instance-attribute

Municipal acconto of the next tax year.

ccnl_engine.inputs.SurtaxObligation dataclass

Surtax a conguaglio determined, still to withhold in the next year.

Attributes:

Name Type Description
component SurtaxComponent

What the amount is.

tax_year int

Tax year whose conguaglio determined it; it is withheld in tax_year + 1.

jurisdiction str

Region code (ISO 3166-2:IT) or Belfiore code of the municipality it is due to: the one of the tax year of the conguaglio, not of the year it is withheld in.

plan RecoveryPlan

The installments still to post; plan.kind is the component value.

window property

Installment window of the component.

withheld_in property

Tax year whose payslips withhold the installments.

reference_year property

Tax year the surtax is due for: the next one for the acconto.

open(component, tax_year, jurisdiction, amount) classmethod

Return the obligation of amount over the window.

An amount below one cent per installment runs over fewer installments, so that none is zero.

Returns:

Type Description
SurtaxObligation

The obligation with no installment posted.

Raises:

Type Description
ValueError

When amount is below one cent.

part(amount)

Return amount withheld of this obligation as a run part.

Returns:

Type Description
SurtaxPart

The part of the component and reference year.

post(run, *, year, month, regular)

Return what a run of year and month withholds of it.

The last run of the employment withholds the residual. Otherwise a regular run of the window withholds the next installment, and the one of the last month, or any regular run after the window, the residual; nothing is withheld before the window, on another kind of run, or before :attr:withheld_in.

Returns:

Type Description
PostedInstallment | None

What the run withholds, None when nothing, and the

SurtaxObligation | None

obligation after it, None once settled.

ccnl_engine.inputs.DeferredShortfall dataclass

IRPEF of a conguaglio deferred on the worker's written request.

Attributes:

Name Type Description
tax_year int

Tax year whose conguaglio found the shortfall; it is withheld in tax_year + 1.

signed_on date

Date of the written request.

deferred_from date

First day of the pay period of the conguaglio: the interest runs from its month.

irpef Decimal

IRPEF still to withhold, positive.

withheld_in property

Tax year whose payslips withhold the deferred IRPEF.

months_to(year, month)

Whole months from the conguaglio month to year and month.

Returns:

Type Description
int

The number of months, at least zero.

due_in(year, month)

Whether a payslip of year and month may withhold it.

Returns:

Type Description
bool

True from March of :attr:withheld_in to its December.

post(available, year, month)

Return what a payslip leaving available pay withholds of it.

The principal is the largest amount whose interest still fits in available, at most the residual.

Returns:

Type Description
DeferredInstallment | None

The installment, None when nothing fits, and the shortfall

DeferredShortfall | None

left after it, None once exhausted.

JSON form of a request

request_to_json writes a PeriodInput, a CompetenceYearPlan or a TaxYearPlan as JSON, and request_from_json reads it back equal, through the constructors of every value, so a request read from JSON is validated like one built in Python. Each value is tagged with its type ({"$type": "Employment", "fields": {...}}, {"$enum": ...}); decimals are strings ({"$decimal": "1234.50"}), dates ISO 8601 ({"$date": "2026-01-28"}), and run-keyed maps keep their int or str keys ({"$map": [[3, ...], ["2026-12-thirteenth", ...]]}). The envelope carries schema_version, bumped when a field changes; unlike a persisted state, a request carries no engine or bundle version and reads across releases.

ccnl_engine.inputs.request_to_json(request)

Return request as JSON text, with its schema version.

Decimals are written as strings and dates in ISO 8601, so the text reads back equal with :func:request_from_json.

Returns:

Type Description
str

The JSON text of the request.

ccnl_engine.inputs.request_from_json(text, kind)

Return the request of type kind written by :func:request_to_json.

Every value is rebuilt through its constructor, so the request is validated as if built in Python. A text that is not such JSON, of another schema version or holding another kind of request raises :class:~ccnl_engine.errors.InvalidInputError, and so does the first rejected value, with its path, e.g. "PeriodInput.facts.events[1].hours", as field.

Parameters:

Name Type Description Default
text str

The JSON text.

required
kind type[R]

:class:~ccnl_engine.PeriodInput, :class:~ccnl_engine.CompetenceYearPlan or :class:~ccnl_engine.TaxYearPlan.

required

Returns:

Type Description
R

The request.

validate_request_json reads the same JSON and returns every error at once instead of raising the first, for a batch import that shows a row all its problems: each InvalidInputError carries the path of the rejected value from the root, e.g. PeriodInput.facts.events[1].hours, and an empty tuple means the request reads. An object reports at most one error of its own, and only once its children are valid; the CCNL and the level are checked by the run, not here.

ccnl_engine.inputs.validate_request_json(text, kind)

Return every error of the request of type kind in text.

text is the JSON of :func:~ccnl_engine.inputs.request_to_json. Each error is an :class:~ccnl_engine.errors.InvalidInputError whose field is the path of the rejected value from the root, e.g. "PeriodInput.facts.events[1].hours". A text that is not such JSON, of another schema version or of another kind of request is one error with no field: no value can be read.

What is checked is what the constructors check, so a text without errors reads with :func:~ccnl_engine.inputs.request_from_json. An object reports at most one error of its own, the first its constructor finds, and is checked only once its children are valid. Whether the bundle holds the CCNL and the level is not checked: the run reports it.

Parameters:

Name Type Description Default
text str

The JSON text.

required
kind type[R]

:class:~ccnl_engine.PeriodInput, :class:~ccnl_engine.CompetenceYearPlan or :class:~ccnl_engine.TaxYearPlan.

required

Returns:

Type Description
tuple[InvalidInputError, ...]

The errors in the order of the JSON, () when it is valid.