529 lines
21 KiB
HTML
529 lines
21 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>GL Analyzer — Undo Designs</title>
|
|
<link href="https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=Inter:wght@300;400;500;600&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet">
|
|
<style>
|
|
:root {
|
|
--navy: #0C1A3A;
|
|
--navy-2: #12244C;
|
|
--navy-3: #1a2f5e;
|
|
--navy-4: #0a1428;
|
|
--cyan: #00D4FF;
|
|
--cyan-dim: rgba(0,212,255,.12);
|
|
--cyan-glow: rgba(0,212,255,.06);
|
|
--blue: #1B8EF8;
|
|
--green: #10D98A;
|
|
--green-dim: rgba(16,217,138,.12);
|
|
--red: #F04438;
|
|
--red-dim: rgba(240,68,56,.12);
|
|
--amber: #F79009;
|
|
--amber-dim: rgba(247,144,9,.12);
|
|
--w1: rgba(255,255,255,.95);
|
|
--w2: rgba(255,255,255,.65);
|
|
--w3: rgba(255,255,255,.35);
|
|
--w4: rgba(255,255,255,.10);
|
|
--w5: rgba(255,255,255,.05);
|
|
--border: rgba(255,255,255,.07);
|
|
--border-c: rgba(0,212,255,.18);
|
|
--mono: 'JetBrains Mono', monospace;
|
|
--disp: 'Space Grotesk', sans-serif;
|
|
--body: 'Inter', sans-serif;
|
|
--radius: 10px;
|
|
}
|
|
|
|
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
|
|
|
|
body {
|
|
font-family: var(--body);
|
|
background: var(--navy-4);
|
|
color: var(--w1);
|
|
min-height: 100vh;
|
|
-webkit-font-smoothing: antialiased;
|
|
display: flex;
|
|
flex-direction: column;
|
|
}
|
|
|
|
body::before {
|
|
content: '';
|
|
position: fixed; inset: 0; pointer-events: none; z-index: 0;
|
|
background-image: radial-gradient(circle, rgba(0,212,255,.07) 1px, transparent 1px);
|
|
background-size: 28px 28px;
|
|
}
|
|
|
|
header {
|
|
position: sticky; top: 0; z-index: 100;
|
|
background: rgba(12,26,58,.85);
|
|
backdrop-filter: blur(12px);
|
|
border-bottom: 1px solid var(--border);
|
|
padding: 0 32px;
|
|
height: 60px;
|
|
display: flex; align-items: center; justify-content: space-between;
|
|
}
|
|
.logo {
|
|
display: flex; align-items: center; gap: 10px;
|
|
font-family: var(--disp); font-size: 15px; font-weight: 600;
|
|
color: var(--w1); text-decoration: none;
|
|
}
|
|
.logo-icon {
|
|
width: 30px; height: 30px;
|
|
background: linear-gradient(135deg, var(--navy-3), var(--navy-2));
|
|
border: 1px solid var(--border-c);
|
|
border-radius: 7px;
|
|
display: flex; align-items: center; justify-content: center;
|
|
}
|
|
.logo-icon svg { width: 16px; height: 16px; }
|
|
.logo span { color: var(--cyan); }
|
|
|
|
main {
|
|
position: relative; z-index: 1;
|
|
flex: 1;
|
|
max-width: 820px;
|
|
width: 100%;
|
|
margin: 0 auto;
|
|
padding: 48px 24px 80px;
|
|
}
|
|
|
|
.page-title { margin-bottom: 24px; }
|
|
.eyebrow {
|
|
font-family: var(--mono); font-size: 10px;
|
|
letter-spacing: .16em; text-transform: uppercase;
|
|
color: var(--cyan); margin-bottom: 10px;
|
|
}
|
|
.page-title h1 {
|
|
font-family: var(--disp); font-size: 26px; font-weight: 700;
|
|
color: var(--w1); line-height: 1.2; margin-bottom: 8px;
|
|
}
|
|
.page-title p { font-size: 14px; color: var(--w2); line-height: 1.6; }
|
|
|
|
.card {
|
|
background: var(--navy-2);
|
|
border: 1px solid var(--border);
|
|
border-radius: var(--radius);
|
|
padding: 24px;
|
|
margin-bottom: 16px;
|
|
transition: opacity .2s;
|
|
}
|
|
.card.disabled { opacity: .4; pointer-events: none; }
|
|
.card-label {
|
|
display: flex; align-items: center; gap: 8px;
|
|
font-family: var(--mono); font-size: 9.5px; letter-spacing: .14em;
|
|
text-transform: uppercase; color: var(--w3); margin-bottom: 14px;
|
|
}
|
|
.card-label .step-num {
|
|
width: 18px; height: 18px; border-radius: 50%;
|
|
background: var(--cyan-dim); color: var(--cyan);
|
|
display: flex; align-items: center; justify-content: center;
|
|
font-size: 10px; font-weight: 600;
|
|
}
|
|
|
|
.file-zone {
|
|
border: 1.5px dashed var(--border);
|
|
border-radius: 8px;
|
|
padding: 22px 16px;
|
|
text-align: center;
|
|
cursor: pointer;
|
|
transition: all .2s;
|
|
position: relative;
|
|
}
|
|
.file-zone:hover, .file-zone.drag-over { border-color: var(--cyan); background: var(--cyan-glow); }
|
|
.file-zone input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
|
|
.file-zone-label { font-size: 13px; color: var(--w2); }
|
|
.file-zone-label strong { color: var(--cyan); }
|
|
.file-zone-sub { font-size: 11px; color: var(--w3); margin-top: 4px; }
|
|
.file-chosen { font-family: var(--mono); font-size: 11.5px; color: var(--green); margin-top: 8px; }
|
|
.field-note { font-size: 11.5px; color: var(--w3); margin-top: 6px; line-height: 1.5; }
|
|
|
|
.btn {
|
|
display: inline-flex; align-items: center; justify-content: center; gap: 8px;
|
|
padding: 11px 22px; border-radius: 8px; border: none;
|
|
font-family: var(--disp); font-size: 13px; font-weight: 600;
|
|
cursor: pointer; transition: all .2s; text-decoration: none;
|
|
width: 100%; margin-top: 18px;
|
|
}
|
|
.btn-primary { background: linear-gradient(135deg, var(--cyan), var(--blue)); color: var(--navy); }
|
|
.btn-primary:hover { filter: brightness(1.08); }
|
|
.btn-primary:disabled { opacity: .4; cursor: not-allowed; filter: none; }
|
|
|
|
.spinner {
|
|
display: none;
|
|
align-items: center; gap: 8px;
|
|
font-family: var(--mono); font-size: 11px; color: var(--w3);
|
|
margin-top: 12px;
|
|
}
|
|
.spinner.visible { display: flex; }
|
|
.spinner-dot {
|
|
width: 6px; height: 6px; border-radius: 50%; background: var(--cyan);
|
|
animation: pulse 1s infinite ease-in-out;
|
|
}
|
|
@keyframes pulse { 0%,100% { opacity: .3; } 50% { opacity: 1; } }
|
|
|
|
.error-note {
|
|
display: none;
|
|
font-size: 12px; color: var(--red); background: var(--red-dim);
|
|
border: 1px solid rgba(240,68,56,.2); border-radius: 8px;
|
|
padding: 12px 14px; margin-top: 12px;
|
|
}
|
|
.error-note.visible { display: block; }
|
|
|
|
.checklist { max-height: 320px; overflow-y: auto; border: 1px solid var(--w5); border-radius: 8px; }
|
|
.check-row {
|
|
display: flex; align-items: center; gap: 10px;
|
|
padding: 9px 12px; border-bottom: 1px solid var(--w5); cursor: pointer;
|
|
}
|
|
.check-row:last-child { border-bottom: none; }
|
|
.check-row:hover { background: var(--cyan-glow); }
|
|
.check-row input { accent-color: var(--cyan); width: 15px; height: 15px; flex-shrink: 0; }
|
|
.check-row .name { font-size: 12.5px; color: var(--w1); flex: 1; }
|
|
.check-row .meta { font-family: var(--mono); font-size: 10.5px; color: var(--w3); }
|
|
.check-row .fill { font-family: var(--mono); font-size: 10.5px; padding: 2px 7px; border-radius: 20px; }
|
|
.fill-high { background: var(--green-dim); color: var(--green); }
|
|
.fill-mid { background: var(--amber-dim); color: var(--amber); }
|
|
.fill-low { background: var(--red-dim); color: var(--red); }
|
|
|
|
.filter-input {
|
|
width: 100%; padding: 9px 12px; margin-bottom: 8px;
|
|
background: var(--navy-4); border: 1px solid var(--w5); border-radius: 8px;
|
|
color: var(--w1); font-size: 12.5px; font-family: var(--body);
|
|
}
|
|
.filter-input:focus { outline: none; border-color: var(--cyan); }
|
|
.filter-input::placeholder { color: var(--w3); }
|
|
|
|
.field-group-label {
|
|
font-size: 11.5px; color: var(--w2); margin: 16px 0 8px; font-weight: 500;
|
|
}
|
|
.field-group-label:first-child { margin-top: 0; }
|
|
|
|
.result-section { margin-bottom: 24px; }
|
|
.result-header {
|
|
display: flex; align-items: center; justify-content: space-between;
|
|
margin-bottom: 10px;
|
|
}
|
|
.result-title { font-family: var(--disp); font-size: 14px; font-weight: 600; color: var(--w1); }
|
|
.result-total { font-family: var(--mono); font-size: 13px; color: var(--cyan); }
|
|
|
|
.result-table-wrap { overflow-x: auto; border: 1px solid var(--w5); border-radius: 8px; }
|
|
table.result-table { width: 100%; border-collapse: collapse; font-size: 11.5px; }
|
|
table.result-table th {
|
|
text-align: left; padding: 8px 10px; background: var(--navy-3);
|
|
font-family: var(--mono); font-size: 9px; letter-spacing: .05em; text-transform: uppercase;
|
|
color: var(--w3); white-space: nowrap; border-bottom: 1px solid var(--w5);
|
|
}
|
|
table.result-table td {
|
|
padding: 7px 10px; border-bottom: 1px solid var(--w5); color: var(--w2);
|
|
white-space: nowrap; max-width: 260px; overflow: hidden; text-overflow: ellipsis;
|
|
}
|
|
table.result-table td.num { text-align: right; font-family: var(--mono); color: var(--w1); }
|
|
table.result-table tr.total-row td { font-weight: 600; color: var(--w1); border-bottom: none; }
|
|
table.result-table tr:last-child td { border-bottom: none; }
|
|
|
|
.download-link {
|
|
display: inline-flex; align-items: center; gap: 6px;
|
|
font-family: var(--mono); font-size: 12px; color: var(--cyan);
|
|
text-decoration: none; margin-top: 16px;
|
|
}
|
|
.download-link:hover { text-decoration: underline; }
|
|
|
|
footer { position: relative; z-index: 1; text-align: center; padding: 20px; font-size: 11px; color: var(--w3); border-top: 1px solid var(--border); }
|
|
footer a { color: var(--cyan); text-decoration: none; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
|
|
<header>
|
|
<a class="logo" href="/">
|
|
<div class="logo-icon">
|
|
<svg viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
<path d="M2 4h12M2 8h8M2 12h5" stroke="#00D4FF" stroke-width="1.5" stroke-linecap="round"/>
|
|
</svg>
|
|
</div>
|
|
GL <span>Analyzer</span>
|
|
</a>
|
|
</header>
|
|
|
|
<main>
|
|
<div class="page-title">
|
|
<div class="eyebrow">Planeterra International Foundation</div>
|
|
<h1>GL Analyzer</h1>
|
|
<p>Upload a GL extract, pick any account(s), then pick which field to group by and which extra fields to show. Nets out reversing/wash entries the same way the Financial Reports tool's Balance Sheet schedules do, then shows exactly what's making up the balance.</p>
|
|
</div>
|
|
|
|
<div class="card" id="step1Card">
|
|
<div class="card-label"><span class="step-num">1</span> Upload GL Extract</div>
|
|
<div class="file-zone" id="fileZone">
|
|
<input type="file" id="fileInput" accept=".xlsx,.xls">
|
|
<div class="file-zone-label"><strong>Drop your GL extract here</strong> or browse</div>
|
|
<div class="file-zone-sub">A GL Dump export (any header row position, scanned automatically)</div>
|
|
</div>
|
|
<div class="file-chosen" id="fileChosen" style="display:none"></div>
|
|
<button class="btn btn-primary" id="uploadBtn" disabled>Upload</button>
|
|
<div class="spinner" id="uploadSpinner"><div class="spinner-dot"></div>Uploading…</div>
|
|
<div class="error-note" id="uploadError"></div>
|
|
</div>
|
|
|
|
<div class="card disabled" id="step2Card">
|
|
<div class="card-label"><span class="step-num">2</span> Select Account(s)</div>
|
|
<input type="text" class="filter-input" id="acctFilter" placeholder="Filter by code or name…">
|
|
<div class="checklist" id="acctList"></div>
|
|
<button class="btn btn-primary" id="headersBtn" disabled>Show Available Fields</button>
|
|
<div class="spinner" id="headersSpinner"><div class="spinner-dot"></div>Checking fields…</div>
|
|
<div class="error-note" id="headersError"></div>
|
|
</div>
|
|
|
|
<div class="card disabled" id="step3Card">
|
|
<div class="card-label"><span class="step-num">3</span> Choose Fields</div>
|
|
<p class="field-note" style="margin-bottom:4px">Percentages show how often each field is actually populated across the GL lines for your selected account(s) — pick a main field with good coverage, or the schedule will mostly show "(blank)".</p>
|
|
|
|
<div class="field-group-label">Main field (what to group the balance by)</div>
|
|
<input type="text" class="filter-input" id="mainFilter" placeholder="Filter fields…">
|
|
<div class="checklist" id="mainHeaderList"></div>
|
|
|
|
<div class="field-group-label">Extra fields to show alongside each row (optional)</div>
|
|
<input type="text" class="filter-input" id="extraFilter" placeholder="Filter fields…">
|
|
<div class="checklist" id="extraHeaderList"></div>
|
|
|
|
<button class="btn btn-primary" id="generateBtn" disabled>Generate</button>
|
|
<div class="spinner" id="generateSpinner"><div class="spinner-dot"></div>Generating…</div>
|
|
<div class="error-note" id="generateError"></div>
|
|
</div>
|
|
|
|
<div class="card" id="resultCard" style="display:none">
|
|
<div class="card-label">Results</div>
|
|
<div id="resultSections"></div>
|
|
<a class="download-link" id="downloadLink" href="#">
|
|
<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5"><path d="M12 3v14m0 0l-5-5m5 5l5-5M4 21h16"/></svg>
|
|
Download Excel workbook
|
|
</a>
|
|
</div>
|
|
</main>
|
|
|
|
<footer>
|
|
Built by <a href="https://undodesigns.com" target="_blank">Undo Designs</a> · GL Analyzer v1
|
|
</footer>
|
|
|
|
<script>
|
|
const $ = id => document.getElementById(id);
|
|
function escapeHtml(s) {
|
|
return String(s).replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>');
|
|
}
|
|
function fmtMoney(n) {
|
|
if (n === null || n === undefined) return '';
|
|
const sign = n < 0 ? '-' : '';
|
|
return sign + '$' + Math.abs(n).toLocaleString('en-US', {minimumFractionDigits: 2});
|
|
}
|
|
function fillClass(pct) {
|
|
if (pct >= 60) return 'fill-high';
|
|
if (pct >= 15) return 'fill-mid';
|
|
return 'fill-low';
|
|
}
|
|
|
|
let chosenFile = null;
|
|
let uploadId = null;
|
|
let allAccounts = [];
|
|
let allHeaders = [];
|
|
let selectedAccountLabels = [];
|
|
|
|
// ── Step 1: upload ──────────────────────────────────────────────────────
|
|
const fileZone = $('fileZone'), fileInput = $('fileInput');
|
|
function handleFile(file) {
|
|
if (!file || !/\.(xlsx|xls)$/i.test(file.name)) return;
|
|
chosenFile = file;
|
|
$('fileChosen').textContent = file.name;
|
|
$('fileChosen').style.display = 'block';
|
|
$('uploadBtn').disabled = false;
|
|
}
|
|
fileInput.addEventListener('change', () => handleFile(fileInput.files[0]));
|
|
fileZone.addEventListener('dragover', e => { e.preventDefault(); fileZone.classList.add('drag-over'); });
|
|
fileZone.addEventListener('dragleave', () => fileZone.classList.remove('drag-over'));
|
|
fileZone.addEventListener('drop', e => {
|
|
e.preventDefault(); fileZone.classList.remove('drag-over');
|
|
handleFile(e.dataTransfer.files[0]);
|
|
});
|
|
|
|
$('uploadBtn').addEventListener('click', async () => {
|
|
if (!chosenFile) return;
|
|
$('uploadBtn').disabled = true;
|
|
$('uploadSpinner').classList.add('visible');
|
|
$('uploadError').classList.remove('visible');
|
|
|
|
const fd = new FormData();
|
|
fd.append('gl_file', chosenFile);
|
|
try {
|
|
const r = await fetch('/gl-analyzer/api/upload', { method: 'POST', body: fd });
|
|
const d = await r.json();
|
|
if (d.status === 'ok') {
|
|
uploadId = d.upload_id;
|
|
allAccounts = d.accounts;
|
|
renderAccountList();
|
|
$('step2Card').classList.remove('disabled');
|
|
$('step3Card').classList.add('disabled');
|
|
$('resultCard').style.display = 'none';
|
|
} else {
|
|
$('uploadError').textContent = d.error || 'Unexpected error';
|
|
$('uploadError').classList.add('visible');
|
|
}
|
|
} catch (e) {
|
|
$('uploadError').textContent = 'Network error: ' + e.message;
|
|
$('uploadError').classList.add('visible');
|
|
}
|
|
$('uploadSpinner').classList.remove('visible');
|
|
$('uploadBtn').disabled = false;
|
|
});
|
|
|
|
// ── Step 2: account selection ───────────────────────────────────────────
|
|
function renderAccountList(filterText) {
|
|
const f = (filterText || '').toLowerCase();
|
|
const rows = allAccounts.filter(a => !f || a.label.toLowerCase().includes(f) || a.code.includes(f));
|
|
$('acctList').innerHTML = rows.map(a => `
|
|
<label class="check-row">
|
|
<input type="checkbox" class="acct-check" value="${escapeHtml(a.label)}">
|
|
<span class="name">${escapeHtml(a.label)}</span>
|
|
<span class="meta">${a.line_count.toLocaleString()} lines</span>
|
|
</label>`).join('') || '<div style="padding:14px;color:var(--w3);font-size:12px">No matching accounts</div>';
|
|
$('acctList').querySelectorAll('.acct-check').forEach(cb => {
|
|
cb.addEventListener('change', updateHeadersBtnState);
|
|
});
|
|
}
|
|
$('acctFilter').addEventListener('input', e => renderAccountList(e.target.value));
|
|
function updateHeadersBtnState() {
|
|
const checked = $('acctList').querySelectorAll('.acct-check:checked');
|
|
$('headersBtn').disabled = checked.length === 0;
|
|
}
|
|
|
|
$('headersBtn').addEventListener('click', async () => {
|
|
const checked = [...$('acctList').querySelectorAll('.acct-check:checked')];
|
|
selectedAccountLabels = checked.map(cb => cb.value);
|
|
const codes = [...new Set(selectedAccountLabels.map(l => l.split(':')[0]))];
|
|
|
|
$('headersBtn').disabled = true;
|
|
$('headersSpinner').classList.add('visible');
|
|
$('headersError').classList.remove('visible');
|
|
|
|
try {
|
|
const r = await fetch('/gl-analyzer/api/headers', {
|
|
method: 'POST', headers: {'Content-Type': 'application/json'},
|
|
body: JSON.stringify({upload_id: uploadId, account_codes: codes}),
|
|
});
|
|
const d = await r.json();
|
|
if (d.status === 'ok') {
|
|
allHeaders = d.columns;
|
|
renderHeaderLists();
|
|
$('step3Card').classList.remove('disabled');
|
|
$('resultCard').style.display = 'none';
|
|
} else {
|
|
$('headersError').textContent = d.error || 'Unexpected error';
|
|
$('headersError').classList.add('visible');
|
|
}
|
|
} catch (e) {
|
|
$('headersError').textContent = 'Network error: ' + e.message;
|
|
$('headersError').classList.add('visible');
|
|
}
|
|
$('headersSpinner').classList.remove('visible');
|
|
$('headersBtn').disabled = false;
|
|
});
|
|
|
|
// ── Step 3: field selection ─────────────────────────────────────────────
|
|
function renderHeaderLists(mainFilterText, extraFilterText) {
|
|
const mf = (mainFilterText || '').toLowerCase();
|
|
const ef = (extraFilterText || '').toLowerCase();
|
|
const currentMain = $('mainHeaderList').querySelector('input:checked')?.value;
|
|
const currentExtras = new Set([...$('extraHeaderList').querySelectorAll('input:checked')].map(i => i.value));
|
|
|
|
const mainRows = allHeaders.filter(h => !mf || h.name.toLowerCase().includes(mf));
|
|
$('mainHeaderList').innerHTML = mainRows.map(h => `
|
|
<label class="check-row">
|
|
<input type="radio" name="mainHeader" value="${escapeHtml(h.name)}" ${h.name === currentMain ? 'checked' : ''}>
|
|
<span class="name">${escapeHtml(h.name)}</span>
|
|
<span class="fill ${fillClass(h.fill_pct)}">${h.fill_pct}%</span>
|
|
</label>`).join('');
|
|
|
|
const extraRows = allHeaders.filter(h => !ef || h.name.toLowerCase().includes(ef));
|
|
$('extraHeaderList').innerHTML = extraRows.map(h => `
|
|
<label class="check-row">
|
|
<input type="checkbox" class="extra-check" value="${escapeHtml(h.name)}" ${currentExtras.has(h.name) ? 'checked' : ''}>
|
|
<span class="name">${escapeHtml(h.name)}</span>
|
|
<span class="fill ${fillClass(h.fill_pct)}">${h.fill_pct}%</span>
|
|
</label>`).join('');
|
|
|
|
$('mainHeaderList').querySelectorAll('input').forEach(i => i.addEventListener('change', updateGenerateBtnState));
|
|
updateGenerateBtnState();
|
|
}
|
|
$('mainFilter').addEventListener('input', e => renderHeaderLists(e.target.value, $('extraFilter').value));
|
|
$('extraFilter').addEventListener('input', e => renderHeaderLists($('mainFilter').value, e.target.value));
|
|
function updateGenerateBtnState() {
|
|
$('generateBtn').disabled = !$('mainHeaderList').querySelector('input:checked');
|
|
}
|
|
|
|
$('generateBtn').addEventListener('click', async () => {
|
|
const mainHeader = $('mainHeaderList').querySelector('input:checked')?.value;
|
|
if (!mainHeader) return;
|
|
const extraHeaders = [...$('extraHeaderList').querySelectorAll('input:checked')].map(i => i.value).filter(h => h !== mainHeader);
|
|
|
|
$('generateBtn').disabled = true;
|
|
$('generateSpinner').classList.add('visible');
|
|
$('generateError').classList.remove('visible');
|
|
|
|
try {
|
|
const r = await fetch('/gl-analyzer/api/generate', {
|
|
method: 'POST', headers: {'Content-Type': 'application/json'},
|
|
body: JSON.stringify({
|
|
upload_id: uploadId, accounts: selectedAccountLabels,
|
|
main_header: mainHeader, extra_headers: extraHeaders,
|
|
}),
|
|
});
|
|
const d = await r.json();
|
|
if (d.status === 'ok') {
|
|
renderResults(d);
|
|
$('resultCard').style.display = 'block';
|
|
$('resultCard').scrollIntoView({behavior: 'smooth', block: 'start'});
|
|
} else {
|
|
$('generateError').textContent = d.error || 'Unexpected error';
|
|
$('generateError').classList.add('visible');
|
|
}
|
|
} catch (e) {
|
|
$('generateError').textContent = 'Network error: ' + e.message;
|
|
$('generateError').classList.add('visible');
|
|
}
|
|
$('generateSpinner').classList.remove('visible');
|
|
$('generateBtn').disabled = false;
|
|
});
|
|
|
|
// ── Results ──────────────────────────────────────────────────────────────
|
|
function renderResults(d) {
|
|
$('resultSections').innerHTML = d.accounts.map(a => {
|
|
const extraCols = d.extra_headers;
|
|
const head = `<tr>
|
|
<th>Description</th>
|
|
${extraCols.map(c => `<th>${escapeHtml(c)}</th>`).join('')}
|
|
<th>Orig Curr</th><th>Curr</th><th>Rate</th><th>Amt (CAD)</th>
|
|
</tr>`;
|
|
const body = a.rows.map(r => `<tr>
|
|
<td>${escapeHtml(r.category)}</td>
|
|
${extraCols.map(c => `<td title="${escapeHtml(r[c] ?? '')}">${escapeHtml(r[c] ?? '')}</td>`).join('')}
|
|
<td class="num">${r.orig_total !== null ? fmtMoney(r.orig_total) : ''}</td>
|
|
<td>${r.orig_currency ?? ''}</td>
|
|
<td class="num">${r.rate !== null ? r.rate.toFixed(4) : ''}</td>
|
|
<td class="num">${fmtMoney(r.amt_cad)}</td>
|
|
</tr>`).join('');
|
|
const totalRow = `<tr class="total-row">
|
|
<td>Total</td>${extraCols.map(() => '<td></td>').join('')}<td></td><td></td><td></td>
|
|
<td class="num">${fmtMoney(a.total)}</td>
|
|
</tr>`;
|
|
return `<div class="result-section">
|
|
<div class="result-header">
|
|
<div class="result-title">${escapeHtml(a.account)}</div>
|
|
<div class="result-total">${fmtMoney(a.total)} · ${a.row_count} row${a.row_count === 1 ? '' : 's'}</div>
|
|
</div>
|
|
<div class="result-table-wrap">
|
|
<table class="result-table">${head}${body || '<tr><td colspan="99" style="color:var(--w3)">No matching GL activity</td></tr>'}${totalRow}</table>
|
|
</div>
|
|
</div>`;
|
|
}).join('');
|
|
$('downloadLink').href = `/gl-analyzer/api/download/${encodeURIComponent(d.download_filename)}`;
|
|
}
|
|
</script>
|
|
</body>
|
|
</html>
|