Files
KomediruzeckiandGitHub a43b742bf9 chore: remove pre-Vite/pre-rebrand leftovers; single source for export pages (#343)
Delete dead artifacts nothing references:
- public/ (root): old Finance Manager manifest, placeholder icons, and
  stale hashed bundles from the pre-Vite build; nothing serves this dir
  (backend serves frontend/dist, prod deploys frontend/dist)
- index.html (root): pre-migration app shell pointing at a hardcoded
  old dist hash and the old manifest
- frontend/css/ + frontend/.build-manifest.json: pre-Vite build system
- frontend/manifest.json: stray unreferenced manifest duplicate
- frontend/manifest.webmanifest, registerSW.js, workbox-cc85cf5a.js(+map):
  VitePWA build outputs committed by accident (regenerated into dist/)
- frontend/icon-*.png/svg, favicon.ico: old placeholder icons at package
  root, byte-identical to the deleted public/ ones; live icons are in
  frontend/public/
- frontend/.eslintrc.cjs + .eslintrc.json: ignored since flat config
  (eslint.config.js); lint verified clean after removal
- frontend/babel.config.js: no babel/jest deps remain
- frontend/fix-selectors.sh, test-output.*, tsc_errors.txt: one-off
  migration script and debug artifacts (now gitignored)

Export pages had forked into two drifting copies: frontend/export*.html
(shipped to dist by the copy plugin and served by the self-host backend;
had the escapeHtml XSS hardening but still said Finance Manager) and
frontend/public/export*.html (rebranded in #304 but missing the XSS
fix, only ever served by vite dev, which nothing uses these pages from).
Keep the hardened root copies as the single source, apply the one-line
rebrand there, and delete the stale public/ copies.

Verified: typecheck, eslint, and a production build — dist contains the
rebranded+hardened export pages, generated manifest.webmanifest, and the
fixed icon-192.png.
2026-07-17 00:55:16 +02:00

561 lines
16 KiB
HTML

<!doctype html>
<html lang="en" data-theme="light">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Monthly Financial Report</title>
<script src="/chart.umd.min.js"></script>
<style>
:root {
--bg: #f8fafc;
--card-bg: #ffffff;
--text: #1e293b;
--text-secondary: #64748b;
--text-muted: #475569;
--border: #e2e8f0;
--border-light: #f1f5f9;
--summary-bg: #f1f5f9;
--summary-border: #cbd5e1;
--table-header-bg: #f1f5f9;
--table-stripe: #f8fafc;
--chart-grid: rgba(0, 0, 0, 0.06);
--chart-tick: #64748b;
}
[data-theme='dark'] {
--bg: #0f172a;
--card-bg: #1e293b;
--text: #e2e8f0;
--text-secondary: #94a3b8;
--text-muted: #94a3b8;
--border: #334155;
--border-light: #1e293b;
--summary-bg: #1e293b;
--summary-border: #334155;
--table-header-bg: #334155;
--table-stripe: #1a2332;
--chart-grid: rgba(255, 255, 255, 0.08);
--chart-tick: #94a3b8;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family:
-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
background: var(--bg);
color: var(--text);
padding: 30px;
width: 700px;
margin: 0 auto;
}
.header {
text-align: center;
margin-bottom: 20px;
padding-bottom: 14px;
border-bottom: 2px solid var(--border);
}
.header h1 {
font-size: 22px;
font-weight: 700;
color: var(--text);
margin-bottom: 4px;
}
.header .subtitle {
font-size: 12px;
color: var(--text-secondary);
}
.summary-box {
background: var(--summary-bg);
border: 1px solid var(--summary-border);
border-radius: 8px;
padding: 14px 20px;
margin-bottom: 18px;
}
.summary-box h3 {
font-size: 13px;
font-weight: 700;
margin-bottom: 10px;
text-align: center;
color: var(--text);
}
.summary-stats {
display: flex;
justify-content: space-around;
text-align: center;
}
.stat-label {
font-size: 10px;
color: var(--text-secondary);
font-weight: 600;
text-transform: uppercase;
letter-spacing: 0.05em;
margin-bottom: 4px;
}
.stat-value {
font-size: 16px;
font-weight: 700;
}
.stat-income .stat-value {
color: #059669;
}
.stat-expense .stat-value {
color: #dc2626;
}
.stat-net .stat-value {
color: #059669;
}
.stat-net.negative .stat-value {
color: #dc2626;
}
[data-theme='dark'] .stat-income .stat-value {
color: #10b981;
}
[data-theme='dark'] .stat-expense .stat-value {
color: #f87171;
}
[data-theme='dark'] .stat-net .stat-value {
color: #10b981;
}
[data-theme='dark'] .stat-net.negative .stat-value {
color: #f87171;
}
.charts-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 16px;
margin-bottom: 16px;
}
.chart-card {
background: var(--card-bg);
border: 1px solid var(--border);
border-radius: 8px;
padding: 14px;
}
.chart-card h3 {
font-size: 12px;
font-weight: 700;
color: var(--text);
margin-bottom: 10px;
padding-bottom: 6px;
border-bottom: 1px solid var(--border);
}
.chart-card canvas {
max-width: 100%;
}
.breakdown-table {
background: var(--card-bg);
border: 1px solid var(--border);
border-radius: 8px;
overflow: hidden;
}
.breakdown-table h3 {
font-size: 13px;
font-weight: 700;
color: var(--text);
padding: 12px 16px;
border-bottom: 1px solid var(--border);
}
table {
width: 100%;
border-collapse: collapse;
font-size: 11px;
}
thead th {
background: var(--table-header-bg);
font-weight: 700;
font-size: 10px;
text-transform: uppercase;
letter-spacing: 0.04em;
color: var(--text-muted);
padding: 7px 10px;
text-align: right;
border-bottom: 1px solid var(--border);
}
thead th:first-child {
text-align: left;
}
tbody tr:nth-child(even) {
background: var(--table-stripe);
}
tbody td {
padding: 6px 10px;
text-align: right;
border-bottom: 1px solid var(--border-light);
}
tbody td:first-child {
text-align: left;
font-weight: 500;
}
tbody tr:last-child td {
border-bottom: none;
}
.val-income {
color: #059669;
font-weight: 600;
}
.val-expense {
color: #dc2626;
font-weight: 600;
}
.val-positive {
color: #059669;
font-weight: 600;
}
.val-negative {
color: #dc2626;
font-weight: 600;
}
[data-theme='dark'] .val-income {
color: #10b981;
}
[data-theme='dark'] .val-expense {
color: #f87171;
}
[data-theme='dark'] .val-positive {
color: #10b981;
}
[data-theme='dark'] .val-negative {
color: #f87171;
}
@media print {
body {
background: white;
padding: 15px;
}
.header h1,
.header .subtitle,
.summary-box h3,
.stat-label,
.chart-card h3,
.breakdown-table h3 {
color: #1e293b !important;
}
.stat-income .stat-value {
color: #059669 !important;
}
.stat-expense .stat-value {
color: #dc2626 !important;
}
.stat-net .stat-value {
color: #059669 !important;
}
.stat-net.negative .stat-value {
color: #dc2626 !important;
}
.val-income {
color: #059669 !important;
}
.val-expense {
color: #dc2626 !important;
}
.val-positive {
color: #059669 !important;
}
.val-negative {
color: #dc2626 !important;
}
.chart-card {
break-inside: avoid;
}
table {
break-inside: avoid;
}
}
</style>
</head>
<body>
<div class="header">
<h1>Monthly Financial Report — <span id="report-month"></span></h1>
<div class="subtitle">Token Circles &nbsp;|&nbsp; <span id="gen-date"></span></div>
</div>
<div class="summary-box">
<h3>Monthly Summary</h3>
<div class="summary-stats">
<div class="stat-income">
<div class="stat-label">Total Income</div>
<div class="stat-value" id="total-income">—</div>
</div>
<div class="stat-expense">
<div class="stat-label">Total Expenses</div>
<div class="stat-value" id="total-expense">—</div>
</div>
<div class="stat-net" id="net-wrap">
<div class="stat-label">Net Savings</div>
<div class="stat-value" id="net-savings">—</div>
</div>
</div>
</div>
<div class="charts-grid">
<div class="chart-card">
<h3>Income by Category</h3>
<canvas id="chart-income" width="300" height="180"></canvas>
</div>
<div class="chart-card">
<h3>Expenses by Category</h3>
<canvas id="chart-expense" width="300" height="180"></canvas>
</div>
</div>
<div class="breakdown-table">
<h3>Category Breakdown</h3>
<table>
<thead>
<tr>
<th>Category</th>
<th style="text-align: right">Income</th>
<th style="text-align: right">Expenses</th>
<th style="text-align: right">Net</th>
</tr>
</thead>
<tbody id="breakdown-tbody"></tbody>
</table>
</div>
<script>
;(function () {
const symbols = { EUR: '€', USD: '$', GBP: '£', CHF: 'CHF ' }
const currency = window.__DATA__ ? window.__DATA__.currency : 'USD'
const sym = symbols[currency] || currency + ' '
function fmt(amt) {
return sym + amt.toFixed(2).replace(/\B(?=(\d{3})+(?!\d))/g, ',')
}
// HTML Escaper for XSS protection
function escapeHtml(str) {
if (!str) return ''
return String(str).replace(/[&<>"']/g, function (m) {
return { '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[m]
})
}
const data = window.__DATA__
if (!data) {
document.body.innerHTML =
'<p style="padding:40px;text-align:center;color:#dc2626;">Error: No data provided.</p>'
window.__RENDER_DONE__ = true
return
}
// Apply theme
const isDark = data.theme === 'dark'
document.documentElement.setAttribute('data-theme', isDark ? 'dark' : 'light')
const monthNames = [
'January',
'February',
'March',
'April',
'May',
'June',
'July',
'August',
'September',
'October',
'November',
'December',
]
const [year, month] = (data.yearMonth || '').split('-')
const monthName = monthNames[parseInt(month) - 1] || data.yearMonth
document.getElementById('report-month').textContent = `${monthName} ${year}`
document.getElementById('gen-date').textContent = new Date().toLocaleDateString('en-US', {
year: 'numeric',
month: 'long',
day: 'numeric',
})
const totalIncome = data.summary.totalIncome
const totalExpense = data.summary.totalExpense
const netSavings = data.summary.netSavings
document.getElementById('total-income').textContent = fmt(totalIncome)
document.getElementById('total-expense').textContent = fmt(totalExpense)
document.getElementById('net-savings').textContent = fmt(netSavings)
const netWrap = document.getElementById('net-wrap')
if (netSavings < 0) netWrap.classList.add('negative')
// Chart.js dark-mode aware defaults
const gridColor = isDark ? 'rgba(255,255,255,0.08)' : 'rgba(0,0,0,0.06)'
const tickColor = isDark ? '#94a3b8' : '#64748b'
const legendColor = isDark ? '#94a3b8' : '#475569'
const doughnutBorder = isDark ? '#1e293b' : '#ffffff'
// --- Income Doughnut Chart ---
const incomeCtx = document.getElementById('chart-income').getContext('2d')
const incomeData = data.incomeByCategory || []
const incomeFiltered = incomeData.filter((c) => c.total > 0)
if (incomeFiltered.length > 0) {
new Chart(incomeCtx, {
type: 'doughnut',
data: {
labels: incomeFiltered.map((c) => escapeHtml(c.name)),
datasets: [
{
data: incomeFiltered.map((c) => c.total),
backgroundColor: incomeFiltered.map((c) => c.color || '#059669'),
borderWidth: 2,
borderColor: doughnutBorder,
},
],
},
options: {
responsive: true,
plugins: {
legend: {
position: 'right',
labels: { font: { size: 10 }, boxWidth: 10, padding: 6, color: legendColor },
},
tooltip: {
callbacks: {
label: function (ctx) {
const val = ctx.raw
const sum = ctx.dataset.data.reduce((a, b) => a + b, 0)
const pct = sum > 0 ? ((val / sum) * 100).toFixed(1) : 0
return ' ' + ctx.label + ': ' + fmt(val) + ' (' + pct + '%)'
},
},
},
},
animation: { duration: 0 },
},
})
}
// --- Expense Doughnut Chart ---
const expenseCtx = document.getElementById('chart-expense').getContext('2d')
const expenseData = data.expenseByCategory || []
const expenseFiltered = expenseData.filter((c) => c.total > 0)
if (expenseFiltered.length > 0) {
new Chart(expenseCtx, {
type: 'doughnut',
data: {
labels: expenseFiltered.map((c) => escapeHtml(c.name)),
datasets: [
{
data: expenseFiltered.map((c) => c.total),
backgroundColor: expenseFiltered.map((c) => c.color || '#dc2626'),
borderWidth: 2,
borderColor: doughnutBorder,
},
],
},
options: {
responsive: true,
plugins: {
legend: {
position: 'right',
labels: { font: { size: 10 }, boxWidth: 10, padding: 6, color: legendColor },
},
tooltip: {
callbacks: {
label: function (ctx) {
const val = ctx.raw
const sum = ctx.dataset.data.reduce((a, b) => a + b, 0)
const pct = sum > 0 ? ((val / sum) * 100).toFixed(1) : 0
return ' ' + ctx.label + ': ' + fmt(val) + ' (' + pct + '%)'
},
},
},
},
animation: { duration: 0 },
},
})
}
// --- Category Breakdown Table ---
const tbody = document.getElementById('breakdown-tbody')
const allCategories = {}
incomeData.forEach((c) => {
if (!allCategories[c.name])
allCategories[c.name] = { name: c.name, color: c.color, income: 0, expense: 0 }
})
expenseData.forEach((c) => {
if (!allCategories[c.name])
allCategories[c.name] = { name: c.name, color: c.color, income: 0, expense: 0 }
})
incomeData.forEach((c) => {
if (allCategories[c.name]) allCategories[c.name].income = c.total
})
expenseData.forEach((c) => {
if (allCategories[c.name]) allCategories[c.name].expense = c.total
})
const sortedCats = Object.values(allCategories)
.filter((c) => c.income > 0 || c.expense > 0)
.sort((a, b) => b.income + b.expense - (a.income + a.expense))
sortedCats.forEach((c) => {
const net = c.income - c.expense
const tr = document.createElement('tr')
tr.innerHTML =
'<td><span style="display:inline-block;width:8px;height:8px;border-radius:50%;background:' +
escapeHtml(c.color || '#6b7280') +
';margin-right:6px;"></span>' +
escapeHtml(c.name) +
'</td>' +
'<td class="val-income">' +
fmt(c.income) +
'</td>' +
'<td class="val-expense">' +
fmt(c.expense) +
'</td>' +
'<td class="' +
(net >= 0 ? 'val-positive' : 'val-negative') +
'">' +
fmt(net) +
'</td>'
tbody.appendChild(tr)
})
if (sortedCats.length === 0) {
const tr = document.createElement('tr')
tr.innerHTML =
'<td colspan="4" style="text-align:center;color:#64748b;padding:20px;">No transactions this month</td>'
tbody.appendChild(tr)
}
// Signal that rendering is done
window.__CHART_RENDER_DONE__ = true
setTimeout(() => {
window.__RENDER_DONE__ = true
}, 500)
})()
</script>
</body>
</html>