Reafctor import

This commit is contained in:
CHIEFSOFT\ameye
2025-06-18 23:29:09 -04:00
parent 405c837499
commit 500e749acb
2 changed files with 48 additions and 15 deletions
+31
View File
@@ -7,6 +7,7 @@ from app.utils.logger import logger
from app.integrations.simbrella import SimbrellaClient
from app.services.loan import LoanService
from app.services.repayment import RepaymentService
from app.services.salary import SalaryService
autocall_bp = Blueprint("autocall", __name__)
@@ -112,9 +113,39 @@ def penal_charge():
@autocall_bp.route("/analytic-salary-detect", methods=["POST"])
def salary_detect():
#***************************************************
# PART 1 Accept any new import of salary detection
#**************************************************
data = request.get_json()
logger.info(f"Calling Salary Detect Endpoints")
try:
salary = SalaryService.add_salary_data(data)
if salary:
logger.info(f"Successful Salary Added")
# return ResponseHelper.success(salary.to_dict(), "Successful")
except Exception as e:
logger.info(f"Failed to save salary: {e}")
# ***************************************************
# PART 2 SELECT * FROM salaries WHERE status IS NULL ORDER BY id ASC
# **************************************************
#in the loop
# USE the customerID to find thu user Loan
# if loan is/are found for the user
# INSERT INTO repayments TABLE
# repayment = cls(
# customer_id=customer_id,
# loan_id=loan.id,
# product_id=loan.product_id,
# transaction_id = transaction_id,
# created_at=datetime.now(timezone.utc),
# updated_at=datetime.now(timezone.utc),
# initiated_by='SALARY_DETECT'
# )
# by the time you call this you must be on repayment table
response = SimbrellaClient.collect_loan_user_salary_detect(data)
return response