From 1a6ac6a37ffd5b659531c56ef8a2a7847c5b8772 Mon Sep 17 00:00:00 2001 From: VivianDee <115420678+VivianDee@users.noreply.github.com> Date: Thu, 12 Jun 2025 14:00:15 +0100 Subject: [PATCH] Update offer_analysis.py --- app/api/services/offer_analysis.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/app/api/services/offer_analysis.py b/app/api/services/offer_analysis.py index 11ec0a1..750af01 100644 --- a/app/api/services/offer_analysis.py +++ b/app/api/services/offer_analysis.py @@ -67,7 +67,7 @@ class OfferAnalysis: failed_false_rules.append(rule) - # Expects false + # Salary rules for key in RAC_SALARY_PAYMENTS: value = rack_response.get(key) if isinstance(value, Decimal): @@ -95,13 +95,23 @@ class OfferAnalysis: # Check consistency rule consistent_income = rack_response.get("rule7-consistent-salary-amount", False) - if consistent_income: - eligible_amount = min_salary * Decimal("0.5") - else: - eligible_amount = min_salary * Decimal("0.75") + # Determine percentage based on offer tenure + tenure = getattr(offer, "tenure", 30) + if tenure == 30: + eligible_amount = min_salary * Decimal("0.5") + + elif tenure == 90 and consistent_income: + eligible_amount = min_salary * Decimal("0.75") + + else: # Income is not consistent + eligible_amount = min_salary * Decimal("0.5") + + logger.info(f"Calculated eligible amount from RAC: {eligible_amount} based on {'stable' if consistent_income else 'unstable'} income.") + return eligible_amount.quantize(Decimal("1.00")) + # "racResponse": { # "accountStatus": true, # "bvnValidated": true,