fix
This commit is contained in:
@@ -280,9 +280,17 @@ function renderRegisterTable(result) {
|
||||
const el = document.getElementById('accounting-register-table');
|
||||
if (!el) return;
|
||||
|
||||
const rows = result.rows || [];
|
||||
let rows = result.rows || [];
|
||||
const meta = result.meta || {};
|
||||
|
||||
// ── Punkt 1: neueste Einträge oben ──
|
||||
rows = rows.slice().sort((a, b) => {
|
||||
const da = a.date || '';
|
||||
const db = b.date || '';
|
||||
if (db !== da) return db.localeCompare(da);
|
||||
return 0;
|
||||
});
|
||||
|
||||
if (!rows.length) {
|
||||
el.innerHTML = `
|
||||
<div class="p-4 bg-gray-50 border border-gray-200 rounded-lg text-gray-600">
|
||||
@@ -291,27 +299,20 @@ function renderRegisterTable(result) {
|
||||
return;
|
||||
}
|
||||
|
||||
const tbody = rows.map(r => `
|
||||
<tr class="border-t hover:bg-gray-50">
|
||||
<td class="px-3 py-2 text-sm whitespace-nowrap">${escapeHtml(r.date || '')}</td>
|
||||
<td class="px-3 py-2 text-sm">${escapeHtml(r.type || '')}</td>
|
||||
<td class="px-3 py-2 text-sm">${escapeHtml(r.docNum || '')}</td>
|
||||
<td class="px-3 py-2 text-sm">${escapeHtml(r.payee || '')}</td>
|
||||
<td class="px-3 py-2 text-sm text-gray-600">${escapeHtml(r.splitAccount || '')}</td>
|
||||
<td class="px-3 py-2 text-sm text-gray-500" title="${escapeHtml(r.memo || '')}">${escapeHtml((r.memo || '').slice(0, 60))}</td>
|
||||
<td class="px-3 py-2 text-sm text-right whitespace-nowrap ${r.amount < 0 ? 'text-red-600' : 'text-gray-900'}">
|
||||
${r.amount != null ? fmtMoney(r.amount) : ''}
|
||||
</td>
|
||||
</tr>
|
||||
`).join('');
|
||||
const tbody = rows.map(r => renderRegisterRow(r)).join('');
|
||||
|
||||
// ── Punkt 5: dynamische Anzahl ──
|
||||
el.innerHTML = `
|
||||
<div class="bg-white rounded-lg shadow-sm border border-gray-200 overflow-hidden">
|
||||
<div class="px-4 py-2 border-b bg-gray-50 text-xs text-gray-500">
|
||||
${escapeHtml(meta.reportName || 'Transaction List')}
|
||||
${meta.startPeriod ? '— ' + escapeHtml(meta.startPeriod) : ''}
|
||||
${meta.endPeriod ? ' to ' + escapeHtml(meta.endPeriod) : ''}
|
||||
· ${rows.length} rows
|
||||
<div class="px-4 py-2 border-b bg-gray-50 flex items-center justify-between">
|
||||
<div class="text-xs text-gray-500">
|
||||
${escapeHtml(meta.reportName || 'Transaction List')}
|
||||
${meta.startPeriod ? '— ' + escapeHtml(meta.startPeriod) : ''}
|
||||
${meta.endPeriod ? ' to ' + escapeHtml(meta.endPeriod) : ''}
|
||||
</div>
|
||||
<div class="text-sm font-semibold text-gray-700">
|
||||
${rows.length} ${rows.length === 1 ? 'transaction' : 'transactions'}
|
||||
</div>
|
||||
</div>
|
||||
<div class="overflow-x-auto">
|
||||
<table class="min-w-full text-sm">
|
||||
@@ -323,6 +324,7 @@ function renderRegisterTable(result) {
|
||||
<th class="px-3 py-2 text-left font-medium text-gray-700">Payee</th>
|
||||
<th class="px-3 py-2 text-left font-medium text-gray-700">Split / Category</th>
|
||||
<th class="px-3 py-2 text-left font-medium text-gray-700">Memo</th>
|
||||
<th class="px-3 py-2 text-center font-medium text-gray-700" title="Reconciled (R) / Cleared (C)">✓</th>
|
||||
<th class="px-3 py-2 text-right font-medium text-gray-700">Amount</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@@ -332,6 +334,47 @@ function renderRegisterTable(result) {
|
||||
</div>`;
|
||||
}
|
||||
|
||||
function renderRegisterRow(r) {
|
||||
const isSplit = r.splitAccount === '-Split-';
|
||||
const splitCellContent = isSplit ? renderSplitCell(r) : escapeHtml(r.splitAccount || '');
|
||||
|
||||
// Punkt 3: Cleared-Status anzeigen mit Farbe
|
||||
let clrBadge = '';
|
||||
if (r.clearedStatus === 'R') {
|
||||
clrBadge = `<span class="inline-block px-1.5 py-0.5 text-xs font-bold text-green-700 bg-green-100 rounded" title="Reconciled">R</span>`;
|
||||
} else if (r.clearedStatus === 'C') {
|
||||
clrBadge = `<span class="inline-block px-1.5 py-0.5 text-xs font-bold text-blue-700 bg-blue-100 rounded" title="Cleared">C</span>`;
|
||||
}
|
||||
|
||||
return `
|
||||
<tr class="border-t hover:bg-gray-50 align-top">
|
||||
<td class="px-3 py-2 text-sm whitespace-nowrap">${escapeHtml(r.date || '')}</td>
|
||||
<td class="px-3 py-2 text-sm">${escapeHtml(r.type || '')}</td>
|
||||
<td class="px-3 py-2 text-sm">${escapeHtml(r.docNum || '')}</td>
|
||||
<td class="px-3 py-2 text-sm">${escapeHtml(r.payee || '')}</td>
|
||||
<td class="px-3 py-2 text-sm text-gray-600">${splitCellContent}</td>
|
||||
<td class="px-3 py-2 text-sm text-gray-500">${escapeHtml(r.memo || '')}</td>
|
||||
<td class="px-3 py-2 text-sm text-center">${clrBadge}</td>
|
||||
<td class="px-3 py-2 text-sm text-right whitespace-nowrap ${r.amount < 0 ? 'text-red-600' : 'text-gray-900'}">
|
||||
${r.amount != null ? fmtMoney(r.amount) : ''}
|
||||
</td>
|
||||
</tr>`;
|
||||
}
|
||||
|
||||
// Punkt 4: Split-Aufschlüsselung
|
||||
function renderSplitCell(r) {
|
||||
if (!r.splits || !r.splits.length) {
|
||||
return `<span class="text-gray-500 italic">-Split-</span>`;
|
||||
}
|
||||
const lines = r.splits.map(s => `
|
||||
<div class="flex justify-between gap-3 text-xs">
|
||||
<span class="text-gray-700">${escapeHtml(s.account || '?')}</span>
|
||||
<span class="text-gray-600 whitespace-nowrap">${s.amount != null ? fmtMoney(s.amount) : ''}</span>
|
||||
</div>
|
||||
`).join('');
|
||||
return `<div class="space-y-0.5">${lines}</div>`;
|
||||
}
|
||||
|
||||
// ────────────────────────────────────────────────────────────────────
|
||||
// Reports — P&L + Balance Sheet
|
||||
// ────────────────────────────────────────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user