customer with loan listing
This commit is contained in:
@@ -31,36 +31,19 @@ class LoanStatusService(BaseService):
|
||||
|
||||
customer_id = validated_data.get('customerId')
|
||||
logger.info(f"Looking for customer *** {customer_id}")
|
||||
customer = Customer.get_customer(customer_id)
|
||||
customer = Customer.get_customer_with_loan_list(customer_id)
|
||||
transactionId = validated_data.get('transactionId')
|
||||
account_id = validated_data.get('accountId')
|
||||
|
||||
if(LoanStatusService.validate_account_ownership(account_id = account_id, customer_id = customer_id)):
|
||||
|
||||
# Get loans
|
||||
loans = [loan.to_dict() for loan in customer.loans if loan.status == LoanStatus.ACTIVE]
|
||||
|
||||
transaction = LoanStatusService.log_transaction(validated_data = validated_data)
|
||||
|
||||
if not transaction:
|
||||
logger.error(f"Failed to log transaction")
|
||||
return ResponseHelper.error(result_description="Failed to log transaction.")
|
||||
else:
|
||||
return ResponseHelper.error(result_description="Invalid Customer or Account")
|
||||
|
||||
|
||||
# loans = [
|
||||
# {
|
||||
# "debtId": "123456789",
|
||||
# "loanDate": "2019-10-18 14:26:21.063",
|
||||
# "dueDate": "2019-11-20 14:26:21.063",
|
||||
# "currentLoanAmount": 8500,
|
||||
# "initialLoanAmount": 10000,
|
||||
# "defaultPenaltyFee": 0,
|
||||
# "continuousFee": 0,
|
||||
# "productId": "101"
|
||||
# }
|
||||
# ]
|
||||
|
||||
total_debt_amount = sum(
|
||||
loan.get("currentLoanAmount") or 0
|
||||
|
||||
@@ -34,7 +34,7 @@ class RepaymentService(BaseService):
|
||||
loan_id = validated_data.get('debtId')
|
||||
product_id = validated_data.get('productId')
|
||||
account_id = validated_data.get('accountId')
|
||||
customer = Customer.get_customer(customer_id)
|
||||
customer = Customer.get_customer_with_loan_list(customer_id)
|
||||
transaction_id = validated_data.get('transactionId')
|
||||
|
||||
if(RepaymentService.validate_account_ownership(account_id = account_id, customer_id = customer_id)):
|
||||
|
||||
@@ -72,7 +72,7 @@ class Customer(db.Model):
|
||||
return customer
|
||||
|
||||
@classmethod
|
||||
def get_customer(cls, customer_id):
|
||||
def get_customer_with_loan_list(cls, customer_id):
|
||||
"""
|
||||
Get customer by ID.
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user