Merge branch 'test' of DigiFi/digifi-EventManager into master
This commit is contained in:
@@ -120,8 +120,10 @@ def direct_loan():
|
|||||||
}), 400
|
}), 400
|
||||||
|
|
||||||
# Check if the loan exists
|
# Check if the loan exists
|
||||||
|
logger.info(f"Checking if loan with transaction id {data['transactionId']} exists")
|
||||||
loan = LoanService.get_loan_by_transaction_id(transaction_id=data['transactionId'])
|
loan = LoanService.get_loan_by_transaction_id(transaction_id=data['transactionId'])
|
||||||
if not loan:
|
if not loan:
|
||||||
|
logger.warning(f"Loan with transaction id {data['transactionId']} does not exist")
|
||||||
return jsonify({
|
return jsonify({
|
||||||
"status": "error",
|
"status": "error",
|
||||||
"message": f"Loan with transaction id {data['transactionId']} does not exist"
|
"message": f"Loan with transaction id {data['transactionId']} does not exist"
|
||||||
@@ -165,8 +167,10 @@ def direct_repayment():
|
|||||||
}), 400
|
}), 400
|
||||||
|
|
||||||
# Check if the loan exists
|
# Check if the loan exists
|
||||||
|
logger.info(f"Checking if loan with transaction id {data['transactionId']} exists")
|
||||||
loan = LoanService.get_loan_by_transaction_id(transaction_id=data['transactionId'])
|
loan = LoanService.get_loan_by_transaction_id(transaction_id=data['transactionId'])
|
||||||
if not loan:
|
if not loan:
|
||||||
|
logger.info(f"Loan with transaction id {data['transactionId']} does not exist")
|
||||||
return jsonify({
|
return jsonify({
|
||||||
"status": "error",
|
"status": "error",
|
||||||
"message": f"Loan with transaction id {data['transactionId']} does not exist"
|
"message": f"Loan with transaction id {data['transactionId']} does not exist"
|
||||||
@@ -176,6 +180,7 @@ def direct_repayment():
|
|||||||
|
|
||||||
# check if loan has been repaid
|
# check if loan has been repaid
|
||||||
if loan_data.get("status") == LoanStatus.REPAID and loan_data.get("balance") <= 0:
|
if loan_data.get("status") == LoanStatus.REPAID and loan_data.get("balance") <= 0:
|
||||||
|
logger.info(f"Loan with Id {loan_data.get('debtId')} has been repaid")
|
||||||
return jsonify({
|
return jsonify({
|
||||||
"status": "error",
|
"status": "error",
|
||||||
"message": f"loan with Id {loan_data.get('debtId')} has been repaid"
|
"message": f"loan with Id {loan_data.get('debtId')} has been repaid"
|
||||||
@@ -196,6 +201,7 @@ def direct_repayment():
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
repayment = RepaymentService.create_repayment(repayment_data)
|
repayment = RepaymentService.create_repayment(repayment_data)
|
||||||
|
logger.info(f"Repayment created: {repayment}")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
db.session.rollback()
|
db.session.rollback()
|
||||||
logger.error(f"Repayment creation raised exception: {e}")
|
logger.error(f"Repayment creation raised exception: {e}")
|
||||||
|
|||||||
Reference in New Issue
Block a user