cadrumo.application.filing.export module¶
Typed records for the local declaration export / verify lifecycle.
The CLI exposes two primitives the application layer must back end-to-end:
modelo export writes an AEAT declaration file from a validated registry snapshot for an approved
domain.filing.schema.ModeloDraftand reports the byte-level summary the operator needs to track the artefact (output path, draft identity, content hash, format).modelo export verification re-reads a previously exported file and confirms that its casilla payload still matches the approved draft. The verdict is a closed enum; the diff (if any) is reported as a tuple of mismatched casilla identifiers so the CLI can render a deterministic table.
The records are structured return values for renderers, persistence, and
JSON round trips. Runtime export requires registry-backed
domain.calculations.registry.schema_exports.ExportLayoutDefinition records,
and verification parses payloads through
domain.calculations.registry.export_parse.parse_export_payload().
The records intentionally do not embed the AEAT submission lifecycle
(domain.submission) — local export and live submit are
separate concerns and live submit is permanently forbidden.
This module is the draft-level renderer. The work-unit export service in
application.modelo.export rebuilds an approved
domain.filing.schema.ModeloDraft from a
CalculationRevision, then delegates here to write
and verify the fichero-BOE bytes.
See also
application.modelo.export.export_modelo_revision()Higher-level work-unit export service that replays a calculation revision before calling this draft renderer.
adapters.outbound.aeat.exportOutbound export-format adapter errors and fixed-width helper namespace.
core.access_gate.errors.LiveSubmitForbiddenErrorCore refusal raised for every attempted live AEAT write.
domain.submissionLocal-only submitted-state lifecycle, separate from file export.
- export_draft(draft, *, output_path=None, payload_consumer=None, producer_snapshot, dictionary_values=None, prior_domiciliation_election=None, product_software_identity=None, schema_provider=None)[source]¶
Write an approved draft to a local fichero-BOE file and return a receipt.
The function selects the active registry
ExportLayoutDefinition, renders its fixed-width records, writes onlyoutput_path, and never contacts AEAT. Live submission is outside this surface and is refused bycore.access_gate.errors.LiveSubmitForbiddenError.- Parameters:
draft (
ModeloDraft) – TheModeloDraftto export; must be inAPROBADOstatus.output_path (
Path|None) – Destination path for ordinary filesystem export. Exactly one of this orpayload_consumeris required.payload_consumer (
FilingExportPayloadConsumer|None) – Synchronous destination for validated in-memory bytes, used when plaintext output must not touch a filesystem.producer_snapshot (
FilingProducerSnapshot) – Complete typed filing facts consumed by registry producers.dictionary_values (
Mapping[str,object] |None) – Optional values addressed by the dictionary field id AEAT declares for them, each still carrying its own Python type. Read only by thexml_dictionaryrenderer, which is the only format addressing fields that way; the fixed-width renderer resolves its fields fromheadersand the layout’s record definitions.prior_domiciliation_election (
PriorDomiciliationElection|None) – Typed M303 page-three election used by the shared Nota-3 DID page predicate. Required for Modelo 303; non-M303 exports carry no election authority.product_software_identity (
AeatProductSoftwareIdentity|None) – Explicit reviewed AEAT product authority. Required for Modelo 303’s DP30300 carrier and refused for every other modelo.schema_provider (
RegistrySchemaAccessor|None) – Optional registry schema provider override.
- Return type:
- Returns:
A
DeclaracionExportResultwith the output path, digest, byte size, and casilla provenance for the exported declaration.
See also
verify_export()Re-read a local export file and compare parser-covered casillas against the approved draft.
application.modelo.export.export_modelo_revision()Work-unit-facing export orchestration that supplies an approved draft reconstructed from a calculation revision.
domain.calculations.registry.export_parse.parse_export_payload()Registry parser used by the verification path.
- class ExportLayoutRenderabilityReason(*values)[source]¶
Bases:
StrEnumClosed machine reasons a registry layout cannot render declaration bytes.
This enum is the single decision authority for export renderability. The prose projection below exists only to serve consumers outside this package that still read a rendered sentence; it maps this vocabulary and never decides anything itself.
- NO_COMPLETE_EXPORT_LAYOUTS¶
- XML_DICTIONARY_SOURCE_ABSENT¶
- UNSUPPORTED_LAYOUT_FORMAT¶
- NO_EXPORT_RECORDS¶
- export_layout_renderability_reason_code(layout)[source]¶
Return the closed reason
layoutcannot produce local declaration bytes.- Return type:
- Parameters:
layout (ExportLayoutDefinition | None)
- export_layout_renderability_reason(modelo, layout)[source]¶
Return why
layoutcannot currently produce local declaration bytes.Retained as a rendered projection of
export_layout_renderability_reason_code()for consumers outside this package that place the sentence in an operator payload. Those consumers are the remaining reason this projection exists.- Return type:
- Parameters:
modelo (str)
layout (ExportLayoutDefinition | None)
- render_filing_layout(layout, *, registry_snapshot, draft, headers, producer_snapshot, prior_domiciliation_election, product_software_identity)[source]¶
Render one already-selected layout after enforcing immutable filing context.
Core types:
ModeloDraft,RegistrySnapshot.- Return type:
- Parameters:
layout (ExportLayoutDefinition)
registry_snapshot (RegistrySnapshot)
draft (ModeloDraft)
headers (Mapping[FilingProducerKey, object])
producer_snapshot (FilingProducerSnapshot)
prior_domiciliation_election (PriorDomiciliationElection)
product_software_identity (AeatProductSoftwareIdentity | None)
- render_filing_envelope(request)[source]¶
Render one modelo’s variable envelope from the closed, validated request.
- Return type:
- Parameters:
request (FilingEnvelopeRenderRequest)