Real Estate Investment Budget Planner

Property & Loan Details

Acquisition & Other Upfront Costs

Enter costs in addition to the down payment.

Monthly Holding Costs & Operating Reserves

Budget Summary

Please fill in the details on the previous tabs. The budget summary will be calculated here.

Error: Tool UI elements missing.

"; return; } reibOpenTab(null, reibTabContents[0].id); // Open first tab reibUpdateNavButtons(); }); function reibOpenTab(event, tabId) { let targetButton = null; reibTabContents.forEach(tc => { tc.style.display = "none"; tc.classList.remove('reib-active'); }); reibTabButtons.forEach((btn, index) => { btn.classList.remove('reib-active'); if (btn.getAttribute('onclick').includes(tabId)) { targetButton = btn; reibCurrentTabIndex = index; } }); const targetTab = document.getElementById(tabId); if (targetTab) { targetTab.style.display = "block"; targetTab.classList.add('reib-active');} if (event && event.currentTarget) event.currentTarget.classList.add('reib-active'); else if (targetButton) targetButton.classList.add('reib-active'); reibUpdateNavButtons(); if (tabId === 'reibTabSummary' && typeof reibCalculateAndDisplay === 'function') { reibCalculateAndDisplay(); } } function reibNavigateTab(direction) { let newIdx = reibCurrentTabIndex; if (direction === 'next') newIdx = (reibCurrentTabIndex + 1) % reibTabButtons.length; else if (direction === 'prev') newIdx = (reibCurrentTabIndex - 1 + reibTabButtons.length) % reibTabButtons.length; const targetTabId = reibTabContents[newIdx].id; reibOpenTab({currentTarget: reibTabButtons[newIdx]}, targetTabId); } function reibUpdateNavButtons() { if (!reibPrevButton || !reibNextButton || reibTabButtons.length === 0) return; reibPrevButton.disabled = (reibCurrentTabIndex === 0); reibNextButton.disabled = (reibCurrentTabIndex === reibTabButtons.length - 1); } function reibGetNumValue(id, allowZero = false) { const element = reibAllInputElements[id]; if (!element) { console.warn(`REIB: Input ${id} not found.`); return 0; } const value = parseFloat(element.value); if (isNaN(value) || (!allowZero && value <= 0 && id !== 'reibMonthsOperatingReserve' && id !== 'reibFurnishingCosts' && id !== 'reibOtherAcquisitionCosts' && id !== 'reibHOAFeesMonthly')) { // Allow zero for some fields // Check if field should strictly be positive (and display error or handle) if (id === 'reibPurchasePrice' || id === 'reibDownPaymentPercent' || id === 'reibLoanTermYears' || id === 'reibLoanInterestRate') { return NaN; // Indicate error for critical positive-only fields } return 0; } return value < 0 ? 0 : value; // Ensure non-negative } function reibFormatCurrency(value) { if (isNaN(value)) return "N/A"; return `$${value.toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`; } function calculateMortgage(principal, annualInterestRate, loanTermYears) { if (principal <= 0 || annualInterestRate <= 0 || loanTermYears <= 0) return 0; const monthlyInterestRate = (annualInterestRate / 100) / 12; const numberOfPayments = loanTermYears * 12; if (monthlyInterestRate === 0) return principal / numberOfPayments; // Simple division if no interest const mortgage = principal * (monthlyInterestRate * Math.pow(1 + monthlyInterestRate, numberOfPayments)) / (Math.pow(1 + monthlyInterestRate, numberOfPayments) - 1); return mortgage; } function reibCalculateBudget() { const purchasePrice = reibGetNumValue('reibPurchasePrice'); if (isNaN(purchasePrice) || purchasePrice <=0) { reibBudgetSummaryOutputDiv.innerHTML = "

Property Purchase Price must be a positive number.

