Files
accounted/app/api
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-04-11 17:06:32 +02:00
2026-04-11 17:06:32 +02:00
2026-05-06 11:12:02 +02:00
2026-05-06 11:12:02 +02:00
2026-05-06 11:12:02 +02:00
2026-05-06 11:12:02 +02:00
2026-05-20 10:08:32 +02:00
2026-05-19 13:48:32 +02:00
2026-04-11 17:06:32 +02:00
2026-03-16 11:31:58 +01:00
2026-05-14 01:10:44 +02:00
2026-05-16 10:23:37 +02:00
2026-05-21 01:25:18 +02:00
2026-05-08 15:42:06 +02:00
2026-04-29 16:32:26 +02:00
2026-05-20 12:11:27 +02:00