diff --git a/backend/e2e/bookkeeping-sponsors-design-production-portal.spec.js b/backend/e2e/bookkeeping-sponsors-design-production-portal.spec.js index 6c08b135..eabdc2ab 100644 --- a/backend/e2e/bookkeeping-sponsors-design-production-portal.spec.js +++ b/backend/e2e/bookkeeping-sponsors-design-production-portal.spec.js @@ -293,7 +293,7 @@ test.describe("Bookkeeping and Sponsors design prototype", () => { // The page is the transaction list for the latest month with activity. await expect(page.locator("[data-period-heading]")).toHaveText("July 2026"); const studioRow = page.locator(".bk-row").filter({ hasText: "Example Studio" }); - await expect(studioRow.locator(".bk-flag")).toHaveAttribute("aria-label", "No receipt"); + await expect(studioRow.locator(".bk-cell-icon--missing")).toHaveAttribute("aria-label", "No invoice attached"); await expect(studioRow.locator(".bk-col-eur")).toHaveText("−€320.00"); await expectPalette(page, false); await expectNoPageOverflow(page, 1440); diff --git a/frontend/src/styles/bookkeeping.css b/frontend/src/styles/bookkeeping.css index 8513c99a..b61c3c01 100644 --- a/frontend/src/styles/bookkeeping.css +++ b/frontend/src/styles/bookkeeping.css @@ -200,8 +200,6 @@ tr.bk-month__totals-row > th { .bk-col-class { padding-left: var(--dk-space-1); padding-right: var(--dk-space-1); overflow: hidden; } .bookkeeping-surface .bk-col-subtype .bk-inline-select { width: 8.5em; } .bookkeeping-surface .bk-col-category .bk-inline-select { width: 10.5em; } -.bookkeeping-surface .bk-col-period .bk-inline-select { width: 6.5em; } -.bk-col-flag { width: 4em; padding-right: var(--dk-space-3); text-align: center; } .bk-flag { display: inline-flex; color: var(--dk-text-faint); } .bk-flag svg { width: 14px; height: 14px; } .bk-no-invoice { color: var(--dk-text-muted); font-size: var(--dk-text-xs); white-space: nowrap; } @@ -374,3 +372,89 @@ tr.bk-month__totals-row > th { .bk-inv-note { min-width: 8em; } .bk-inv-dispose { flex-direction: column; align-items: stretch; } } + +/* ---- Table cells: invoice and account are fixed-width, centred icon columns ---- */ +.bk-col-flag, +.bk-col-account { width: 4.5rem; min-width: 4.5rem; max-width: 4.5rem; padding-left: 0; padding-right: 0; text-align: center; vertical-align: middle; } +.bk-table th.bk-col-flag, +.bk-table th.bk-col-account { text-align: center; } +.bookkeeping-surface .bk-table .bk-cell-icon { + position: relative; + display: inline-flex; + align-items: center; + justify-content: center; + width: 32px; + height: 32px; + padding: 0; + border: 0; + border-radius: var(--dk-radius-sm); + background: transparent; + color: var(--dk-text-muted); + line-height: 1; + text-decoration: none; + vertical-align: middle; +} +.bk-cell-icon svg { width: 16px; height: 16px; flex: none; } +button.bk-cell-icon, +a.bk-cell-icon { cursor: pointer; } +button.bk-cell-icon:hover, +a.bk-cell-icon:hover { background: var(--dk-bg-hover); color: var(--dk-text-primary); } +button.bk-cell-icon:focus-visible, +a.bk-cell-icon:focus-visible { outline: 2px solid var(--dk-focus-ring); outline-offset: 1px; } +.bk-cell-icon--invoice { color: var(--dk-accent-default); } +.bk-cell-icon--missing { color: var(--dk-warning-text); opacity: 0.75; } +.bk-cell-icon--quiet, +.bk-cell-icon--empty { color: var(--dk-text-faint); } +.bk-cell-icon__count { + position: absolute; + top: -2px; + right: -2px; + min-width: 14px; + height: 14px; + padding: 0 var(--dk-space-1); + border-radius: 7px; + background: var(--dk-accent-default); + color: var(--dk-text-on-accent, var(--dk-bg-surface)); + font-size: var(--dk-text-xs); + font-weight: var(--dk-weight-semibold); + line-height: 14px; + text-align: center; +} + +/* ---- Transaction detail dialog ---- */ +.bk-transaction-dialog { width: min(40rem, calc(100vw - 2rem)); max-height: calc(100vh - 2rem); padding: 0; border: 1px solid var(--dk-border-default); border-radius: var(--dk-radius-lg); background: var(--dk-bg-surface); color: var(--dk-text-body); } +.bk-transaction-dialog::backdrop { background: var(--dk-bg-backdrop); } +.bk-transaction-dialog__header { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: var(--dk-space-3); padding: var(--dk-space-3) var(--dk-space-4); border-bottom: 1px solid var(--dk-border-default); background: var(--dk-bg-surface); } +.bk-transaction-dialog__header h2 { margin: 0; overflow: hidden; color: var(--dk-text-heading); font-size: var(--dk-text-base); font-weight: var(--dk-weight-semibold); text-overflow: ellipsis; white-space: nowrap; } +.bk-transaction-dialog__close { flex: none; padding: var(--dk-space-1) var(--dk-space-3); border: 1px solid var(--dk-border-default); border-radius: var(--dk-radius-sm); background: transparent; color: var(--dk-text-body); font: inherit; font-size: var(--dk-text-sm); cursor: pointer; } +.bk-transaction-dialog__close:hover { background: var(--dk-bg-hover); } +.bk-transaction-dialog__content { display: flex; flex-direction: column; gap: var(--dk-space-3); padding: var(--dk-space-4); } +.bk-transaction-dialog__content > section { padding: var(--dk-space-3) var(--dk-space-4); border: 1px solid var(--dk-border-default); border-radius: var(--dk-radius-md); } +.bk-transaction-dialog__content h3 { margin: 0 0 var(--dk-space-2); color: var(--dk-text-muted); font-size: var(--dk-text-xs); font-weight: var(--dk-weight-semibold); letter-spacing: 0.04em; text-transform: uppercase; } +.bk-transaction-invoices__list { display: flex; flex-direction: column; gap: var(--dk-space-2); margin: 0; padding: 0; list-style: none; } +.bk-transaction-invoice { display: flex; align-items: center; justify-content: space-between; gap: var(--dk-space-3); } +.bk-transaction-invoice__name { min-width: 0; overflow: hidden; color: var(--dk-text-heading); font-weight: var(--dk-weight-medium); text-overflow: ellipsis; white-space: nowrap; } +.bk-transaction-invoice__open { flex: none; } +.bk-transaction-invoices--missing { border-style: dashed; background: var(--dk-warning-bg); } +.bk-transaction-invoices__none { margin: 0; color: var(--dk-warning-text); font-weight: var(--dk-weight-semibold); } +.bk-transaction-invoices__hint { margin: var(--dk-space-1) 0 0; color: var(--dk-text-muted); font-size: var(--dk-text-sm); } +.bk-transaction-summary__vendor { margin: 0; color: var(--dk-text-heading); font-size: var(--dk-text-lg); font-weight: var(--dk-weight-semibold); } +.bk-transaction-summary__amount { margin: var(--dk-space-1) 0 0; color: var(--dk-text-heading); font-size: 1.5rem; font-weight: var(--dk-weight-semibold); font-variant-numeric: tabular-nums; } +.bk-transaction-summary__what { margin: var(--dk-space-1) 0 var(--dk-space-3); color: var(--dk-text-muted); } +.bk-transaction-summary__what span { color: var(--dk-text-faint); font-size: var(--dk-text-xs); text-transform: uppercase; letter-spacing: 0.04em; margin-right: var(--dk-space-1); } +.bk-transaction-summary__facts, +.bk-transaction-statement__facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); gap: var(--dk-space-3) var(--dk-space-4); margin: 0; } +.bk-transaction-field { min-width: 0; } +.bk-transaction-field dt, +.bk-transaction-statement__facts dt { color: var(--dk-text-muted); font-size: var(--dk-text-xs); } +.bk-transaction-field dd, +.bk-transaction-statement__facts dd { margin: var(--dk-space-1) 0 0; overflow-wrap: anywhere; color: var(--dk-text-heading); font-variant-numeric: tabular-nums; } +.bk-transaction-statement__record { display: flex; flex-direction: column; gap: var(--dk-space-1); width: 100%; margin-bottom: var(--dk-space-3); padding: var(--dk-space-2) var(--dk-space-3); border: 1px solid var(--dk-border-default); border-radius: var(--dk-radius-sm); background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer; } +.bk-transaction-statement__record:hover { background: var(--dk-bg-hover); } +.bk-transaction-statement__none { margin: 0 0 var(--dk-space-2); color: var(--dk-text-muted); } +.bk-transaction-statement__candidate-label { display: flex; flex-direction: column; gap: var(--dk-space-1); margin-bottom: var(--dk-space-2); color: var(--dk-text-muted); font-size: var(--dk-text-sm); } +.bk-transaction-statement__candidate-label select { padding: var(--dk-space-2); border: 1px solid var(--dk-border-default); border-radius: var(--dk-radius-sm); color: var(--dk-text-body); font: inherit; } +@media (max-width: 640px) { + .bk-transaction-dialog { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; border: 0; border-radius: 0; } + .bk-transaction-dialog__content { padding: var(--dk-space-3); } +} diff --git a/frontend/src/surfaces/finance/bookkeeping-ledger.js b/frontend/src/surfaces/finance/bookkeeping-ledger.js index 2370e874..91b8b0c1 100644 --- a/frontend/src/surfaces/finance/bookkeeping-ledger.js +++ b/frontend/src/surfaces/finance/bookkeeping-ledger.js @@ -1,6 +1,6 @@ // The transaction table: one dense row per transaction, the same columns // as the bookkeeping spreadsheet it replaces (date, counterparty, what, -// original amount, EUR amount, account, type, category, period). Pure +// original amount, EUR amount, account, type, category). Pure // functions from records to markup and from URL state to filters; the // surface (bookkeeping.js) owns fetching, events and saving. import { sponsorRecordPath } from "../../core/sponsor-routes.js"; @@ -12,12 +12,12 @@ import { bookkeepingVendorPresentation } from "./bookkeeping-vendors.js"; export const LEDGER_PARAMS = ["month", "q", "account", "dir", "category", "needs", "tx", "view"]; export const SECONDARY_VIEWS = ["files", "package", "invoices", "tuition", "inventory"]; -// The spreadsheet's classification columns, in its order and wording: -// "Type" is stored as `subtype`, "Category" as `category`, "Period" as `period`. +// The classification columns: "Type" is stored as `subtype`, "Category" as +// `category`. The spreadsheet's Period column is not shown in the table: it +// was copied in with the sheet layout (efdd13e5), nobody asked for it. export const CLASSIFICATION_FIELDS = [ { field: "subtype", label: "Type" }, { field: "category", label: "Category" }, - { field: "period", label: "Period" }, ]; // The account a transaction went through. The sheet's Statement column holds @@ -126,11 +126,32 @@ export function linkedEvidenceDocuments(entry, links, documents) { const ids = new Set((Array.isArray(links) ? links : []) .filter((link) => link.transactionId === entry.id && link.coverageType === "evidence") .map((link) => String(link.documentId || ""))); - return (Array.isArray(documents) ? documents : []).filter((document) => + const linked = (Array.isArray(documents) ? documents : []).filter((document) => ids.has(String(document.id || "")) && document.status === "active" && INVOICE_EVIDENCE_TYPES.has(String(document.documentType || "")), ); + return linked.length ? linked : invoiceSourceDocuments(entry); +} + +export const INVOICE_SOURCE_PREFIX = "invoice:"; + +/** + * Rows the invoice intake booked (sourceType "invoice") hold their PDF as the + * confirmed invoice's source artifact, not as a bookkeeping document link, so + * /links never lists it. The month package already resolves it that way; the + * table does the same and opens it through /invoices/:id/document. + */ +export function invoiceSourceDocuments(entry) { + const invoiceId = String(entry?.invoiceId || "").trim(); + if (!invoiceId || !String(entry?.documentArtifactId || "").trim()) return []; + const number = String(entry.invoiceNumber || "").trim(); + return [{ + id: `${INVOICE_SOURCE_PREFIX}${invoiceId}`, + status: "active", + documentType: "invoice", + originalFilename: number ? `Invoice ${number}` : `Invoice from ${entry.counterparty || "vendor"}`, + }]; } // URL state -> filters. Unknown values fall back to "show everything". @@ -296,8 +317,42 @@ const icon = { bank: '', + missing: '', }; +// Invoice cell: always one control on the same axis. Attached -> one PDF icon +// (with a count when several); missing -> one muted dashed icon. +function invoiceCellMarkup(documents, hasAttachedFlag, e, txId) { + const count = documents.length; + if (count === 1) { + const [document] = documents; + const label = document.originalFilename || "invoice or receipt PDF"; + return html``; + } + if (count > 1) + return html``; + if (hasAttachedFlag) + return html`${icon.receipt}`; + return html`${icon.missing}`; +} + +// Account cell: bank icon (opens the statement when matched), a muted bank +// icon with the account name in the tooltip when there is only a label, and +// a dash when there is nothing. +function accountCellMarkup(account, accountDoc, e) { + const title = accountDoc?.statementPeriod ? `${account} — open ${accountDoc.statementPeriod} statement` : account; + if (accountDoc?.statementDocumentId) + return html``; + if (account) + return html`${icon.bank}`; + return html`—`; +} + export function ledgerRowMarkup(entry, { hasEvidence, hasInvoice = () => false, vocab, selectedId, financeEntry, statementLinks = new Map(), e }) { const direction = entryDirection(entry); const net = netValue(entry, financeEntry); @@ -313,27 +368,8 @@ export function ledgerRowMarkup(entry, { hasEvidence, hasInvoice = () => false, const invoiceEvidence = hasInvoice(entry.id); const invoiceDocuments = Array.isArray(invoiceEvidence) ? invoiceEvidence : []; const hasInvoiceAttached = invoiceDocuments.length > 0 || invoiceEvidence === true; - // One compact icon per invoice PDF; the filename lives in the tooltip - // instead of a wide "View PDF" button on every row. - const invoiceActions = invoiceDocuments.length - ? invoiceDocuments.map((document) => html``).join("") - : hasInvoiceAttached - ? html`${icon.receipt}` - : html`No invoice`; const account = resolveAccountName(entry, statementLinks); const accountDoc = statementLinks instanceof Map ? statementLinks.get(String(entry.id || "")) : null; - const accountStatementTitle = accountDoc?.statementPeriod - ? `${accountDoc.statementPeriod} statement` - : "statement"; - const accountCell = accountDoc?.statementDocumentId - ? html`` - : e(account || "—"); return html` ${dateCell(entry, e)} @@ -351,11 +387,8 @@ export function ledgerRowMarkup(entry, { hasEvidence, hasInvoice = () => false, id: entry.id, field, label: `${label} for ${entry.counterparty || "transaction"}`, value: entry[field], options: vocab[field] || [], e, })}`).join("")} - - ${invoiceActions} - ${hasEvidence(entry.id) ? "" : html`${icon.receipt}`} - - ${accountCell} + ${invoiceCellMarkup(invoiceDocuments, hasInvoiceAttached, e, entry.id)} + ${accountCellMarkup(account, accountDoc, e)} `; } @@ -380,8 +413,9 @@ function bankOnlyRowMarkup(entry, e) { : e(signedAmount(eur, "EUR"))} — ${CLASSIFICATION_FIELDS.map(({ field }) => html`${e(entry[field] || "")}`).join("")} - Bank statement - ${e(accountOf(entry))} + ${icon.bank} + ${accountCellMarkup(accountOf(entry), null, e)} `; } @@ -409,21 +443,7 @@ function allocationChildMarkup(entry, allocation, { getAllocationDocument = () = const document = getAllocationDocument(entry, allocation); const accountName = resolveAccountName(entry, statementLinks); const statementLink = statementLinks instanceof Map ? statementLinks.get(String(entry.id || "")) : null; - const accountStatementTitle = statementLink?.statementPeriod - ? `${statementLink.statementPeriod} statement` - : "statement"; - const accountCell = statementLink?.statementDocumentId - ? html`` - : e(accountName || "—"); - const pdfAction = document - ? html`` - : html`No linked PDF`; + const pdfAction = invoiceCellMarkup(document ? [document] : [], false, e, entry.id); return html` ${dateCell(child, e)} @@ -439,7 +459,7 @@ function allocationChildMarkup(entry, allocation, { getAllocationDocument = () = ${e(vat || "—")} ${CLASSIFICATION_FIELDS.map(({ field }) => html`${e(allocation[field] || "")}`).join("")} ${pdfAction} - ${accountCell} + ${accountCellMarkup(accountName, statementLink, e)} `; } @@ -457,7 +477,7 @@ export function ledgerHeadMarkup() { `; } -const COLUMN_COUNT = 9; +const COLUMN_COUNT = 8; // One totals row at the bottom of a month: money in and money out, no net. // The figures are the Finance overview's own (financeTotals from diff --git a/frontend/src/surfaces/finance/bookkeeping-transaction-dialog.js b/frontend/src/surfaces/finance/bookkeeping-transaction-dialog.js index dcdb342c..8b9879f3 100644 --- a/frontend/src/surfaces/finance/bookkeeping-transaction-dialog.js +++ b/frontend/src/surfaces/finance/bookkeeping-transaction-dialog.js @@ -43,22 +43,20 @@ function invoiceMarkup(document, index, e) { const id = text(document?.id || document?.documentId); const filename = text(document?.filename || document?.originalFilename || document?.fileName || document?.name); const label = filename ? `Open invoice · ${filename}` : "Open invoice"; - const buttonParts = [ - '`, - ]; const control = id - ? buttonParts.join(" ") + ? `${e(filename || `Attached invoice ${index + 1}`)} + ` : `${e(filename || `Attached invoice ${index + 1}`)}`; return `
  • ${control}
  • `; } function invoiceSectionMarkup(documents, e) { if (!documents.length) { - return `
    + return `

    Invoice

    No invoice

    +

    Nothing is attached to this transaction yet. Attach one from the suggestions below.

    `; } return `
    @@ -223,6 +221,7 @@ export function bookkeepingTransactionSummaryMarkup({

    Transaction

    ${e(transaction.counterparty || "Unknown")}

    +

    ${e(signedAmountMarkup(eurValue, "EUR", amount))}

    What for ${e(transaction.description || "Not recorded")}

    ${fieldMarkup("Raw bank name", e(presentation.rawCounterparty || "Unknown"), e)} diff --git a/frontend/src/surfaces/finance/bookkeeping.js b/frontend/src/surfaces/finance/bookkeeping.js index 46a44267..0d8cc5a7 100644 --- a/frontend/src/surfaces/finance/bookkeeping.js +++ b/frontend/src/surfaces/finance/bookkeeping.js @@ -16,6 +16,8 @@ import { filtersFromParams, groupByMonth, inLens, + INVOICE_SOURCE_PREFIX, + invoiceSourceDocuments, linkedEvidenceDocuments, LEDGER_PARAMS, ledgerTableMarkup, @@ -160,7 +162,8 @@ export function createBookkeepingSurface(context) { const hasEvidence = (id) => bankOnlyEntries.some((entry) => entry.id === id) - || links.some((l) => l.transactionId === id && l.coverageType === "evidence"); + || links.some((l) => l.transactionId === id && l.coverageType === "evidence") + || invoiceSourceDocuments(entries.find((candidate) => candidate.id === id)).length > 0; const hasInvoice = (id) => { const entry = entries.find((candidate) => candidate.id === id); const linked = linkedEvidenceDocuments(entry, links, documents); @@ -455,11 +458,15 @@ export function createBookkeepingSurface(context) { async function viewDocument(id) { const tab = globalThis.open?.("", "_blank"); try { - const result = await api(`/documents/${encodeURIComponent(id)}/download?disposition=inline`); + const fromInvoice = String(id).startsWith(INVOICE_SOURCE_PREFIX); + const result = fromInvoice + ? await api(`/invoices/${encodeURIComponent(String(id).slice(INVOICE_SOURCE_PREFIX.length))}/document`) + : await api(`/documents/${encodeURIComponent(id)}/download?disposition=inline`); + const url = fromInvoice ? result.url : result.downloadUrl; if (tab) { tab.opener = null; - tab.location.href = result.downloadUrl; - } else openPrivateDownload(result.downloadUrl); + tab.location.href = url; + } else openPrivateDownload(url); } catch (error) { tab?.close?.(); throw error; @@ -646,6 +653,12 @@ export function createBookkeepingSurface(context) { syncUrl(); return; } + const opener = event.target.closest("button[data-open-tx]"); + if (opener) { + event.preventDefault(); + openTransaction(opener.dataset.openTx); + return; + } if (event.target.closest("select, button, input")) return; const row = event.target.closest("[data-tx]"); if (!row) return; diff --git a/frontend/test/bookkeeping-ledger.test.mjs b/frontend/test/bookkeeping-ledger.test.mjs index c129e676..ac06c13e 100644 --- a/frontend/test/bookkeeping-ledger.test.mjs +++ b/frontend/test/bookkeeping-ledger.test.mjs @@ -13,6 +13,8 @@ import { groupByMonth, inLens, linkedEvidenceDocuments, + invoiceSourceDocuments, + ledgerHeadMarkup, ledgerRowMarkup, ledgerTableMarkup, needsCategory, @@ -101,7 +103,7 @@ test("the account column sits last and links to the uploaded statement", () => { groups: groupByMonth(rows), hasEvidence: () => false, vocab: {}, selectedId: "", statementLinks: links, e: escapeHtml, }); assert.match(markup, /Invoice<\/th>\s*Account<\/th>/); - assert.match(markup, /]*class="dk-icon-button dk-icon-button--sm bk-account-view"[^>]*data-view-document="doc-1"[\s\S]*?>[\s\S]*?<\/button>/, + assert.match(markup, /]*class="dk-icon-button dk-icon-button--sm bk-cell-icon bk-account-view"[^>]*data-view-document="doc-1"[\s\S]*?>[\s\S]*?<\/button>/, "the linked statement is one compact account icon"); assert.match(markup, /title="Revolut Business — open 2026-09 statement"/, "the tooltip carries the full account name and statement period"); @@ -253,7 +255,7 @@ test("allocated invoices replace the aggregate row while totals and payment dril .map((match) => match[1]); assert.equal(childRows.length, 3); for (const row of childRows) { - assert.equal((row.match(/ row.indexOf("bk-col-flag"), "Account is the last allocation cell"); } assert.match(markup, /aria-label="Open original payment for Synthetic Compute GmbH"/); @@ -324,7 +326,7 @@ test("classified owner, fee, and TK statement rows stay visible without becoming const markup = ledgerTableMarkup({ groups, hasEvidence: () => true, vocab: {}, selectedId: "", e: escapeHtml }); assert.equal((markup.match(/data-bank-only=/g) || []).length, 3); const bankRow = markup.match(/ bankRow.indexOf("bk-col-flag"), "Account is the last bank-only cell"); assert.match(markup, /Synthetic Owner Transfer[\s\S]*Owner withdrawal · confirmed/); assert.match(markup, /Monthly account fee[\s\S]*Bank fee · confirmed/); @@ -397,12 +399,30 @@ test("linked active receipt PDFs render direct View actions for every evidence l selectedId: "", e: escapeHtml, }); - for (const document of documents) { - assert.match(markup, new RegExp(`data-view-document="${document.id}"`)); - assert.match(markup, new RegExp(`aria-label="View ${document.originalFilename}"`)); - } - assert.equal((markup.match(/class="dk-icon-button dk-icon-button--sm bk-evidence-view"/g) || []).length, 3, - "each invoice PDF is one compact icon, not a wide View PDF button"); + assert.equal((markup.match(/bk-evidence-view/g) || []).length, 1, + "several invoices are one icon with a count, so the column never shifts"); + assert.match(markup, /3<\/span>/); + assert.match(markup, /data-open-tx="synthetic-payment"/, "the count icon opens the detail panel that lists every invoice"); +}); + +test("the table has no Period column and the invoice cell has one consistent state", () => { + const entry = { id: "t1", counterparty: "Synthetic Vendor", amount: "10.00", currency: "EUR", entryType: "expense", period: "Monthly" }; + const head = ledgerHeadMarkup(); + assert.doesNotMatch(head, />Period false, hasInvoice: () => [], vocab: {}, selectedId: "", e: escapeHtml }); + assert.match(none, /bk-cell-icon--missing/); + assert.doesNotMatch(none, /No invoice<|bk-no-invoice|bk-col-period/); + assert.match(none, /bk-cell-icon--empty/, "an empty account is a centred dash cell, same cell as icons"); +}); + +test("an invoice-intake row shows its source PDF although no bookkeeping link exists", () => { + const entry = { id: "inv-1", counterparty: "Google Commerce Limited", invoiceId: "inv-1", documentArtifactId: "email-document-x", invoiceNumber: "SOP.1", sourceType: "invoice" }; + assert.deepEqual(invoiceSourceDocuments({ id: "m", counterparty: "Manual" }), []); + const docs = linkedEvidenceDocuments(entry, [], []); + assert.deepEqual(docs.map((d) => d.id), ["invoice:inv-1"]); + const markup = ledgerRowMarkup(entry, { hasEvidence: () => true, hasInvoice: () => docs, vocab: {}, selectedId: "", e: escapeHtml }); + assert.match(markup, /data-view-document="invoice:inv-1"/); + assert.match(markup, /aria-label="View Invoice SOP.1"/); }); test("the month tax section lists debits and refunds with a money-out total", () => {