aeat.application.modelo._calculation_source_staging module¶
Staged source-resolution helpers for bucket aggregation calculations.
These helpers let source resolvers that depend on current-year registry values run the registry engine once without persisting a calculation revision. The staged values feed prorrata and bienes-inversion regularizacion resolvers and add diagnostics for source kinds that would otherwise default to a silent zero.
See also
calculate_modelo_revision_from_bucket_aggregation()Bucket-backed calculate path that composes these staging helpers.
CalculationSourceResolutionSource-mesh envelope merged and diagnosed by this module.
merge_source_resolutions()Merge primitive used after staged prorrata and bienes-inversion resolutions are produced.
collect_unhandled_source_diagnostics()Diagnostic sweep used to surface declared-but-unhandled source kinds.
ProrrataRegularizacionSourceResolverResolver fed by materialised current-year prorrata registry values.
BienesInversionRegularizacionSourceResolverDependent capital-goods resolver composed with the staged prorrata pass.
calculate_registry_snapshot()Registry engine invoked without persistence to materialise current-year casilla values for staged resolvers.
- Governing vault records
2026-05-20-calculation-source-connectivity-adrand2026-06-10-calculation-engine-foundations-auditdefine the source-mesh design and no-dormant-source-resolver audit that govern these staging helpers.
- class SourceResolutionRegistryValues(values, initial_casilla_ids, unresolved_casilla_ids=(), missing_casilla_ids=())[source]¶
Bases:
objectRegistry-engine values materialised for a staged source resolver.
- Parameters:
- resolve_prorrata_regularizacion_sources(*, registry_snapshot, work_unit, context, source_resolution, casilla_inputs, text_casilla_inputs, binding_values, enum_binding_values, date_binding_values, relation_values, filing_period_date)[source]¶
Resolve prorrata and dependent capital-goods staged mesh sources.
- Parameters:
registry_snapshot (
RegistrySnapshot) – The target revision’sRegistrySnapshot, consulted to check whether the revision declares aprorrata_regularizacion-sourced binding at all.work_unit (
WorkUnit) – TheWorkUnitaddressing the target filing, threaded to the staged registry engine run.context (
CalculationSourceContext) – TheCalculationSourceContextthe staged prorrata and bienes-inversion resolvers resolve against.source_resolution (
CalculationSourceResolution) – The upstreamCalculationSourceResolutionmesh envelope the staged resolutions are merged into.casilla_inputs (
Mapping[TypeAliasType,Decimal] |None) – Operator- and backend-supplied casilla values that seed the staged registry run.text_casilla_inputs (
Mapping[TypeAliasType,str] |None) – Text-typed casilla inputs seeding the staged run.binding_values (
Mapping[TypeAliasType,Decimal] |None) – Caller-supplied Decimal binding values overlaid on the source resolution’s own binding values.enum_binding_values (
Mapping[TypeAliasType,str] |None) – Caller-supplied enum (string) binding values overlaid on the source resolution’s enum binding values.date_binding_values (
Mapping[TypeAliasType,date] |None) – Caller-supplied date binding values overlaid on the source resolution’s date binding values.relation_values (
Mapping[TypeAliasType,Decimal] |None) – Caller-supplied relation values overlaid on the source resolution’s relation values.filing_period_date (
date|None) – The filing period date used for period-sensitive resolution.
- Return type:
- Returns:
The source resolution unchanged when the revision declares no
prorrata_regularizacionbinding, otherwise the source resolution merged with the staged prorrata and bienes-inversion resolutions.
- materialise_prorrata_regularizacion_current_year_values(*, registry_snapshot, work_unit, casilla_inputs, backend_casilla_inputs, binding_values, enum_binding_values=None, date_binding_values=None, text_casilla_inputs=None, relation_values=None, unresolved_relation_ids=(), unresolved_binding_ids=(), filing_period_date=None)[source]¶
Materialise the current-year values needed by
prorrata_regularizacion.- Parameters:
registry_snapshot (
RegistrySnapshot) – The target revision’sRegistrySnapshot, used to resolve the current-year casilla ids through the registry engine.work_unit (
WorkUnit) – TheWorkUnitaddressing the target filing, threaded to the staged registry engine run.casilla_inputs (
Mapping[TypeAliasType,Decimal]) – Operator- and backend-supplied casilla values that seed the staged registry run.backend_casilla_inputs (
Mapping[TypeAliasType,Decimal] |None) – Casilla values already bound by the backend source resolution, seeded into the staged run.binding_values (
Mapping[TypeAliasType,Decimal]) – Decimal binding values overlaid on the staged run.enum_binding_values (
Mapping[TypeAliasType,str] |None) – Enum (string) binding values for the staged run.date_binding_values (
Mapping[TypeAliasType,date] |None) – Date binding values for the staged run.text_casilla_inputs (
Mapping[TypeAliasType,str] |None) – Text-typed casilla inputs for the staged run.relation_values (
Mapping[TypeAliasType,Decimal] |None) – Relation values for the staged run.unresolved_relation_ids (
tuple[TypeAliasType,...]) – Relation ids still unresolved after the backend pass, propagated so the engine does not treat them as zero.unresolved_binding_ids (
tuple[TypeAliasType,...]) – Binding ids still unresolved after the backend pass, propagated so the engine does not treat them as zero.filing_period_date (
date|None) – The filing period date used for period-sensitive resolution.
- Return type:
- Returns:
The narrowed
SourceResolutionRegistryValuesfor the four prorrata current-year casillas, or an empty materialisation when the revision does not declare all of them.
- materialise_registry_values_for_source_resolution(*, registry_snapshot, work_unit, casilla_inputs, backend_casilla_inputs, binding_values, enum_binding_values=None, date_binding_values=None, text_casilla_inputs=None, relation_values=None, unresolved_relation_ids=(), unresolved_binding_ids=(), staging_binding_defaults=None, filing_period_date=None)[source]¶
Run the registry engine without persistence so staged resolvers can read current values.
registry_snapshotis the compiledRegistrySnapshotthe engine evaluates the staged current-year values against.
- add_unhandled_source_diagnostics(revision, source_resolution)[source]¶
Add advisories for declared binding sources not handled by the mesh.
revisionis the compiledModeloRevisionwhose declared binding sources are checked against the mesh’s owned-source set.- Return type:
- Parameters:
revision (ModeloRevision)
source_resolution (CalculationSourceResolution)
- add_expected_missing_binding_diagnostics(revision, source_resolution)[source]¶
Mark present-source, no-value binding gaps unresolved instead of silent.
revisionis the compiledModeloRevisionwhose bound casillas are checked for present-source, no-value binding gaps.- Return type:
- Parameters:
revision (ModeloRevision)
source_resolution (CalculationSourceResolution)
- expected_but_missing_binding_ids(revision, *, owned_sources, resolved_binding_values)[source]¶
Return direct bound bindings whose present source resolved no value.
revisionis the compiledModeloRevisionwhose bindings and casillas are scanned for present-source, no-value gaps.- Return type:
tuple[tuple[TypeAliasType,TypeAliasType,BindingSourceKind],...]- Parameters:
revision (ModeloRevision)
owned_sources (frozenset[BindingSourceKind])