From 8323075ff720bcc70b75c4d25dc10e3fcbe31904 Mon Sep 17 00:00:00 2001 From: "CHIEFSOFT\\ameye" Date: Fri, 7 Nov 2025 18:36:18 -0500 Subject: [PATCH] layered found loan --- app/routes/autocall.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/app/routes/autocall.py b/app/routes/autocall.py index 4abdaf3..5a0f47b 100644 --- a/app/routes/autocall.py +++ b/app/routes/autocall.py @@ -125,12 +125,18 @@ def direct_loan(): loan = LoanService.get_loan_by_transaction_id(transaction_id=transaction_id) if not loan: - logger.warning(f"Loan with transaction id {transaction_id} does not exist") - return jsonify({ - "status": "error", - "message": f"Loan with transaction id {transaction_id} does not exist" - }), 400 + first_error = f"Loan with transaction id {transaction_id} does not exist" + logger.warning(first_error) + loan = LoanService.get_latest_loan_without_disburse_date() + if not loan: + logger.info(f"No loan found without disbursement date") + return jsonify({ + "status": "error", + "first_error": first_error, + "message": f"No loan found without disbursement date" + }), 400 + # Tried 2 method to get the loan record at this point loan_data = loan.to_dict() # Prevent double disbursement