Housing Cost Optimization Planner
Your Current Housing Cost Snapshot
Renting Details
Owning Details (Monthly Costs)
Rent vs. Buy Comparison
Renting Scenario
Buying Scenario
Mortgage Optimization Tools
Is Refinancing Right for You?
Pay Off Your Mortgage Faster!
See How Your Down Payment Changes Things
Housing Affordability Estimator
Estimate what you might comfortably afford based on common guidelines. These are estimates only.
For Home Price Estimation (Optional Advanced):
Download Report
Generate a PDF summary of your housing cost analyses and scenarios.
Time Saved: ${Math.floor(yearsSaved)} years and ${Math.round((yearsSaved % 1) * 12)} months
Total Interest Saved: $${totalInterestSaved.toFixed(2)}
`; extraPaymentsResultsEl.style.display = 'block'; } window.hcot_calculateDownPaymentImpact = function() { const homePrice = getNum(dpHomePriceEl); const interestRate = getNum(dpInterestRateEl); const loanTerm = getNum(dpLoanTermEl); const downPaymentPercent = getNum(dpDownPaymentPercentEl); const pmiRate = getNum(dpPMIRateEl); if (homePrice <= 0 || interestRate <= 0 || loanTerm <= 0 || downPaymentPercent < 0 || downPaymentPercent > 100) { alert("Please enter valid home price, interest rate, loan term, and down payment percentage."); return; } const downPaymentAmount = homePrice * (downPaymentPercent / 100); const loanAmount = homePrice - downPaymentAmount; const monthlyPandI = calculateMonthlyMortgage(loanAmount, interestRate, loanTerm); const monthlyPMI = calculatePMI(loanAmount, homePrice, pmiRate); const totalInterest = calculateTotalInterestPaid(loanAmount, monthlyPandI, loanTerm); downPaymentResultsEl.innerHTML = `Down Payment Impact Analysis
For a Home Price of $${homePrice.toFixed(2)}:
With a ${downPaymentPercent}% Down Payment ($${downPaymentAmount.toFixed(2)}):
- Loan Amount: $${loanAmount.toFixed(2)}
- Estimated Monthly P&I: $${monthlyPandI.toFixed(2)} ${monthlyPMI > 0 ? `
- Estimated Monthly PMI: $${monthlyPMI.toFixed(2)} ` : '
- No PMI expected (with 20%+ down) '}
- Total Monthly P&I + PMI: $${(monthlyPandI + monthlyPMI).toFixed(2)}
- Total Interest Paid Over Loan Life: $${totalInterest.toFixed(2)}
Try different down payment percentages to see how it affects your loan and payments.
`; downPaymentResultsEl.style.display = 'block'; } // --- Tab 4: Affordability & Export --- window.hcot_calculateAffordability = function() { const grossAnnualIncome = getNum(affordGrossIncomeEl); const monthlyDebts = getNum(affordMonthlyDebtsEl); const housingRatio = getNum(affordHousingRatioEl, 28) / 100; const dtiRatio = getNum(affordDTIRatioEl, 36) / 100; const estInterestRate = getNum(affordEstInterestRateEl, 0); const estLoanTerm = getNum(affordEstLoanTermEl, 30); const estPropTaxRatePercent = getNum(affordEstPropTaxRateEl, 0); const estHomeInsRatePercent = getNum(affordEstHomeInsRateEl, 0); if (grossAnnualIncome <= 0) { alert("Please enter a valid gross annual income."); return; } const grossMonthlyIncome = grossAnnualIncome / 12; const affordableHousingPayment_frontEnd = grossMonthlyIncome * housingRatio; const affordableHousingPayment_backEnd = (grossMonthlyIncome * dtiRatio) - monthlyDebts; const finalAffordableMonthlyPITI = Math.min(affordableHousingPayment_frontEnd, affordableHousingPayment_backEnd); let resultsHtml = `Housing Affordability Estimation
Gross Monthly Income: $${grossMonthlyIncome.toFixed(2)}
Affordable Monthly Housing Cost (PITI) based on ${housingRatio*100}% Front-End Ratio: $${affordableHousingPayment_frontEnd.toFixed(2)}
Affordable Monthly Housing Cost (PITI) based on ${dtiRatio*100}% Back-End DTI (after $${monthlyDebts.toFixed(2)} other debts): $${affordableHousingPayment_backEnd.toFixed(2)}
Recommended Max Monthly Housing Payment (PITI): $${finalAffordableMonthlyPITI.toFixed(2)}
`; // Estimate affordable home price (simplified) if (estInterestRate > 0 && estLoanTerm > 0 && estPropTaxRatePercent > 0 && estHomeInsRatePercent > 0 && finalAffordableMonthlyPITI > 0) { // PITI = P&I + T + I // P&I = PITI - T - I // For estimation, assume T and I are % of home price (HP) // T_monthly = (HP * estPropTaxRatePercent/100) / 12 // I_monthly = (HP * estHomeInsRatePercent/100) / 12 // P&I_monthly = M_factor * HP * (1 - assumed_dp_percent) // This gets complex to solve for HP directly. Simpler: iterate or provide a range. // Iterative approach: let lowHP = 10000, highHP = 2000000, midHP = 0, estPITI = 0; let affordableHomePrice = 0; const assumedDownPaymentPercentForAffordability = 0.10; // Assume 10% DP for this estimation for (let i = 0; i < 20; i++) { // Max 20 iterations for binary search midHP = (lowHP + highHP) / 2; if(midHP <=0) break; const estLoan = midHP * (1 - assumedDownPaymentPercentForAffordability); const estPandI = calculateMonthlyMortgage(estLoan, estInterestRate, estLoanTerm); const estTaxesMonthly = (midHP * (estPropTaxRatePercent / 100)) / 12; const estInsuranceMonthly = (midHP * (estHomeInsRatePercent / 100)) / 12; // Simplified PMI estimate if DP is less than 20% (always true for 10% assumed DP) const estPMIMonthly = calculatePMI(estLoan, midHP, getNum(dpPMIRateEl, 0.58)); estPITI = estPandI + estTaxesMonthly + estInsuranceMonthly + estPMIMonthly; if (estPITI > finalAffordableMonthlyPITI) { highHP = midHP; } else { affordableHomePrice = midHP; // Potential match lowHP = midHP; } if (highHP - lowHP < 1000) break; // Converged enough } if(affordableHomePrice > 0){ resultsHtml += `Estimated Affordable Home Price Range (with ~10% down, assuming provided rates for tax/ins/mortgage): ~$${Math.floor(affordableHomePrice / 1000) * 1000}
`; resultsHtml += `This home price estimate is very rough and depends heavily on your down payment, actual tax/insurance rates, and current mortgage rates. Use as a general guideline.
`; } else { resultsHtml += `Could not estimate affordable home price with the given parameters. Ensure all rates for estimation are filled in.
`; } } else { resultsHtml += `To estimate affordable home price, please fill in assumed mortgage rate, term, property tax rate, and home insurance rate under "For Home Price Estimation".
`; } affordabilityResultsEl.innerHTML = resultsHtml; affordabilityResultsEl.style.display = 'block'; } // --- Sub-section Toggling --- window.hcot_toggleSubSection = function(toggleButton, sectionId) { const sectionContent = document.getElementById(sectionId); const icon = toggleButton.querySelector('i'); if (sectionContent) { if (sectionContent.classList.contains('active')) { sectionContent.classList.remove('active'); if(icon) icon.classList.replace('fa-chevron-up', 'fa-chevron-down'); } else { sectionContent.classList.add('active'); if(icon) icon.classList.replace('fa-chevron-down', 'fa-chevron-up'); } } } // --- PDF Download --- if (downloadPdfButton) { downloadPdfButton.addEventListener('click', function() { let pdfHtml = `Housing Cost Optimization Report
`; pdfHtml += `Generated on: ${new Date().toLocaleDateString()}
`; // Section 1: Current Housing Costs if (currentCostsResultsEl && currentCostsResultsEl.style.display !== 'none' && currentCostsResultsEl.innerHTML.length > 20) { pdfHtml += `My Current Housing Snapshot
`; pdfHtml += `Current Situation: ${currentSituationRentingEl.checked ? 'Renting' : 'Owning'}
`; // Add inputs here... e.g., Rent: $value, P&I: $value etc. if(currentSituationRentingEl.checked){ pdfHtml += `Monthly Rent: $${getNum(currentRentEl).toFixed(2)}
`; pdfHtml += `Renter's Insurance: $${getNum(currentRentersInsuranceEl).toFixed(2)}
`; } else { pdfHtml += `P&I: $${getNum(currentPandIEl).toFixed(2)}
`; pdfHtml += `Property Taxes: $${getNum(currentPropertyTaxesEl).toFixed(2)}
`; pdfHtml += `Home Insurance: $${getNum(currentHomeInsuranceEl).toFixed(2)}
`; pdfHtml += `HOA: $${getNum(currentHOAEl).toFixed(2)}
`; pdfHtml += `PMI: $${getNum(currentPMIEl).toFixed(2)}
`; pdfHtml += `Maintenance: $${getNum(currentMaintenanceEl).toFixed(2)}
`; } pdfHtml += `Rent vs. Buy Analyzer
`; // Add inputs... pdfHtml += `Inputs:
Rent: $${getNum(rvbRentEl).toFixed(2)}, Renters Ins: $${getNum(rvbRentersInsEl).toFixed(2)}
Home Price: $${getNum(rvbHomePriceEl).toFixed(2)}, DP: ${getNum(rvbDownPaymentPercentEl)}%, Rate: ${getNum(rvbInterestRateEl)}%, Term: ${getVal(rvbLoanTermEl)} yrs
Taxes: $${getNum(rvbPropertyTaxEl).toFixed(2)}/yr, Home Ins: $${getNum(rvbHomeInsEl).toFixed(2)}/yr, HOA: $${getNum(rvbHOAEl).toFixed(2)}/mo
PMI Rate: ${getNum(rvbPMIRateEl)}%/yr, Maintenance: ${getNum(rvbMaintenanceEl)}%/yr, Closing: ${getNum(rvbClosingCostsEl)}%
Refinance Analysis
`; pdfHtml += `Inputs:
Current Balance: $${getNum(refiCurrentBalanceEl).toFixed(2)}, Rate: ${getNum(refiCurrentRateEl)}%, Term: ${getNum(refiRemainingTermEl)} yrs
New Rate: ${getNum(refiNewRateEl)}%, New Term: ${getNum(refiNewTermEl)} yrs, Costs: $${getNum(refiCostsEl).toFixed(2)}
Extra Payments Analysis
`; pdfHtml += `Inputs:
Balance: $${getNum(epLoanBalanceEl).toFixed(2)}, Rate: ${getNum(epInterestRateEl)}%, Term: ${getNum(epRemainingTermEl)} yrs, Extra: $${getNum(epExtraPaymentEl).toFixed(2)}/mo
Down Payment Impact
`; pdfHtml += `Inputs:
Home Price: $${getNum(dpHomePriceEl).toFixed(2)}, Rate: ${getNum(dpInterestRateEl)}%, Term: ${getVal(dpLoanTermEl)} yrs, DP: ${getNum(dpDownPaymentPercentEl)}%
Housing Affordability Estimation
`; pdfHtml += `Inputs:
Income: $${getNum(affordGrossIncomeEl).toFixed(2)}/yr, Monthly Debts: $${getNum(affordMonthlyDebtsEl).toFixed(2)}
Housing Ratio: ${getNum(affordHousingRatioEl)}%, DTI Ratio: ${getNum(affordDTIRatioEl)}%
