Car Loan Refinancing Calculator
Current Loan Details
New Loan Offer Details
Refinance Summary
Please fill in your current and new loan details to see the results.
Potential Total Savings Over Loan Life: ${totalSavings >= 0 ? 'Save $' : 'Costs $'} ${Math.abs(totalSavings).toFixed(2)}
`; resultsOutput.innerHTML = outputHTML; } // --- PDF Download Functionality --- function rccDownloadPDF() { if (!rccLastCalculationData) { alert("Please calculate the results first before downloading the PDF."); // Optionally, switch to results tab and calculate rccSwitchTab(null, 'rccResultsTab'); rccCalculateRefinance(); if (!rccLastCalculationData) return; // Still no data after trying to calculate } const { jsPDF } = window.jspdf; const doc = new jsPDF(); const { currentBalance, currentRate, totalCurrentTermMonths, currentMonthlyPayment, totalPaidCurrent, totalInterestCurrent, newRate, totalNewTermMonths, newMonthlyPayment, totalPaidNew, totalInterestNew, monthlyDifference, totalSavings } = rccLastCalculationData; let y = 20; const lineSpacing = 7; const sectionSpacing = 10; const indent = 15; const primaryColor = [0, 121, 107]; // RGB for #00796b doc.setFontSize(16); doc.setTextColor(primaryColor[0], primaryColor[1], primaryColor[2]); doc.text("Car Loan Refinancing Report", doc.internal.pageSize.getWidth() / 2, y, { align: 'center' }); y += sectionSpacing * 1.5; doc.setFontSize(12); doc.setTextColor(51, 51, 51); // #333 // Current Loan Details doc.setFontSize(14); doc.setTextColor(primaryColor[0], primaryColor[1], primaryColor[2]); doc.text("Current Loan Details", indent, y); y += lineSpacing * 1.5; doc.setFontSize(10); doc.setTextColor(51, 51, 51); doc.text(`Outstanding Balance: $${currentBalance.toFixed(2)}`, indent + 5, y); y += lineSpacing; doc.text(`Annual Interest Rate: ${currentRate.toFixed(2)}%`, indent + 5, y); y += lineSpacing; doc.text(`Remaining Term: ${totalCurrentTermMonths} months`, indent + 5, y); y += lineSpacing; doc.setFont(undefined, 'bold'); doc.text(`Estimated Monthly Payment: $${currentMonthlyPayment.toFixed(2)}`, indent + 5, y); y += lineSpacing; doc.setFont(undefined, 'normal'); doc.text(`Total Interest to be Paid: $${totalInterestCurrent.toFixed(2)}`, indent + 5, y); y += lineSpacing; doc.text(`Total Amount to be Paid: $${totalPaidCurrent.toFixed(2)}`, indent + 5, y); y += sectionSpacing; // New Loan Offer doc.setFontSize(14); doc.setTextColor(primaryColor[0], primaryColor[1], primaryColor[2]); doc.text("New Loan Offer Details", indent, y); y += lineSpacing * 1.5; doc.setFontSize(10); doc.setTextColor(51, 51, 51); doc.text(`Refinanced Loan Balance: $${currentBalance.toFixed(2)}`, indent + 5, y); y += lineSpacing; doc.text(`New Annual Interest Rate: ${newRate.toFixed(2)}%`, indent + 5, y); y += lineSpacing; doc.text(`New Loan Term: ${totalNewTermMonths} months`, indent + 5, y); y += lineSpacing; doc.setFont(undefined, 'bold'); doc.text(`New Monthly Payment: $${newMonthlyPayment.toFixed(2)}`, indent + 5, y); y += lineSpacing; doc.setFont(undefined, 'normal'); doc.text(`Total Interest to be Paid: $${totalInterestNew.toFixed(2)}`, indent + 5, y); y += lineSpacing; doc.text(`Total Amount to be Paid: $${totalPaidNew.toFixed(2)}`, indent + 5, y); y += sectionSpacing; // Summary of Changes doc.setFontSize(14); doc.setTextColor(primaryColor[0], primaryColor[1], primaryColor[2]); doc.text("Summary of Changes", indent, y); y += lineSpacing * 1.5; doc.setFontSize(12); doc.setTextColor(51, 51, 51); let monthlyChangeText = `Change in Monthly Payment: ${monthlyDifference >= 0 ? 'Save $' : 'Costs $'}${Math.abs(monthlyDifference).toFixed(2)} per month`; if (monthlyDifference >= 0) doc.setTextColor(39, 174, 96); // Green for savings else doc.setTextColor(192, 57, 43); // Red for cost doc.text(monthlyChangeText, indent + 5, y); y += lineSpacing; doc.setTextColor(51, 51, 51); // Reset color let totalSavingsText = `Potential Total Savings: ${totalSavings >= 0 ? 'Save $' : 'Costs $'}${Math.abs(totalSavings).toFixed(2)} over loan life`; if (totalSavings >= 0) doc.setTextColor(39, 174, 96); else doc.setTextColor(192, 57, 43); doc.text(totalSavingsText, indent + 5, y); y += lineSpacing; doc.setTextColor(51, 51, 51); doc.save("Car_Loan_Refinance_Summary.pdf"); } // Initial setup rccUpdateNavButtons(); // Set initial state of nav buttons // Make functions globally accessible if called from inline HTML window.rccSwitchTab = rccSwitchTab; window.rccNavigateTab = rccNavigateTab; window.rccCalculateRefinance = rccCalculateRefinance; window.rccDownloadPDF = rccDownloadPDF;