From 334cb0f2d6338b08fb4517e0be02462daa8cb58d Mon Sep 17 00:00:00 2001 From: "CHIEFSOFT\\ameye" Date: Sat, 10 May 2025 06:58:17 -0400 Subject: [PATCH] Staered --- app/api/services/offer_analysis.py | 8 +++++--- app/api/services/provide_loan.py | 2 +- app/models/loan.py | 8 ++++++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/app/api/services/offer_analysis.py b/app/api/services/offer_analysis.py index 44b2472..17736e7 100644 --- a/app/api/services/offer_analysis.py +++ b/app/api/services/offer_analysis.py @@ -30,9 +30,6 @@ class OfferAnalysis: if not offer: raise ValueError("Invalid Offer.") original_transaction = transaction_id - # we can now find the origin transactions - customer_loan = Loan.get_customer_current_active_loan(customer_id) - return transaction_offer, offer, eligible_amount, original_transaction @@ -40,6 +37,10 @@ class OfferAnalysis: def decide_offer(transaction_id, rac_check, validated_data,customer): # if we have active offers - we have to feed off it + # we can now find the origin transactions + last_customer_loan = Loan.get_customer_last_loan(customer.id) #Find the last loan - it will have original_transaction + logger.info(f"{last_customer_loan}") + """ Find the last loan - it will have original_transaction @@ -48,6 +49,7 @@ class OfferAnalysis: This will give you the eligible_amount = REAL_ELIGIBLIBLE_AMOUNT Sum all loans amount with same original_transaction together = Sum_active loans. = SUM_OF_ACTIVE_LOAN + [*** we will come back to this action to make sure w dont count already paid loans *******] The new eligible amount will be = REAL_ELIGIBLIBLE_AMOUNT - SUM_OF_ACTIVE_LOAN diff --git a/app/api/services/provide_loan.py b/app/api/services/provide_loan.py index fb9178b..88db200 100644 --- a/app/api/services/provide_loan.py +++ b/app/api/services/provide_loan.py @@ -146,7 +146,7 @@ class ProvideLoanService(BaseService): # charges = Charge.get_offer_charges(offer.id) - logger.info(f"{charges}") + # logger.info(f"{charges}") loan_id = loan.id diff --git a/app/models/loan.py b/app/models/loan.py index 9a43d8e..8143944 100644 --- a/app/models/loan.py +++ b/app/models/loan.py @@ -6,6 +6,8 @@ from sqlalchemy.exc import IntegrityError from sqlalchemy.orm import relationship from dateutil.relativedelta import relativedelta from datetime import timedelta +import logging +logger = logging.getLogger(__name__) class Loan(db.Model): @@ -134,11 +136,13 @@ class Loan(db.Model): return loan @classmethod - def get_customer_current_active_loan(cls, customer_id): + def get_customer_last_loan(cls, customer_id): """ Get customer's active loans. """ + logger.info(f"Find last loan for [customer_id] ==>>>> {customer_id}") loan = cls.query.filter_by( customer_id = customer_id).first() + logger.info(f" Active Loan ==>>>> RESULT************************ AMEYE") if not loan: loan = { "eligible_amount": 0, @@ -147,7 +151,7 @@ class Loan(db.Model): "transaction_id": "", "resultDescription": "No Active Loan" } - + logger.info(f" Active Loan ==>>>> RESULT*********************") logger.info(f" Active Loan ==>>>> {loan}") return loan