Files
accounted/vitest.config.ts
T
Jakob Wennberg b38b3d0230 fix(bookkeeping): settle öre differences to 3740 and improve supplier-invoice matching (#699)
Whole-krona Bankgiro/Swish payments of öre-bearing invoices were stranded
as partially_paid forever (e.g. 11 231 paid on an 11 231,25 invoice left
0,25 kr open). Book the sub-krona residual to BAS 3740 (Öres- och
kronutjämning) and settle the invoice in full, on both the supplier- and
customer-invoice match flows.

New shared pure helpers buildSupplierPaymentClearingLines +
planSupplierPayment mirror the customer-side primitives; routing preview
and commit through the same builder also fixes two pre-existing
preview↔commit drifts (payment account + line descriptions). Öre
absorption is accrual-only — cash entries book the full invoice, so
absorbing there would hide a 1930 discrepancy.

Also improves supplier-invoice ↔ bank matching:
- Pass-3 date window now spans [invoice_date-5, due_date+5] instead of
  due_date ±5, so early payments auto-match; an ambiguity guard demotes
  non-unique amount matches to suggestions.
- New retroactive matcher (on supplier_invoice.registered/.approved)
  surfaces the settling bank payment when the invoice is registered after
  the payment was imported. Matches are written as suggestions for
  one-click confirm-to-book, never silently auto-booked.

Tests: new unit tests for both pure helpers; extended matching, handler,
customer öre, and route suites. Full suite green (407 files / 5364 tests).

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-09 19:09:39 +02:00

49 lines
1.3 KiB
TypeScript

import { defineConfig } from 'vitest/config'
import path from 'path'
const alias = { '@': path.resolve(__dirname, '.') }
const unitProject = {
resolve: { alias },
test: {
name: 'unit',
globals: true,
environment: 'node' as const,
include: ['**/*.test.ts'],
// `.claude/worktrees/*` are ephemeral agent checkouts whose `@/*` imports
// resolve back to this root — never part of the suite.
exclude: ['**/node_modules/**', '**/*.pg.test.ts', '**/.claude/**'],
},
}
const pgRealProject = {
resolve: { alias },
test: {
name: 'pg-real',
globals: true,
environment: 'node' as const,
include: ['**/*.pg.test.ts'],
exclude: ['**/node_modules/**', '**/.claude/**'],
setupFiles: ['tests/pg/setup.ts'],
// One-connection-at-a-time to avoid cross-file DB contention.
fileParallelism: false,
testTimeout: 15000,
},
}
// Only register the pg-real project when DATABASE_URL is set. Local devs
// running a bare `vitest run` would otherwise hit the schema sanity check
// against a non-existent DB. `npm run test:pg` is the opt-in entry point.
const projects = process.env.DATABASE_URL
? [unitProject, pgRealProject]
: [unitProject]
export default defineConfig({
resolve: { alias },
test: {
globals: true,
environment: 'node',
projects,
},
})