* fix: prevent credit notes from entering payment flow
* fix: persist and display customer personal numbers
* feat: configure automatic invoice reminder days
* fix: issue credit notes through send flow
* chore: add repository agent guidance
* feat(mcp): route tools across user companies
* fix(articles): delete unused register entries
* feat(invoices): improve issued invoice actions
* feat(supplier-invoices): retain uploaded source documents
* docs: record implementation decisions
* feat: enhance customer personal number handling and validation
- Updated CustomerForm to allow personal numbers in the format of "********-1234" for individual customers.
- Added validation to ensure personal numbers are only accepted for individual customers in CreateCustomerSchema.
- Implemented masking and encryption for personal numbers to enhance data protection.
- Introduced new utility functions for masking and encrypting personal numbers.
- Added database migration to enforce unique constraints on credit note relationships and prevent duplicate entries.
- Enhanced error handling and logging for credit note issuance and invoice processing.
- Updated tests to cover new credit note creation guards and personal number handling.
* test: enhance list companies test with supabase query mocks
* fix(invoices): book remaining_amount + emit invoice.paid on agent mark-paid path (#825)
The agent/MCP commit path commitMarkInvoicePaid flipped status to 'paid' and set
paid_amount = total but never wrote remaining_amount (left at the original total)
and never emitted invoice.paid — so partial state and webhooks diverged from the
dashboard and v1 mark-paid routes.
Route the agent path through the shared planInvoicePayment helper (the source of
truth introduced in #841): compute paid/remaining/status with the overpayment
guard BEFORE booking the JE (so a rejected payment never burns a voucher number),
persist remaining_amount + the partially_paid transition, and best-effort emit
invoice.paid for webhook parity.
Adds lib/pending-operations/__tests__/mark-invoice-paid.test.ts covering the
state + event behaviour of this path.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* fix(invoices): address review feedback on agent mark-paid path (#825)
- CAS-guard 409 message now reflects the expanded payable states: the UPDATE
filter accepts partially_paid (reachable via a concurrent settle race), not
just sent/overdue.
- Derive the settle amount from total − paid_amount when remaining_amount is
null (legacy rows) instead of falling back to the full total, so a prior
partial payment is not double-counted into a false overpayment rejection.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* fix(invoices): derive remaining from total − paid_amount on all mark-paid surfaces (#825)
The dashboard and v1 mark-paid routes defaulted the settle amount to invoice.total
when remaining_amount was null, which over-settles a legacy invoice that has a
prior partial payment recorded in paid_amount (false overpayment / AR over-credit).
Align both with the agent path (commit.ts): remaining_amount ?? total − paid_amount.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>