Files
accounted/lib
Jakob WennbergandClaude Opus 4.7 2879f6ed17 fix(inbox): sync matched_transaction_id on MCP-staged document attach (#549)
* fix(inbox): sync matched_transaction_id on MCP-staged document attach

The REST attach route (app/api/transactions/[id]/attach-document) already
updates invoice_inbox_items.matched_transaction_id so the inbox list shows
the "Kopplad till transaktion" indicator. The MCP-staged path through
commitAttachDocumentToTransaction did not, leaving inbox rows looking
unprocessed after a /pending approval. Mirror the REST behaviour with a
best-effort UPDATE (idempotent, gated on both FK columns being NULL).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* fix(review): inspect supabase error on best-effort inbox link

The Supabase client resolves with { error } rather than rejecting on
RLS/DB failures, so the previous try/catch wrapping the inbox UPDATE
never fired for the documented failure modes — the console.error was
dead code. Switch to destructured { error } + if-block, matching the
pattern used elsewhere in commit.ts.

Applied to both the new MCP-staged path (lib/pending-operations/commit.ts)
and the pre-existing REST route (app/api/transactions/[id]/attach-document/
route.ts) it was mirrored from. Both tests now assert console.error fires
with the expected payload, so the swallow-and-log path is exercised for
real instead of passing for the wrong reason.

Addresses Greptile P1 + P2 on PR #549.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-21 14:00:49 +02:00
..
2026-05-06 11:12:02 +02:00
2026-05-21 01:25:18 +02:00
2026-05-20 12:11:27 +02:00
2026-03-21 00:47:54 +01:00
2026-02-24 16:06:36 +01:00
2026-05-05 09:53:37 +02:00
2026-05-13 00:26:04 +02:00
2026-05-18 13:17:15 +02:00
2026-05-06 11:12:02 +02:00
2026-04-22 18:14:01 +02:00
2026-05-19 13:48:32 +02:00
2026-05-21 01:25:18 +02:00
2026-05-17 23:52:49 +02:00
2026-04-15 11:17:39 +02:00
2026-05-13 15:17:32 +02:00
2026-05-06 11:12:02 +02:00
2026-05-08 15:42:06 +02:00
2026-04-29 16:32:26 +02:00
2026-05-13 00:26:04 +02:00