aeat.application.live._borrador_100 module

Application-live persistence for captured Modelo 100 borrador snapshots.

Borrador100 is the proof-of-concept consumer of the shared _snapshot_base lifecycle abstraction. The public exception class names (BorradorSnapshotNotFoundError on lookup miss, LiveApplicationInputError on input-validation failures), Borrador100SnapshotService class identity, storage namespace, object-key layout, and method signatures are preserved exactly; only the inline state-machine, supersession, and content-id helpers have been routed through the shared base.

Snapshot records are wrapped in an Envelope and persisted through a SecureObjectRepository at FINANCIAL SensitivityClass under the borrador namespace.

exception BorradorSnapshotNotFoundError(message=None, *, context=None, suggestion=None, translated_message=None)[source]

Bases: SnapshotNotFoundError

Raised when a Modelo 100 borrador snapshot lookup misses by id.

SnapshotNotFoundError inherits AeatError first, so MRO routes __init__ through the structured constructor (accepts suggestion= / context= kwargs) rather than KeyError’s C-level constructor. Listing AeatError explicitly here would violate C3 linearization.

Parameters:
  • message (str | None)

  • context (Mapping[str, object] | None)

  • suggestion (str | None)

  • translated_message (str | None)

Return type:

None

code: ClassVar[ErrorCode]
class Borrador100Snapshot(**data)[source]

Bases: BaseModel

Captured Modelo 100 borrador values available to application consumers.

Parameters:
  • snapshot_id (str)

  • 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)])

  • modelo (str)

  • filing_year (int)

  • period (Period)

  • captured_at (datetime)

  • source_url (str)

  • state (SnapshotLifecycleState)

  • binding_values (Mapping[BindingId, _BorradorValue])

  • superseded_by_snapshot_id (str | None)

  • discarded_at (datetime | None)

  • discarded_by (str)

  • discard_reason (str)

snapshot_id: str
bucket_id: BucketId
modelo: str
filing_year: int
period: Period
captured_at: datetime
source_url: str
state: SnapshotLifecycleState
binding_values: Mapping[BindingId, _BorradorValue]
superseded_by_snapshot_id: str | None
discarded_at: datetime | None
discarded_by: str
discard_reason: str
borrador_100_snapshot_object_key(bucket_id, snapshot_id)[source]

Return the secure-object key for one bucket’s Modelo 100 borrador snapshot.

Return type:

str

Parameters:
  • bucket_id (str)

  • snapshot_id (str)

derive_borrador_100_snapshot_id(*, filing_year, period, captured_at, source_url, binding_values)[source]

Return the content-addressed id for one Modelo 100 borrador capture.

The canonical-JSON shape is preserved exactly so existing on-disk snapshot ids remain valid: routing through derive_snapshot_id_from_json does not change the hashed bytes.

Return type:

str

Parameters:
class Borrador100SnapshotRepository(*, bucket_id, objects=None)[source]

Bases: object

Secure-DB repository for captured Modelo 100 borrador snapshots.

Composes the shared SecureSnapshotRepository (one canonical encrypted secure-object snapshot store) rather than re-implementing the load / resolve / list / save boilerplate; the public class identity, method signatures, and BorradorSnapshotNotFoundError messages are preserved, and list_snapshots keeps the borrador captured_at ordering.

Parameters:
property bucket_id: str
exists(snapshot_id)[source]
Return type:

bool

Parameters:

snapshot_id (str)

load(snapshot_id)[source]
Return type:

Borrador100Snapshot

Parameters:

snapshot_id (str)

list_snapshots()[source]
Return type:

tuple[Borrador100Snapshot, ...]

resolve(snapshot_id)[source]
Return type:

Borrador100Snapshot

Parameters:

snapshot_id (str)

save(snapshot)[source]
Return type:

None

Parameters:

snapshot (Borrador100Snapshot)

class Borrador100SnapshotService(*, bucket_id, repository=None)[source]

Bases: SnapshotService[Borrador100Snapshot]

Canonical backend service for bucket-scoped Modelo 100 borrador snapshots.

Parameters:
capture(*, filing_year, period, captured_at, source_url, binding_values)[source]
Return type:

Borrador100Snapshot

Parameters:
list_snapshots(*, filing_year=None, state=SnapshotLifecycleState.ACTIVE)[source]
Return type:

tuple[Borrador100Snapshot, ...]

Parameters:
show(snapshot_id)[source]
Return type:

Borrador100Snapshot

Parameters:

snapshot_id (str)

latest_for_year(*, filing_year, period=None)[source]
Return type:

Borrador100Snapshot | None

Parameters: