filter overdue loans by schedule #44

Merged
ameye merged 1 commits from test into master 2025-08-25 10:53:10 +00:00
+9
View File
@@ -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")