This is a node module that allows you to calculate the maximum mortgage that you can afford based on your salary and the initial Deposit you will make.
It is based on the assumption that no more than 36% of your salary before taxes should be designated to the mortgage to avoid financial problems.
You can check the article about the Underwriter for more information.
The maximum allowed by law is a 43% before taxes, however many articles suggest that you shouldn't take a mortgage over 36%.
- The formula used to obtain the payment:
- The formula used to obtain the mortgage 1 :
npm install mortgage-calculator
or download the minified version
var mortgageCalculator = require("mortgage-calculator");
On the browser.
window.mortgageCalculator will be exposed after including the script.
This method will tell you the price of the house that you can afford. The value returned will be an object with numbers.
initialDeposit: How much money will you pay upfront.
monthlyIncome: Gross monthly income.
interest: Interest rate.
term: Duration in years of the mortgage. Default:
payments: number of payments, the term has priority, if no term is provided, will use payments, if no payments are provided, it will use the term's default.
monthlyExpenses: Personal monthly expenses.
age: Age of the youngest person taking the loan.
maxAge: Maximum age restricts the length of the term. Default:
riskRate: Maximum percent of risk. Default:
personalTaxRate: Percent of the monthly income that is paid as taxes. Default:
42.) -> future version.
// when calling the functionmortgageCalculator// Will return an object like this one.ObjectmaxMonthlyPayment: 432totalPriceHouse: 978943150262mortgageTotal: 778943150262totalInterest: 15090217746
This method will format an integer to the desired localized format. The value returned will be an string.
This will be the value you want to format.
// Calling the function with this argumentmortgageCalculator;// returns the default format"$123,456,789.12"
This method will give you the table of amortization.
mortgageCalculator.amortization(capital, pay, periods, interest);
Total value of the mortgage we want to obtain the amortization table for.
Calculated monthly pay obtained from mortgageCalculator.getMaxMortgage
Number of payments for the amortization.
Annual interest not expressed in %
example: 3% --> 3/100 = 0.03
// When calling the function with the following parametersmortgageCalculator;// will return the following (abbreviated)"period": 1"amortizationInterest": 125"amortizationCapital": 41097"remainingCapital": 458903"period": 2"amortizationInterest": 11472574999999999"amortizationCapital": 411997425"remainingCapital": 4177032574999999"period": 3"amortizationInterest": 10442581437499998"amortizationCapital": 41302741856250003"remainingCapital": 37640051564374994"period": 4"amortizationInterest": 9410012891093748"amortizationCapital": 4140599871089063"remainingCapital": 33499451693285932// abbreviated"period": 12"amortizationInterest": 10559892142203449"amortizationCapital": 422395685688138"remainingCapital": 0
To start run:
For test use command:
For test on Browsers use testem:
1: This formula comes from: