From 31e38da4730604d7cb3d687f167544230260e139 Mon Sep 17 00:00:00 2001 From: VivianDee <115420678+VivianDee@users.noreply.github.com> Date: Thu, 19 Jun 2025 12:49:15 +0100 Subject: [PATCH] [add]: pending salaries --- app/models/salary.py | 13 ++++++++++++- app/routes/autocall.py | 8 ++++++++ app/services/salary.py | 9 ++++++++- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/app/models/salary.py b/app/models/salary.py index dd5cbac..52c21b9 100644 --- a/app/models/salary.py +++ b/app/models/salary.py @@ -57,4 +57,15 @@ class Salary(db.Model): except Exception as e: db.session.rollback() logger.info(f"error : {str(e)}") - raise Exception(f"Error adding salary data: {str(e)}") \ No newline at end of file + raise Exception(f"Error adding salary data: {str(e)}") + + @classmethod + def get_pending_salaries(cls): + """ + Retrieve all salary entries with status 'START', ordered by ID ascending. + """ + try: + return cls.query.filter_by(status='START').order_by(cls.id.asc()).all() + except Exception as e: + logger.error(f"Error fetching pending salaries: {str(e)}") + return [] diff --git a/app/routes/autocall.py b/app/routes/autocall.py index a29b913..c2aff66 100644 --- a/app/routes/autocall.py +++ b/app/routes/autocall.py @@ -131,6 +131,14 @@ def salary_detect(): # PART 2 SELECT * FROM salaries WHERE status IS 'START' ORDER BY id ASC # ************************************************** + pending_salaries = SalaryService.get_pending_salaries() + + if not pending_salaries: + logger.info(f"No pending salaries found") + # return ResponseHelper.success([], "No pending salaries found") + + logger.info(f"Found {len(pending_salaries)} pending salaries") + #in the loop # USE the customerID to find thu user Loan # if loan is/are found for the user diff --git a/app/services/salary.py b/app/services/salary.py index dfb27d2..c0cbbf3 100644 --- a/app/services/salary.py +++ b/app/services/salary.py @@ -8,4 +8,11 @@ class SalaryService: """ Add a new salary data entry. """ - return Salary.add_salary_data(data) \ No newline at end of file + return Salary.add_salary_data(data) + + @classmethod + def get_pending_salaries(cls): + """ + Get the pending salary for a given customer. + """ + return Salary.get_pending_salaries() \ No newline at end of file