From 9e22e0fcf370cdcfe78ec7f0b466f59db83b2d45 Mon Sep 17 00:00:00 2001 From: "CHIEFSOFT\\ameye" Date: Sat, 24 May 2025 07:41:20 -0400 Subject: [PATCH] customer with loan listing --- app/api/services/loan_status.py | 19 +------------------ app/api/services/repayment.py | 2 +- app/models/customer.py | 2 +- 3 files changed, 3 insertions(+), 20 deletions(-) diff --git a/app/api/services/loan_status.py b/app/api/services/loan_status.py index 34376ac..704b2d4 100644 --- a/app/api/services/loan_status.py +++ b/app/api/services/loan_status.py @@ -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 diff --git a/app/api/services/repayment.py b/app/api/services/repayment.py index 78dda2f..c3f3671 100644 --- a/app/api/services/repayment.py +++ b/app/api/services/repayment.py @@ -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)): diff --git a/app/models/customer.py b/app/models/customer.py index 7498c87..882dd34 100644 --- a/app/models/customer.py +++ b/app/models/customer.py @@ -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. """