aeat.domain.iva_compensation._balance module

Pure IVA-compensation wallet balance projection for Modelo 303.

Summarises a IvaCompensationCarryForwardReport into a balance snapshot. All logic here is pure: it depends only on decimal, pydantic, STRICT_FROZEN_CONFIG-style strict config, and the sibling carry-forward records. The repository-backed orchestration that loads stored period states and builds the report lives in the application layer.

class IvaWalletBalanceReport(**data)[source]

Bases: BaseModel

Aggregated IVA compensation carry-forward balance as of a reference year.

Parameters:
as_of_year: int
total_balance: Decimal
active_balance: Decimal
expired_balance: Decimal
lot_count: int
next_expiry_year: int | None
unallocated_applied_amount: Decimal
build_iva_wallet_balance_report(carry_forward)[source]

Summarise a carry-forward report into a balance snapshot.

total_balance is the gross remaining balance across all positive lots. active_balance is the portion still inside the four-year compensation window, including lots due for expiry review. expired_balance is the portion past that window and therefore not usable without separate review.

next_expiry_year is source_filing_year + 4 for the earliest non-expired lot that still carries a non-zero remaining balance (the lot closest to its four-year expiry boundary). None when no non-expired lots with remaining balance exist.

Returns an IvaWalletBalanceReport.

Return type:

IvaWalletBalanceReport

Parameters:

carry_forward (IvaCompensationCarryForwardReport)