cadrumo.application.modelo.amendment_actions module

Amendment actions for externally filed modelo baselines.

amend_modelo_revision() starts from a current, externally evidenced ModeloRecord, builds a corrected CalculationRevision with an explicit CalculationRevisionAmendmentKind, supersedes the baseline filing, and stores the new amendment record as current.

The side effects update the work-unit pointers and emit modelo.amended through the application-owned bucket-event capability, matching the event-history path used by imported and locally filed returns.

Only filing records carrying ExternalEvidence can enter this path. The standard local calculate -> verify -> file chain remains separate: locally filed records have no external evidence and must be corrected through their own re-file workflow. Amendment overrides are resolved against the target registry snapshot, rejected when they use printed or undeclared casilla tokens, and projected back onto the CasillaObservation contract so the new revision keeps legal/source provenance for both overridden and inherited casillas.

See also

import_external_filing_evidence():

Creates the AEAT-attested baseline that this module amends.

amendment_observations():

Carries or rebuilds observation provenance for the corrected casilla map.

ExternalEvidence:

Filing-record evidence marker required before this amendment path can run.

reject_unknown_override_casillas():

Canonicalizes amendment override casilla ids against the registry.

reject_incomplete_amendment_casillas():

Reuses the registry completeness gate before the amendment is filed.

Core types: RegistrySnapshot.

amend_modelo_revision(*, from_filing_record_id, overrides, amendment_kind, m303_rectificativa_motive=None, detail_rows=None, reason, actor, ports, clock=None, operation=None, result_disposition=None)[source]

Build and file an amendment of the period’s latest AEAT-confirmed declaration.

from_filing_record_id must identify the in-force ModeloRecord of the period, confirmed or still pending. Its CalculationRevision supplies the full casilla map; overrides replace only corrected casillas after registry validation, while unchanged casillas are inherited. The amendment references the latest confirmed declaration; a pending in-force entry is marked DESCARTADA, and with no confirmed declaration the amendment is refused. The resulting revision records the requested CalculationRevisionAmendmentKind, stores the stripped reason, receives registry-grounded observations, transitions through VERIFICADO_COMPLETO to PRESENTADO, and becomes the current filed revision for the WorkUnit.

The confirmed baseline is linked to the new current amendment record. The new filing record is an internal filing envelope: the record stays PENDIENTE, external_evidence is cleared, and amends_filing_record_id points back to the baseline. The amendment’s observations are written to the pending-local layer, and a modelo.amended bucket event records the amendment kind, override count, work-unit id, amended baseline id and any discarded entry, all in one unit of work. result_disposition is the Modelo 303 declaration disposition of the correction; when omitted, the period’s effective recorded disposition is kept.

Return type:

ModeloRecord

Returns:

The new current ModeloRecord for the amended return.

Parameters:

See also

aeat app modelo work amend:

CLI command that validates --from-filing-record, --kind, --reason, and --set before calling this service.

import_external_filing_evidence():

Production import path that creates accepted external-evidence baselines.

amendment_observations():

Builds the CasillaObservation rows persisted on the amendment revision.