cadrumo.domain.calculations.registry.retenciones_bindings module

Retenciones-aggregation registry binding helpers (RET-1).

The per-family module for the retenciones_aggregation binding source — the calc-mesh source that materialises retenciones-family scalars from the dedicated per-perceptor retención store. Extracted as its own family module per aeat-architecture-boundaries; the cross-family validator dispatch in bindings registers this family’s validate(binding) -> list[str] entry.

The materialisation depends on a _RetencionesAggregationProtocol rather than the application-layer RetencionesAggregation, so the domain layer stays independent of the application aggregation service.

The resolver walks the declared ModeloRevision bindings and emits only canonical binding values for this source family.

class RetencionesAggregationFact(*values)[source]

Bases: StrEnum

A figure a retenciones aggregation binding totals across matched rows.

PERCEPTOR_COUNT_DISTINCT
TAXABLE_BASE_SUM
RETENCION_AMOUNT_SUM
validate_retenciones_aggregation_binding(binding)[source]

Accumulating registry-build validator for a retenciones_aggregation binding.

Validates the selector shape against RetencionesAggregationProvider (the single build-time contract per aeat-registry-bindings), preserving the underlying pydantic field message in the diagnostic.

Return type:

list[str]

Parameters:

binding (BindingDefinition)

resolve_retenciones_aggregation_binding_values(revision, aggregation, *, authority=None)[source]

Materialise every retenciones_aggregation binding on a ModeloRevision.

Returns a binding value for every binding whose source is BindingSourceKind.RETENCIONES_AGGREGATION, keyed by the selector’s declared fact.

Return type:

dict[TypeAliasType, Decimal]

Parameters:
class RetencionesAggregationProvider(**data)[source]

Bases: BaseModel

Validated form of a retenciones_aggregation binding selector.

Carries the target casilla id and the scalar fact this source serves. Annual summary modelos still keep their monetary totals on relation-prefill bindings; Modelo 115 uses the same per-perceptor store directly for its quarterly perceptor count and taxable base.

Parameters:

data (Any)

kind: Literal[BindingSourceKind.RETENCIONES_AGGREGATION]
target_casilla_id: CasillaId
schemes: Annotated[tuple[RetencionScheme, ...], BeforeValidator(coerce_enum_tuple(RetencionScheme))]
fact: RetencionesAggregationFactField