aeat.application.modelo._external_import_actions module

External filing import actions for modelo baselines.

import_external_filing_evidence() turns AEAT-attested external evidence into a presented CalculationRevision plus current ModeloRecord. Evidence-bearing imports validate the referenced Justificante, stamp an ExternalEvidence payload on the filing record, supersede any prior current filing for the same target, and emit modelo.filing.imported through BucketEventHistoryRepository.

The imported record is the production baseline consumed by the amendment path. It is intentionally distinct from a locally calculated and filed return: external_evidence marks that the values came from official AEAT evidence, while external_filing_observations() keeps the imported casilla values on the same registry-grounded CasillaObservation contract as local calculation revisions.

See also

filing_record_import():

CLI surface that parses filing-record import options and calls this service.

amend_modelo_revision():

Consumes the imported current ModeloRecord as an amendment baseline.

justificante:

Receipt metadata store required by justificante-PDF, CSV-register, and live-capture evidence kinds.

reject_unknown_import_casillas():

Resolves the registry snapshot and refuses noncanonical or undeclared imported casilla ids.

ExternalEvidence:

Filing-record metadata that records the official evidence source.

import_external_filing_evidence(*, work_unit_id, casilla_values, evidence_kind, evidence_reference_id, actor='aeat-import', work_unit_repository=None, calculation_repository=None, filing_repository=None, bucket_event_repository=None, justificante_repository=None, expected_tax_id=None, clock=None)[source]

Persist an externally-filed return and return its current ModeloRecord.

The target WorkUnit supplies the bucket, modelo, filing year, period, and registry revision used to validate imported casilla ids. Justificante-bound evidence kinds require a stored Justificante whose modelo, year, period, and taxpayer id match the target.

The service writes a PRESENTADO CalculationRevision containing the imported values and registry-grounded observations, creates a VIGENTE filing record with ExternalEvidence, supersedes any previous current filing for the same target, advances the work-unit pointers, and emits modelo.filing.imported.

Return type:

ModeloRecord

Returns:

The new current ModeloRecord carrying the external evidence metadata.

Parameters:

See also

external_filing_observations():

Builds provenance-bearing observations for imported casilla values.

amend_modelo_revision():

Requires this external-evidence baseline before filing amendments.

justificante:

Stores the receipt metadata checked for receipt-bound evidence references.