From 524836f52aaf4c0aca3752d0f13535cd41e0c88a Mon Sep 17 00:00:00 2001 From: Chinenye Nmoh Date: Mon, 25 Aug 2025 11:00:40 +0100 Subject: [PATCH] added repayment_schedule --- app/routes/autocall.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/routes/autocall.py b/app/routes/autocall.py index 0ceb155..46492ef 100644 --- a/app/routes/autocall.py +++ b/app/routes/autocall.py @@ -291,6 +291,15 @@ def process_overdue_loan(loan): if not full_loan_data: logger.warning(f"Full Loan ID {loan.loan_id} not found in database") else: + #lets check if the loan with the repayment has been repaid, then update the loan schedule to paid + if full_loan_data.to_dict().get("status") == LoanStatus.REPAID and full_loan_data.to_dict().get("balance") == 0: + try: + LoanRepaymentScheduleService.update_repayment_schedule_status(loan.id, paid=True) + logger.info(f"Updated Loan Repayment Schedule ID {loan.id} to PAID") + return + except Exception as e: + db.session.rollback() + logger.error(f"Failed to update Loan Repayment Schedule ID {loan.id} to PAID: {e}") customer_id = full_loan_data.to_dict().get("customerId") loan_status = full_loan_data.to_dict().get("status") -- 2.34.1