aeat.domain.calculations.registry._queries module¶
Typed read API for modelo registry introspection surfaces.
RegistryQueryService wraps a ValidatedRegistryAuthority and exposes
structured report objects for the CLI list, describe, casillas, formulas, and
bindings commands. Queries narrow to a single ModeloDefinition and
then to one ModeloRevision selected by filing year, period, and
optional revision id.
- class RegistryQueryService(authority)[source]¶
Bases:
objectStable Python facade over the validated modelo registry authority.
- Parameters:
authority (ValidatedRegistryAuthority)
- list_modelos(*, year=None, domain=None)[source]¶
Return a catalogue listing of all registered modelos.
Each entry is a lightweight
ModeloListRowcarrying only summary fields — no revision details are resolved. The rows are sorted ascending by modelo code.- Parameters:
year (
int|None) – When supplied, restricts the listing to modelos that have at least one revision whoseperiod_selectorcovers the given filing year.Nonereturns all registered modelos.domain (
TaxDomain|None) – When supplied, restricts the listing to modelos whose registryTaxDomainequals the requested tax family (e.g.TaxDomain.IVA).Nonereturns every family. Theyearanddomainfilters compose: passing both narrows to modelos that satisfy each.
- Return type:
- Returns:
A
ModeloListReportcontaining the matching rows.
- source_inventory()[source]¶
Report every
BindingSourceKindthe committed registry declares, and where.Walks every committed modelo revision and every binding it declares, grouping by the binding’s
sourcekind. The result records, per source kind, the committed revisions that declare it and the per-revision binding count. This is a pure registry introspection surface — it does not consult the live calculation mesh — so it stays inside the domain boundary. A caller in the application layer joins this inventory against the disposition registry (build_binding_source_dispositions) to prove that every declared source kind is enrolled or explicitly deferred, never silently blank (theno-dormant-source-resolversconnectivity contract).- Return type:
- Returns:
A
RegistrySourceInventoryReportwhose rows are sorted by the source kind’s string value; each row’s sites are sorted by(modelo, revision_id).
- support_matrix()[source]¶
Return the registry-wide per-modelo support/capability matrix.
For every modelo the authority can load, builds a
ModeloEntrycapturing supported revisions, calc/manifest/export/extractor capability flags, declared per-ejercicio casilla renames, declared deprecation (support-removal) decisions, and declared AEAT-portal cross-references — every field read or folded directly from the loaded registry, never hand-maintained (seeno-dormant-source-resolvers/no-silent-under-declaration).- Return type:
- Returns:
A
ModeloSupportMatrixReportwhose entries are sorted bymodelo_id.
- describe_modelo(modelo, *, period=None, as_of=None)[source]¶
Return a full describe report for one modelo and its resolved revision.
Resolves the revision using the same precedence logic as the other query methods: when
periodis a bare registry token (e.g."1T","0A"), the revision that declares it is selected; whenperiodisNone, the latest revision byvalid_fromis returned. Usedescribe_modelo_for_scopewhen the filing year must participate in revision selection.- Parameters:
modelo (
str) – Short numeric identifier for the modelo (e.g."303").period (
str|None) – Optional period narrowing. Accepted forms are bare registry period tokens ("1T","0A","01"-"12") or declared non-date tokens such as"alta".as_of (
date|None) – Optional calendar date for validity gating. Defaults to today whenNone.
- Return type:
- Returns:
A
ModeloDescribeReportfor the resolved revision.- Raises:
RegistryValidationError – When
modelois not registered, the period is not declared by any revision, or no revision covers the requested scope.
- describe_modelo_for_scope(modelo, *, filing_year, period, as_of=None)[source]¶
Return a
ModeloDescribeReportfor a scope.- Return type:
- Parameters:
- casillas(modelo, *, period=None, as_of=None, input_kind=None, required=None, form_number=None)[source]¶
Return the casilla (numbered-box) listing for a resolved modelo revision.
A casilla is a numbered input box on an AEAT tax form. The listing includes every casilla in the resolved revision, optionally filtered to a subset by kind, required flag, or form page number.
- Parameters:
modelo (
str) – Short numeric identifier for the modelo (e.g."303").period (
str|None) – Optional period narrowing; seedescribe_modelofor accepted forms.as_of (
date|None) – Optional calendar date for validity gating.input_kind (
InputKind|None) – When supplied, restricts rows to casillas of the givenInputKind(e.g.InputKind.MANUAL,InputKind.COMPUTED).required (
bool|None) – When supplied, restricts rows to casillas whoserequiredflag matches this value.form_number (
str|None) – When supplied, restricts rows to casillas on the given physical form page or sub-form.
- Return type:
- Returns:
A
ModeloCasillasReportfor the resolved revision, containing the filtered casilla rows.- Raises:
RegistryValidationError – When the modelo or period is not registered, or no revision covers the requested scope.
- casillas_for_scope(modelo, *, filing_year, period, as_of=None, input_kind=None, required=None, form_number=None)[source]¶
Return a
ModeloCasillasReportfor a scope.
- casilla(modelo, casilla, *, period=None, as_of=None)[source]¶
Return the full semantic detail for one casilla on a resolved revision.
Addresses a single casilla by its canonical id or its printed
numberand surfaces the authoritative label, legal/source grounding, input kind, and — when the casilla is computed — the resolved formula expression. Revision selection follows the same precedence asdescribe_modelo().- Parameters:
- Return type:
- Returns:
A
ModeloCasillaDetailReportfor the addressed casilla.- Raises:
RegistryValidationError – When the modelo or period is not registered, no revision covers the requested scope, or the casilla id/number is not defined by the resolved revision.
- casilla_for_scope(modelo, casilla, *, filing_year, period, as_of=None)[source]¶
Return a
ModeloCasillaDetailReportfor a scope.
- bindings_for_scope(modelo, *, filing_year, period, as_of=None)[source]¶
Return bindings for a specific filing scope (already-parsed year + period).
Unlike bindings, this method accepts the already-parsed
filing_yearinteger and registryperiodstring (e.g."1T","01") produced by the CLI’s period-parsing step. This avoids re-parsing a user-facing period string when the caller already holds the decomposed values.- Return type:
- Returns:
A
ModeloBindingsReportfor the requested filing scope.- Parameters:
- formulas_for_scope(modelo, *, filing_year, period, as_of=None)[source]¶
Return a
ModeloFormulasReportfor a scope.- Return type:
- Parameters:
- bindings_for_year(modelo, *, filing_year, as_of=None)[source]¶
Return a
ModeloBindingsReportforfiling_year.bindingswith no period resolves the latest revision, which for a multi-revision modelo (e.g. Modelo 100, one revision per renta year) reports binding ids for the wrong year. This method instead selects the revision whoseperiod_selectorcoversfiling_year— the same revision a work unit created for the same(modelo, filing_year)resolves — so the reported binding ids are the ones the calculation will accept.- Return type:
- Parameters:
- bindings(modelo, *, period=None, as_of=None)[source]¶
Return the full binding listing for a resolved modelo revision.
A binding maps a financial-data source to a casilla or formula input. For year-specific binding ids (e.g. when a multi-revision modelo publishes different binding names per renta year) prefer
bindings_for_yearorbindings_for_scopeso the resolved revision matches the one the calculation engine will use.- Parameters:
- Return type:
- Returns:
A
ModeloBindingsReportfor the resolved revision.- Raises:
RegistryValidationError – When the modelo or period is not registered, or no revision covers the requested scope.
- formulas(modelo, *, period=None, as_of=None)[source]¶
Return the full formula listing for a resolved modelo revision.
Each row exposes one formula’s target_casilla_id and its complete input dependency set (casillas, bindings, parameters, and relation references), letting contributors inspect what drives a computed casilla without reading the raw registry TOML.
- Parameters:
- Return type:
- Returns:
A
ModeloFormulasReportfor the resolved revision.- Raises:
RegistryValidationError – When the modelo or period is not registered, or no revision covers the requested scope.