Original Loan Term: ${lpfFormatTerm(originalTotalMonths)}
| Payment Strategy |
Effective Payment |
Payoff Time |
Total Interest Paid |
Interest Saved |
Time Saved |
| Standard Monthly |
$${standardPlan.monthlyPayment.toFixed(2)} / month |
${lpfFormatTerm(standardPlan.actualMonthsToPayoff)} |
$${standardPlan.totalInterest.toFixed(2)} |
- |
- |
Biweekly ($${biweeklyPaymentAmount} every 2 weeks) |
Equiv. to $${(standardPlan.monthlyPayment * 13/12).toFixed(2)} / month |
${lpfFormatTerm(biweeklyPlan.actualMonthsToPayoff)} |
$${biweeklyPlan.totalInterest.toFixed(2)} |
$${(standardPlan.totalInterest - biweeklyPlan.totalInterest).toFixed(2)} |
${lpfFormatTerm(standardPlan.actualMonthsToPayoff - biweeklyPlan.actualMonthsToPayoff)} |
| Monthly + Extra $${userExtraMonthlyPayment.toFixed(2)} |
$${extraPmtPlan.effectivePayment.toFixed(2)} / month |
${lpfFormatTerm(extraPmtPlan.actualMonthsToPayoff)} |
$${extraPmtPlan.totalInterest.toFixed(2)} |
$${(standardPlan.totalInterest - extraPmtPlan.totalInterest).toFixed(2)} |
${lpfFormatTerm(standardPlan.actualMonthsToPayoff - extraPmtPlan.actualMonthsToPayoff)} |
`;
resultsOutputEl.innerHTML = outputHTML;
}
function lpfDownloadPDF() {
if (!lpfLastCalculationData) {
alert("Please calculate comparisons first.");
lpfNavigateTab('lpfComparisonTab'); lpfCalculateAllScenarios();
if (!lpfLastCalculationData) return;
}
const { jsPDF } = window.jspdf;
const doc = new jsPDF({orientation: 'landscape'}); // Landscape for wider table
const { inputs, standard, biweekly, extraPayment } = lpfLastCalculationData;
const primaryColor = [0, 121, 107];
let y = 15;
doc.setFontSize(16); doc.setTextColor(primaryColor[0], primaryColor[1], primaryColor[2]);
doc.text("Loan Payment Strategy Comparison", doc.internal.pageSize.getWidth() / 2, y, { align: 'center' });
y += 8;
doc.setFontSize(8); doc.setTextColor(100);
doc.text("Illustrative comparison based on user inputs. Lender policies vary.", doc.internal.pageSize.getWidth() / 2, y, { align: 'center' });
y += 10;
doc.setFontSize(10); doc.setTextColor(51, 51, 51);
doc.text("Loan Inputs:", 14, y); y += 6;
doc.text(` Loan Amount: $${inputs.loanAmount.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2})}`, 14, y);
doc.text(`Annual Interest Rate: ${inputs.annualRate.toFixed(2)}%`, 150, y); y += 6;
doc.text(` Original Term: ${lpfFormatTerm(inputs.originalTotalMonths)}`, 14, y);
doc.text(`Extra Monthly Payment Input: $${inputs.userExtraMonthlyPayment.toFixed(2)}`, 150, y); y += 10;
const head = [['Payment Strategy', 'Effective Pmt', 'Payoff Time', 'Total Interest', 'Interest Saved', 'Time Saved']];
const body = [
['Standard Monthly', `$${standard.monthlyPayment.toFixed(2)}`, lpfFormatTerm(standard.actualMonthsToPayoff), `$${standard.totalInterest.toFixed(2)}`, '-', '-'],
[`Biweekly ($${(standard.monthlyPayment/2).toFixed(2)}/2wks)`, `~ $${(standard.monthlyPayment*13/12).toFixed(2)}/mo`, lpfFormatTerm(biweekly.actualMonthsToPayoff), `$${biweekly.totalInterest.toFixed(2)}`, `$${(standard.totalInterest - biweekly.totalInterest).toFixed(2)}`, lpfFormatTerm(standard.actualMonthsToPayoff - biweekly.actualMonthsToPayoff)],
[`Monthly + Extra $${inputs.userExtraMonthlyPayment.toFixed(2)}`, `$${extraPayment.effectivePayment.toFixed(2)}`, lpfFormatTerm(extraPayment.actualMonthsToPayoff), `$${extraPayment.totalInterest.toFixed(2)}`, `$${(standard.totalInterest - extraPayment.totalInterest).toFixed(2)}`, lpfFormatTerm(standard.actualMonthsToPayoff - extraPayment.actualMonthsToPayoff)]
];
doc.autoTable({ startY: y, head: head, body: body, theme: 'grid',
headStyles: { fillColor: primaryColor, textColor: [255,255,255], halign: 'center', fontSize:8 },
bodyStyles: {fontSize: 8},
columnStyles: {
0: { halign: 'left', cellWidth: 55 },
1: { halign: 'center', cellWidth: 40 },
2: { halign: 'center', cellWidth: 45 },
3: { halign: 'right', cellWidth: 40 },
4: { halign: 'right', cellWidth: 40 },
5: { halign: 'center', cellWidth: 45 }
}
});
y = doc.lastAutoTable.finalY + 10;
if (y > 160) { doc.addPage(); y = 20; }
doc.setFontSize(9); doc.setTextColor(85, 85, 85);
const advisoryTitle = "Understanding Your Payment Strategy Comparison:";
const advisoryContent = [
"Estimates Only: Calculations are based on your inputs. Actual outcomes depend on lender policies.",
"Biweekly Payments: Assumes 13 full monthly payments per year (half payment every two weeks), with extra applied to principal.",
"Extra Payments: Ensure extra payments are applied directly to principal. Confirm with lender.",
"Lender Policies are Key: Verify if lender accepts accelerated payments, how they're applied, and if any fees exist."
];
doc.setFont(undefined, 'bold'); doc.text(advisoryTitle, 14, y); y +=5;
doc.setFont(undefined, 'normal');
advisoryContent.forEach(line => {
const splitLine = doc.splitTextToSize(`• ${line}`, doc.internal.pageSize.getWidth() - 28 - 5); // 14 margin, 5 for bullet
doc.text(splitLine, 14, y);
y += (splitLine.length * 3.5) + 1; // Adjust line height for 9pt font in PDF
if (y > 180 && advisoryContent.indexOf(line) < advisoryContent.length -1) { doc.addPage(); y = 20; }
});
y+=3;
doc.setFontSize(8); doc.setFont(undefined, 'italic'); doc.setTextColor(100);
doc.text("This tool is for illustrative purposes. Always confirm details with your lender.", 14, y);
doc.save("Loan_Payment_Strategy_Savings.pdf");
}
lpfSwitchTab(null, 'lpfLoanInputsTab');
window.lpfSwitchTab = lpfSwitchTab;
window.lpfNavigateTab = lpfNavigateTab;
window.lpfCalculateAllScenarios = lpfCalculateAllScenarios;
window.lpfDownloadPDF = lpfDownloadPDF;