Source code for aeat.application.calculations._iva_wallet_balance
"""Repository-backed IVA compensation wallet balance query.Loads stored Modelo 303 compensation period states and projects them into thepure:class:`~domain.iva_compensation.IvaWalletBalanceReport` summaryowned by the IVA-compensation domain. The summary projection and its record areexposed from :mod:`domain.iva_compensation`; this module is the applicationorchestration that wires:class:`~application.calculations.IvaCompensationHistoryRepository`to that pure projection.See Also: :func:`~domain.iva_compensation.build_iva_compensation_carry_forward_report` Builds the FIFO lot projection from stored period states. :func:`~domain.iva_compensation.build_iva_wallet_balance_report` Collapses the carry-forward lots into the operator-facing balance snapshot."""from__future__importannotationsfrom...domain.iva_compensationimport(IvaWalletBalanceReport,build_iva_compensation_carry_forward_report,build_iva_wallet_balance_report,)from._iva_compensation_historyimportIvaCompensationHistoryRepository
[docs]defquery_iva_wallet_balance(*,as_of_year:int)->IvaWalletBalanceReport:"""Load all stored IVA compensation period states and return the balance report. Reads :class:`~domain.iva_compensation.IvaCompensationPeriodState` rows from :class:`~application.calculations.IvaCompensationHistoryRepository`, builds a :class:`~domain.iva_compensation.IvaCompensationCarryForwardReport`, and returns an :class:`~domain.iva_compensation.IvaWalletBalanceReport` summarising available compensation as of ``as_of_year``. """repo=IvaCompensationHistoryRepository()states=repo.list_periods()carry_forward=build_iva_compensation_carry_forward_report(states,as_of_year=as_of_year)returnbuild_iva_wallet_balance_report(carry_forward)