cadrumo.domain.calculations.registry.export module

Resolved export layouts for registry-backed AEAT record designs.

Resolves export layouts declared on a ModeloRevision and verifies them against a RegistrySnapshot. The resolved layout is a ResolvedExportLayout ready for fixed-width filing assembly.

class ResolvedExportLayout(**data)[source]

Bases: RegistryModel

A selected, validated export layout ready for read-only filing assembly.

Parameters:

data (Any)

layout: ExportLayoutDefinition
ordered_fields: tuple[ExportFieldDefinition, ...]
fields_by_id: Mapping[ExportFieldId, ExportFieldDefinition]
fields_by_casilla: Mapping[CasillaId, tuple[ExportFieldDefinition, ...]]
resolve_export_layout(snapshot, layout_id=None)[source]

Resolve one export layout from a validated registry snapshot.

Parameters:
  • snapshot (RegistrySnapshot) – The RegistrySnapshot to resolve the layout from.

  • layout_id (str | None) – Identifier of the export layout to resolve. May be None when the revision declares exactly one layout; otherwise required to disambiguate.

Return type:

ResolvedExportLayout

Returns:

The ResolvedExportLayout for the selected layout.

derive_export_layouts_from_bindings(revision)[source]

Return revision export layouts with binding-derived fields resolved.

Some official AEAT record designs expose structured filing records that are already represented as registry bindings. In those cases the export layout declares the record-level intent via binding_record and this resolver derives field coordinates from the binding selectors instead of requiring a second coordinate table in TOML.

Parameters:

revision (ModeloRevision) – The ModeloRevision whose export layouts and bindings are used to derive the resolved field coordinates.

Return type:

tuple[ExportLayoutDefinition, ...]

Returns:

Tuple of ExportLayoutDefinition with binding-derived fields populated.

fixed_width_record_casilla_ids(records)[source]

Return the casillas records address by casilla id in a fixed-width layout.

A fixed-width record addresses a casilla through a CASILLA-kind field, or through the row_field_casilla_ids mapping that names which casilla a repeated binding row’s slot belongs to. This is the sole derivation of that set, shared by two callers that must never disagree about it:

  • the pre-write parity gate (boe_representable_casilla_ids()), which passes only the records this filing’s disposition actually emits, so a casilla the disposition suppresses is not demanded; and

  • the registry-build export-exemption validation, which passes EVERY declared record, so a casilla addressed on any disposition needs no exemption reason.

The two scopes are deliberate and the build scope is the wider one: build time knows no disposition, and demanding a reason from a casilla some disposition does file would be a false refusal.

A casilla addressed only through a BINDING-kind field is NOT in this set — such a field names the binding, not the casilla, so no casilla-keyed scan can see it. That is a real representation channel, not an oversight, which is why FILED_VIA_BINDING_FIELD exists to declare it rather than the scan being widened to guess at it.

Parameters:

records (Sequence[ExportRecordDefinition]) – The fixed-width export records to scan.

Return type:

frozenset[TypeAliasType]

Returns:

Frozen set of casilla ids the records address by casilla id.

clasificar_casillas_oficiales(revision, *, sources=None, source_payloads=None)[source]

Classify every revision casilla by its official export representation.

Binding-derived record fields are resolved before any channel is measured. Fixed-width CASILLA fields, repeated-row slot mappings, and official XML dictionary entries address a casilla directly. A casilla carrying the reviewed FILED_VIA_BINDING_FIELD exemption is represented through a binding when the resolved design actually contains binding fields. All remaining casillas are explicitly undefined.

XML dictionaries are external registry evidence. A revision containing one therefore requires the signed source projection and catalogue rather than silently treating an unavailable dictionary as an undefined export surface.

Core types: ModeloRevision.

Return type:

Mapping[TypeAliasType, EstadoCasillaOficial]

Parameters:
export_fields_overlap(left, right)[source]
Return type:

bool

Parameters: