aeat.application.modelo._amendment_kind_resolution module¶
Period-aware amendment-kind resolution and the liability-increase guard.
AEAT’s amendment mechanism for a self-assessment changed over time (see
_amendment_kind_regime for the full grounding). Before the
autoliquidación rectificativa unification, a correction that raised the
tax due filed as a complementaria (LGT art. 122.2) while a correction
that lowered it required the separate solicitud de rectificación
procedure (LGT art. 120.3) — a self-filed complementaria cannot lawfully
lower a taxpayer’s own declared liability. This module is the single place
that:
refuses an operator-requested
CalculationRevisionAmendmentKindthat the resolved(modelo, period)does not legally permit, naming the accepted kind set in the refusal (never a bare “invalid” message); andclassifies, for a pre-rectificativa period, whether the requested correction increases or decreases the taxpayer’s declared liability, so a
complementariarequested for a liability-decreasing correction is refused with guidance toward thesolicitud de rectificaciónprocedure instead of being silently accepted as if it were lawful.
amend_modelo_revision() calls
assert_amendment_kind_permitted() before it persists anything, so an
illegal kind can never reach the catalogue.
See also
resolve_amendment_kind_regime():Codified per-modelo, period-aware permitted-kind table this module binds to
CalculationRevisionAmendmentKind.amend_modelo_revision():The composition path that calls this module’s guard before building the amendment revision.
- assert_amendment_kind_permitted(*, modelo, period, amendment_kind)[source]¶
Refuse
amendment_kindunless the resolved period legally permits it.Reads the codified regime from
resolve_amendment_kind_regime()formodeloandperiodand checksamendment_kindagainst the permitted set. A modelo with no codified rectificativa-adoption boundary (e.g. M130/M131, which carry no bundled rectificativa grounding) always resolves to the pre-rectificativa complementaria/sustitutiva pair, so requestingrectificativafor such a modelo is refused at every period until a bundled AEAT source grounds an effective date.- Raises:
AmendmentKindNotPermittedError – When
amendment_kindis outside the resolved period’s permitted set. The refusal names both the requested kind and the full accepted set.- Return type:
- Parameters:
modelo (str)
period (Period)
amendment_kind (CalculationRevisionAmendmentKind)
- liability_direction_for_amendment(*, baseline_result, corrected_result)[source]¶
Classify whether a correction increases, decreases, or leaves liability unchanged.
Thin, typed wrapper over
classify_amendment_liability_direction()for callers inside the modelo application layer.baseline_resultandcorrected_resultare the modelo’s signed final-result casilla value before and after the operator’s overrides.The classification is load-bearing only for pre-rectificativa periods:
INCREASEiscomplementariaterritory (LGT art. 122.2);DECREASEissolicitud de rectificaciónterritory (LGT art. 120.3) that a self-filed complementaria cannot lawfully carry — seeamend_modelo_revision()’s pre-rectificativa complementaria-direction guard.- Return type:
- Parameters:
- assert_complementaria_liability_direction_permitted(*, modelo, period, amendment_kind, baseline_casilla_values, corrected_casilla_values)[source]¶
Refuse a pre-rectificativa
complementariathat decreases liability.Only load-bearing for a pre-rectificativa period (see
resolve_amendment_kind_regime()): once rectificativa applies, both directions route through the unified mechanism and this guard is a no-op. For a pre-rectificativa period requestingCOMPLEMENTARIA, sums the modelo’s codified final-result casilla(s) (result_disposition_casilla_ids()) before and after the operator’s overrides and refuses when the correction lowers the declared liability — that correction is legally asolicitud de rectificación(LGT art. 120.3), not a complementaria (LGT art. 122.2).A modelo with no codified result-disposition spec, or a correction that does not touch the result casilla(s), is not refused: there is no basis to classify a direction, so the guard degrades to a no-op rather than fabricating a comparison.
- Raises:
AmendmentComplementariaLiabilityDecreaseError – When a pre-rectificativa complementaria would lower the taxpayer’s declared liability.
- Return type:
- Parameters: