aeat.application.filing._import module

Reconstruct a ModeloDraft from an AEAT justificante PDF.

The operator keeps the justificante PDF of a past filing on disk. This module parses the PDF into a Justificante via adapters.inbound.justificante.parse_justificante(), validates the printed period against the active registry subview, asks application.filing.build_draft() to materialise an empty draft scaffold, and co-produces a companion ModeloPresentado record so the import can be used as an amendment baseline.

The justificante is receipt metadata, not a full casilla-value source. When the active registry requires inputs or binding values that the receipt cannot provide, import fails with ModeloImportError instead of fabricating tax values.

No AEAT certificate authentication or network call is involved — the command is a pure offline transform from (PDF bytes) → (draft, submission, warnings).

This is not the production external-evidence import path for current filing records. It does not create a ModeloRecord, attach ExternalEvidence, or infer missing casilla values from receipt metadata.

See also

adapters.inbound.justificante

Local PDF parser that extracts the typed receipt record.

application.filing.build_runtime_schema_provider()

Registry-backed schema provider used to validate supported periods and build the draft scaffold.

application.filing.build_complementaria()

Amendment flow that can consume the imported submission baseline.

application.modelo.import_external_filing_evidence()

External-evidence import path that builds the current ModeloRecord baseline consumed by work-unit amendments.

class RegistryImportSchemaProvider(*args, **kwargs)[source]

Bases: CasillaSchemaProvider, Protocol

Combined casilla schema and period-subview provider used by the import path.

Implementations must satisfy both the domain.filing.CasillaSchemaProvider contract (for draft construction) and expose get_subview so import_filing_from_justificante() can look up the supported period tokens for a given modelo during period canonicalisation. The production implementation is build_runtime_schema_provider().

get_subview(modelo)[source]
Return type:

_RegistryPeriodSubview

Parameters:

modelo (str)

class JustificanteImportResult(draft, submission, warnings)[source]

Bases: object

Outcome of a import_filing_from_justificante() call.

The container is deliberately a frozen dataclass rather than a pydantic model because it wraps two already-validated pydantic records and defers the ModeloPresentado type to runtime (the aeat.adapters.outbound.aeat.export package itself imports application.filing, so pulling ModeloPresentado in at module scope would cycle).

Variables:
  • draft – The freshly built ModeloDraft scaffold.

  • submission – The companion ModeloPresentado that lets the amendment engine treat the imported draft as a baseline.

  • warnings – Multilingual advisory messages. The CLI renders these so the operator knows which fields still need input.

Parameters:
draft: ModeloDraft
submission: ModeloPresentado
warnings: tuple[str, ...]
import_filing_from_justificante(pdf_path, *, schema_provider)[source]

Reconstruct a draft + submission record from a justificante PDF.

Parameters:
  • pdf_path (Path) – Path to the justificante PDF on disk. Must exist.

  • schema_provider (RegistryImportSchemaProvider) – Casilla schema provider used by the filing builder. Callers typically pass build_runtime_schema_provider().

Return type:

JustificanteImportResult

Returns:

A JustificanteImportResult with draft, companion submission, and any advisory warnings.

Raises:

ModeloImportError – If the modelo has no registered builder or the printed period cannot be canonicalised.