Source code for cadrumo.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.balance.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 the required:class:`~application.calculations.iva_compensation_history_ports.IvaCompensationHistoryRepositoryProtocol`to that pure projection.See Also: :func:`~domain.iva_compensation.carry_forward.build_iva_compensation_carry_forward_report` Builds the FIFO lot projection from stored period states. :func:`~domain.iva_compensation.balance.build_iva_wallet_balance_report` Collapses the carry-forward lots into the operator-facing balance snapshot."""from__future__importannotationsfrom...domain.iva_compensation.balanceimportIvaWalletBalanceReport,build_iva_wallet_balance_reportfrom...domain.iva_compensation.carry_forwardimportbuild_iva_compensation_carry_forward_reportfrom.iva_compensation_history_portsimportIvaCompensationHistoryRepositoryProtocol
[docs]defquery_iva_wallet_balance(*,as_of_year:int,repository:IvaCompensationHistoryRepositoryProtocol,)->IvaWalletBalanceReport:"""Load all stored IVA compensation period states and return the balance report. Reads :class:`~domain.iva_compensation.carry_forward.IvaCompensationPeriodState` rows from :class:`~application.calculations.iva_compensation_history_ports.IvaCompensationHistoryRepositoryProtocol`, builds a :class:`~domain.iva_compensation.carry_forward.IvaCompensationCarryForwardReport`, and returns an :class:`~domain.iva_compensation.balance.IvaWalletBalanceReport` summarising available compensation as of ``as_of_year``. """states=repository.list_periods()carry_forward=build_iva_compensation_carry_forward_report(states,as_of_year=as_of_year)returnbuild_iva_wallet_balance_report(carry_forward)