aeat.domain.calculations.registry._constructs module

Construct resolution for registry revisions.

Resolves named construct groups declared on a ModeloRevision into typed ResolvedConstruct records that list every member (casilla, formula, binding, etc.) with its id and value.

class ResolvedConstructMember(kind, id, value)[source]

Bases: object

One member resolved from a registry construct group.

A construct group bundles heterogeneous registry entities (casillas, formulas, parameters, bindings, etc.) under a common id. Each member records the entity kind (e.g. "casilla", "formula"), its registry id string, and the fully-typed value object retrieved from the revision index.

Parameters:
kind: str
id: str
value: object
class ResolvedConstruct(**data)[source]

Bases: RegistryModel

A fully-resolved registry construct group for one ModeloRevision.

A construct is a named thematic bundle declared in the registry TOML that groups related revision entities (casillas, formulas, bindings, etc.) so that consumers can iterate over them without knowing the full revision schema. After resolution every member carries its typed value object, not just its id string.

legal_refs and source_refs carry the provenance declared on the construct entry in the TOML tree; they are propagated unchanged from the ModeloRevision construct record.

Parameters:
  • id (str)

  • title (str)

  • legal_refs (Annotated[tuple[LegalRefId, ...], FieldInfo(annotation=NoneType, required=True, metadata=[MinLen(min_length=1)])])

  • source_refs (Annotated[tuple[SourceRefId, ...], FieldInfo(annotation=NoneType, required=True, metadata=[MinLen(min_length=1)])])

  • members (tuple[ResolvedConstructMember, ...])

id: str
title: str
legal_refs: LegalRefs
source_refs: SourceRefs
members: tuple[ResolvedConstructMember, ...]
members_of_kind(kind)[source]

Return every member whose kind matches the given string.

Parameters:

kind (str) – Entity kind to filter on, e.g. "casilla" or "formula".

Return type:

tuple[ResolvedConstructMember, ...]

Returns:

A tuple of matching ResolvedConstructMember instances, empty if no members carry the requested kind.

resolve_revision_constructs(revision)[source]

Resolve all construct groups declared on a revision.

Iterates over revision.constructs in declaration order and calls resolve_construct for each entry.

Parameters:

revision (ModeloRevision) – The ModeloRevision (a dated version of an AEAT modelo — tax form) whose construct groups should be resolved.

Return type:

tuple[ResolvedConstruct, ...]

Returns:

A tuple of ResolvedConstruct records in the same order as revision.constructs.

Raises:

RegistrySnapshotError – if any construct or its member references are missing from the revision.

resolve_construct(revision, construct_id)[source]

Resolve a single named construct group from a revision.

Looks up construct_id in revision.constructs, then iterates every member collection declared on the construct (casillas, formulas, parameters, bindings, and the remaining entity kinds in _CONSTRUCT_MEMBER_INDEXES) to build the typed ResolvedConstructMember list. Each member id is looked up in a pre-built revision index; an unknown id raises RegistrySnapshotError immediately.

Parameters:
Return type:

ResolvedConstruct

Returns:

A ResolvedConstruct carrying all members with their typed values.

Raises:

RegistrySnapshotError – if construct_id is not declared on the revision, or if any member id does not exist in the corresponding revision collection.