aeat.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 authority_via_resources() (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.

class DataInventoryCasilla(casilla_id, number, label, localized_labels=<factory>, legal_refs=(), source_refs=(), binding_id=None, binding_source=None)[source]

Bases: object

One casilla entry on a data-inventory checklist.

Parameters:
  • casilla_id (CasillaId)

  • number (str)

  • label (str)

  • localized_labels (dict[str, str])

  • legal_refs (tuple[LegalRefId, ...])

  • source_refs (tuple[SourceRefId, ...])

  • binding_id (BindingId | None)

  • binding_source (str | None)

casilla_id: TypeAliasType
number: str
label: str
localized_labels: dict[str, str]
legal_refs: tuple[TypeAliasType, ...]
source_refs: tuple[TypeAliasType, ...]
binding_id: TypeAliasType | None
binding_source: str | None
class DataInventoryChecklist(modelo, revision_id, filing_year, period, required_manual, optional_manual, ledger_derivable, profile_derivable, unresolved_profile_bindings, profile_checked)[source]

Bases: object

Composed “what data do I need” checklist for one modelo/year/period.

required_manual and optional_manual are the casillas an operator must (or may) hand-enter. ledger_derivable are casillas the ledger aggregation mesh populates automatically once the relevant transactions are imported and classified — the operator imports these rather than typing them. profile_derivable are casillas populated from the active taxpayer profile (coefficients such as the home-office usage ratio); unresolved_profile_bindings names 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: str
filing_year: int
period: str
required_manual: tuple[DataInventoryCasilla, ...]
optional_manual: tuple[DataInventoryCasilla, ...]
ledger_derivable: tuple[DataInventoryCasilla, ...]
profile_derivable: tuple[DataInventoryCasilla, ...]
unresolved_profile_bindings: tuple[TypeAliasType, ...]
profile_checked: bool
data_inventory_checklist(*, modelo, filing_year, period, bucket_id)[source]

Compose the data-inventory checklist for one modelo / year / period.

Reads the resolved RegistrySnapshot for (modelo, filing_year, period) and classifies every casilla:

  • input_kind == MANUAL casillas split into required_manual / optional_manual by their required flag.

  • input_kind == BOUND casillas are classified by their binding’s BindingSourceKind: ledger-aggregation sources become ledger_derivable; profile sources become profile_derivable. Every other bound source (previous-filing carry, relation prefill, live observation, constant value, …) requires no operator data-gathering action and is intentionally omitted from the checklist.

  • COMPUTED and INFORMATIONAL casillas need no source data and are omitted.

When bucket_id names an active profile, profile_derivable bindings are cross-checked against profile_resolvable_binding_ids() and any binding the profile has not yet resolved is surfaced in unresolved_profile_bindings — the coefficient-missing warning the issue calls for (e.g. an unset home-office ratio). profile_checked is False when no bucket_id was supplied or the check could not run; callers should not read an empty unresolved_profile_bindings as “all clear” in that case.

Raises:

RegistrySnapshotError – When the registry has no revision covering (modelo, filing_year, period).

Return type:

DataInventoryChecklist

Returns:

A DataInventoryChecklist.

Parameters: