Quick explainer 🎥
Video: How Canadian mortgage affordability (GDS/TDS) is calculated.
const income = $("#income");
const debts = $("#debts");
const rate = $("#rate");
const years = $("#years");
const payment = $("#payment");
const mortgage = $("#mortgage");
const note = $("#note");
const fmt = v => new Intl.NumberFormat("en-CA", { style: "currency", currency: "CAD", maximumFractionDigits: 0 }).format(v || 0);
function mortgageFromPayment(pmt, r, n){
if (r <= 0) return pmt * n;
return pmt * (1 - Math.pow(1 + r, -n)) / r;
}
function run(){
const inc = Math.max(0, Number(income.value || 0));
const debt = Math.max(0, Number(debts.value || 0));
const rateVal = Math.max(0, Number(rate.value || 0)) / 100;
const yrs = Math.max(5, Number(years.value || 25));
if (!inc || !rateVal){
payment.textContent = "-";
mortgage.textContent = "-";
note.textContent = "Enter income and rate.";
return;
}
const monthlyIncome = inc / 12;
const gdsLimit = monthlyIncome * 0.32;
const tdsLimit = monthlyIncome * 0.40 - debt;
const maxPmt = Math.max(0, Math.min(gdsLimit, tdsLimit));
const n = yrs * 12;
const monthlyRate = rateVal / 12;
const loan = mortgageFromPayment(maxPmt, monthlyRate, n);
payment.textContent = fmt(maxPmt);
mortgage.textContent = fmt(loan);
note.textContent = "Estimate only; excludes property taxes, heating, condo fees.";
}
[income, debts, rate, years].forEach(el => el.addEventListener("input", debounce(run, 120)));
$("#y").textContent = new Date().getFullYear();