cadrumo.domain.calculations.registry.ledger_renta_gastos_estimacion_directa_bindings module

Canonical Renta estimacion directa ledger-gastos binding family.

class RentaGastosEstimacionDirectaObservationProtocol(*args, **kwargs)[source]

Bases: Protocol

Structural protocol for first-slice Renta estimación directa gastos observations.

The registry only needs these four attributes to resolve ledger_renta_gastos_estimacion_directa_aggregation bindings; the full RentaDeductibleExpenseObservation satisfies this protocol without any explicit declaration.

Properties are declared read-only so that concrete attributes satisfy the protocol under strict covariant checking.

property modelo: str

Return the Modelo series associated with the gasto observation.

property period: str

Return the filing period associated with the gasto observation.

property target_casilla_id: CasillaId

Return the declaration casilla receiving the deductible amount.

property deductible_amount: Decimal

Return the deductible amount carried by the observation.

validate_ledger_renta_gastos_estimacion_directa_aggregation_binding_definition(binding)[source]

Validate a ledger_renta_gastos_estimacion_directa_aggregation binding definition.

Return type:

None

Parameters:

binding (BindingDefinition)

resolve_ledger_renta_gastos_estimacion_directa_aggregation_binding_values(revision, observations)[source]

Resolve every ledger_renta_gastos_estimacion_directa_aggregation binding on revision.

Delegates the filter/aggregate skeleton to resolve_ledger_family_binding_values(), shared by every ledger family resolver.

Parameters:
Return type:

dict[TypeAliasType, Decimal]

unsupported_ledger_renta_gastos_estimacion_directa_observations(revision, observations)[source]

Return the RentaGastosEstimacionDirectaObservationProtocol rows no binding on revision can consume.

Delegates the screen to unsupported_ledger_family_observations() — see that function for the shared fail-closed contract (why an unmatched observation is a modelling gap, not a legitimate zero). This family’s own contribution is narrow: the (modelo, period, target_casilla_id) match predicate (reused from the resolver’s _renta_gastos_estimacion_directa_build_matcher) and a zero-deductible_amount false-fire guard. No extra_exclusion.

Parameters:
Return type:

tuple[RentaGastosEstimacionDirectaObservationProtocol, ...]

Returns:

Tuple of observations whose non-zero deductible amount is selected by no ledger_renta_gastos_estimacion_directa_aggregation binding.

renta_first_slice_binding_target_casillas(revision)[source]

Return the target_casilla_id set this revision’s own bindings route to.

Unlike the universal BOE-prescribed first-slice routing projection spanning every filing year the application supports), this returns only the casillas a ledger_renta_gastos_estimacion_directa_aggregation binding on THIS revision actually targets. Older Modelo 100 revisions (2020-2023) declare no such bindings at all – the first-slice ledger-aggregation mechanism did not yet exist for them – so their required set is legitimately empty even though the universal routing table’s codomain is wider. The snapshot-time referential-integrity gate (cadrumo.domain.renta.first_slice_routing_integrity) uses this per-revision set rather than the universal table so it only fails when a binding THIS revision actually declares points at a casilla absent from that same revision – the real defect class the gate exists to catch, not “does every filing year’s estimación directa casilla exist on every other filing year’s revision” (it does not, by BOE design: casillas are added, split, and renumbered across years).

Parameters:

revision (ModeloRevision) – The ModeloRevision whose own ledger_renta_gastos_estimacion_directa_aggregation binding selectors are inspected.

Return type:

frozenset[TypeAliasType]

validate_ledger_renta_gastos_estimacion_directa_aggregation_binding(binding)[source]

Validate a ledger_renta_gastos_estimacion_directa_aggregation binding at registry-build time.

Accumulating list[str] validator over LedgerRentaGastosEstimacionDirectaProvider; runs the fact/aggregation-op invariant at build time through invariant_diagnostics(), whose raise-style body is validate_ledger_renta_gastos_estimacion_directa_aggregation_binding_definition().

Return type:

list[str]

Parameters:

binding (BindingDefinition)

class LedgerRentaGastosEstimacionDirectaProvider(**data)[source]

Bases: BaseModel

Validated form of a ledger_renta_gastos_estimacion_directa_aggregation binding selector.

Parameters:

data (Any)

kind: Literal[BindingSourceKind.LEDGER_RENTA_GASTOS_ESTIMACION_DIRECTA_AGGREGATION]
modelo: Modelo
period: Literal['0A']
target_casilla_id: CasillaId
fact: Literal['deductible_amount_sum']