cadrumo.application.modelo.declarations_workspace module¶
Pure, frontend-neutral projection for the Declarations workspace.
Callers preload the secure Modelo catalogues and provide explicit source observations. This module validates their joins and projects only natural declaration coordinates, lifecycle states, and non-sensitive timestamps. It does not resolve repositories, contact AEAT, or retain financial/evidence payloads for serialization.
Core types:
CalculationRevision,
ModeloRecord.
- exception DeclarationsWorkspaceProjectionError(message=None, *, context=None, translated_message=None)[source]¶
Bases:
CadrumoErrorThe supplied authorities cannot form one coherent safe snapshot.
- Parameters:
- Return type:
None
- code¶
- class DeclarationsWorkspaceZone(*values)[source]¶
Bases:
StrEnumExact read areas owned by the Declarations landing.
- DECLARATIONS¶
- CALCULATION_REVISIONS¶
- FILING_HISTORY¶
- class DeclarationsWorkspaceSource(*values)[source]¶
Bases:
StrEnumCanonical source axes retained by the projection.
- LOCAL_DECLARATIONS¶
- LOCAL_CALCULATIONS¶
- LOCAL_FILINGS¶
- LOCAL_LIFECYCLE¶
- AEAT_EVIDENCE¶
- class DeclarationsWorkspaceAvailability(*values)[source]¶
Bases:
StrEnumWhether a source snapshot can make an authoritative claim.
- AVAILABLE¶
- LOCKED¶
- STALE¶
- NEVER_CAPTURED¶
- UNAVAILABLE¶
- class DeclarationsLifecycleKind(*values)[source]¶
Bases:
StrEnumSanitized lifecycle meanings accepted by the workspace projection.
VERIFICATION_REFUSEDexists because a refusal has nowhere else honest to go. Without it a surface reading the kind alone would either drop the event, which turns a refusal into an absence, or fold it intoVERIFIED, which reports a refused verification as a passed one.- CREATED¶
- RENAMED¶
- CALCULATED¶
- VERIFIED¶
- VERIFICATION_REFUSED¶
- FILED¶
- SUPERSEDED¶
- AMENDED¶
- DISCARDED¶
- EXTERNAL_EVIDENCE_IMPORTED¶
- EXPORTED¶
- RECONCILED¶
- OBSERVATION_OVERRIDDEN¶
- OBSERVATION_OVERRIDE_CLEARED¶
- class DeclarationsWorkspaceZoneObservationV1(**data)[source]¶
Bases:
BaseModelCaller-observed availability before any rows are projected.
- Parameters:
data (Any)
- zone: DeclarationsWorkspaceZone¶
- availability: DeclarationsWorkspaceAvailability¶
- observed_at: UtcInstant | None¶
- reason_code: NamespacedId | None¶
- class DeclarationsWorkspaceZoneStateV1(**data)[source]¶
Bases:
DeclarationsWorkspaceZoneObservationV1One zone’s authority, freshness, and measured cardinality.
- Parameters:
zone (DeclarationsWorkspaceZone)
availability (DeclarationsWorkspaceAvailability)
observed_at (Annotated[datetime, AfterValidator(func=~cadrumo.core.time.utc.validate_utc_aware)] | None)
reason_code (Annotated[str, StringConstraints(strip_whitespace=None, to_upper=None, to_lower=None, strict=None, min_length=3, max_length=160, pattern=^[a-z][a-z0-9_]*(?:\.[a-z][a-z0-9_]*)+$, ascii_only=None)] | None)
- sources: tuple[DeclarationsWorkspaceSource, ...]¶
- item_count: NonNegativeInt | None¶
- class DeclarationsWorkspaceDeclarationRefV1(**data)[source]¶
Bases:
BaseModelSafe natural coordinate for one local declaration.
- Parameters:
data (Any)
- work_unit_id: WorkUnitId¶
- modelo: ModeloCode¶
- filing_year: FilingYear¶
- period: Period¶
- state: WorkUnitState¶
- has_current_calculation: bool¶
- has_current_filing: bool¶
- settled_result: str | None¶
The declaration’s own settled figure, when the registry grounds one.
None means the answer is UNKNOWN, and a surface must render it that way rather than as a blank or a zero. Three distinct situations reach it, and none of them is “the result is nothing”: the modelo’s settlement chain is not modelled (303 and 130 today declare no result role at all), no current calculation exists yet, or the calculation exists and has not computed that cell.
- class DeclarationsWorkspaceCalculationRevisionRefV1(**data)[source]¶
Bases:
BaseModelSafe state reference for one calculation version.
- Parameters:
data (Any)
- calculation_revision_id: CalculationRevisionId¶
- work_unit_id: WorkUnitId¶
- modelo: ModeloCode¶
- filing_year: FilingYear¶
- period: Period¶
- state: CalculationRevisionState¶
- created_at: UtcInstant¶
- updated_at: UtcInstant¶
- is_current: bool¶
- is_filed: bool¶
- class DeclarationsWorkspaceFilingRefV1(**data)[source]¶
Bases:
BaseModelOne chain entry: local currency, origin, AEAT confirmation and correction link.
- Parameters:
data (Any)
- filing_record_id: FilingRecordId¶
- work_unit_id: WorkUnitId¶
- calculation_revision_id: CalculationRevisionId¶
- modelo: ModeloCode¶
- filing_year: FilingYear¶
- period: Period¶
- filed_at: UtcInstant¶
- local_status: ModeloRecordStatus¶
- origin: FilingOrigin¶
- confirmation: AeatConfirmationState¶
- declaration_kind: FilingDeclarationKind¶
- amends_filing_record_id: FilingRecordId | None¶
- evidence_kind: ExternalEvidenceKind | None¶
- class DeclarationsSanitizedLifecycleFactV1(**data)[source]¶
Bases:
BaseModelPayload-free lifecycle fact supplied by an application authority.
- Parameters:
data (Any)
- fact_id: str¶
- work_unit_id: WorkUnitId¶
- occurred_at: UtcInstant¶
- kind: DeclarationsLifecycleKind¶
- class DeclarationsWorkspaceLifecycleRefV1(**data)[source]¶
Bases:
BaseModelSanitized lifecycle fact joined to its natural declaration address.
- Parameters:
data (Any)
- fact_id: str¶
- work_unit_id: WorkUnitId¶
- modelo: ModeloCode¶
- filing_year: FilingYear¶
- period: Period¶
- occurred_at: UtcInstant¶
- kind: DeclarationsLifecycleKind¶
- class DeclarationsWorkspaceProjectionV1(**data)[source]¶
Bases:
BaseModelImmutable safe index over one coherent preloaded Declarations snapshot.
- Parameters:
data (Any)
- contract_version: int¶
- bucket_id: BucketId¶
- zones: tuple[DeclarationsWorkspaceZoneStateV1, ...]¶
- declarations: tuple[DeclarationsWorkspaceDeclarationRefV1, ...]¶
- calculation_revisions: tuple[DeclarationsWorkspaceCalculationRevisionRefV1, ...]¶
- filings: tuple[DeclarationsWorkspaceFilingRefV1, ...]¶
- lifecycle: tuple[DeclarationsWorkspaceLifecycleRefV1, ...]¶
- project_declarations_workspace(*, operation, bucket_id, work_units, calculation_revisions, filing_records, lifecycle_facts, zone_observations, result_casilla_reader=None)[source]¶
Validate and safely project already-loaded local authorities.
- Return type:
- Parameters:
operation (PinnedAuthorityOperation)
bucket_id (Annotated[str, StringConstraints(strip_whitespace=True, to_upper=None, to_lower=None, strict=None, min_length=1, max_length=128, pattern=None, ascii_only=None)])
work_units (WorkUnitCatalogue)
calculation_revisions (CalculationRevisionCatalogue)
filing_records (ModeloRecordCatalogue)
lifecycle_facts (tuple[DeclarationsSanitizedLifecycleFactV1, ...])
zone_observations (tuple[DeclarationsWorkspaceZoneObservationV1, ...])
result_casilla_reader (Callable[[ModeloCode, int, Period], str | None] | None)
- DeclarationResultCasillaReaderV1¶
Names the casilla that settles one modelo revision, or nothing.
Injected rather than resolved here: this module joins already-loaded local authorities and holds no registry access, and giving it some would put registry loading inside a projection that is meant to be a pure join.
- class SettledResultUnitV1(*args, **kwargs)[source]¶
Bases:
ProtocolThe work-unit surface
_settled_result()actually reads.Declared structurally so the reader’s contract is the four attributes it consumes rather than the whole
WorkUnitaggregate. A caller that can supply a modelo, year, period and current calculation id is a valid argument, which is what the settlement tests exercise.- property modelo: ModeloCode¶