aeat.domain.iva_compensation._reconciliation module¶
IVA compensation reconciliation decision data models.
The live AEAT wallet is external state. Local Modelo 303 recurrence is internal reconstruction. These pure typed records describe the evidence sources, the explicit taxpayer override, and the effective binding decision consumed by Modelo 303 calculation. They carry no adapter or application coupling: the orchestration that produces them from live wallet observations and prior-filing recurrence stays in the application layer.
The IvaCompensationReconciliationDecision model encodes the
regulatory invariant relating selected_authority to
selected_amount and the blocked-wallet refusal in its
model_validator.
- class IvaCompensationOverride(**data)[source]¶
Bases:
BaseModelExplicit taxpayer override for Modelo 303 prior compensation.
- amount: Decimal¶
- reason: str¶
- evidence_locator: str¶
- recorded_at: datetime¶
- class IvaCompensationAuthoritySource(**data)[source]¶
Bases:
BaseModelOne evidence source considered by an IVA compensation decision.
- Parameters:
- source_kind: IvaCompensationAuthorityKind¶
- amount: Decimal | None¶
- source_locator: str¶
- captured_at: datetime | None¶
- source_modelo: str | None¶
- source_filing_year: int | None¶
- source_periods: tuple[Period, ...]¶
- class IvaCompensationReconciliationDecision(**data)[source]¶
Bases:
BaseModelEffective prior-compensation binding decision for Modelo 303.
This record is persisted and replayed by calculation. A live wallet fetch creates evidence; this decision says whether that evidence can safely drive the binding or whether review is required.
- Parameters:
taxpayer_nif (str)
target_year (int)
target_period (Period)
selected_authority (IvaCompensationAuthority)
selected_amount (Decimal | None)
wallet_amount (Decimal | None)
local_recurrence_amount (Decimal | None)
override_amount (Decimal | None)
divergence (IvaCompensationDivergence)
blocked (bool)
stale_wallet (bool)
reason (str)
wallet_captured_at (datetime | None)
authority_sources (tuple[IvaCompensationAuthoritySource, ...])
decided_at (datetime)
- taxpayer_nif: str¶
- target_year: int¶
- target_period: Period¶
- selected_authority: IvaCompensationAuthority¶
- selected_amount: Decimal | None¶
- wallet_amount: Decimal | None¶
- local_recurrence_amount: Decimal | None¶
- override_amount: Decimal | None¶
- divergence: IvaCompensationDivergence¶
- blocked: bool¶
- stale_wallet: bool¶
- reason: str¶
- wallet_captured_at: datetime | None¶
- authority_sources: tuple[IvaCompensationAuthoritySource, ...]¶
- decided_at: datetime¶
- class IvaCompensationWalletObservationProtocol(*args, **kwargs)[source]¶
Bases:
ProtocolStructural port for an AEAT IVA-compensation wallet observation.
Lets the reconciliation decision logic stay in the domain without importing the Sede adapter record that produces it; the adapter’s
IvaCompensationWalletObservationsatisfies this protocol structurally. Members are read-only (the reconciliation only reads them), which keeps the protocol covariant so a record whose attributes are subtypes (e.g. anAnyHttpUrlsource_url) still satisfies it.
- class LocalIvaCompensationRecurrenceProtocol(*args, **kwargs)[source]¶
Bases:
ProtocolStructural port for a local Modelo 303 recurrence record.
The application’s
LocalIvaCompensationRecurrencesatisfies this protocol structurally; the domain projects it into an authority source without importing the application layer. Members are read-only for covariance.
- reconcile_iva_compensation_wallet(*, taxpayer_nif, target_year, target_period, wallet, local_recurrence_amount, local_recurrence_source=None, override=None, decided_at=None, max_wallet_age_days=31, is_first_iva_period=False)[source]¶
Return the
IvaCompensationReconciliationDecisionfor casilla110.- Return type:
- Parameters:
taxpayer_nif (str)
target_year (int)
target_period (Period)
wallet (IvaCompensationWalletObservationProtocol | None)
local_recurrence_amount (Decimal | None)
local_recurrence_source (IvaCompensationAuthoritySource | None)
override (IvaCompensationOverride | None)
decided_at (datetime | None)
max_wallet_age_days (int)
is_first_iva_period (bool)
- local_recurrence_authority_source(recurrence)[source]¶
Project a local Modelo 303 recurrence record into an
IvaCompensationAuthoritySource.- Return type:
- Parameters:
recurrence (LocalIvaCompensationRecurrenceProtocol | None)