"""Ledger Contract Advance Applied Logic.""" from sqlalchemy.engine.row import Row from moneyhub import models def get_by_account_and_statement_periods( account_id: int, statement_period_ids: list[int], contract_id: int | None ) -> list[Row | dict]: """Get applied advances for an account and statement period. Args: account_id (int): The id of an account statement_period_ids (list): The ids of the statement periods contract_id: Optional id of the contract Returns: list: List of paid advances """ return models.LedgerContractAdvanceApplied.get_by_account_and_statement_periods( account_id, statement_period_ids, contract_id)