"; reibDownloadPdfButtonElem.style.display = 'none'; return null; } const downPaymentPercent = reibGetNumValue('reibDownPaymentPercent'); if (isNaN(downPaymentPercent) || downPaymentPercent < 0 || downPaymentPercent > 100) { reibBudgetSummaryOutputDiv.innerHTML = "

Down Payment Percent must be between 0 and 100.

"; reibDownloadPdfButtonElem.style.display = 'none'; return null; } const loanInterestRate = reibGetNumValue('reibLoanInterestRate', true); // Allow zero interest for cash or creative scenarios const loanTermYears = reibGetNumValue('reibLoanTermYears'); if ((downPaymentPercent < 100) && (isNaN(loanInterestRate) || isNaN(loanTermYears) || loanTermYears <=0 || loanInterestRate < 0 )) { reibBudgetSummaryOutputDiv.innerHTML = "

Loan Interest Rate and Term must be valid if not paying 100% down.

"; reibDownloadPdfButtonElem.style.display = 'none'; return null; } const downPaymentAmount = purchasePrice * (downPaymentPercent / 100); const loanAmount = purchasePrice - downPaymentAmount; const annualPropertyTaxes = reibGetNumValue('reibAnnualPropertyTaxes', true); const annualInsurance = reibGetNumValue('reibAnnualInsurance', true); const loanClosingCosts = reibGetNumValue('reibLoanClosingCosts', true); const inspectionFees = reibGetNumValue('reibInspectionFees', true); const initialRepairs = reibGetNumValue('reibInitialRepairs', true); const legalFees = reibGetNumValue('reibLegalFees', true); const utilitySetupFees = reibGetNumValue('reibUtilitySetupFees', true); const furnishingCosts = reibGetNumValue('reibFurnishingCosts', true); const otherAcquisitionCosts = reibGetNumValue('reibOtherAcquisitionCosts', true); const totalOtherUpfrontCosts = inspectionFees + initialRepairs + legalFees + utilitySetupFees + furnishingCosts + otherAcquisitionCosts + (loanAmount > 0 ? loanClosingCosts : 0); const totalUpfrontCapitalNeeded = downPaymentAmount + totalOtherUpfrontCosts; // Monthly Costs const monthlyPI = loanAmount > 0 ? calculateMortgage(loanAmount, loanInterestRate, loanTermYears) : 0; const monthlyTaxes = annualPropertyTaxes / 12; const monthlyInsurance = annualInsurance / 12; const hoaFeesMonthly = reibGetNumValue('reibHOAFeesMonthly', true); const utilitiesMonthly = reibGetNumValue('reibUtilitiesMonthly', true); const maintenanceReserveMonthly = reibGetNumValue('reibMaintenanceReserveMonthly', true); const totalMonthlyHoldingCosts = monthlyPI + monthlyTaxes + monthlyInsurance + hoaFeesMonthly + utilitiesMonthly + maintenanceReserveMonthly; const monthsOperatingReserve = reibGetNumValue('reibMonthsOperatingReserve', true); const operatingReserveAmount = totalMonthlyHoldingCosts * monthsOperatingReserve; const totalCapitalWithReserve = totalUpfrontCapitalNeeded + operatingReserveAmount; return { purchasePrice, downPaymentPercent, downPaymentAmount, loanAmount, loanInterestRate, loanTermYears, annualPropertyTaxes, annualInsurance, loanClosingCosts, inspectionFees, initialRepairs, legalFees, utilitySetupFees, furnishingCosts, otherAcquisitionCosts, totalOtherUpfrontCosts, totalUpfrontCapitalNeeded, monthlyPI, monthlyTaxes, monthlyInsurance, hoaFeesMonthly, utilitiesMonthly, maintenanceReserveMonthly, totalMonthlyHoldingCosts, monthsOperatingReserve, operatingReserveAmount, totalCapitalWithReserve }; } function reibCalculateAndDisplay() { if (!reibBudgetSummaryOutputDiv || !reibDownloadPdfButtonElem) { console.error("REIB: Summary output elements not found."); return; } const budget = reibCalculateBudget(); if (!budget) return; // Error message already handled in reibCalculateBudget reibBudgetSummaryOutputDiv.innerHTML = `
Upfront Capital Needed for Acquisition
Purchase Price: ${reibFormatCurrency(budget.purchasePrice)}
Down Payment (${budget.downPaymentPercent}%): ${reibFormatCurrency(budget.downPaymentAmount)}
${budget.loanAmount > 0 ? `
Loan Closing Costs: ${reibFormatCurrency(budget.loanClosingCosts)}
` : ''}
Inspection Fees: ${reibFormatCurrency(budget.inspectionFees)}
Initial Repairs/Renovations: ${reibFormatCurrency(budget.initialRepairs)}
Legal Fees: ${reibFormatCurrency(budget.legalFees)}
Utility Setup/Transfer: ${reibFormatCurrency(budget.utilitySetupFees)}
Furnishing Costs: ${reibFormatCurrency(budget.furnishingCosts)}
Other Acquisition Costs: ${reibFormatCurrency(budget.otherAcquisitionCosts)}

