added salary table
This commit was merged in pull request #25.
This commit is contained in:
@@ -10,6 +10,7 @@ from app.services.transactions import TransactionService
|
||||
from app.services.repayment import RepaymentService
|
||||
from app.extensions import db
|
||||
from app.services.repayments_data import RepaymentsData
|
||||
from app.services.salary import SalaryService
|
||||
|
||||
|
||||
class SimbrellaClient:
|
||||
@@ -186,7 +187,18 @@ class SimbrellaClient:
|
||||
@staticmethod
|
||||
def collect_loan_user_salary_detect(data):
|
||||
#InitiatedBy = SALARY_DETECT
|
||||
return SimbrellaClient._collect_loan(data)
|
||||
logger.info(f"salary data: {data}")
|
||||
try:
|
||||
salary = SalaryService.add_salary_data(data)
|
||||
if salary:
|
||||
return ResponseHelper.success(salary.to_dict(), "Successful")
|
||||
|
||||
except Exception as e:
|
||||
logger.info(f"Failed to save salary: {e}")
|
||||
return ResponseHelper.error(message="Failed to call salary endpoint",
|
||||
status_code=400,
|
||||
error=str(e) )
|
||||
|
||||
|
||||
@staticmethod
|
||||
def collect_loan_user_due_payment(data):
|
||||
@@ -218,6 +230,7 @@ class SimbrellaClient:
|
||||
return ResponseHelper.error("Loan not found")
|
||||
|
||||
loan_data = loan.to_dict()
|
||||
logger.info(f"loan dict : {loan_data}")
|
||||
|
||||
if repayment_data['repayDate'] is not None:
|
||||
logger.info(
|
||||
@@ -242,7 +255,7 @@ class SimbrellaClient:
|
||||
"channel": "USSD",
|
||||
"collectionMethod": "1",
|
||||
"lienAmount": 0,
|
||||
"countryId": "01",
|
||||
"countryId": "NG",
|
||||
"comment": "COLLECT LOAN"
|
||||
}
|
||||
|
||||
@@ -263,6 +276,7 @@ class SimbrellaClient:
|
||||
"repaymentAmount": collect_loan_data.get('collectAmount'),
|
||||
"responseCode": result.get('responseCode'),
|
||||
"responseDescr": result.get('responseMessage'),
|
||||
"balance":result.get('lienAmount')
|
||||
}
|
||||
|
||||
new_repayment_data = RepaymentsData.add_repayment_data(data_to_add)
|
||||
|
||||
Reference in New Issue
Block a user