From 2ebdeed635de808197039426515c86a5d12482eb Mon Sep 17 00:00:00 2001 From: Randy Shreeves Date: Mon, 24 Jun 2024 14:10:12 -0600 Subject: [PATCH] Resolved issue #115: Divide by zero error Adjusted affordability_calculator.py function to test if the home_affordability class variable is 0 before attempting to divide. Verified test cases still pass after making adjustment. --- home-choice-pro/models/affordability_calculator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/home-choice-pro/models/affordability_calculator.py b/home-choice-pro/models/affordability_calculator.py index d74fb9f..905cbdc 100644 --- a/home-choice-pro/models/affordability_calculator.py +++ b/home-choice-pro/models/affordability_calculator.py @@ -172,7 +172,7 @@ def _adjust_for_property_taxes_and_insurance(self): def _calculate_monthly_pmi_payment(self) -> float: """Helper function to factor PMI percentage into home affordability price.""" loan_amount = self.calculate_loan_principal() - if loan_amount == 0: + if loan_amount == 0 or self.home_affordability_price == 0: return 0.0 loan_to_value_ratio = loan_amount / self.home_affordability_price if loan_to_value_ratio <= 0.8: