From cf2e1fc2a7ee697e9abd41ff1bc9c037e1a9eb4c Mon Sep 17 00:00:00 2001 From: "CHIEFSOFT\\ameye" Date: Fri, 30 May 2025 20:36:44 -0400 Subject: [PATCH] get loan --- app/integrations/simbrella.py | 2 +- app/models/loan.py | 4 ++++ app/services/loan.py | 8 ++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/app/integrations/simbrella.py b/app/integrations/simbrella.py index eea251a..1e44b41 100644 --- a/app/integrations/simbrella.py +++ b/app/integrations/simbrella.py @@ -91,7 +91,7 @@ class SimbrellaClient: logger.info(f"Checking if repayment exists") repayment = RepaymentService.get_repayment_by_transaction_id(transaction_id=data['transactionId']) logger.info(f"Repayment Response From Database ** : {repayment}") - loan = LoanService.get_loan_charge_by_debt_id(debt_id=repayment.loan_id) + loan = LoanService.get_loan_by_debt_id(debt_id=repayment.loan_id) # If repayment is not found if not repayment: diff --git a/app/models/loan.py b/app/models/loan.py index bbb9715..f0386e8 100644 --- a/app/models/loan.py +++ b/app/models/loan.py @@ -72,6 +72,10 @@ class Loan(db.Model): def get_loan_by_transaction_id(cls, transaction_id): return cls.query.filter_by(transaction_id=transaction_id).first() + @classmethod + def get_loan_by_debt_id(cls, debt_id): + return cls.query.filter_by(id=debt_id).first() + @classmethod def set_disbursement_date(cls, loan_id, customer_id): """ diff --git a/app/services/loan.py b/app/services/loan.py index d0dc75c..c22ba6c 100644 --- a/app/services/loan.py +++ b/app/services/loan.py @@ -9,6 +9,14 @@ class LoanService: """ return Loan.get_loan_by_transaction_id(transaction_id) + @classmethod + def get_loan_by_debt_id(cls, debt_id): + """ + Get the loan by transaction ID + """ + return Loan.get_loan_by_debt_id(debt_id) + + @classmethod def get_loan_charge_by_debt_id(cls, debt_id): """