Merge branch 'test' of DigiFi/digifi-EventManager into master
This commit is contained in:
@@ -92,9 +92,8 @@ class SimbrellaClient:
|
|||||||
vat_fee = loan_charges.get("VAT")['amount']
|
vat_fee = loan_charges.get("VAT")['amount']
|
||||||
interest_fee = loan_charges.get("INTEREST")['amount']
|
interest_fee = loan_charges.get("INTEREST")['amount']
|
||||||
insurance_fee = loan_charges.get("INSURANCE")['amount']
|
insurance_fee = loan_charges.get("INSURANCE")['amount']
|
||||||
|
product_id = str(loan_data.get('productId', ""))
|
||||||
debtId = str(loan_data.get('debtId', "")).strip().zfill(6)
|
debtId = str(loan_data.get('debtId', "")).strip().zfill(6)
|
||||||
product_id = str(loan_data.get('productId', ''))
|
|
||||||
disbursement_data = {
|
disbursement_data = {
|
||||||
"transactionId": loan_data.get('transactionId'),
|
"transactionId": loan_data.get('transactionId'),
|
||||||
"fbnTransactionId": loan_data.get('transactionId'),
|
"fbnTransactionId": loan_data.get('transactionId'),
|
||||||
@@ -103,10 +102,10 @@ class SimbrellaClient:
|
|||||||
"accountId": loan_data.get('accountId'),
|
"accountId": loan_data.get('accountId'),
|
||||||
"productId": str(loan_data.get('productId', "")),
|
"productId": str(loan_data.get('productId', "")),
|
||||||
"provideAmount": loan_data.get('currentLoanAmount'),
|
"provideAmount": loan_data.get('currentLoanAmount'),
|
||||||
"collectAmountInterest": interest_fee if product_id != '3MPC' else 0, #send charges for only 1 month loan
|
"collectAmountInterest": interest_fee if product_id != '3MPC' else 0,
|
||||||
"collectAmountMgtFee": mgt_fee if product_id != '3MPC' else 0,
|
"collectAmountMgtFee": mgt_fee,
|
||||||
"collectAmountInsurance": insurance_fee if product_id != '3MPC' else 0,
|
"collectAmountInsurance": insurance_fee,
|
||||||
"collectAmountVAT": vat_fee if product_id != '3MPC' else 0,
|
"collectAmountVAT": vat_fee,
|
||||||
"countryId": "01",
|
"countryId": "01",
|
||||||
"comment": "Loan Disbursement",
|
"comment": "Loan Disbursement",
|
||||||
}
|
}
|
||||||
@@ -148,7 +147,17 @@ class SimbrellaClient:
|
|||||||
result.get('responseMessage', ''))
|
result.get('responseMessage', ''))
|
||||||
reload_loan = LoanService.get_loan_by_transaction_id(transaction_id=data['transactionId'])
|
reload_loan = LoanService.get_loan_by_transaction_id(transaction_id=data['transactionId'])
|
||||||
reload_loan_data = reload_loan.to_dict()
|
reload_loan_data = reload_loan.to_dict()
|
||||||
|
#mark repayment schedule as active
|
||||||
|
repayment_schedule = LoanRepaymentScheduleService.get_repayment_schedule_by_loan_id(
|
||||||
|
reload_loan_data['debtId'], include_paid=False)
|
||||||
|
logger.info(f'Loan repayment schedule: {repayment_schedule}')
|
||||||
|
if repayment_schedule:
|
||||||
|
for schedule in repayment_schedule:
|
||||||
|
logger.info(f"Updating repayment schedule ID {schedule.id} status to ACTIVE")
|
||||||
|
LoanRepaymentScheduleService.update_repayment_schedule_status_to_active(schedule.id)
|
||||||
|
|
||||||
SimbrellaClient.verify_disbursement_transaction(reload_loan_data)
|
SimbrellaClient.verify_disbursement_transaction(reload_loan_data)
|
||||||
|
|
||||||
return ResponseHelper.success(response.json(), "Successful")
|
return ResponseHelper.success(response.json(), "Successful")
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|||||||
+9
-3
@@ -236,9 +236,15 @@ class Loan(db.Model):
|
|||||||
"""
|
"""
|
||||||
Get the latest loan without a disbursement date.
|
Get the latest loan without a disbursement date.
|
||||||
"""
|
"""
|
||||||
return cls.query.filter(
|
logger.info("Fetching latest loan without disburse date")
|
||||||
cls.disburse_date.is_(None)
|
|
||||||
).order_by(cls.created_at.desc()).first()
|
try:
|
||||||
|
return cls.query.filter(
|
||||||
|
cls.disburse_date.is_(None)
|
||||||
|
).order_by(cls.created_at.desc()).first()
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f"Error fetching latest loan without disburse date: {e}")
|
||||||
|
raise
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_latest_loan_with_disburse_date(cls):
|
def get_latest_loan_with_disburse_date(cls):
|
||||||
|
|||||||
@@ -215,6 +215,24 @@ class LoanRepaymentSchedule(db.Model):
|
|||||||
logger.error(f"Error updating repayment schedule {schedule_id} after loan repayment: {e}")
|
logger.error(f"Error updating repayment schedule {schedule_id} after loan repayment: {e}")
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def update_repayment_schedule_status_to_active(cls, schedule_id):
|
||||||
|
"""
|
||||||
|
Update repayment schedule status to ACTIVE.
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
schedule = cls.query.get(schedule_id)
|
||||||
|
if not schedule:
|
||||||
|
raise ValueError(f"Schedule with ID {schedule_id} does not exist.")
|
||||||
|
schedule.paid_status = RepaymentScheduleStatus.ACTIVE
|
||||||
|
schedule.updated_at = datetime.now(timezone.utc)
|
||||||
|
db.session.commit()
|
||||||
|
logger.info(f"Updated repayment schedule ID {schedule_id} status to ACTIVE")
|
||||||
|
return schedule.to_dict()
|
||||||
|
except Exception as e:
|
||||||
|
db.session.rollback()
|
||||||
|
logger.error(f"Error updating repayment schedule status for schedule {schedule_id}: {e}")
|
||||||
|
raise
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def update_repayment_schedule_balance(cls, schedule_id, amount_collected):
|
def update_repayment_schedule_balance(cls, schedule_id, amount_collected):
|
||||||
|
|||||||
@@ -32,7 +32,12 @@ class LoanRepaymentScheduleService:
|
|||||||
Update repayment schedule status.
|
Update repayment schedule status.
|
||||||
"""
|
"""
|
||||||
return LoanRepaymentSchedule.update_repayment_schedule_status(schedule_id)
|
return LoanRepaymentSchedule.update_repayment_schedule_status(schedule_id)
|
||||||
|
@classmethod
|
||||||
|
def update_repayment_schedule_status_to_active(cls, schedule_id):
|
||||||
|
"""
|
||||||
|
Update repayment schedule status.
|
||||||
|
"""
|
||||||
|
return LoanRepaymentSchedule.update_repayment_schedule_status_to_active(schedule_id)
|
||||||
@classmethod
|
@classmethod
|
||||||
def update_repayment_schedule_balance(cls, schedule_id, amount_collected):
|
def update_repayment_schedule_balance(cls, schedule_id, amount_collected):
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user