"""Reserves Handler.""" from fastapi import APIRouter from moneyhub.logic import ledger_reserve_release_schedule as schedule_logic from moneyhub.logic import statement_reserves as statement_logic from moneyhub.schemas.ledger_reserve_release_schedule import LedgerReserveReleaseScheduleSchema from moneyhub.schemas.statement_reserves import StatementReservesSchema reserves_router = APIRouter(prefix='/reserves', tags=['reserves']) @reserves_router.get( '/account/{account_id}/statement-period/{statement_period_id}/schedules', response_model_exclude_unset=True, status_code=200 ) def get_ledger_reserve_release_schedules_by_account_id( account_id: int, statement_period_id: int ) -> list[LedgerReserveReleaseScheduleSchema]: """GET ledger reserve release schedules for a specified account. Args: account_id (int): The id of an account statement_period_id (int): The id of a statement period Returns: list: list of ledger reserve release schedules """ return schedule_logic.get_reserve_release_schedules(account_id, statement_period_id) @reserves_router.get( '/account/{account_id}/statement-period/{statement_period_id}', status_code=200 ) def get_statement_reserves_by_account_id( account_id: int, statement_period_id: int, contract_id: int | None = None ) -> StatementReservesSchema | None: """GET statement reserves totals 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: StatementReservesSchema: dict of statement reserves totals """ return statement_logic.get_statement_reserves( account_id, contract_id, statement_period_id)