Update provide_loan.py
This commit is contained in:
@@ -35,7 +35,13 @@ class ProvideLoanService(BaseService):
|
|||||||
if (ProvideLoanService.validate_account_ownership(account_id = account_id, customer_id = customer_id)):
|
if (ProvideLoanService.validate_account_ownership(account_id = account_id, customer_id = customer_id)):
|
||||||
|
|
||||||
transaction = ProvideLoanService.log_transaction(validated_data = validated_data)
|
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
|
# Save the loan details here
|
||||||
loan_id = f"loan_{transaction.id}"
|
loan_id = f"loan_{transaction.id}"
|
||||||
|
|
||||||
@@ -48,15 +54,13 @@ class ProvideLoanService(BaseService):
|
|||||||
status="active"
|
status="active"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if not loan:
|
||||||
|
logger.error(f"Failed to save loan details")
|
||||||
|
|
||||||
|
|
||||||
if not transaction:
|
|
||||||
logger.error(f"Failed to log transaction")
|
|
||||||
return jsonify({
|
return jsonify({
|
||||||
"message": "Failed to log transaction."
|
"message": "Failed to save loan details."
|
||||||
}), 400
|
}), 400
|
||||||
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
return jsonify({
|
return jsonify({
|
||||||
"message": "Invalid Customer or Account"
|
"message": "Invalid Customer or Account"
|
||||||
|
|||||||
Reference in New Issue
Block a user