changed amount to salary amount #28

Merged
ameye merged 1 commits from test into master 2025-06-20 13:30:08 +00:00
4 changed files with 16 additions and 18 deletions
+9 -15
View File
@@ -183,23 +183,17 @@ class SimbrellaClient:
# InitiatedBy = USER_INITIATED # InitiatedBy = USER_INITIATED
logger.info(f"Calling CollectLoan collect_loan_user_initiated ******* endpoint with data: {data}") logger.info(f"Calling CollectLoan collect_loan_user_initiated ******* endpoint with data: {data}")
return SimbrellaClient._collect_loan(data,"1") return SimbrellaClient._collect_loan(data,"1")
@staticmethod @staticmethod
def collect_loan_user_salary_detect(data): def collect_loan_user_salary_detect(data):
#InitiatedBy = SALARY_DETECT try:
# logger.info(f"salary data: {data}") return SimbrellaClient._collect_loan(data, "2")
# try: except Exception as e:
# salary = SalaryService.add_salary_data(data) logger.error(f"Error in collect_loan_user_salary_detect: {e}")
# if salary: return ResponseHelper.error(
# return ResponseHelper.success(salary.to_dict(), "Successful") message="Failed to collect loan for salary detection",
# status_code=500,
# except Exception as e: error=str(e)
# logger.info(f"Failed to save salary: {e}") )
# return ResponseHelper.error(message="Failed to call salary endpoint",
# status_code=400,
# error=str(e) )
return SimbrellaClient._collect_loan(data,"2")
@staticmethod @staticmethod
+2 -2
View File
@@ -29,7 +29,7 @@ class Salary(db.Model):
'id': self.id, 'id': self.id,
'customerId': self.customer_id, 'customerId': self.customer_id,
'accountId' : self.account_id, 'accountId' : self.account_id,
'amount': self.amount, 'salaryAmount': self.amount,
'status': self.status, 'status': self.status,
'createdAt': self.created_at.isoformat() if self.created_at else None, 'createdAt': self.created_at.isoformat() if self.created_at else None,
'updatedAt': self.updated_at.isoformat() if self.updated_at else None, 'updatedAt': self.updated_at.isoformat() if self.updated_at else None,
@@ -45,7 +45,7 @@ class Salary(db.Model):
try: try:
new_data = cls( new_data = cls(
customer_id=data.get('customerId'), customer_id=data.get('customerId'),
amount=data.get('amount', 0.0), amount=data.get('salaryAmount', 0.0),
status='START', status='START',
salary_date = datetime.strptime(data.get('salaryDate'), "%Y-%m-%d").date() if data.get('salaryDate') else None, salary_date = datetime.strptime(data.get('salaryDate'), "%Y-%m-%d").date() if data.get('salaryDate') else None,
account_id=data.get('accountId') account_id=data.get('accountId')
+4
View File
@@ -121,6 +121,10 @@ def salary_detect():
payload = request.get_json() payload = request.get_json()
logger.info("Calling Salary Detect endpoint") logger.info("Calling Salary Detect endpoint")
if payload is None:
logger.warning("No payload received in request")
return ResponseHelper.error("Missing request payload", status_code=400)
# 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)
+1 -1
View File
@@ -192,7 +192,7 @@ paths:
example: "OP621868" example: "OP621868"
status: status:
type: string type: string
amount: salaryAmount:
type: number type: number
example: 200000 example: 200000
salaryDate: salaryDate: