cadrumo.domain.contribuyente.meses_trabajo module

The one grammar for the months a mother met the Art. 81.1 requirements.

Art. 81.2 prorates its guardería increment by “el número de meses en que se cumplan de forma simultánea los requisitos exigidos en el artículo 81.1 y 2”, which is an intersection of two month SETS. A count cannot express it: a mother entitled May to August against nursery paid January to June overlaps in two months, and the manual works exactly that case to 1.000 ÷ 12 × 2 = 166,67 while a count-based min(4, 6) yields four and 333,33 — an over-grant of the deducción, which under-declares tax.

This module is why the months are now carried rather than counted. It shares the month-specification grammar with guarderia_mensual rather than restating it, so the two descendant month surfaces cannot drift into accepting different forms through different doors.

Accepted form:

MM[;MM...]
MM-MM              (an inclusive month range)

Ranges are INPUT only. serialise_meses_trabajo() always emits the expanded, month-sorted MM form, so the stored fact has exactly one representation and a save-then-reload round-trip is byte-stable regardless of which form the operator typed.

Every malformed input REFUSES rather than dropping the offending month. A month that vanished between typing and storage would silently change the proration basis, and this set exists precisely to stop the basis being guessed.

MESES_TRABAJO_ACCEPTED_FORM

The accepted form, quoted verbatim in every refusal so the operator is told what to write rather than only what was wrong.

parse_meses_trabajo(raw, *, field)[source]

Parse the worked-months grammar into canonical, ascending months.

Parameters:
  • raw (str) – The operator-supplied months. A blank string yields an empty tuple, which means “no qualifying months declared”.

  • field (str) – The path or key naming this value in a refusal, so the operator is told which descendant and which door the bad value came through.

Return type:

tuple[int, ...]

Returns:

The declared months, ascending, with every range expanded and no repeats.

Raises:

ProfileAnswerTypeError – If any entry is malformed, names a month outside 1-12, inverts a range, or repeats a month.

serialise_meses_trabajo(months)[source]

Render months in the one canonical form, ascending.

Ranges are never emitted, so the stored fact has exactly one representation for a given set and the fact index, the wizard’s resume projection and the CLI payload round-trip byte-for-byte whichever form was typed.

Return type:

str

Parameters:

months (Iterable[int])