added collect loan
This commit is contained in:
+18
-3
@@ -6,6 +6,7 @@ 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
|
||||
from app.services.repayment import RepaymentService
|
||||
|
||||
autocall_bp = Blueprint("autocall", __name__)
|
||||
|
||||
@@ -65,17 +66,31 @@ def refresh_verify_collection():
|
||||
|
||||
return response
|
||||
|
||||
|
||||
@autocall_bp.route("/refresh-collection", methods=["GET"])
|
||||
def refresh_collection():
|
||||
data = request.get_json()
|
||||
#data = request.get_json()
|
||||
logger.info(f"Calling Collection ")
|
||||
#grab the last repayments with repay date is none
|
||||
repayment = RepaymentService.get_latest_repayment_without_repay_date()
|
||||
if not repayment:
|
||||
logger.info(f"No repayment found without disbursement date")
|
||||
return 0
|
||||
logger.info(f"Calling repay loan endpoint with data: {repayment}")
|
||||
repayment_data = repayment.to_dict()
|
||||
logger.info(f"here is the dict form of repayment {repayment_data}")
|
||||
|
||||
data = {
|
||||
"transactionId": repayment_data['transactionId'],
|
||||
"debtId": repayment_data['loanId'],
|
||||
"customerId": repayment_data['customerId'],
|
||||
"productId": repayment_data['productId'],
|
||||
}
|
||||
logger.info(f"Data being sent to Simbrella: {data}")
|
||||
logger.info(f"calling simbrella")
|
||||
response = SimbrellaClient.collect_loan(data)
|
||||
|
||||
return response
|
||||
|
||||
|
||||
@autocall_bp.route("/payment-callback", methods=["POST"])
|
||||
def payment_callback():
|
||||
data = request.get_json()
|
||||
|
||||
Reference in New Issue
Block a user