Total Upfront Capital Needed: ${reibFormatCurrency(budget.totalUpfrontCapitalNeeded)}
Estimated Monthly Holding Costs
${budget.loanAmount > 0 ? `
Principal & Interest (P&I): ${reibFormatCurrency(budget.monthlyPI)}
` : ''}
Property Taxes (Monthly): ${reibFormatCurrency(budget.monthlyTaxes)}
Homeowners Insurance (Monthly): ${reibFormatCurrency(budget.monthlyInsurance)}
HOA Fees (Monthly): ${reibFormatCurrency(budget.hoaFeesMonthly)}
Estimated Utilities (Monthly): ${reibFormatCurrency(budget.utilitiesMonthly)}
Maintenance Reserve (Monthly): ${reibFormatCurrency(budget.maintenanceReserveMonthly)}

Total Estimated Monthly Holding Costs: ${reibFormatCurrency(budget.totalMonthlyHoldingCosts)}
Total Capital Outlook
Total Upfront Capital Needed: ${reibFormatCurrency(budget.totalUpfrontCapitalNeeded)}
Operating Reserve (${budget.monthsOperatingReserve} Months): ${reibFormatCurrency(budget.operatingReserveAmount)}

Total Estimated Capital (Upfront + Reserve): ${reibFormatCurrency(budget.totalCapitalWithReserve)}
`; reibDownloadPdfButtonElem.style.display = 'inline-block'; } async function reibDownloadPDF() { const { jsPDF } = window.jspdf; if (typeof html2canvas === 'undefined' || typeof jsPDF === 'undefined') { alert('Error: PDF generation libraries not loaded.'); return; } const budget = reibCalculateBudget(); if (!budget) { alert("Cannot generate PDF: please ensure all inputs are valid and budget is calculated."); return; } const pdfContentWrapper = document.createElement('div'); pdfContentWrapper.className = 'reib-pdf-content-wrapper'; let inputsHTML = `

Property & Loan Details

`; inputsHTML += `
Purchase Price: ${reibFormatCurrency(budget.purchasePrice)}
`; inputsHTML += `
Down Payment: ${budget.downPaymentPercent}% (${reibFormatCurrency(budget.downPaymentAmount)})
`; inputsHTML += `
Loan Amount: ${reibFormatCurrency(budget.loanAmount)}
`; inputsHTML += `
Interest Rate: ${budget.loanInterestRate}%
`; inputsHTML += `
Loan Term: ${budget.loanTermYears} Years
`; inputsHTML += `
Annual Property Taxes: ${reibFormatCurrency(budget.annualPropertyTaxes)}
`; inputsHTML += `
Annual Insurance: ${reibFormatCurrency(budget.annualInsurance)}
`; let upfrontCostsHTML = `

Acquisition & Other Upfront Costs

