Debt Consolidation Loan Estimator
List Your Current Debts
Current Debt Summary:
Total Outstanding Debt: $0.00
Total Current Monthly Payments: $0.00
Weighted Average APR: 0.00%
New Debt Consolidation Loan Terms
Consolidation Estimate & Comparison
Sum of Current Monthly Payments: ${dce_formatCurrency(currentTotalMonthlyPayments)}
Weighted Average APR of Current Debts: ${dce_formatPercent(currentWeightedAPR)}
Estimated New Consolidation Loan
Loan Amount (Consolidated Debt): ${dce_formatCurrency(newLoanPrincipal)}
Estimated APR for New Loan: ${dce_formatPercent(newLoanAPR)}
New Loan Term: ${newLoanTermMonths} months
Estimated Monthly Payment (EMI): ${dce_formatCurrency(newEMI)}
Total Interest Paid with New Loan: ${dce_formatCurrency(newTotalInterestPayable)}
Total Amount Paid with New Loan: ${dce_formatCurrency(newTotalAmountPayable)}
Potential Impact of Consolidation
Change in Total Monthly Payment: ${monthlyPaymentChange > 0 ? 'Save approx. ' + dce_formatCurrency(monthlyPaymentChange) + '/month' : (monthlyPaymentChange < 0 ? 'Increase by approx. ' + dce_formatCurrency(Math.abs(monthlyPaymentChange)) + '/month' : 'No change in monthly payment.')}
Number of Payments to Manage: From multiple to one single payment.
Repayment Horizon: You'll have a fixed ${newLoanTermMonths}-month term to clear these consolidated debts.
`; if (newLoanAPR < currentWeightedAPR && newTotalInterestPayable < (currentTotalMonthlyPayments * newLoanTermMonths - newLoanPrincipal) && currentWeightedAPR > 0) { // Crude comparison for interest if applicable resultsHTML += `Potential Interest Savings: If the new APR (${dce_formatPercent(newLoanAPR)}) is lower than your current weighted average APR (${dce_formatPercent(currentWeightedAPR)}), and you complete the ${newLoanTermMonths}-month term, you are likely to save on total interest paid compared to making similar total payments over the same period on higher-rate debts. The total interest on this consolidation loan is ${dce_formatCurrency(newTotalInterestPayable)}.
`; } else if (newLoanAPR > currentWeightedAPR && currentWeightedAPR > 0) { resultsHTML += `Note on Interest: The APR for the new consolidation loan (${dce_formatPercent(newLoanAPR)}) is higher than your current weighted average APR (${dce_formatPercent(currentWeightedAPR)}). While it might simplify payments, ensure this is the best financial option regarding total interest paid.
`; } if(dce_el.resultsSummary) dce_el.resultsSummary.innerHTML = resultsHTML; if(dce_el.pdfDownloadBtn && dce_el.pdfDownloadBtn.style) dce_el.pdfDownloadBtn.style.display = 'block'; } function dce_resetForm() { if(dce_el.debtEntriesContainer) dce_el.debtEntriesContainer.innerHTML = ""; // Clear dynamic entries dce_debtEntryCount = 0; dce_addDebtEntry(); // Add one default dce_addDebtEntry(); // Add second default if(dce_el.newLoanAPR) dce_el.newLoanAPR.value = "10.0"; if(dce_el.newLoanTerm) dce_el.newLoanTerm.value = "36"; dce_updateCurrentDebtSummary(); // Recalculates summary and new loan principal display document.querySelectorAll('#debtConsolidationEstimator .dce-error-message').forEach(el => el.textContent = ''); if(dce_el.resultsSummary) dce_el.resultsSummary.innerHTML = ""; if(dce_el.pdfDownloadBtn && dce_el.pdfDownloadBtn.style) dce_el.pdfDownloadBtn.style.display = 'none'; if(dce_el.resultsTabButton) dce_el.resultsTabButton.disabled = true; dce_currentTab = 0; dce_openTab(null, 'dce-tabCurrentDebts'); } function dce_downloadPDF() { if (typeof window.jspdf === 'undefined' || typeof window.jspdf.jsPDF !== 'function' || typeof window.jspdf.jsPDF.API.autoTable !== 'function' || typeof window.html2canvas !== 'function') { alert("PDF generation library not loaded. Check CDN links & internet connection."); return; } const jsPDFConstructor = window.jspdf.jsPDF; const resultsSummaryContent = dce_el.resultsSummary; if (!resultsSummaryContent || !resultsSummaryContent.innerHTML.includes("Estimated New Consolidation Loan")) { alert("No results to download. Please calculate the estimate first."); return; } const pdf = new jsPDFConstructor('p', 'pt', 'a4'); const toolTitle = "Debt Consolidation Loan Estimate"; const margins = { top: 40, bottom: 40, left: 30, right: 30 }; let yPos = margins.top; pdf.setFontSize(18); pdf.text(toolTitle, pdf.internal.pageSize.getWidth() / 2, yPos, { align: 'center' }); yPos += 30; // Current Debts Summary (from displayed values) pdf.setFontSize(11); pdf.text("Summary of Your Current Debts:", margins.left, yPos); yPos += 15; pdf.setFontSize(9); pdf.text(`- Total Outstanding Debt: ${dce_el.currentTotalDebtDisplay.textContent}`, margins.left + 10, yPos); yPos += 13; pdf.text(`- Total Current Monthly Payments: ${dce_el.currentTotalMonthlyPaymentsDisplay.textContent}`, margins.left + 10, yPos); yPos += 13; pdf.text(`- Weighted Average APR: ${dce_el.currentWeightedAPRDisplay.textContent}`, margins.left + 10, yPos); yPos += 20; // New Loan Terms pdf.setFontSize(11); pdf.text("Proposed New Consolidation Loan Terms:", margins.left, yPos); yPos += 15; pdf.setFontSize(9); pdf.text(`- Loan Amount to Consolidate: ${dce_el.newLoanPrincipalDisplay.textContent}`, margins.left + 10, yPos); yPos += 13; pdf.text(`- Estimated APR: ${dce_el.newLoanAPR.value}%`, margins.left + 10, yPos); yPos += 13; pdf.text(`- Loan Term: ${dce_el.newLoanTerm.value} months`, margins.left + 10, yPos); yPos += 20; // Results Summary using html2canvas for better formatting capture const elementToCapture = dce_el.resultsSummary; if (elementToCapture) { if (yPos > pdf.internal.pageSize.getHeight() - margins.bottom - 100) { // Check space pdf.addPage(); yPos = margins.top; } pdf.setFontSize(11); pdf.text("Consolidation Estimate Details:", margins.left, yPos); yPos += 5; // Small gap html2canvas(elementToCapture, {scale: 1.5, backgroundColor: '#ffffff', useCORS: true}).then(canvas => { const imgData = canvas.toDataURL('image/png'); const imgProps = pdf.getImageProperties(imgData); const pdfWidth = pdf.internal.pageSize.getWidth() - margins.left - margins.right; const pdfHeight = (imgProps.height * pdfWidth) / imgProps.width; if (yPos + pdfHeight > pdf.internal.pageSize.getHeight() - margins.bottom) { pdf.addPage(); yPos = margins.top; } pdf.addImage(imgData, 'PNG', margins.left, yPos, pdfWidth, pdfHeight); yPos += pdfHeight + 20; // Disclaimer const disclaimerElement = document.querySelector('#debtConsolidationEstimator .dce-disclaimer-note'); if (disclaimerElement) { if (yPos > pdf.internal.pageSize.getHeight() - margins.bottom - 40) { pdf.addPage(); yPos = margins.top; } pdf.setFontSize(8); const disclaimerLines = pdf.splitTextToSize(disclaimerElement.innerText.trim(), pdf.internal.pageSize.getWidth() - margins.left - margins.right); pdf.text(disclaimerLines, margins.left, yPos); } pdf.save('Debt_Consolidation_Estimate.pdf'); }).catch(err => { console.error("Error generating PDF summary with html2canvas:", err); alert("Error rendering summary to PDF. The PDF will be generated without the formatted summary section."); // Fallback to text if html2canvas fails? Or just save what we have. // For now, just alert and save what might have been drawn before. const disclaimerElement = document.querySelector('#debtConsolidationEstimator .dce-disclaimer-note'); if (disclaimerElement) { /* ... add disclaimer ... */ } pdf.save('Debt_Consolidation_Estimate_Partial.pdf'); }); } else { pdf.save('Debt_Consolidation_Estimate_InputsOnly.pdf'); } }