aeat.domain.calculations.registry._observation_fold module¶
One observation-fold helper for cross-filing fold-ins.
The single gather-and-fold primitive shared by both relation fold paths (the
application-layer relation prefill and the domain-layer
domain.calculations.registry.resolve_relation_values_from_observations()).
It matches the source filings a
RegistryFoldRequirement declares and
extracts the source casilla value per period, then folds the gathered values
through the requirement’s declared copy / sum aggregation to one
Decimal.
Lives in the domain registry package (not the application source mesh) because the domain relation resolver consumes it and the hexagonal direction forbids a domain module importing the application layer.
See also
domain.calculations.registry._relationsDomain relation resolver that gathers and folds requirements here.
domain.calculations.registry._bindings_previous_filingPrevious-filing binding resolver that reuses
fold_sum_or_copy().
- gather_observed_requirement_values(requirement, observations)[source]¶
Return the source-casilla values matched for one fold requirement, per period.
Matches exactly one
RegistryModeloObservationper declared source period and extracts the requirement’s single sourceCasillaIdvalue from each. The returned tuple carries one value perrequirement.periodsentry, in declaration order, ready forfold_observed_requirement_values().- Return type:
- Parameters:
requirement (RegistryFoldRequirement)
observations (tuple[RegistryModeloObservation, ...])
- fold_sum_or_copy(op, values, *, subject, copy_unit)[source]¶
Fold a value sequence through the shared
sum/copyarithmetic.The one place
sum(add every value) andcopy(require exactly one value and return it) are implemented.subjectandcopy_unitcarry the caller’s diagnostic vocabulary so a refused copy names the right entity (a relation requirement’s observation, or a binding’s source casilla). An op that is neithersumnorcopyis rejected; callers handle any other op (e.g. the Modelo 130prior_pagos_fraccionadosidentity) before delegating.Used by both
fold_observed_requirement_values()anddomain.calculations.registry.resolve_previous_filing_binding_values().
- fold_observed_requirement_values(requirement, values)[source]¶
Fold per-period source values through a requirement’s
copy/sumop.copyrequires exactly one gathered value and returns it;sumadds the gathered values. This is the one fold both relation paths apply to aRegistryFoldRequirement; the period match isgather_observed_requirement_values().- Return type:
- Parameters:
requirement (RegistryFoldRequirement)
- resolve_observed_requirement_value(requirement, observations)[source]¶
Gather and fold one requirement to a single
Decimal.Convenience wrapper for callers that already hold the normalized
RegistryModeloObservationrows.- Return type:
- Parameters:
requirement (RegistryFoldRequirement)
observations (tuple[RegistryModeloObservation, ...])