filter overdue loans by schedule #44
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user