cadrumo.core.amendment_kind_regime module

Period-aware amendment mechanics driven by a registry policy projection.

The registry projection owns the dated procedure vocabulary and adoption boundaries. This core module only compares a period with a supplied policy and returns the corresponding regime; it deliberately contains no legal catalogue or model-specific boundary defaults.

See also

cadrumo.domain.calculations.registry.amendment_regime_policy:

Typed resolver for the selected governed policy fact.

class AmendmentLiabilityDirection(*values)[source]

Bases: StrEnum

Direction of an amendment’s effect on the taxpayer’s declared liability.

Under the pre-rectificativa dual regime, the direction determines which of the two legally-distinct procedures applies: an INCREASE (the corrected resultado raises the tax due, or lowers a requested devolución) is a complementaria (LGT art. 122.2); a DECREASE (the corrected resultado lowers the tax due, or raises a requested devolución) requires the solicitud de rectificación procedure (LGT art. 120.3) rather than a self-filed complementaria. Post-rectificativa, the direction no longer selects a different legal mechanism (both raise and lower route through the unified rectificativa), so this classification is only load-bearing for pre-rectificativa periods.

INCREASE
DECREASE
UNCHANGED
class AmendmentRegimePolicy(rectificativa_effective_from, pre_rectificativa_kinds, post_rectificativa_kinds)[source]

Bases: object

Registry-projected amendment policy consumed by core mechanics.

The core layer deliberately owns only the date comparison and regime selection mechanics. Procedure vocabulary and adoption boundaries are supplied by the selected, validated registry fact through this typed projection; an absent or malformed projection therefore fails closed at the registry boundary instead of falling back to a Python catalogue.

Parameters:
rectificativa_effective_from: Mapping[str, date]
pre_rectificativa_kinds: frozenset[str]
post_rectificativa_kinds: frozenset[str]
class AmendmentKindRegime(permitted_kinds, rectificativa_effective)[source]

Bases: object

The codified amendment-kind regime resolved for one (modelo, period).

Variables:
  • permitted_kinds – The closed set of CalculationRevisionAmendmentKind string values legally available for this modelo and period. "sustitutiva" is always permitted (a material restatement is never barred by the rectificativa timeline); "rectificativa" is permitted only once the modelo’s own effective period is reached; "complementaria" is permitted only before that point (once rectificativa applies, it replaces complementaria for the modelo’s ordinary corrective filings — see CalculationRevisionAmendmentKind.RECTIFICATIVA’s docstring).

  • rectificativa_effective – Whether the resolved period is within the modelo’s rectificativa-supported window (True) or the pre-rectificativa dual regime still applies (False).

Parameters:
permitted_kinds: frozenset[str]
rectificativa_effective: bool
resolve_amendment_kind_regime(modelo, period, *, policy, rectificativa_effective_from=None)[source]

Resolve the codified amendment-kind regime for modelo at period.

Returns an AmendmentKindRegime naming the legally-permitted CalculationRevisionAmendmentKind string values for this (modelo, period) pair. A modelo with no registry- declared boundary always resolves to the projected pre-rectificativa pair; the core never invents rectificativa support.

For a period with no calendar date span (an instalment clave or an extended/ad-hoc form), the resolution falls back to filing_year >= <the modelo's boundary year> using the boundary date’s year, since no calendar comparison is possible for those forms.

policy is the typed projection of the selected amendment-regime fact. rectificativa_effective_from is an explicit mechanics seam for a caller that has already projected an alternate boundary mapping; it does not provide a default policy or a fallback vocabulary.

Return type:

AmendmentKindRegime

Parameters:
classify_amendment_liability_direction(*, baseline_result, corrected_result)[source]

Classify whether a correction increases, decreases, or leaves liability unchanged.

baseline_result and corrected_result are the modelo’s signed final result casilla value (a positive value means “a ingresar” tax due; a negative value means a credit or refund position, modelo-dependent) before and after the operator’s overrides. An increase in the signed result (a higher amount to pay, or a lower credit/refund) is INCREASE (LGT art. 122.2, complementaria territory); a decrease is DECREASE (LGT art. 120.3, solicitud de rectificación territory pre-unification). Equal values are UNCHANGED.

Accepts any Decimal-comparable numeric type so callers do not need to import decimal solely to call this classifier.

Return type:

str

Parameters:
  • baseline_result (SupportsAllComparisons)

  • corrected_result (SupportsAllComparisons)