aeat.domain.calculations.registry._binding_selector_utils module¶
Shared selector normalization and field-validator helpers for registry bindings.
- class BindingFixedExportSelector(**data)[source]¶
Bases:
BaseModelTyped fixed-width export projection carried by a binding selector.
- Parameters:
- record: str¶
- offset: int¶
- length: int¶
- data_type: BindingExportDataType¶
- field: str | None¶
- class BindingRowExportSelector(**data)[source]¶
Bases:
BaseModelTyped row-field export projection carried by a binding selector.
- record: str¶
- row_field: str¶
- class BindingRowSetSelector(**data)[source]¶
Bases:
BaseModelTyped row-set projection carried by a row-producing binding selector.
- fact: Literal['row_field']¶
- row_field: str¶
- grouping: str¶
- record: str | None¶
- selector_as_dict(binding)[source]¶
Return a plain selector mapping without injected source metadata.
- Return type:
- Parameters:
binding (DataBindingDefinition)
- class BooleanBindingEncodedValue(**data)[source]¶
Bases:
BaseModelOne accepted decimal encoding of a boolean-casilla
manual_inputbinding.A
manual_inputbinding whose selector declaresdata_type = "boolean"(the Modelo 100 estimación-directa modality flag is the canonical case) is consumed by the registry formulas as a numeric1/0operand. The operator therefore supplies a decimal on the--bindingchannel, yet the accepted values and their meaning are opaque from the rawDataBindingDefinition. This record makes one accepted value explicit:encoded_valueis the decimal the operator types,boolean_meaningis the affirmative/negative sense it carries, andregistry_valueis the underlying casilla token the boolean maps to (the selector’s declaredtrue_value/false_value).- encoded_value: str¶
- boolean_meaning: bool¶
- registry_value: str¶
- boolean_binding_encoded_values(binding)[source]¶
Return the decimal encoding of a boolean-casilla
manual_inputbinding.The result is empty for every binding that is not a boolean-casilla
manual_inputselector, so a caller can read a non-empty result as “this binding is a decimal-encoded boolean flag”. The encoding follows the registry convention that a boolean operand is consumed as1(true) /0(false); each sense is paired with the selector’s declaredtrue_value/false_valuecasilla token, so the mapping is derived from the binding definition, never hardcoded per modelo.- Return type:
- Returns:
Zero or two
BooleanBindingEncodedValuerows.- Parameters:
binding (DataBindingDefinition)
- binding_export_selector(binding)[source]¶
Return the typed export projection embedded in
binding.selector.Binding source-family selectors remain authoritative for business facts. Export record resolution only needs the official record-coordinate projection; this helper parses that projection once into a typed fixed-field or row-field selector instead of letting callers probe the raw selector map.
- Return type:
BindingFixedExportSelector|BindingRowExportSelector|None- Parameters:
binding (DataBindingDefinition)
- binding_row_set_selector(binding)[source]¶
Return the typed row-set projection embedded in
binding.selector.Source-family selectors remain the authority for fact-specific filters. Row-set consumers only need the common
fact = "row_field"projection that names the detail grouping and the emitted row field, so callers parse that projection once instead of probing the raw selector map.- Return type:
- Returns:
The parsed
BindingRowSetSelector, orNonewhen the binding selector does not declare a row-set projection.- Parameters:
binding (DataBindingDefinition)
- selector_against_model(binding, selector_model)[source]¶
Validate
binding.selectoragainstselector_model, accumulating diagnostics.Projects the selector through
selector_as_dict()(the same normalised mapping the resolve-time helpers see, so the build gate is never stricter than runtime), validates against the strict pydantic model, and returns the underlying field message verbatim in a diagnostic naming the binding id, its source, and the violated model. The underlying pydantic error is preserved rather than flattened to a generic “malformed selector”, matching the shape the counterpart/withholding build-time lift already emits.Returns an empty list when the selector validates.
- Return type:
- Parameters:
binding (DataBindingDefinition)
selector_model (type[BaseModel])
- invariant_diagnostics(binding, label, check)[source]¶
Run a raise-style op/fact invariant
checkand collect its diagnostic.The detail-record, previous-filing, counterpart, withholding, invoice, and ledger families enforce their op/fact cross-invariants by raising
RegistryValidationError. This adapter runs the raisingcheckand converts the raised message into one accumulating diagnostic string naming the binding id, its source, and thelabelfamily, preserving the underlying field message. Returns an empty list when the invariant holds.- Return type:
- Parameters:
binding (DataBindingDefinition)
label (str)
check (Callable[[DataBindingDefinition], object])
- uppercase_alpha_code(field_label)[source]¶
Build a field validator that rejects a non-uppercase-alphabetic code.
Shared by the binding observation models whose ISO country / member-state / currency codes must be uppercase alphabetic;
field_labelnames the field in the raisedRegistryValidationError.
- intracommunity_clave_validator()[source]¶
Build the shared
intracommunity_clavefield validator.Both
InvoiceObservationandCounterpartAggregationObservationcarried a byte-identicalintracommunity_clavefield validator: a clave is optional, must be uppercase, and must be one of the closed AEAT clave de operación set. The single factory replaces both copies.
- validate_rectification_fields(observation)[source]¶
Enforce the rectification-field coupling shared by the invoice families.
A rectification observation must declare
rectified_year,rectified_periodandrectified_base_previous; a non-rectification observation must declare none of them.InvoiceObservationandCounterpartAggregationObservationcarried a byte-identical_validate_rectificationmodel validator; this one shared check replaces both, raisingRegistryValidationErroron a violation.- Return type:
- Parameters:
observation (_RectifiableObservation)
- unique_tuple(label)[source]¶
Build a field validator that rejects duplicate entries in a tuple field.
Shared by the binding requirement models;
labelnames the offending tuple in the raisedRegistryValidationError("<label> entries must be unique").