diff --git a/app/api/services/provide_loan.py b/app/api/services/provide_loan.py index ad30b6b..58c02cf 100644 --- a/app/api/services/provide_loan.py +++ b/app/api/services/provide_loan.py @@ -35,7 +35,13 @@ class ProvideLoanService(BaseService): if (ProvideLoanService.validate_account_ownership(account_id = account_id, customer_id = customer_id)): transaction = ProvideLoanService.log_transaction(validated_data = validated_data) - + + if not transaction: + logger.error(f"Failed to log transaction") + return jsonify({ + "message": "Failed to log transaction." + }), 400 + # Save the loan details here loan_id = f"loan_{transaction.id}" @@ -48,15 +54,13 @@ class ProvideLoanService(BaseService): status="active" ) - - - - - if not transaction: - logger.error(f"Failed to log transaction") + if not loan: + logger.error(f"Failed to save loan details") return jsonify({ - "message": "Failed to log transaction." + "message": "Failed to save loan details." }), 400 + + else: return jsonify({ "message": "Invalid Customer or Account"