Update offer_analysis.py

This commit is contained in:
VivianDee
2025-06-12 14:00:15 +01:00
parent a2158a768e
commit 1a6ac6a37f
+13 -3
View File
@@ -67,7 +67,7 @@ class OfferAnalysis:
failed_false_rules.append(rule) failed_false_rules.append(rule)
# Expects false # Salary rules
for key in RAC_SALARY_PAYMENTS: for key in RAC_SALARY_PAYMENTS:
value = rack_response.get(key) value = rack_response.get(key)
if isinstance(value, Decimal): if isinstance(value, Decimal):
@@ -95,13 +95,23 @@ class OfferAnalysis:
# Check consistency rule # Check consistency rule
consistent_income = rack_response.get("rule7-consistent-salary-amount", False) consistent_income = rack_response.get("rule7-consistent-salary-amount", False)
if consistent_income: # Determine percentage based on offer tenure
tenure = getattr(offer, "tenure", 30)
if tenure == 30:
eligible_amount = min_salary * Decimal("0.5") eligible_amount = min_salary * Decimal("0.5")
else:
elif tenure == 90 and consistent_income:
eligible_amount = min_salary * Decimal("0.75") 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.") 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")) return eligible_amount.quantize(Decimal("1.00"))
# "racResponse": { # "racResponse": {
# "accountStatus": true, # "accountStatus": true,
# "bvnValidated": true, # "bvnValidated": true,