cadrumo.application.modelo._calculation_modelo_adjustments module¶
Modelo-specific adjustment helpers for calculation actions.
These private helpers keep model-specific edge cases out of the generic calculation action path: M131 fixed-record data-base projections, M390/M303 cross-period reconciliation refusal, and M349 row-template/display suppression. They operate on the already resolved registry snapshot and preserve the typed observation contract that the calculation action persists.
See also
calculate_modelo_revision()Application calculation action that calls these adjustment helpers.
calculate_registry_snapshot()Registry engine whose output is adjusted before persistence.
RegistrySnapshotLaw-determined snapshot used for relation and period requirements.
ModeloRevisionRevision whose export layouts, bindings, and relations drive the model-specific adjustments.
CasillaObservationProvenance-bearing observation rows filtered with M349 template fields.
WorkUnitModelo, filing year, and period context selecting each adjustment.
- detail_row_declaration_modelos(*, effective_date)[source]¶
Return registry-declared detail-row declaration modelos.
Detail-row ownership is authored by the selected registry revision. This calculation helper deliberately does not carry a second, module-level owner catalogue; callers that need the declaration surface query the revision instead.
- require_detail_rows_declared_for_their_owning_modelo(*, work_unit, detail_rows)[source]¶
Refuse any detail row whose typed kind belongs to a different modelo.
Each
ModeloDetailRowsubtype is a bespoke per-modelo shape (M184 member, M232 vinculada, M349 operador/rectificación, M347 contraparte, M210 agrupación renta) that is never legitimately declared against a different modelo’s work unit. Before this check existed, a mismatched row was silently PERSISTED into that revision’sdetail_rowswhile contributing to no figure – a taxpayer-declared row that appeared to exist yet affected nothing, with no advisory anywhere. Every kind now refuses through one convention rather than five ad hoc call sites.This runs at the calculate boundary’s single funnel (
_calculate_modelo_revision_with_trusted_mesh_sources()), so both the direct and bucket-aggregation calculate entry points are covered.- Return type:
- Parameters:
work_unit (WorkUnit)
detail_rows (tuple[Modelo184MemberRow | Modelo232VinculadaRow | Modelo349OperadorRow | Modelo349RectificacionRow | Modelo347ContraparteRow | Modelo210AgrupacionRentaRow, ...])
- union_detail_rows_by_identity(*, resolver_rows, caller_rows)[source]¶
Union resolver-produced and caller-supplied detail rows by identity.
Naive concatenation double-counts a row two supply paths both name – an invoice-derived M349 operador row the operator also enters manually, for instance – inflating every downstream count and sum derived from the row set. Rows are grouped by (row type, natural identity); a group fed by only one path passes through unchanged. A group fed by BOTH paths unions to the resolver’s row when every remaining field (the declarable figures) agrees, and REFUSES, naming the identity and the divergent fields, when they disagree – an unstated precedence pick between two supply paths on a filing-grade value is not this function’s call to make.
Two same-path rows sharing an identity (two caller rows, or two resolver rows) are left as duplicates for the caller to see: this function’s contract is cross-path union, not intra-path deduplication, which is a different defect with a different owner.
- Return type:
tuple[Modelo184MemberRow|Modelo232VinculadaRow|Modelo349OperadorRow|Modelo349RectificacionRow|Modelo347ContraparteRow|Modelo210AgrupacionRentaRow,...]- Parameters:
resolver_rows (tuple[Modelo184MemberRow | Modelo232VinculadaRow | Modelo349OperadorRow | Modelo349RectificacionRow | Modelo347ContraparteRow | Modelo210AgrupacionRentaRow, ...])
caller_rows (tuple[Modelo184MemberRow | Modelo232VinculadaRow | Modelo349OperadorRow | Modelo349RectificacionRow | Modelo347ContraparteRow | Modelo210AgrupacionRentaRow, ...])
- reconciliation_relation_targets(snapshot)[source]¶
Return selected annual-relation targets from the registry revision.
Core types:
RegistrySnapshot.
- detail_row_binding_values_for_calculation(*, work_unit, revision, detail_rows)¶
- Return type:
- Parameters:
work_unit (WorkUnit)
revision (ModeloRevision)
detail_rows (tuple[Modelo184MemberRow | Modelo232VinculadaRow | Modelo349OperadorRow | Modelo349RectificacionRow | Modelo347ContraparteRow | Modelo210AgrupacionRentaRow, ...])
- m131_objective_estimation_data_base_inputs(*, work_unit, revision, binding_values)¶
Project M131 page-1/DPA datos-base fixed-record bindings into liquidation inputs.
- raise_if_m390_303_reconciliation_would_save_silent_zero(*, work_unit, snapshot, casilla_values, resolved_binding_values)¶
Refuse an M390 draft that would save zero 303 reconciliation slots from missing fold-in evidence.
- suppress_m349_row_field_template_outputs(*, work_unit, revision, casilla_values, observations)¶
- Return type:
tuple[dict[TypeAliasType,Decimal],tuple[CasillaObservation,...]]- Parameters:
work_unit (WorkUnit)
revision (ModeloRevision)
observations (tuple[CasillaObservation, ...])