cadrumo.application.filing._export_xml_dictionary module

XML-dictionary declaration export renderer.

Renders approved declaration drafts through registry xml_dictionary export layouts. The renderer reuses the official AEAT dictionary and XSD source refs resolved by the registry schema provider, then writes only a local XML payload for the draft export path.

See also

export_draft()

Draft export service that selects this renderer for XML dictionary layouts.

ModeloDraft

Approved declaration draft whose casilla and header values are rendered.

ExportLayoutDefinition

Registry export layout carrying dictionary and XSD source references.

XmlDictionaryEntry

Parsed dictionary row consumed while projecting XML fields.

xml_dictionary_entries()

Registry helper that reads the official dictionary source.

RegistrySchemaAccessor

Runtime schema provider that resolves source roots and references.

render_xml_dictionary_layout(layout, *, draft, headers, dictionary_values=None, schema_provider)[source]

Render an XML-dictionary layout for an approved declaration draft.

Parameters:
Return type:

bytes

Returns:

UTF-8 XML declaration bytes for the local export artefact.

expected_xml_dictionary_root_identity(layout, *, draft, schema_provider)[source]

Return the Declaracion root attributes draft identifies itself by.

The sole declaration of the root-attribute contract. The writer builds the element from it and verify_export() rebuilds the same mapping to compare against what a file on disk actually carries, so the two halves cannot name different attributes — which is how the verifier came to check none of them at all.

Parameters:
Return type:

dict[str, str]

Returns:

The root attributes, keyed exactly as they appear on the element.

read_xml_dictionary_root_identity(payload)[source]

Return the root identity attributes carried by an exported XML declaration.

Parameters:

payload (bytes) – The exported XML declaration bytes.

Return type:

Mapping[str, str]

Returns:

The declared root attributes, keyed as expected_xml_dictionary_root_identity() writes them. A key is absent when the file omits that attribute, which the caller must treat as a divergence rather than as a match.

Raises:

FilingExportValidationError – The payload is not parseable XML, or its root is not a Declaracion element.

format_xml_dictionary_value(data_type, value)[source]

Render one value in the form the dictionary row’s declared type accepts.

The row’s data_type decides the rendering, not the Python type of the value. Deciding from the value alone cannot distinguish rows that happen to carry the same Python type but are declared differently by AEAT: every boolean rendered as "S"/"N" regardless of whether the row was tipo_logico (which accepts only 0/1) or tipo_SINO_Exclusivo (only SI/NO), and every numeric row was rendered with two decimals even where the row is an xs:integer.

Parameters:
  • data_type (str) – The dictionary row’s declared type code.

  • value (object) – The scalar to render.

Return type:

str

Returns:

The rendered text for the XML element or attribute.