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:
StrEnumDirection 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 acomplementaria(LGT art. 122.2); aDECREASE(the corrected resultado lowers the tax due, or raises a requested devolución) requires thesolicitud de rectificaciónprocedure (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:
objectRegistry-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:
- class AmendmentKindRegime(permitted_kinds, rectificativa_effective)[source]¶
Bases:
objectThe codified amendment-kind regime resolved for one (modelo, period).
- Variables:
permitted_kinds – The closed set of
CalculationRevisionAmendmentKindstring 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 — seeCalculationRevisionAmendmentKind.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:
- resolve_amendment_kind_regime(modelo, period, *, policy, rectificativa_effective_from=None)[source]¶
Resolve the codified amendment-kind regime for
modeloatperiod.Returns an
AmendmentKindRegimenaming the legally-permittedCalculationRevisionAmendmentKindstring 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.policyis the typed projection of the selected amendment-regime fact.rectificativa_effective_fromis 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:
modelo (str)
period (Period)
policy (AmendmentRegimePolicy)
rectificativa_effective_from (Mapping[str, date] | None)
- classify_amendment_liability_direction(*, baseline_result, corrected_result)[source]¶
Classify whether a correction increases, decreases, or leaves liability unchanged.
baseline_resultandcorrected_resultare 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) isINCREASE(LGT art. 122.2, complementaria territory); a decrease isDECREASE(LGT art. 120.3, solicitud de rectificación territory pre-unification). Equal values areUNCHANGED.Accepts any
Decimal-comparable numeric type so callers do not need to importdecimalsolely to call this classifier.- Return type:
str
- Parameters:
baseline_result (SupportsAllComparisons)
corrected_result (SupportsAllComparisons)