cadrumo.application.modelo.calculation_diagnostics module

Post-calculation advisory coordination for bucket aggregation calculations.

The bucket aggregation calculate path first resolves source-backed values, executes the registry formula engine, and persists the calculated revision. This module then fans out advisory-only checks over the loaded ModeloRevision and the computed CasillaId value map, returning non-blocking CalculationSourceDiagnostic rows for the caller to append to source mesh diagnostics. It does not compute, override, or persist casilla values.

The prior-payment collectors need persisted filing observations, so the coordinator shares one CalculationObservationRepositoryProtocol instance across them. The official-box and settlement collectors read only the revision structure and calculated casilla values. Together the collectors extend the source mesh’s no-silent-under-declaration diagnostics with checks whose evidence only exists after the revision has been calculated.

See also

calculate_modelo_revision_from_bucket_aggregation_with_diagnostics():

Calls this coordinator after the calculation revision has been created.

collect_official_box_unpopulated_diagnostics():

Mirrors registry-authored ADVISORY predicates as calculate diagnostics.

prior_payment_advisory:

Emits Modelo 130 prior-payment carry degradation advisories.

collect_settlement_not_computed_diagnostics():

Emits structural settlement-completeness advisories for partially modelled revisions.

collect_bienes_inversion_regularizacion_diagnostics():

Emits the Modelo 303 capital-goods IVA regularización proposed-casilla-43 advisory.

collect_prorrata_regularizacion_diagnostics():

Emits the Modelo 303 annual prorrata-general regularización proposed-casilla-44 advisory.

collect_bucket_aggregation_advisory_diagnostics(revision, casilla_values, *, modelo, period_token, filing_year, bucket_id, observation_repository, prorrata_register_repository, bienes_inversion_repository, transaction_repository, profile=None)[source]

Return advisory diagnostics raised after bucket aggregation calculation.

Runs the calculate-path advisory collectors in tuple order: official-box transcription, Modelo 130 prior-payment under-deduction, Modelo 130 prior-payment minoracion capture, settlement-not-computed structure, the Modelo 100 mínimo-por-descendientes undeclared-facts advisory, the Modelo 303 capital-goods IVA regularización (LIVA arts. 107-110) proposed-casilla-43 advisory, and the Modelo 303 annual prorrata-general regularización (LIVA arts. 104-105) proposed-casilla-44 advisory. These diagnostics are informational and non-blocking; the calculation result already exists, and the caller merely appends these rows to the source mesh’s existing CalculationSourceDiagnostic sequence.

The Modelo 100 mínimo-por-descendientes casillas (0513/0514) are no longer advisory-only for the halving/blank-entry checks a prior interim module raised: a computed engine (inject_derived_minimo_descendientes_facts()) that derives the Art. 58/61 LIRPF aggregate — including the custodia-compartida halving — directly from the active profile, so those two checks are structurally unreachable and were retired. A new, narrower advisory (collect_minimo_descendientes_undeclared_diagnostics()) replaces them: because a genuinely childless profile and a profile that simply never declared its descendientes both resolve 0513 to the same zero, this collector flags the ambiguous case (0513 = 0 and no descendiente facts declared at all) and points the operator at aeat config profile descendiente add.

Parameters:
  • revision (ModeloRevision) – The ModeloRevision whose predicates, casillas, and formulas are inspected.

  • casilla_values (Mapping[TypeAliasType, Decimal]) – Computed engine values keyed by CasillaId.

  • modelo (str) – Target modelo identifier used by modelo-specific advisory collectors.

  • period_token (str) – Bare registry period token for the filing being calculated.

  • filing_year (int) – Filing year whose same-ejercicio prior observations may be inspected.

  • bucket_id (str) – Bucket identifier used by profile-backed advisory collectors.

  • observation_repository (CalculationObservationRepositoryProtocol) – Required bucket-bound observation repository used by prior-payment advisory collectors.

  • prorrata_register_repository (ProrrataRegisterServiceRepositoryProtocol) – Required bucket-bound prorrata register capability used by the Modelo 303 regularización advisory.

  • bienes_inversion_repository (BienesInversionIvaRegisterRepositoryProtocol) – Required bucket-bound capital-goods register capability used by the Modelo 303 regularización advisory.

  • transaction_repository (TransactionCatalogueRepositoryProtocol) – Required bucket-bound transaction catalogue capability used by the annual IVA settlement advisory.

  • profile (ModeloWorkProfile | None) – The bucket’s profile when the calculation already loaded it; when omitted, the profile-backed collectors read it themselves.

Return type:

tuple[CalculationSourceDiagnostic, ...]

Returns:

Tuple of CalculationSourceDiagnostic advisory rows, or an empty tuple when no post-calculation advisory fires.

See also

CalculationObservationRepositoryProtocol:

Supplies the prior-filing observation catalogue used by the Modelo 130 prior-payment advisory collectors.

calculate_modelo_revision_from_bucket_aggregation_with_diagnostics():

Appends this tuple to the source mesh diagnostics on the returned bucket aggregation result.