cadrumo.application.modelo.m145_communication_records module¶
Modelo 145 local communication record creation and read-back.
This module owns the bucket-local record lifecycle for the Modelo 145 payer communication workflow. It validates operator-provided casilla values against the active registry revision, persists the local record, renders the official export layout, and records delivery/completion transitions without creating an AEAT filing path.
See also
m145_communicationFocused ownership contract consumed by this record service.
build_m145_communication_service_contract()Registry-backed ownership contract that refuses filing-like surfaces.
M145CommunicationCreateCommandStrict create-command DTO consumed by
create_m145_communication_record().M145CommunicationRecordPersisted bucket-local communication record handled by this module.
M145CommunicationValidationResultValidation result returned before export and on explicit validation.
ModeloRevisionRegistry revision whose casillas, legal refs, source refs, and export layouts ground every record and rendered payload.
RegistrySnapshotSnapshot wrapper resolved before create, validate, and export work.
- exception M145CommunicationServiceError(message=None, *, context=None, translated_message=None)[source]¶
Bases:
ModeloErrorBase error for Modelo 145 local communication service failures.
- Parameters:
- Return type:
None
- code¶
- exception M145CommunicationRecordNotFoundError(message=None, *, context=None, translated_message=None)[source]¶
Bases:
M145CommunicationServiceErrorRaised when a Modelo 145 communication record lookup targets no record.
- Parameters:
- Return type:
None
- code¶
- exception M145CommunicationRecordAmbiguousError(message=None, *, context=None, translated_message=None)[source]¶
Bases:
M145CommunicationServiceErrorRaised when a Modelo 145 communication record prefix matches multiple records.
- Parameters:
- Return type:
None
- code¶
- exception M145CommunicationRecordValidationError(message=None, *, context=None, translated_message=None)[source]¶
Bases:
M145CommunicationServiceErrorRaised when a Modelo 145 communication operation is blocked by validation.
- Parameters:
- Return type:
None
- code¶
- exception M145CommunicationRecordExportError(message=None, *, context=None, translated_message=None)[source]¶
Bases:
M145CommunicationServiceErrorRaised when a Modelo 145 communication export cannot be rendered.
- Parameters:
- Return type:
None
- code¶
- exception M145CommunicationRecordTransitionError(message=None, *, context=None, translated_message=None)[source]¶
Bases:
M145CommunicationServiceErrorRaised when a Modelo 145 communication state transition is not allowed.
- Parameters:
- Return type:
None
- code¶
- class M145CommunicationRecordState(*values)[source]¶
Bases:
StrEnumCreation-state vocabulary for local Modelo 145 communication records.
- CREATED¶
- DELIVERED_TO_PAYER¶
- LOCALLY_COMPLETED¶
- class M145CommunicationValidationIssueKind(*values)[source]¶
Bases:
StrEnumClosed issue vocabulary for Modelo 145 local communication validation.
- REVISION_MISMATCH¶
- SOURCE_AUTHORITY_MISMATCH¶
- UNDECLARED_CASILLA¶
- MISSING_REQUIRED¶
- INVALID_VALUE¶
- MISSING_SOURCE_AUTHORITY¶
- UNSUPPORTED_DATA_TYPE¶
- class M145CommunicationValidationIssue(**data)[source]¶
Bases:
BaseModelOne registry-backed validation issue for a local communication record.
- Parameters:
data (Any)
- kind: M145CommunicationValidationIssueKind¶
- casilla_id: CasillaId | None¶
- data_type: str | None¶
- message: str¶
- legal_refs: tuple[str, ...]¶
- source_refs: tuple[str, ...]¶
- class M145CommunicationValidationResult(**data)[source]¶
Bases:
BaseModelRegistry-backed validation result for one local communication record.
- Parameters:
data (Any)
- schema_version: str¶
- communication_record_id: M145CommunicationRecordId¶
- bucket_id: BucketId¶
- service_owner: str¶
- modelo: str¶
- communication_year: int¶
- period_token: M145CommunicationPeriod¶
- revision_id: RevisionId¶
- valid: bool¶
- issue_count: NonNegativeInt¶
- issues: tuple[M145CommunicationValidationIssue, ...]¶
- legal_refs: tuple[str, ...]¶
- source_refs: tuple[str, ...]¶
- class M145CommunicationExportResult(**data)[source]¶
Bases:
BaseModelRegistry-layout export payload for one local communication record.
byte_lengthandpayload_sha256are a RECEIPT forpayload: the communication event records them, and later history is anchored on them rather than on the bytes. A receipt that does not describe its own payload is worse than no receipt, because it reads as verified provenance.- Parameters:
data (Any)
- schema_version: str¶
- communication_record_id: M145CommunicationRecordId¶
- bucket_id: BucketId¶
- service_owner: str¶
- modelo: str¶
- communication_year: int¶
- period_token: M145CommunicationPeriod¶
- revision_id: RevisionId¶
- export_layout_id: str¶
- encoding: str¶
- record_count: int¶
- byte_length: int¶
- payload_sha256: ContentDigest¶
- payload: bytes¶
- legal_refs: tuple[str, ...]¶
- source_refs: tuple[str, ...]¶
- class M145CommunicationCreateCommand(**data)[source]¶
Bases:
BaseModelOperator request to create a local Modelo 145 payer communication record.
- Parameters:
data (Any)
- communication_year: int¶
- period_token: M145CommunicationPeriod¶
- field_values: dict[CasillaId, M145CommunicationFieldValue]¶
- note: str | None¶
- class M145CommunicationRecord(**data)[source]¶
Bases:
BaseModelPersisted bucket-local Modelo 145 communication record.
- Parameters:
data (Any)
- communication_record_id: M145CommunicationRecordId¶
- bucket_id: BucketId¶
- service_owner: str¶
- modelo: str¶
- communication_year: int¶
- period_token: M145CommunicationPeriod¶
- revision_id: RevisionId¶
- state: M145CommunicationRecordState¶
- field_values: dict[CasillaId, M145CommunicationFieldValue]¶
- legal_refs: tuple[str, ...]¶
- source_refs: tuple[str, ...]¶
- created_at: datetime¶
- delivered_to_payer_at: datetime | None¶
- locally_completed_at: datetime | None¶
- note: str | None¶
- property registry_snapshot_ref: RegistrySnapshotRef¶
Return the canonical coordinate represented by this record’s distributed identity fields.
- derive_m145_communication_record_id(*, bucket_id, communication_year, period_token, revision_id, field_values)[source]¶
Return the content-addressed id for a Modelo 145 communication record.
- Return type:
- Parameters:
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)])
communication_year (int)
period_token (M145CommunicationPeriod | str)
revision_id (RevisionId)
- m145_communication_record_object_key(bucket_id, communication_record_id)[source]¶
Return the secure-object storage key for one Modelo 145 communication record.
- read_m145_communication_record(communication_record_id, *, bucket_id, ports, operation)[source]¶
Return one Modelo 145 communication record by id or unambiguous prefix.
- Return type:
- Parameters:
communication_record_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)])
ports (M145CommunicationRecordsPorts)
operation (PinnedAuthorityOperation)
- validate_m145_communication_record(communication_record_id, *, bucket_id, ports, operation)[source]¶
Validate one persisted Modelo 145 communication record against registry authority.
- Return type:
- Parameters:
communication_record_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)])
ports (M145CommunicationRecordsPorts)
operation (PinnedAuthorityOperation)
- export_m145_communication_record(communication_record_id, *, bucket_id, renderer, ports, operation, actor='cadrumo.application.modelo')[source]¶
Render one Modelo 145 communication record through the registry export layout.
rendereris supplied by the composition root rather than resolved here: the fixed-width AEAT wire format is an adapter concern, and importing it from this layer is what the port exists to avoid.- Return type:
- Parameters:
communication_record_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)])
renderer (FicheroBoeRecordRenderer)
ports (M145CommunicationRecordsPorts)
operation (PinnedAuthorityOperation)
actor (str)
- mark_m145_communication_record_delivered_to_payer(communication_record_id, *, bucket_id, ports, operation, actor='cadrumo.application.modelo')[source]¶
Mark one valid local communication record as delivered to the payer.
- Return type:
- Parameters:
communication_record_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)])
ports (M145CommunicationRecordsPorts)
operation (PinnedAuthorityOperation)
actor (str)
- mark_m145_communication_record_locally_completed(communication_record_id, *, bucket_id, ports, operation, actor='cadrumo.application.modelo')[source]¶
Mark one payer-delivered local communication record as locally completed.
- Return type:
- Parameters:
communication_record_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)])
ports (M145CommunicationRecordsPorts)
operation (PinnedAuthorityOperation)
actor (str)
- create_m145_communication_record(command, *, bucket_id, ports, operation, actor='cadrumo.application.modelo')[source]¶
Persist a bucket-local Modelo 145 communication record.
Creation stores the operator-provided registry casilla values as a local payer communication record. It validates that every value is keyed by a casilla declared in the active Modelo 145 registry revision, persists the local record, and emits the communication-created bucket event.
- Return type:
- Parameters:
command (M145CommunicationCreateCommand)
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)])
ports (M145CommunicationRecordsPorts)
operation (PinnedAuthorityOperation)
actor (str)