Update offer_analysis.py

This commit was merged in pull request #30.
This commit is contained in:
Vivian Dee
2025-05-10 15:42:09 +01:00
parent 4718c9c50b
commit 6d743ea09b
+9 -9
View File
@@ -40,23 +40,23 @@ class OfferAnalysis:
# we can now find the origin transactions
# Find the last loan - it will have original_transaction
last_customer_loan = Loan.get_customer_last_loan(customer.id)
logger.info(f"{last_customer_loan}")
# last_customer_loan = Loan.get_customer_last_loan(customer.id)
# logger.info(f"{last_customer_loan}")
new_eligible_amount = 0
if last_customer_loan:
original_transaction = last_customer_loan.original_transaction or last_customer_loan.transaction_id
# if last_customer_loan:
# original_transaction = last_customer_loan.original_transaction or last_customer_loan.transaction_id
real_eligible_amount = last_customer_loan.eligible_amount
# real_eligible_amount = last_customer_loan.eligible_amount
active_loans = Loan.get_active_loans_by_original_transaction(original_transaction)
# active_loans = Loan.get_active_loans_by_original_transaction(original_transaction)
sum_active_loans = sum(loan.current_loan_amount for loan in active_loans)
# sum_active_loans = sum(loan.current_loan_amount for loan in active_loans)
new_eligible_amount = max(real_eligible_amount - sum_active_loans, 0)
# new_eligible_amount = max(real_eligible_amount - sum_active_loans, 0)
logger.info(f"Real eligible: {real_eligible_amount}, Sum of active: {sum_active_loans}, New eligible: {new_eligible_amount}")
# logger.info(f"Real eligible: {real_eligible_amount}, Sum of active: {sum_active_loans}, New eligible: {new_eligible_amount}")
# Construct eligible_offers