cadrumo.application.modelo.data_inventory module¶
Data-inventory checklist composer for one modelo / filing-year / period.
Composes the registry-authoritative facts an operator needs before they can calculate a modelo: which manual casillas are required, which are optional, which are populated automatically from the bucket ledger, and which are populated from the active taxpayer profile (with a per-binding readiness flag so an unset profile fact — e.g. the home-office usage ratio — surfaces as an actionable gap rather than a silent blank downstream).
This module owns the read-only composition over
(the generation-pinned indexed registry operation)
(the registry snapshot for the casilla/binding declarations) and
profile_resolvable_binding_ids()
(the profile-fact resolution already used by the bindings list --missing
surface), so the CLI requires command stays a thin projection layer. No new
aggregation path is introduced: the same registry snapshot and profile-binding
resolver the calculate path uses are read, not re-derived.
See also
required_input_casilla_ids_for_revision()Sibling helper returning only the bare required/optional id tuples (used by amendment completeness checks); this module composes the richer operator-facing checklist over the same snapshot.
profile_resolvable_binding_ids()Profile-fact binding resolver reused here to flag missing coefficients.
Core types:
ModeloRevision.
- class DataInventoryCasilla(casilla_id, number, label, legal_refs, source_refs, binding_id=None, binding_source=None)[source]¶
Bases:
objectOne casilla entry on a data-inventory checklist.
legal_refsandsource_refsare mandatory and non-empty: regulatory grounding travels with a casilla all the way to the operator, so an entry that cannot say which provision establishes it has nothing to show and must not be built. The refs are copied from the registryCasillaDefinition, which already refuses an ungrounded casilla at registry build; enforcing it here too means the checklist type states the guarantee itself rather than inheriting it from wherever its fields happened to come from.- Parameters:
-
casilla_id:
TypeAliasType¶
- class DataInventoryChecklist(modelo, revision_id, filing_year, period, required_manual, optional_manual, ledger_derivable, profile_derivable, previous_filing, relation_prefill, live_observation, unbucketed_sources, unresolved_profile_bindings, unresolved_profile_keys, profile_checked)[source]¶
Bases:
objectComposed “what data do I need” checklist for one modelo/year/period.
required_manualandoptional_manualare the casillas an operator must (or may) hand-enter.ledger_derivableare casillas the ledger aggregation mesh populates automatically once the relevant transactions are imported and classified — the operator imports these rather than typing them.profile_derivableare casillas populated from the active taxpayer profile (coefficients such as the home-office usage ratio).previous_filingandrelation_prefillexpose the two distinct cross-filing channels.live_observationcontains bucket-local observation, register, and invoice-backed sources; it does not imply a remote AEAT query.unbucketed_sourcespreserves any remaining declared binding pair for an advisory instead of silently dropping it.unresolved_profile_bindingsnames the subset of those bindings the active profile has not yet supplied a fact for, so the checklist can warn the operator before they calculate and hit a missing-binding refusal.- Parameters:
modelo (str)
revision_id (RevisionId)
filing_year (int)
period (str)
required_manual (tuple[DataInventoryCasilla, ...])
optional_manual (tuple[DataInventoryCasilla, ...])
ledger_derivable (tuple[DataInventoryCasilla, ...])
profile_derivable (tuple[DataInventoryCasilla, ...])
previous_filing (tuple[DataInventoryCasilla, ...])
relation_prefill (tuple[DataInventoryCasilla, ...])
live_observation (tuple[DataInventoryCasilla, ...])
unbucketed_sources (tuple[DataInventoryCasilla, ...])
unresolved_profile_bindings (tuple[BindingId, ...])
profile_checked (bool)
-
revision_id:
TypeAliasType¶
-
required_manual:
tuple[DataInventoryCasilla,...]¶
-
optional_manual:
tuple[DataInventoryCasilla,...]¶
-
ledger_derivable:
tuple[DataInventoryCasilla,...]¶
-
profile_derivable:
tuple[DataInventoryCasilla,...]¶
-
previous_filing:
tuple[DataInventoryCasilla,...]¶
-
relation_prefill:
tuple[DataInventoryCasilla,...]¶
-
live_observation:
tuple[DataInventoryCasilla,...]¶
-
unbucketed_sources:
tuple[DataInventoryCasilla,...]¶
-
unresolved_profile_keys:
tuple[str,...]¶ The profile keys those unresolved bindings consume, in binding order and de-duplicated. Carried alongside the binding ids because the operator needs to know WHICH PROFILE FACT to supply, and a binding id names the registry’s internal consumer of that fact rather than the fact itself.
- data_inventory_checklist(*, modelo, filing_year, period, bucket_id, operation)[source]¶
Compose the data-inventory checklist for one modelo / year / period.
Reads the resolved
RegistrySnapshotfor(modelo, filing_year, period)and classifies every casilla:input_kind == MANUALcasillas split intorequired_manual/optional_manualby theirrequiredflag.input_kind == BOUNDcasillas are classified by their binding’sBindingSourceKind: ledger-aggregation sources becomeledger_derivable;profilesources becomeprofile_derivable; prior-filing carries, relation prefills, and bucket-local observation/register/invoice sources have their own buckets. Source kinds outside those explicit buckets remain visible inunbucketed_sourcesso taxonomy growth cannot silently disappear.COMPUTEDandINFORMATIONALcasillas need no source data and are omitted.
When
bucket_idnames an active profile,profile_derivablebindings are cross-checked againstprofile_resolvable_binding_ids()and any binding the profile has not yet resolved is surfaced inunresolved_profile_bindings— the coefficient-missing warning the issue calls for (e.g. an unset home-office ratio).profile_checkedisFalsewhen nobucket_idwas supplied or the check could not run; callers should not read an emptyunresolved_profile_bindingsas “all clear” in that case.- Raises:
RegistrySnapshotError – When the registry has no revision covering
(modelo, filing_year, period).- Return type:
- Returns:
- Parameters:
modelo (str)
filing_year (int)
period (Period)
bucket_id (str | None)
operation (PinnedAuthorityOperation)