Compares investing the Original Capital Gain of ${ozroi_formatCurrency(i.originalGainToDefer)} in an OZ vs. paying taxes upfront and investing the remainder in a regular taxable account at the same ${i.qofAnnualReturnPercent.toFixed(1)}% annual return for ${i.holdingPeriodYears} years.
| Metric |
Opportunity Zone Investment |
Regular Taxable Investment |
| Initial Amount for Comparison | ${ozroi_formatCurrency(i.originalGainToDefer)} (Deferred) | ${ozroi_formatCurrency(i.originalGainToDefer)} |
| Upfront Tax on Original Gain | Deferred (Paid later: ${ozroi_formatCurrency(r.taxOnOriginalGainAmount)}) | ${ozroi_formatCurrency(i.originalGainToDefer * (i.totalCgTaxRate/100))} |
| Net Amount Effectively Invested (from original gain) | ${ozroi_formatCurrency(i.qofInvestmentAmount)} (into QOF) | ${ozroi_formatCurrency(r.netAfterOriginalGainTaxImmediate)} |
| Future Value of Investment (Pre-Tax on its own growth) | ${ozroi_formatCurrency(r.futureValueOfQOF)} (QOF portion) | ${ozroi_formatCurrency(r.futureValueOfTaxableEquivalent)} |
| Tax on Investment Growth | ${ozroi_formatCurrency(r.taxOnQOFGain)} (Potentially $0 if 10+ yrs) | ${ozroi_formatCurrency(r.taxOnTaxableEquivalentGain)} |
| Net Proceeds After Investment Growth Tax | ${ozroi_formatCurrency(r.netProceedsFromQOF_afterOwnTax)} | ${ozroi_formatCurrency(r.netProceedsTaxableEquivalent)} |
| Less: Tax on Original Deferred Gain (Paid from proceeds) | (${ozroi_formatCurrency(r.taxOnOriginalGainAmount)}) | (Already Paid Upfront) |
| FINAL NET VALUE (After ALL Taxes) | ${ozroi_formatCurrency(r.finalNetValueFromOZInvestment)} | ${ozroi_formatCurrency(r.netProceedsTaxableEquivalent)} |
`;
const pdfBtn = document.getElementById('ozroi_downloadPdfButton');
if(pdfBtn) pdfBtn.style.display = 'block';
}
// --- PDF Generation ---
function ozroi_downloadPDF() {
if (!ozroi_results) { alert("Please calculate results first."); return; }
if (typeof window.jspdf === 'undefined' || typeof window.jspdf.jsPDF === 'undefined') {
alert('Core PDF library (jsPDF) is not loaded.'); console.error('jsPDF library not found.'); return;
}
const { jsPDF: JSPDF } = window.jspdf;
const doc = new JSPDF();
if (typeof doc.autoTable !== 'function') {
alert('PDF Table plugin (jsPDF-AutoTable) is not loaded correctly. PDF generation for tables will fail.');
console.error('doc.autoTable is not a function. jsPDF-AutoTable plugin error.'); return;
}
let y = 15; const m = 15; const cw = doc.internal.pageSize.getWidth() - (2 * m);
const i = ozroi_results.inputs;
const r = ozroi_results.calculations;
function addLine(text, size, style = 'normal', indent = 0, spacing = 2.5) {
if (y > 275) { doc.addPage(); y = m; }
doc.setFontSize(size); doc.setFont(undefined, style);
const lines = doc.splitTextToSize(text, cw - indent); doc.text(lines, m + indent, y);
y += (lines.length * (size * 0.35)) + spacing;
}
addLine(`Opportunity Zone Investment ROI Analysis`, 18, 'bold', 0, 5);
addLine(`Report Date: ${new Date().toLocaleDateString()}`, 9, 'italic', 0, 5);
addLine("Investment & Tax Assumptions:", 12, 'bold', 0, 4);
let inputData = [
["Original Capital Gains to Defer:", ozroi_formatCurrency(i.originalGainToDefer)],
["Amount Invested into QOF:", ozroi_formatCurrency(i.qofInvestmentAmount)],
["QOF Investment Date:", i.investmentDateStr],
["QOF Expected Annual Return:", ozroi_formatPercent(i.qofAnnualReturnPercent)],
["Planned Holding Period:", `${i.holdingPeriodYears} years`],
["Total Capital Gains Tax Rate:", ozroi_formatPercent(i.totalCgTaxRate) + ` (Fed: ${i.fedCgRate}%, NIIT: ${i.niitRate}%, State: ${i.stateCgRate}%)`],
];
doc.autoTable({ startY: y, body: inputData, theme: 'plain', styles: {fontSize: 9, cellPadding: 1}, columnStyles: {0:{fontStyle:'bold'}}});
y = doc.lastAutoTable.finalY + 6;
addLine("Opportunity Zone Investment Summary:", 12, 'bold', 0, 4);
let ozSummaryData = [
["Future Value of QOF (Pre-tax):", ozroi_formatCurrency(r.futureValueOfQOF)],
["Gain on QOF Investment (Pre-tax):", ozroi_formatCurrency(r.gainOnQOFInvestment)],
["Tax on QOF Investment Gain:", ozroi_formatCurrency(r.taxOnQOFGain) + (i.holdingPeriodYears >= 10 ? " (Primarily state, if applicable)" : "")],
["Net Proceeds from QOF (after its own tax):", ozroi_formatCurrency(r.netProceedsFromQOF_afterOwnTax)],
["Tax Due on Original Deferred Gain (in 2027):", ozroi_formatCurrency(r.taxOnOriginalGainAmount)],
["FINAL NET VALUE FROM OZ STRATEGY:", ozroi_formatCurrency(r.finalNetValueFromOZInvestment), {fontStyle:'bold'}],
];
doc.autoTable({ startY: y, body: ozSummaryData, theme: 'plain', styles: {fontSize: 9, cellPadding: 1}, columnStyles: {0:{fontStyle:'bold'}}});
y = doc.lastAutoTable.finalY + 6;
addLine("Comparison vs. Regular Taxable Investment (Based on Original Gain of "+ozroi_formatCurrency(i.originalGainToDefer)+"):", 12, 'bold', 0, 4);
const head = [['Metric', 'Opportunity Zone', 'Regular Taxable']];
const body = [
['Initial Amount', `${ozroi_formatCurrency(i.originalGainToDefer)} (Deferred Tax)`, `${ozroi_formatCurrency(i.originalGainToDefer)}`],
['Upfront Tax on Original Gain', `Deferred (Paid: ${ozroi_formatCurrency(r.taxOnOriginalGainAmount)})`, `${ozroi_formatCurrency(i.originalGainToDefer * i.totalCgTaxRate/100)}`],
['Net Amount Effectively Invested', `${ozroi_formatCurrency(i.qofInvestmentAmount)}`, `${ozroi_formatCurrency(r.netAfterOriginalGainTaxImmediate)}`],
['FV of Investment (Pre-Own Growth Tax)', `${ozroi_formatCurrency(r.futureValueOfQOF)}`, `${ozroi_formatCurrency(r.futureValueOfTaxableEquivalent)}`],
['Tax on Investment Growth', `${ozroi_formatCurrency(r.taxOnQOFGain)}`, `${ozroi_formatCurrency(r.taxOnTaxableEquivalentGain)}`],
['Net Proceeds (After Growth Tax)', `${ozroi_formatCurrency(r.netProceedsFromQOF_afterOwnTax)}`, `${ozroi_formatCurrency(r.netProceedsTaxableEquivalent)}`],
['Less Tax on Original Gain', `(${ozroi_formatCurrency(r.taxOnOriginalGainAmount)})`, `(Paid Upfront)`],
[{content: 'FINAL NET VALUE (ALL TAXES)', styles: {fontStyle: 'bold'}},
{content: ozroi_formatCurrency(r.finalNetValueFromOZInvestment), styles: {fontStyle: 'bold'}},
{content: ozroi_formatCurrency(r.netProceedsTaxableEquivalent), styles: {fontStyle: 'bold'}}]
];
doc.autoTable({
startY: y, head: head, body: body, theme: 'grid',
headStyles: { fillColor: [39, 174, 96], textColor: 255, fontSize: 9 },
styles: { fontSize: 8, cellPadding: 1.5 },
columnStyles: { 0: {fontStyle:'bold', cellWidth: 60}, 1:{halign:'right'}, 2:{halign:'right'} }
});
y = doc.lastAutoTable.finalY + 7;
addLine("Disclaimer: This is a conceptual illustration for informational purposes only and not tax or investment advice. Consult with qualified professionals. OZ rules are complex and subject to change. Basis step-up benefits on original deferred gains are generally not available for new investments due to passed deadlines.", 7, 'italic');
doc.save(`OZ_ROI_Analysis_${i.originalGainToDefer}.pdf`);
}