From e9fc91dbc8314a25a0d71b7ee4344d3fc4ccfd5e Mon Sep 17 00:00:00 2001 From: Anders Betts Date: Fri, 18 Sep 2026 22:16:32 +0200 Subject: attachments: link/unlink from the TUI, multi-voucher links MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The voucher detail can attach a file to an existing voucher (^F) and the underlag picker (f) can remove a link (d, confirmed). The Underlag inbox links a highlighted item to a voucher picked from a list (k). attachment.link and attachment.unlink are new write commands (dry-run, audited); unlinked files return to the inbox. The same content may now link to several vouchers — only the same voucher/attachment pair is a CONFLICT, matching the table's primary key. --- docs/PROTOCOL.md | 8 +++++++- docs/STATE.md | 8 ++++---- docs/TUI-GUIDELINES.md | 4 +++- 3 files changed, 14 insertions(+), 6 deletions(-) (limited to 'docs') diff --git a/docs/PROTOCOL.md b/docs/PROTOCOL.md index e3e629b..75f384f 100644 --- a/docs/PROTOCOL.md +++ b/docs/PROTOCOL.md @@ -351,11 +351,17 @@ required. |---|---|---| | `attachment.put` | `filename`, `mime`, `content_base64`, `voucher_id?` | ≤ max_attachment_bytes | | `attachment.get` | `id` | returns base64 + sha256 | +| `attachment.link` | `id`, `voucher_id` | write; audited | +| `attachment.unlink` | `id`, `voucher_id` | write; audited | | `attachment.list` | `voucher_id?`, `unlinked?`, `limit`, `cursor` | inbox = `unlinked:true` | Attachments are immutable and content-addressed by SHA-256. They are linked to vouchers at posting time (`attachment_ids`) or afterwards via -`attachment.put` with `voucher_id`; links are separate insert-only rows. +`attachment.put` with `voucher_id` or `attachment.link`; links are audited +rows, and `attachment.unlink` removes one (an unlinked attachment returns +to the inbox). One attachment may be linked to several vouchers (the link +key is the voucher/attachment pair); linking the same pair twice is a +`CONFLICT`. ### 7.6 Reports diff --git a/docs/STATE.md b/docs/STATE.md index 0e5d36e..517e62a 100644 --- a/docs/STATE.md +++ b/docs/STATE.md @@ -82,10 +82,10 @@ server/protocol/ledger only. ## Pending decisions -- Link attachments after posting (API already supports - `attachment.put {voucher_id}`): proposed TUI actions — `Ctrl+F` in the - voucher detail to upload+link, and selecting an inbox item and pressing a - key to link it to a voucher picked from a list. Waiting for a go-ahead. +- Attachments are complete: download (voucher detail `f`, Underlag `Enter`, + SHA-256 verified, text inline), attach to an existing voucher (`^F`), + remove a link (`d` in the `f` picker) and link an inbox item to a voucher + (`k`). - Next backend milestone: **bokslut automation** vs **K2/SRU** (eSKD is done: `report.vat_eskd` + `s = spara eSKD` in the momsrapport). - Moms `report_rules` seed is a corrected starter mapping (schema v3), but diff --git a/docs/TUI-GUIDELINES.md b/docs/TUI-GUIDELINES.md index acb3748..a54fef8 100644 --- a/docs/TUI-GUIDELINES.md +++ b/docs/TUI-GUIDELINES.md @@ -29,7 +29,9 @@ there. | `a` | Add/upload (Underlag) | | `c` | Correct (voucher detail) | | `d` | Delete/arkivera the selected row (only where the action exists; asks for confirmation) | -| `Ctrl+F` | Attach a file (voucher form) / pick a file (Underlag) via the file browser | +| `f` | Voucher detail: list the voucher's underlag — Enter fetches, `d` removes the link (asks first). Underlag: Enter fetches | +| `Ctrl+F` | Attach a file via the file browser (voucher form and voucher detail) | +| `k` | Underlag: link the highlighted attachment to a voucher picked from a list | | `Ctrl+X` | Clear the current row — only inside row editors (never "new") | | `Ctrl+Enter` | Save/post the current form. Enabled via xterm `modifyOtherKeys`; terminals that cannot send it keep `F9` working | -- cgit v1.3