XBRL Tool Dashboard

XBRL Tool: Financial Statement Analysis

Current Ratio

0.0

Debt-to-Equity

0.0

Net Profit Margin

0%

Return on Equity (ROE)

0%

Income Statement Summary ($)

Asset Composition

Financial Data Log

No financial data to display.

`; } renderIncomeChart(metrics.incomeData); renderAssetChart(metrics.assetData); }; const renderIncomeChart = (incomeData) => { const ctx = elements.incomeChartCanvas?.getContext('2d'); if (!ctx) return; const labels = Object.keys(incomeData); const data = Object.values(incomeData); if (incomeChart) incomeChart.destroy(); incomeChart = new Chart(ctx, { type: 'bar', data: { labels, datasets: [{ label: 'Amount ($)', data, backgroundColor: ['#3b82f6', '#10b981', '#22c55e'] }] }, options: { responsive: true, maintainAspectRatio: true, plugins: { legend: { display: false } }, scales: { y: { ticks: { callback: value => formatCurrency(value) } } } } }); }; const renderAssetChart = (assetData) => { const ctx = elements.assetChartCanvas?.getContext('2d'); if (!ctx) return; const labels = Object.keys(assetData); const data = Object.values(assetData); if (assetChart) assetChart.destroy(); assetChart = new Chart(ctx, { type: 'pie', data: { labels, datasets: [{ label: 'Asset Composition', data, backgroundColor: ['#6366f1', '#a78bfa'], hoverOffset: 4 }] }, options: { responsive: true, maintainAspectRatio: true, plugins: { legend: { position: 'top' }, tooltip: { callbacks: { label: (c) => `${c.label}: ${formatCurrency(c.raw)}` } } } } }); }; const renderConfigPanel = () => { const container = elements.editableList; if (!container) return; container.innerHTML = ''; financialData.forEach(d => { const card = document.createElement('div'); card.className = 'grid grid-cols-1 md:grid-cols-3 gap-4 items-center bg-white p-3 rounded-lg border'; card.innerHTML = `
`; container.appendChild(card); }); }; const handleAddLog = (e) => { e.preventDefault(); try { const getNumericValue = (id) => parseFloat(document.getElementById(id).value) || 0; const newLog = { id: financialData.length > 0 ? Math.max(...financialData.map(d => d.id)) + 1 : 1, period: document.getElementById('periodName').value, revenue: getNumericValue('revenue'), cogs: getNumericValue('cogs'), netIncome: getNumericValue('netIncome'), currentAssets: getNumericValue('currentAssets'), fixedAssets: getNumericValue('fixedAssets'), currentLiabilities: getNumericValue('currentLiabilities'), longTermDebt: getNumericValue('longTermDebt'), equity: getNumericValue('shareholderEquity'), }; financialData.push(newLog); elements.addForm.reset(); renderAll(); showToast('Financial record added!'); } catch (error) { console.error("Error adding record:", error); showToast("Error: Could not add record."); } }; const handleConfigListClick = (e) => { const target = e.target.closest('button'); if (!target) return; const action = target.dataset.action; const id = parseInt(target.dataset.id, 10); if (action === 'update') { const index = financialData.findIndex(d => d.id === id); if (index === -1) return; const inputs = target.closest('.grid').querySelectorAll('input'); inputs.forEach(input => { const field = input.dataset.field; let value = input.value; if (input.type === 'number') value = parseFloat(value) || 0; financialData[index][field] = value; }); } else if (action === 'delete') { financialData = financialData.filter(d => d.id !== id); } renderAll(); showToast(`Record ${action}d successfully!`); }; const handleGeneratePDF = () => { try { const { jsPDF } = window.jspdf; const doc = new jsPDF(); const metrics = calculateMetrics(); doc.setFontSize(20); doc.text("Financial Statement Analysis Report", 105, 20, null, null, 'center'); doc.setFontSize(10); doc.text(`Generated on: ${new Date().toLocaleDateString()}`, 105, 26, null, null, 'center'); doc.autoTable({ startY: 35, head: [['Metric', 'Value']], body: [ ['Current Ratio', metrics.currentRatio.toFixed(2)], ['Debt-to-Equity', metrics.debtEquity.toFixed(2)], ['Net Profit Margin', `${metrics.profitMargin.toFixed(1)}%`], ['Return on Equity (ROE)', `${metrics.roe.toFixed(1)}%`] ], theme: 'grid' }); let finalY = doc.lastAutoTable.finalY || 60; doc.setFontSize(14); doc.text("Income Statement Summary", 14, finalY + 15); doc.addImage(elements.incomeChartCanvas.toDataURL('image/png', 1.0), 'PNG', 14, finalY + 20, 180, 80); finalY += 95; doc.setFontSize(14); doc.text("Financial Data Log", 14, finalY); const sortedData = [...financialData].sort((a, b) => b.id - a.id); const tableBody = sortedData.map(d => [d.period, formatCurrency(d.revenue), formatCurrency(d.netIncome)]); doc.autoTable({ head: [['Period', 'Revenue', 'Net Income']], body: tableBody, startY: finalY + 5, theme: 'striped', headStyles: { fillColor: [29, 78, 216] } }); doc.save('XBRL-Financial-Report.pdf'); } catch (error) { console.error("Failed to generate PDF:", error); showToast("Error: Could not generate PDF."); } }; const switchTab = (tabName) => { currentTab = tabName; Object.values(elements.tabs).forEach(tab => tab.classList.add('hidden')); Object.values(elements.tabButtons).forEach(btn => btn.classList.remove('active')); elements.tabs[tabName].classList.remove('hidden'); elements.tabButtons[tabName].classList.add('active'); updateNavButtons(); }; const navigateTabs = (direction) => { const currentIndex = tabOrder.indexOf(currentTab); const newIndex = direction === 'next' ? Math.min(currentIndex + 1, tabOrder.length - 1) : Math.max(currentIndex - 1, 0); if (newIndex !== currentIndex) switchTab(tabOrder[newIndex]); }; const updateNavButtons = () => { const currentIndex = tabOrder.indexOf(currentTab); elements.navButtons.prev.disabled = currentIndex === 0; elements.navButtons.next.disabled = currentIndex === tabOrder.length - 1; }; const showToast = (message) => { if (!elements.toast) return; elements.toast.textContent = message; elements.toast.classList.add('show'); setTimeout(() => { elements.toast.classList.remove('show'); }, 3000); } elements.addForm.addEventListener('submit', handleAddLog); elements.editableList.addEventListener('click', handleConfigListClick); elements.pdfButton.addEventListener('click', handleGeneratePDF); elements.tabButtons.dashboard.addEventListener('click', () => switchTab('dashboard')); elements.tabButtons.config.addEventListener('click', () => switchTab('config')); elements.navButtons.prev.addEventListener('click', () => navigateTabs('prev')); elements.navButtons.next.addEventListener('click', () => navigateTabs('next')); renderAll(); updateNavButtons(); });
Scroll to Top