Financial Report Generator (Quarterly/Annually)

Financial Report Generator

Your generated report will appear here. Go to the 'Data Configuration' tab to enter your financial data.

Revenue

Expenses

${profitLossLabel}

${formatCurrency(netProfit)}

Detailed Breakdown

${renderTable(reportData.revenueItems)}
RevenueAmount
Total Revenue${formatCurrency(totalRevenue)}
${renderTable(reportData.expenseItems)}
ExpensesAmount
Total Expenses${formatCurrency(totalExpenses)}
`; // 3. Update UI ui.reportContent.innerHTML = reportHtml; ui.noReportMsg.style.display = 'none'; ui.dashboardActions.style.display = 'flex'; // 4. Switch to dashboard tab (II.B.4.o) switchTab('dashboard'); } // 7. USA-relevant sample data function loadSampleData() { reportData = { revenueItems: [ { id: 0, name: 'Software Sales (USA)', amount: 120000 }, { id: 1, name: 'Consulting Fees', amount: 45000 }, { id: 2, name: 'Support Subscriptions', amount: 15000 } ], expenseItems: [ { id: 3, name: 'Salaries & Benefits (Austin, TX)', amount: 65000 }, { id: 4, name: 'Rent & Utilities', amount: 12000 }, { id: 5, name: 'Marketing & Advertising', amount: 10000 }, { id: 6, name: 'Software & Subscriptions', amount: 3500 } ] }; nextItemId = 7; ui.companyName.value = "TechSolutions LLC"; ui.reportType.value = "Quarterly"; ui.year.value = "2025"; ui.quarter.value = "Q3"; ui.quarterGroup.style.display = 'block'; renderConfigInputs(); } async function downloadPDF() { ui.pdfDownloadBtn.textContent = "Generating..."; ui.pdfDownloadBtn.disabled = true; try { const { jsPDF } = window.jspdf; container.classList.add("frg-pdf-export-mode"); // V.A: Rigorous testing of PDF feature const canvas = await html2canvas(ui.reportContent, { scale: 2 }); container.classList.remove("frg-pdf-export-mode"); const imgData = canvas.toDataURL("image/png"); const pdf = new jsPDF({ orientation: "p", unit: "mm", format: "a4" }); const pdfWidth = pdf.internal.pageSize.getWidth(); const margin = 10; const contentWidth = pdfWidth - margin * 2; const imgHeight = (canvas.height * contentWidth) / canvas.width; pdf.addImage(imgData, "PNG", margin, margin, contentWidth, imgHeight); pdf.save(`${(ui.companyName.value || "Financial_Report").replace(/ /g, "_")}.pdf`); } catch (error) { console.error("PDF Generation Error:", error); alert("An error occurred while creating the PDF."); } finally { ui.pdfDownloadBtn.textContent = "Download Report (PDF)"; ui.pdfDownloadBtn.disabled = false; } } // --- Initial Setup & Event Listeners --- ui.tabs.forEach(tab => tab.addEventListener('click', (e) => switchTab(e.target.dataset.tab))); ui.reportType.addEventListener('change', () => { ui.quarterGroup.style.display = (ui.reportType.value === 'Quarterly') ? 'block' : 'none'; }); // Event delegation for dynamic inputs container.querySelector('#frg-config').addEventListener('click', handleConfigInteraction); container.querySelector('#frg-config').addEventListener('input', handleConfigInput); ui.generateBtn.addEventListener('click', generateReport); ui.loadSampleBtn.addEventListener('click', loadSampleData); ui.pdfDownloadBtn.addEventListener('click', downloadPDF); // Initial call renderConfigInputs(); });
Scroll to Top