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.justificanteLocal 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
ModeloRecordbaseline consumed by work-unit amendments.
- class RegistryImportSchemaProvider(*args, **kwargs)[source]¶
Bases:
CasillaSchemaProvider,ProtocolCombined casilla schema and period-subview provider used by the import path.
Implementations must satisfy both the
domain.filing.CasillaSchemaProvidercontract (for draft construction) and exposeget_subviewsoimport_filing_from_justificante()can look up the supported period tokens for a given modelo during period canonicalisation. The production implementation isbuild_runtime_schema_provider().
- class JustificanteImportResult(draft, submission, warnings)[source]¶
Bases:
objectOutcome 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
ModeloPresentadotype to runtime (theaeat.adapters.outbound.aeat.exportpackage itself importsapplication.filing, so pullingModeloPresentadoin at module scope would cycle).- Variables:
draft – The freshly built
ModeloDraftscaffold.submission – The companion
ModeloPresentadothat 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)
-
draft:
ModeloDraft¶
-
submission:
ModeloPresentado¶
- 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 passbuild_runtime_schema_provider().
- Return type:
- Returns:
A
JustificanteImportResultwithdraft, companionsubmission, and any advisory warnings.- Raises:
ModeloImportError – If the modelo has no registered builder or the printed period cannot be canonicalised.