`;
PEFS_criteriaRecapOutput.innerHTML = recapHTML;
// Display Fund Results
let resultsHTML = `
Fund Screening Details:
`; if (funds.length === 0) { resultsHTML += "No funds were entered for screening.
"; } funds.forEach(fund => { resultsHTML += ``;
resultsHTML += `
`;
});
PEFS_screeningResultsOutput.innerHTML = resultsHTML;
}
function PEFS_processAndShowResults() {
if (!PEFS_collectCriteria()) return; // Validate criteria first
const fundsData = PEFS_collectFundData();
if (fundsData.length === 0) {
alert("Please add at least one fund in Tab 2 to screen.");
PEFS_screeningResultsOutput.innerHTML = "Fund: ${fund.name}
`; resultsHTML += `Overall Result: ${fund.results.overall ? 'Passes Screen' : `Fails Screen (${fund.results.failedCount} criteria not met)`}
`; resultsHTML += `- `;
resultsHTML += `
- Fund Size: ${fund.actualSize || 'N/A'} $MM (Criteria: ${criteria.minFundSize || 'Any'} - ${criteria.maxFundSize || 'Any'} $MM) `; resultsHTML += `
- Geo Focus: ${fund.geoFocus || 'N/A'} (Criteria: ${criteria.geoFocus.length > 0 ? criteria.geoFocus.join(', ') : 'Any'}) `; resultsHTML += `
- Industry Focus: ${fund.industryFocus || 'N/A'} (Criteria: ${criteria.industryFocus.length > 0 ? criteria.industryFocus.join(', ') : 'Any'}) `; resultsHTML += `
- Inv. Stage: ${fund.investmentStage || 'N/A'} (Criteria: ${criteria.investmentStage.length > 0 ? criteria.investmentStage.join(', ') : 'Any'}) `; resultsHTML += `
- IRR: ${fund.irr || 'N/A'}% (Criteria: Min ${criteria.minIrr || 'Any'}%) `; resultsHTML += `
- Mgmt Fee: ${fund.mgmtFee || 'N/A'}% (Criteria: Max ${criteria.maxMgmtFee || 'Any'}%) `; resultsHTML += `
- Carry: ${fund.carry || 'N/A'}% (Criteria: Max ${criteria.maxCarry || 'Any'}%) `; resultsHTML += `
- GP Commit: ${fund.gpCommit || 'N/A'}% (Criteria: Min ${criteria.minGpCommit || 'Any'}%) `; resultsHTML += `
- Vintage: ${fund.vintageYear || 'N/A'} (Criteria: ${criteria.minVintage || 'Any'} - ${criteria.maxVintage || 'Any'}) `; resultsHTML += `
No funds were entered for screening. Please go to 'Input Fund Data' tab.
"; PEFS_navigateToTab('pefs-tab3'); return; } fundsData.forEach(fund => { fund.results = PEFS_screenFund(fund, PEFS_criteria); }); PEFS_displayResults(fundsData, PEFS_criteria); PEFS_navigateToTab('pefs-tab3'); } async function PEFS_generatePDF() { if (!PEFS_criteriaRecapOutput || !PEFS_screeningResultsOutput || !PEFS_pdfSpecificTitle || (PEFS_screeningResultsOutput.innerHTML.includes("Define criteria and input fund data") && PEFS_criteriaRecapOutput.innerHTML === "")) { alert("Please define criteria and screen funds first before downloading the PDF."); return; } PEFS_pdfSpecificTitle.style.display = 'block'; const originalToolTitle = document.querySelector('.pefs-tool-title'); if (originalToolTitle) originalToolTitle.style.display = 'none'; const pdfContentArea = document.getElementById('pefs-pdfExportContent'); const originalBg = pdfContentArea.style.backgroundColor; pdfContentArea.style.backgroundColor = '#ffffff'; try { const canvas = await html2canvas(pdfContentArea, { scale: 2, useCORS: true, backgroundColor: '#ffffff' }); const imgData = canvas.toDataURL('image/png'); const pdf = new jsPDF({ orientation: 'p', unit: 'mm', format: 'a4' }); const pdfWidth = pdf.internal.pageSize.getWidth(); const pdfHeight = pdf.internal.pageSize.getHeight(); const imgProps = pdf.getImageProperties(imgData); const imgRatio = imgProps.width / imgProps.height; let newImgWidth = pdfWidth - 20; // 10mm margin L/R let newImgHeight = newImgWidth / imgRatio; if (newImgHeight > pdfHeight - 20) { // If too tall, scale by height newImgHeight = pdfHeight - 20; // 10mm margin T/B newImgWidth = newImgHeight * imgRatio; } const x = (pdfWidth - newImgWidth) / 2; const y = 10; pdf.addImage(imgData, 'PNG', x, y, newImgWidth, newImgHeight); pdf.save('PE_Fund_Screening_Report.pdf'); } catch (error) { console.error("Error generating PDF:", error); alert("An error occurred while generating the PDF."); } finally { PEFS_pdfSpecificTitle.style.display = 'none'; if (originalToolTitle) originalToolTitle.style.display = 'block'; pdfContentArea.style.backgroundColor = originalBg; } } document.addEventListener('DOMContentLoaded', function() { PEFS_initDOMElements(); if (!PEFS_tabs || !PEFS_tabContents) { console.error("PEFS: Tool initialization failed."); const container = document.getElementById('pefsToolContainer'); if (container) container.innerHTML = "Error: Tool components failed to load.
"; return; } PEFS_tabs.forEach(tab => { tab.addEventListener('click', function() { if (this.dataset && this.dataset.tab) PEFS_navigateToTab(this.dataset.tab); }); }); PEFS_addFundEntry(); // Add one fund entry form by default PEFS_navigateToTab('pefs-tab1'); });