Bank Loan vs. Online Lender Loan Comparison

Compare the financial details of a loan from a traditional bank versus an online lender based on the terms and fees you enter.

Common Loan Details

${summaryMsg}

`; resultsSummaryDiv.style.display = 'block'; if(downloadPdfButton) downloadPdfButton.style.display = 'block'; } if(downloadPdfButton) { downloadPdfButton.onclick = function() { if (!bvol_comparisonDataForPdf) { alert("Please calculate comparison first."); return; } console.log("BVOL Tool: Generating PDF..."); if (typeof window.jspdf === 'undefined' || typeof window.jspdf.jsPDF === 'undefined') { alert('Error: jsPDF library not loaded.'); console.error("BVOL Tool: jsPDF not loaded."); return; } const { jsPDF } = window.jspdf; const doc = new jsPDF('p', 'pt', 'letter'); if (typeof doc.autoTable !== 'function') { alert('Error: jsPDF-AutoTable plugin not loaded.'); console.error("BVOL Tool: jsPDF-AutoTable not loaded."); return; } const { desiredLoanAmount, bank, online } = bvol_comparisonDataForPdf; const pageMargin = 40; const lineHeight = 12; let yPos = pageMargin; doc.setFontSize(18); doc.setTextColor(0, 123, 255); // Primary doc.text("Bank Loan vs. Online Lender Loan Comparison", pageMargin, yPos); yPos += 30; doc.setTextColor(0,0,0); doc.setFontSize(12); doc.text(`Desired Loan Amount (before fees): $${desiredLoanAmount.toFixed(2)}`, pageMargin, yPos); yPos += lineHeight * 2; doc.setFontSize(10); const summaryP = resultsSummaryDiv.querySelector('p'); if (summaryP) { const summaryLines = doc.splitTextToSize(summaryP.innerText.replace(/|<\/strong>/g, ''), doc.internal.pageSize.width - (pageMargin * 2)); // Remove strong tags for PDF text doc.text(summaryLines, pageMargin, yPos); yPos += (summaryLines.length * lineHeight) + (lineHeight * 0.5) ; } const head = [['Feature', 'Traditional Bank Loan', 'Online Lender Loan']]; const body = [ ['Annual Interest Rate', `${bank.rate.toFixed(2)}%`, `${online.rate.toFixed(2)}%`], ['Loan Term', `${bank.term} years`, `${online.term} years`], ['Loan Fees (Financed)', `$${bank.fees.toFixed(2)}`, `$${online.fees.toFixed(2)}`], ['Total Amount Financed', `$${bank.totalAmountFinanced.toFixed(2)}`, `$${online.totalAmountFinanced.toFixed(2)}`], ['Monthly Payment', `$${bank.monthlyPayment.toFixed(2)}`, `$${online.monthlyPayment.toFixed(2)}`], ['Total Interest Paid', `$${bank.totalInterest.toFixed(2)}`, `$${online.totalInterest.toFixed(2)}`], [{content: 'Total Cost of Loan (Interest + Fees)', styles: {fontStyle: 'bold'}}, {content: `$${bank.totalCostOfLoan.toFixed(2)}`, styles: {fontStyle: 'bold', textColor: bank.totalCostOfLoan <= online.totalCostOfLoan ? [40,167,69] : [0,0,0]}}, {content: `$${online.totalCostOfLoan.toFixed(2)}`, styles: {fontStyle: 'bold', textColor: online.totalCostOfLoan < bank.totalCostOfLoan ? [40,167,69] : [0,0,0]}}], ['Total Repayment', `$${bank.totalRepayment.toFixed(2)}`, `$${online.totalRepayment.toFixed(2)}`], ]; doc.autoTable({ head: head, body: body, startY: yPos, headStyles: { fillColor: [0, 123, 255], textColor: [255,255,255], fontSize: 10 }, styles: { fontSize: 9, cellPadding: 5 }, columnStyles: { 0: { halign: 'left', fontStyle: 'bold' }, 1: { halign: 'right' }, 2: { halign: 'right' } }, alternateRowStyles: { fillColor: [233, 236, 239] }, didDrawPage: function (data) { doc.setFontSize(9); doc.text('Page ' + doc.internal.getNumberOfPages(), data.settings.margin.left, doc.internal.pageSize.height - 10); } }); const toolName = "BankVsOnlineLoanComparison"; const date = new Date(); const filename = `${toolName}_${date.getFullYear()}${String(date.getMonth() + 1).padStart(2, '0')}${String(date.getDate()).padStart(2, '0')}.pdf`; doc.save(filename); console.log("BVOL Tool: PDF generated: " + filename); }; } // Initial setup bvol_openTab(null, 'bvolTab1Common'); console.log("BVOL Tool: Initialized. Tab 1 (Common Details) displayed."); // Final critical elements check const allElements = { desiredLoanAmountEl, bankInterestRateEl, bankLoanTermYearsEl, bankFeesEl, onlineInterestRateEl, onlineLoanTermYearsEl, onlineFeesEl, calculateButton, ...tabLinks, ...tabContents, ...errorDivs, commonLoanAmountDisplayEl, resultsCommonInfoDiv, resultsSummaryDiv, comparisonTable, comparisonBody, downloadPdfButton }; let allCriticalFound = true; for (const key in allElements) { if (!allElements[key]) { console.error(`BVOL Tool: CRITICAL - Element for '${key}' was NOT FOUND in the DOM.`); allCriticalFound = false; } } if (!allCriticalFound) { const toolContainer = document.getElementById("bvolLoanComparisonTool"); if (toolContainer) toolContainer.innerHTML = "

Tool initialization failed: Critical HTML element missing. Check console.

"; return; } console.log("BVOL Tool: All critical DOM elements located."); });
Scroll to Top