"""Ledger Contract Advance Applied Handler.""" from fastapi import APIRouter from moneyhub.logic import advances as logic from moneyhub.schemas.advance import AdvanceSchema ledger_contract_advance_applied_router = APIRouter( prefix='/applied-advances', tags=['applied_advanced'] ) @ledger_contract_advance_applied_router.get( '/account/{account_id}/statement-period/{statement_period_id}', status_code=200 ) def get_by_account_and_statement_period( account_id: int, statement_period_id: int, contract_id: int | None = None ) -> list[AdvanceSchema]: """GET applied advances for a specified account. Args: account_id (int): The id of an account statement_period_id (int): The id of the statement period contract_id (int): the id of a contract Returns: list: list of applied advances """ return logic.get_by_account_and_statement_periods( account_id, [statement_period_id], contract_id, )