aeat.domain.modelos._protocols module

Domain-level repository Protocols for the modelos aggregate.

Application-layer code that persists or loads modelo work-unit catalogues, filing records, calculation results, or verification reports depends on these Protocols, not on the concrete adapter-backed repository classes. This keeps the domain layer free of adapter imports while still providing typed port surfaces.

The work-unit, calculation-revision, filing-record, and verification-report protocols return WorkUnitCatalogue, CalculationRevisionCatalogue, ModeloRecordCatalogue, and VerificationReportCatalogue instances while keeping application code independent of concrete storage adapters.

class WorkUnitCatalogueRepositoryProtocol(*args, **kwargs)[source]

Bases: Protocol

Narrow domain-facing repository contract for the work-unit catalogue.

Any object that provides exists, load, and save over a per-bucket WorkUnitCatalogue satisfies this protocol. The concrete secure-object-backed implementation is WorkUnitCatalogueRepository.

property bucket_id: str | None

Return the profile bucket id when this repository resolved one.

exists()[source]

Return whether a work-unit catalogue object has been persisted.

Return type:

bool

load()[source]

Return the persisted WorkUnitCatalogue or an empty catalogue if absent.

Return type:

WorkUnitCatalogue

save(catalogue)[source]

Persist catalogue as the encrypted singleton object.

Return type:

None

Parameters:

catalogue (WorkUnitCatalogue)

class CalculationRevisionCatalogueRepositoryProtocol(*args, **kwargs)[source]

Bases: Protocol

Narrow domain-facing repository contract for calculation revisions.

Any object that provides exists, load, and save over a per-bucket CalculationRevisionCatalogue satisfies this protocol. The concrete secure-object-backed implementation is CalculationRevisionCatalogueRepository.

property bucket_id: str | None

Return the profile bucket id when this repository resolved one.

exists()[source]

Return whether a calculation-revision catalogue object has been persisted.

Return type:

bool

load()[source]

Return the persisted catalogue or an empty catalogue if absent.

Return type:

CalculationRevisionCatalogue

Returns:

The CalculationRevisionCatalogue loaded from storage.

save(catalogue)[source]

Persist catalogue as the encrypted singleton object.

Return type:

None

Parameters:

catalogue (CalculationRevisionCatalogue)

to_secure_object_write(catalogue)[source]

Return the SecureObjectWrite for catalogue without committing it.

Return type:

SecureObjectWrite

Parameters:

catalogue (CalculationRevisionCatalogue)

save_with_secure_object_writes(catalogue, extra_writes)[source]

Persist catalogue plus co-emitted secure-object writes atomically.

Return type:

None

Parameters:
class ModeloRecordCatalogueQueryProtocol(*args, **kwargs)[source]

Bases: Protocol

Query contract exposed by loaded modelo filing-record catalogues.

current_for(*, bucket_id, modelo, filing_year, period, member_nif=None)[source]

Return the current ModeloRecord for a filing tuple and optional group member.

Return type:

ModeloRecord | None

Parameters:
history_for(*, bucket_id, modelo, filing_year, period, member_nif=None)[source]

Return ModeloRecord filing history for a filing tuple and optional group member.

Return type:

tuple[ModeloRecord, ...]

Parameters:
class ModeloRecordCatalogueRepositoryProtocol(*args, **kwargs)[source]

Bases: Protocol

Narrow domain-facing repository contract for modelo filing records.

Any object that provides exists, load, and save over a per-bucket ModeloRecordCatalogue satisfies this protocol. The concrete secure-object-backed implementation is ModeloRecordCatalogueRepository. The loaded catalogue supports member-scoped current_for and history_for lookups for grupo fan-in filings.

property bucket_id: str | None

Return the profile bucket id when this repository resolved one.

exists()[source]

Return whether a modelo-record catalogue object has been persisted.

Return type:

bool

load()[source]

Return the persisted ModeloRecordCatalogue or an empty catalogue if absent.

Return type:

ModeloRecordCatalogue

save(catalogue)[source]

Persist catalogue as the encrypted singleton object.

Return type:

None

Parameters:

catalogue (ModeloRecordCatalogue)

to_secure_object_write(catalogue)[source]

Return the SecureObjectWrite for catalogue without committing it.

Return type:

SecureObjectWrite

Parameters:

catalogue (ModeloRecordCatalogue)

save_with_secure_object_writes(catalogue, extra_writes)[source]

Persist catalogue plus co-emitted secure-object writes atomically.

Return type:

None

Parameters:
class VerificationReportCatalogueRepositoryProtocol(*args, **kwargs)[source]

Bases: Protocol

Narrow domain-facing repository contract for verification reports.

Any object that provides exists, load, and save over a per-bucket VerificationReportCatalogue satisfies this protocol. The concrete secure-object-backed implementation is VerificationReportCatalogueRepository.

property bucket_id: str | None

Return the profile bucket id when this repository resolved one.

exists()[source]

Return whether a verification-report catalogue object has been persisted.

Return type:

bool

load()[source]

Return the persisted catalogue or an empty catalogue if absent.

Return type:

VerificationReportCatalogue

Returns:

The VerificationReportCatalogue loaded from storage.

save(catalogue)[source]

Persist catalogue as the encrypted singleton object.

Return type:

None

Parameters:

catalogue (VerificationReportCatalogue)

class TransactionParticipationIndexRepositoryProtocol(*args, **kwargs)[source]

Bases: Protocol

Narrow domain-facing repository contract for the participation index.

The participation index is a per-transaction, derived-and-rebuildable read-side cache mapping a ledger transaction to the calculation revisions it participates in. Unlike the singleton catalogue repositories, its objects are keyed by transaction_id. Any object that provides exists, load, and save over a TransactionRevisionParticipationIndex satisfies this protocol; the concrete secure-object-backed implementation is TransactionParticipationIndexRepository. Lifecycle correctness never depends on this cache’s freshness — it is rebuilt from the revision catalogue — so the port is a navigation/read seam, not a source of truth.

property bucket_id: str | None

Return the profile bucket id when this repository resolved one.

exists(transaction_id)[source]

Return whether a participation-index object exists for transaction_id.

Return type:

bool

Parameters:

transaction_id (str)

load(transaction_id)[source]

Return the persisted index for transaction_id or an empty index if absent.

Return type:

TransactionRevisionParticipationIndex

Parameters:

transaction_id (str)

save(index)[source]

Persist index as the encrypted per-transaction object.

Return type:

None

Parameters:

index (TransactionRevisionParticipationIndex)