aeat.domain.filing._amendment module

Strict amendment domain records for domain.filing.

Houses the immutable records that describe an AEAT amendment. The amended_draft field on each amendment record holds the originating ModeloDraft that the amendment modifies, keeping the draft’s casilla arithmetic and tax due values bound to the amendment for audit purposes.

Concrete variants are ModeloComplementaria (LGT Art. 122.2) and ModeloSustitutiva (LGT Art. 122.1), the CasillaChange delta entries, and the AmendmentKind enum. The orchestration use case application.filing.build_complementaria() lives at application.filing._complementaria; this module contains only the typed shapes and the deterministic make_amendment_id() helper so the repository (also under domain.filing) can persist amendments without depending on the application layer.

Callers operate on the discriminated union ModeloComplementaria | ModeloSustitutiva. There is no umbrella alias - pick the variant that matches the LGT Art. 122 article you’re filing under.

class AmendmentKind(*values)[source]

Bases: StrEnum

Legally distinct amendment kinds supported by the engine.

COMPLEMENTARIA
SUSTITUTIVA
class CasillaChange(**data)[source]

Bases: BaseModel

One changed casilla in an amendment delta.

Parameters:
casilla_id: CasillaId
old_value: Decimal | None
new_value: Decimal
reason: str
class BaseAmendment(**data)[source]

Bases: BaseModel

Shared shape across the two LGT Art. 122 amendment variants.

Concrete subclasses fix the amendment_kind discriminator to a single AmendmentKind literal so callers select the variant by class, not by enum value.

Parameters:
amendment_id: str
submission_id: str
original_csv: str
original_model: ModeloCode
original_period: Period
delta: CasillaDelta
amended_draft: ModeloDraft
created_at: datetime
class ModeloComplementaria(**data)[source]

Bases: BaseAmendment

LGT Art. 122.2 complementaria: corrects an already-presented filing.

Parameters:
amendment_kind: Literal[AmendmentKind.COMPLEMENTARIA]
class ModeloSustitutiva(**data)[source]

Bases: BaseAmendment

LGT Art. 122.1 sustitutiva: replaces an already-presented filing in full.

Parameters:
amendment_kind: Literal[AmendmentKind.SUSTITUTIVA]
make_amendment_id(*, submission_id, amendment_kind, delta)[source]

Compute a stable amendment identifier.

Return type:

str

Parameters: