Update offer_analysis.py

This commit is contained in:
VivianDee
2025-06-12 14:00:15 +01:00
parent a2158a768e
commit 1a6ac6a37f
+15 -5
View File
@@ -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,