aeat.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
modeloPublic facade that re-exports these Modelo 145 record DTOs and service functions.
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, suggestion=None, translated_message=None)[source]¶
Bases:
ModeloErrorBase error for Modelo 145 local communication service failures.
- Parameters:
- Return type:
None
- code: ClassVar[ErrorCode]¶
- exception M145CommunicationRecordNotFoundError(message=None, *, context=None, suggestion=None, translated_message=None)[source]¶
Bases:
M145CommunicationServiceError,KeyErrorRaised when a Modelo 145 communication record lookup targets no record.
- Parameters:
- Return type:
None
- code: ClassVar[ErrorCode]¶
- exception M145CommunicationRecordAmbiguousError(message=None, *, context=None, suggestion=None, translated_message=None)[source]¶
Bases:
M145CommunicationServiceError,KeyErrorRaised when a Modelo 145 communication record prefix matches multiple records.
- Parameters:
- Return type:
None
- code: ClassVar[ErrorCode]¶
- exception M145CommunicationRecordValidationError(message=None, *, context=None, suggestion=None, translated_message=None)[source]¶
Bases:
M145CommunicationServiceError,ValueErrorRaised when a Modelo 145 communication operation is blocked by validation.
- Parameters:
- Return type:
None
- code: ClassVar[ErrorCode]¶
- exception M145CommunicationRecordExportError(message=None, *, context=None, suggestion=None, translated_message=None)[source]¶
Bases:
M145CommunicationServiceError,ValueErrorRaised when a Modelo 145 communication export cannot be rendered.
- Parameters:
- Return type:
None
- code: ClassVar[ErrorCode]¶
- exception M145CommunicationRecordTransitionError(message=None, *, context=None, suggestion=None, translated_message=None)[source]¶
Bases:
M145CommunicationServiceError,ValueErrorRaised when a Modelo 145 communication state transition is not allowed.
- Parameters:
- Return type:
None
- code: ClassVar[ErrorCode]¶
- class M145CommunicationPeriod(*values)[source]¶
Bases:
StrEnumRegistry-backed local communication period tokens for Modelo 145.
- COMMUNICATION¶
- VARIATION¶
- 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:
- 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:
schema_version (str)
communication_record_id (Annotated[str, FieldInfo(annotation=NoneType, required=True, metadata=[MinLen(min_length=64), MaxLen(max_length=64), _PydanticGeneralMetadata(pattern='^[0-9a-f]{64}$')])])
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)])
service_owner (str)
modelo (str)
communication_year (int)
period_token (M145CommunicationPeriod)
revision_id (str)
valid (bool)
issue_count (int)
issues (tuple[M145CommunicationValidationIssue, ...])
- schema_version: str¶
- communication_record_id: M145CommunicationRecordId¶
- bucket_id: BucketId¶
- service_owner: str¶
- modelo: str¶
- communication_year: int¶
- period_token: M145CommunicationPeriod¶
- revision_id: str¶
- valid: bool¶
- issue_count: int¶
- 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.
- Parameters:
schema_version (str)
communication_record_id (Annotated[str, FieldInfo(annotation=NoneType, required=True, metadata=[MinLen(min_length=64), MaxLen(max_length=64), _PydanticGeneralMetadata(pattern='^[0-9a-f]{64}$')])])
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)])
service_owner (str)
modelo (str)
communication_year (int)
period_token (M145CommunicationPeriod)
revision_id (str)
export_layout_id (str)
encoding (str)
record_count (int)
byte_length (int)
payload_sha256 (str)
payload (bytes)
- schema_version: str¶
- communication_record_id: M145CommunicationRecordId¶
- bucket_id: BucketId¶
- service_owner: str¶
- modelo: str¶
- communication_year: int¶
- period_token: M145CommunicationPeriod¶
- revision_id: str¶
- export_layout_id: str¶
- encoding: str¶
- record_count: int¶
- byte_length: int¶
- payload_sha256: str¶
- 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:
- 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:
communication_record_id (Annotated[str, FieldInfo(annotation=NoneType, required=True, metadata=[MinLen(min_length=64), MaxLen(max_length=64), _PydanticGeneralMetadata(pattern='^[0-9a-f]{64}$')])])
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)])
service_owner (str)
modelo (str)
communication_year (int)
period_token (M145CommunicationPeriod)
revision_id (str)
state (M145CommunicationRecordState)
field_values (dict[CasillaId, Annotated[str, FieldInfo(annotation=NoneType, required=True, metadata=[MaxLen(max_length=512)])]])
created_at (datetime)
delivered_to_payer_at (datetime | None)
locally_completed_at (datetime | None)
note (str | None)
- communication_record_id: M145CommunicationRecordId¶
- bucket_id: BucketId¶
- service_owner: str¶
- modelo: str¶
- communication_year: int¶
- period_token: M145CommunicationPeriod¶
- revision_id: str¶
- 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¶
- 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:
- list_m145_communication_records(*, bucket_id)[source]¶
Return every local Modelo 145 communication record in one bucket.
- read_m145_communication_record(communication_record_id, *, bucket_id)[source]¶
Return one Modelo 145 communication record by id or unambiguous prefix.
- Return type:
- Parameters:
- validate_m145_communication_record(communication_record_id, *, bucket_id)[source]¶
Validate one persisted Modelo 145 communication record against registry authority.
- Return type:
- Parameters:
- export_m145_communication_record(communication_record_id, *, bucket_id, actor='aeat.application.modelo', bucket_event_repository=None)[source]¶
Render one Modelo 145 communication record through the registry export layout.
- 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)])
actor (str)
bucket_event_repository (BucketEventHistoryRepositoryProtocol | None)
- mark_m145_communication_record_delivered_to_payer(communication_record_id, *, bucket_id, actor='aeat.application.modelo', bucket_event_repository=None)[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)])
actor (str)
bucket_event_repository (BucketEventHistoryRepositoryProtocol | None)
- mark_m145_communication_record_locally_completed(communication_record_id, *, bucket_id, actor='aeat.application.modelo', bucket_event_repository=None)[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)])
actor (str)
bucket_event_repository (BucketEventHistoryRepositoryProtocol | None)
- create_m145_communication_record(command, *, bucket_id, actor='aeat.application.modelo', bucket_event_repository=None)[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)])
actor (str)
bucket_event_repository (BucketEventHistoryRepositoryProtocol | None)