"""Logic for Payment Hold History.""" from owsresponse import response from abacus_account import models from abacus_account.schemas import PaymentHoldHistorySchema, PaymentHoldSchema def get_payment_hold_history(account_id): """Retrieve payment hold history for the specified account.""" history_list = [] account_obj = models.Account.get_by_id_or_error(account_id) current_hold = PaymentHoldSchema().dump(account_obj.payment_hold) if current_hold: history_list.append(current_hold) historical_holds = PaymentHoldHistorySchema(many=True).dump( account_obj.payment_hold_history) historical_holds.reverse() history_list += historical_holds return response.Response(message=history_list, status=200)