salary process apart
This commit is contained in:
+14
-16
@@ -129,12 +129,24 @@ def salary_detect():
|
|||||||
if payload:
|
if payload:
|
||||||
# Step 1: Try to add new salary data
|
# Step 1: Try to add new salary data
|
||||||
try:
|
try:
|
||||||
new_salary = SalaryService.add_salary_data(payload)
|
new_salary = SalaryService.add_salary_data(payload) # TODO - This will come as array of salaries - not just one
|
||||||
if new_salary:
|
if new_salary:
|
||||||
logger.info(f"Salary added: {new_salary.id}")
|
logger.info(f"Salary added: {new_salary.id}")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Failed to save salary: {e}")
|
logger.error(f"Failed to save salary: {e}")
|
||||||
|
|
||||||
|
process_salary_list() # TODO - This should be threaded out or removed from here finally
|
||||||
|
|
||||||
|
logger.info(f"Finished processing List")
|
||||||
|
return ResponseHelper.success([], "AutoCall Add Salary Successful")
|
||||||
|
|
||||||
|
@autocall_bp.route("/analytic-salary-process", methods=["POST"])
|
||||||
|
def salary_process():
|
||||||
|
response = process_salary_list()
|
||||||
|
return ResponseHelper.success([], "AutoCall Successful")
|
||||||
|
|
||||||
|
|
||||||
|
def process_salary_list():
|
||||||
# Step 2: Get all pending salaries
|
# Step 2: Get all pending salaries
|
||||||
pending_salaries = SalaryService.get_pending_salaries()
|
pending_salaries = SalaryService.get_pending_salaries()
|
||||||
if not pending_salaries:
|
if not pending_salaries:
|
||||||
@@ -180,18 +192,7 @@ def salary_detect():
|
|||||||
"LoanStatus": loan.status,
|
"LoanStatus": loan.status,
|
||||||
}
|
}
|
||||||
|
|
||||||
# repayment_data = {
|
|
||||||
# "customerId": loan.customer_id,
|
|
||||||
# "loanId": loan_dict["debtId"],
|
|
||||||
# "productId": loan_dict["productId"],
|
|
||||||
# "transactionId": loan_dict["transactionId"],
|
|
||||||
# "initiatedBy": "SALARY_DETECT",
|
|
||||||
# "salaryAmount": pending_salary.amount,
|
|
||||||
# }
|
|
||||||
#
|
|
||||||
logger.info(f"Saving/Creating Repayment Data:{repayment_data}")
|
logger.info(f"Saving/Creating Repayment Data:{repayment_data}")
|
||||||
#logger.info(f"Creating repayment for loan ID {loan_dict['debtId']}")
|
|
||||||
# repayment = RepaymentService.add_repayment(repayment_data)
|
|
||||||
repayment = RepaymentService.create_repayment(repayment_data)
|
repayment = RepaymentService.create_repayment(repayment_data)
|
||||||
LoanService.update_status(loan_id=repayment_data["loanId"],
|
LoanService.update_status(loan_id=repayment_data["loanId"],
|
||||||
status=LoanStatus.START_REPAY) # repay started
|
status=LoanStatus.START_REPAY) # repay started
|
||||||
@@ -206,9 +207,6 @@ def salary_detect():
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Failed to call Simbrella client: {e}")
|
logger.error(f"Failed to call Simbrella client: {e}")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
logger.info(f"Finished processing salary ID: {pending_salary.id}")
|
logger.info(f"Finished processing salary ID: {pending_salary.id}")
|
||||||
return ResponseHelper.success([], "AutoCall Successful")
|
return []
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user