Example #1
0
 def test_nper(self):
     """
     Test nper using values from excel conversions spreadsheet.
     """
     # 12% is 1% per month (0.01)
     test_data = [
         ({"rate": 0.01, "pmt": -200, "pv": 10000}, 69.6607168936),
         ({"rate": 0.01, "pmt": -300, "pv": 10000}, 40.7489071561),
         ({"rate": 0.01, "pmt": -500, "pv": 10000}, 22.425741878),
         ({"rate": 0.01, "pmt": -10100, "pv": 10000}, 1.0),
     ]
     for (params, desired) in test_data:
         actual = nper(**params)
         self.assertAlmostEqual(actual, desired)
Example #2
0
 def calculate_current_loan_estimated_remaining_term(self):
     if self.current_loan_balance and self.current_loan_monthly_payment and self.current_loan_rate:
         rate = self.current_loan_rate / 12.0
         pmt = -self.current_loan_monthly_payment
         pv = self.current_loan_balance
         self.current_loan_estimated_remaining_term = int(round(nper(rate, pmt, pv)))