aeat.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 BucketEventHistoryRepository, 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.

amend_modelo_revision(*, from_filing_record_id, overrides, amendment_kind, reason, actor, work_unit_repository=None, calculation_repository=None, filing_repository=None, bucket_event_repository=None, clock=None)[source]

Build and file an amendment over an externally filed return.

from_filing_record_id must identify the current ModeloRecord for an imported AEAT-attested baseline. The baseline’s CalculationRevision supplies the full casilla map; overrides replace only corrected casillas after registry validation, while unchanged casillas are inherited. 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 baseline filing is marked SUPERSEDIDO and linked to the new current amendment record. The new filing record is an internal filing envelope: aeat_accepted remains false, external_evidence is cleared, and amends_filing_record_id points back to the imported baseline. A modelo.amended bucket event records the amendment kind, override count, work-unit id, and amended baseline id.

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.