`; if (budget.loanAmount > 0) upfrontCostsHTML += `
Loan Closing Costs: ${reibFormatCurrency(budget.loanClosingCosts)}
`; upfrontCostsHTML += `
Inspection Fees: ${reibFormatCurrency(budget.inspectionFees)}
`; upfrontCostsHTML += `
Initial Repairs/Renovations: ${reibFormatCurrency(budget.initialRepairs)}
`; upfrontCostsHTML += `
Legal Fees: ${reibFormatCurrency(budget.legalFees)}
`; upfrontCostsHTML += `
Utility Setup/Transfer: ${reibFormatCurrency(budget.utilitySetupFees)}
`; upfrontCostsHTML += `
Furnishing Costs: ${reibFormatCurrency(budget.furnishingCosts)}
`; upfrontCostsHTML += `
Other Acquisition Costs: ${reibFormatCurrency(budget.otherAcquisitionCosts)}
`; upfrontCostsHTML += `
Total Other Upfront (Excl. Down Payment): ${reibFormatCurrency(budget.totalOtherUpfrontCosts)}
`; let monthlyCostsHTML = `

Estimated Monthly Holding Costs

`; if (budget.loanAmount > 0) monthlyCostsHTML += `
Principal & Interest (P&I): ${reibFormatCurrency(budget.monthlyPI)}
`; monthlyCostsHTML += `
Property Taxes: ${reibFormatCurrency(budget.monthlyTaxes)}
`; monthlyCostsHTML += `
Homeowners Insurance: ${reibFormatCurrency(budget.monthlyInsurance)}
`; monthlyCostsHTML += `
HOA Fees: ${reibFormatCurrency(budget.hoaFeesMonthly)}
`; monthlyCostsHTML += `
Utilities: ${reibFormatCurrency(budget.utilitiesMonthly)}
`; monthlyCostsHTML += `
Maintenance Reserve: ${reibFormatCurrency(budget.maintenanceReserveMonthly)}
`; monthlyCostsHTML += `
Total Monthly Holding Costs: ${reibFormatCurrency(budget.totalMonthlyHoldingCosts)}
`; let summaryHTML = `

Budget Summary

`; summaryHTML += `
Total Upfront Capital Needed: ${reibFormatCurrency(budget.totalUpfrontCapitalNeeded)}
`; summaryHTML += `
Operating Reserve (${budget.monthsOperatingReserve} Months): ${reibFormatCurrency(budget.operatingReserveAmount)}
`; summaryHTML += `
Total Estimated Capital (Upfront + Reserve): ${reibFormatCurrency(budget.totalCapitalWithReserve)}
`; pdfContentWrapper.innerHTML = `

Real Estate Investment Budget Plan

${inputsHTML} ${upfrontCostsHTML} ${monthlyCostsHTML} ${summaryHTML}

Report generated on: ${new Date().toLocaleDateString()} ${new Date().toLocaleTimeString()}

`; document.body.appendChild(pdfContentWrapper); try { const canvas = await html2canvas(pdfContentWrapper, { scale: 2, useCORS: true, backgroundColor: '#ffffff' }); const imgData = canvas.toDataURL('image/png'); const pdf = new jsPDF({ orientation: 'p', unit: 'pt', format: 'a4' }); const pdfWidth = pdf.internal.pageSize.getWidth(); const pdfHeight = pdf.internal.pageSize.getHeight(); const imgProps = pdf.getImageProperties(imgData); const ratio = Math.min((pdfWidth - 40) / imgProps.width, (pdfHeight - 40) / imgProps.height); pdf.addImage(imgData, 'PNG', (pdfWidth - imgProps.width * ratio) / 2, 20, imgProps.width * ratio, imgProps.height * ratio); pdf.save('Real_Estate_Investment_Budget.pdf'); } catch (error) { console.error("Error during PDF generation:", error); alert("An error occurred while generating the PDF."); } finally { document.body.removeChild(pdfContentWrapper); } }
Scroll to Top