original transaction id
This commit is contained in:
+23
-3
@@ -69,6 +69,7 @@ class Loan(db.Model):
|
||||
initial_loan_amount,
|
||||
collection_type,
|
||||
transaction_id,
|
||||
original_transaction,
|
||||
upfront_fee,
|
||||
repayment_amount,
|
||||
installment_amount,
|
||||
@@ -92,7 +93,7 @@ class Loan(db.Model):
|
||||
product_id = product_id,
|
||||
collection_type = collection_type,
|
||||
transaction_id = transaction_id,
|
||||
original_transaction = transaction_id,
|
||||
original_transaction = original_transaction,
|
||||
initial_loan_amount = initial_loan_amount,
|
||||
current_loan_amount = initial_loan_amount,
|
||||
upfront_fee = upfront_fee,
|
||||
@@ -125,13 +126,32 @@ class Loan(db.Model):
|
||||
@classmethod
|
||||
def get_customer_loan(cls, loan_id, customer_id):
|
||||
"""
|
||||
Get customer's active loans.
|
||||
Get customer's active loans by loan_id.
|
||||
"""
|
||||
loan = cls.query.filter_by(id = loan_id, customer_id = customer_id).first()
|
||||
if not loan:
|
||||
raise ValueError(f"Loan with ID {loan_id} does not exist or does not belong to customer {customer_id}.")
|
||||
return loan
|
||||
|
||||
|
||||
@classmethod
|
||||
def get_customer_current_active_loan(cls, customer_id):
|
||||
"""
|
||||
Get customer's active loans.
|
||||
"""
|
||||
loan = cls.query.filter_by( customer_id = customer_id).first()
|
||||
if not loan:
|
||||
loan = {
|
||||
"eligible_amount": 0,
|
||||
"loan_amount": 0,
|
||||
"customer_id": customer_id,
|
||||
"transaction_id": "",
|
||||
"resultDescription": "No Active Loan"
|
||||
}
|
||||
|
||||
logger.info(f"{loan}")
|
||||
|
||||
return loan
|
||||
|
||||
@classmethod
|
||||
def update_status(cls, loan_id, status):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user