eliminated some hardcoded values
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
import requests
|
||||
from app.config import settings
|
||||
from app.services.loan import LoanService
|
||||
from app.utils.auth import get_headers
|
||||
from app.utils.extras import preprocess_loan_charges_data
|
||||
from app.utils.logger import logger
|
||||
from flask import jsonify, current_app
|
||||
from app.services.transactions import TransactionService
|
||||
@@ -26,21 +28,42 @@ class SimbrellaClient:
|
||||
logger.info(f"Transaction id: {data['transactionId']}, was not found")
|
||||
return 0
|
||||
|
||||
# Fetch the loan based on the transaction_id
|
||||
logger.info(f"Fetching the loan with transaction ID: {data['transactionId']}")
|
||||
loan = LoanService.get_loan_by_transaction_id(transaction_id=data['transactionId'])
|
||||
logger.info(f"Response from database: {loan}")
|
||||
|
||||
# If loan is not found
|
||||
if not loan:
|
||||
logger.info(f"Could not find loan with transaction id: {data['transactionId']}")
|
||||
return 0
|
||||
|
||||
loan_data = loan.to_dict()
|
||||
logger.info(f"Here is your loan data: {loan_data}")
|
||||
|
||||
loan_charges = preprocess_loan_charges_data([loan_charge.to_dict() for loan_charge in loan.loan_charges])
|
||||
logger.info(f"Here are your loan_charges: {loan_charges}")
|
||||
|
||||
mgt_fee = loan_charges.get("MGTFEE")['amount']
|
||||
|
||||
vat_fee = loan_charges.get("VAT")['amount']
|
||||
|
||||
disbursement_data ={
|
||||
"requestId": data['requestId'],
|
||||
"transactionId": data['transactionId'],
|
||||
"debtId": "273194670",
|
||||
"debtId": loan_data['debtId'],
|
||||
"customerId": data['customerId'],
|
||||
"accountId": data['accountId'],
|
||||
"productId": "101",
|
||||
"provideAmount": 100000,
|
||||
"productId": loan_data['productId'],
|
||||
"provideAmount": loan_data['currentLoanAmount'],
|
||||
"collectAmountInterest": 5000,
|
||||
"collectAmountMgtFee": 1000,
|
||||
"collectAmountMgtFee": mgt_fee,
|
||||
"collectAmountInsurance": 1000,
|
||||
"collectAmountVAT": 75,
|
||||
"collectAmountVAT": vat_fee,
|
||||
"countryId": "01",
|
||||
"comment": "Loan Disbursement",
|
||||
}
|
||||
|
||||
try:
|
||||
logger.info(f"Here is your Disbursement Request data ****** : {disbursement_data}")
|
||||
response = requests.post(api_url, json=disbursement_data, timeout=10, headers=get_headers())
|
||||
@@ -51,7 +74,6 @@ class SimbrellaClient:
|
||||
#raise
|
||||
return 0
|
||||
|
||||
# return jsonify(response.json()), response.status_code
|
||||
return 1
|
||||
|
||||
@staticmethod
|
||||
|
||||
Reference in New Issue
Block a user