
Jakob WennbergandClaude Opus 4.6
7c3518a080
feat: payment matching audit trail and partial payments (#89)
* feat: payment matching audit trail, partial payments, and match improvements
- Add payment_match_log table (append-only audit trail per BFL 7:1) with
immutability triggers and proper RLS
- Add invoice_payments table for partial payment tracking, mirroring
supplier_invoice_payments pattern
- Add remaining_amount column + partially_paid status to invoices
- Add match-log.ts service for recording match/unmatch state transitions
- Improve match-invoice route: support partial payments, record audit log,
emit payment.matched events, handle storno conflicts
- Improve match-supplier-invoice route: audit logging, partial payment support
- Update invoice-entries.ts for partial payment journal entries
- Update transaction ingest to detect and auto-suggest invoice matches
- Update bank-reconciliation to handle partial payment state
- Add invoice_payments, payment_match_log types and helpers
- Extend tests for match-invoice route and transaction ingest
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: address review feedback — payment matching correctness bugs
- P1: Return 500 on non-23505 payment insert failures instead of
silently continuing with corrupted invoice state (both routes)
- P1: Fix foreign-currency partial payment matching — use proportional
remaining SEK amount instead of full total_sek
- P2: Check error when clearing journal_entry_id after storno
- P2: Add updated_at column + trigger to invoice_payments table
- P2: Make supplier_invoice_payments.user_id NOT NULL after backfill
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-23 13:00:37 +01:00
..
2026-03-05 23:05:49 +01:00
2026-03-23 09:35:37 +01:00
2026-03-21 14:47:47 +01:00
2026-03-20 09:32:29 +01:00
2026-03-23 13:00:37 +01:00
2026-03-21 00:47:54 +01:00
2026-03-19 15:31:56 +01:00
2026-03-22 21:50:13 +01:00
2026-02-24 16:06:36 +01:00
2026-02-24 10:02:13 +01:00
2026-03-05 23:05:49 +01:00
2026-03-16 14:21:32 +01:00
2026-02-23 19:05:16 +01:00
2026-03-23 13:00:37 +01:00
2026-03-21 12:57:14 +01:00
2026-02-23 19:05:16 +01:00
2026-03-20 12:10:08 +01:00
2026-03-23 13:00:37 +01:00
2026-03-23 13:00:37 +01:00
2026-03-21 17:21:34 +01:00
2026-03-11 14:54:53 +01:00
2026-03-05 23:05:49 +01:00
2026-03-23 13:00:37 +01:00
2026-03-04 14:19:56 +01:00
2026-03-09 15:50:56 +01:00
2026-02-24 10:02:13 +01:00
2026-02-13 14:00:46 +01:00