This commit is contained in:
CHIEFSOFT\ameye
2025-06-05 07:13:35 -04:00
parent 67363ff6e5
commit 50769f7faf
5 changed files with 137 additions and 65 deletions
+35 -17
View File
@@ -5,6 +5,7 @@ from app.helpers.response_helper import ResponseHelper
from app.utils.auth import get_headers
from app.utils.logger import logger
from app.integrations.simbrella import SimbrellaClient
from app.services.loan import LoanService
autocall_bp = Blueprint("autocall", __name__)
@@ -12,29 +13,46 @@ autocall_bp = Blueprint("autocall", __name__)
def verify_transaction():
logger.info(f"Calling VerifyTransaction Components")
response = SimbrellaClient.verify_transaction()
loan = LoanService.get_latest_loan_with_disburse_date()
if not loan:
logger.info(f"No loan found without disbursement date")
return 0
logger.info(f"Calling VerifyTransaction endpoint with data: {loan}")
loan_data = loan.to_dict()
data = {
"transactionId": loan_data.get('transactionId'),
"FbnTransactionId": loan_data.get('transactionId'),
"debtId": str(loan_data.get('debtId')),
"customerId": loan_data.get('customerId'),
"accountId": loan_data.get('accountId'),
"productId": str(loan_data.get('productId', "")),
"provideAmount": loan_data.get('currentLoanAmount'),
}
response = SimbrellaClient.verify_transaction(data)
return response
@autocall_bp.route("/refresh-disbursement", methods=["GET"])
def disbursement():
# data = request.json()
logger.info(f"Calling Disbursement Components")
""" data = {
"transactionId": "TRX1749033507722975",
"FbnTransactionId":"TRX1748643654575327",
"debtId": "94696900",
"customerId": "CID00000559140T",
"accountId": "ACC20267810160T",
"productId": "3MPC",
"provideAmount": 10000.0,
"collectAmountInterest": 19.0,
"collectAmountMgtFee": 66.0,
"collectAmountInsurance": 66.0,
"collectAmountVAT": 75.00,
"countryId": "01",
"comment": "Loan Disbursement"
}"""
response = SimbrellaClient.disburse_loan()
loan = LoanService.get_latest_loan_without_disburse_date()
if not loan:
logger.info(f"No loan found without disbursement date")
return 0
logger.info(f"Calling DisburseLoan endpoint with data: {loan}")
loan_data = loan.to_dict()
data = {
"transactionId": loan_data.get('transactionId'),
"FbnTransactionId": loan_data.get('transactionId'),
"debtId": str(loan_data.get('debtId')),
"customerId": loan_data.get('customerId'),
"accountId": loan_data.get('accountId'),
"productId": str(loan_data.get('productId', "")),
"provideAmount": loan_data.get('currentLoanAmount'),
}
response = SimbrellaClient.disburse_loan(data)
return response