cadrumo.domain.calculations.registry.fixed_width_codec module

Canonical semantic-to-wire codec for registry fixed-width export fields.

class ExportPadding(*values)[source]

Bases: StrEnum

Closed fixed-width padding axis declared by registry fields.

LEFT_ZERO
LEFT_SPACE
RIGHT_SPACE
NONE
class ExportJustification(*values)[source]

Bases: StrEnum

Closed fixed-width alignment axis declared by registry fields.

LEFT
RIGHT
NONE
class ExportEncoding(*values)[source]

Bases: StrEnum

Closed character encodings admitted by fixed-width registry records.

ASCII
CP1252
ISO_8859_1
ISO_8859_15
class ExportSignPosition(*values)[source]

Bases: StrEnum

A sign byte an official design reserves ahead of an amount’s magnitude.

The general AEAT convention reserves nothing: an ‘N’ displaces the leading digit of a negative amount and a non-negative amount is digits throughout. Some designs instead subdivide an amount into a leading alphabetic SIGNO position and a numeric magnitude that “no irá precedido de signo alguno”; the magnitude then owns every remaining byte, and the sign byte follows the design’s own rule rather than the general one.

BLANK_OR_N

‘N’ when the amount is below zero, otherwise a space (“En cualquier otro caso el contenido del campo será un espacio”).

N_UNLESS_ZERO

The design fixes the direction (“se consignará siempre una ‘N’”), so the value is a non-negative magnitude written after an ‘N’; when there is nothing to declare the whole slot “se rellenará a ceros”.

exception FixedWidthRecordRenderError(*, field_id, reason, export_record_id, **facts)[source]

Bases: CadrumoError

A registry-owned fixed-record rendering refusal with exact context.

The condition travels as the reason discriminant plus the coordinates that produced it; the operator-facing sentence is resolved from the registered key, so no raise site authors English prose.

Parameters:
Return type:

None

code
validate_fixed_width_shape(field)[source]

Refuse contradictory padding, justification, and sign declarations.

Return type:

None

Parameters:

field (_ExportField)

render_fixed_width_export_field(field, value)[source]

Render one semantic field value to its complete exact-width wire text.

Return type:

str

Parameters:
  • field (_ExportField)

  • value (object)

render_fixed_width_export_record_body(record, *, field_values)[source]

Render one registry-owned fixed-width record without its terminator.

This is the sole registry-owned record-byte producer. The outbound payload assembly owner appends record terminators while composing the final stream.

Return type:

bytes

Parameters:
parse_fixed_width_export_field(field, raw)[source]

Parse and validate one complete exact-width field from wire text.

Return type:

TypeAliasType

Parameters:
  • field (_ExportField)

  • raw (str)

pad_fixed_width_text(value, *, length, padding, justification)[source]

Apply the canonical padding contract to already-rendered text.

Return type:

str

Parameters: