feat: add foreign currency support, refactor bookkeeping engine, and improve invoice inbox document classification
- Add currency-utils module for SEK conversion with exchange rates - Refactor createJournalEntry to use draft+commit flow preventing voucher number gaps (BFL 5 kap. 7§) - Add foreign currency support to invoice entries with per-line SEK conversion - Centralize category-to-account mapping into single source of truth - Refactor invoice inbox to use shared document analyzer with document type classification (receipt, supplier invoice, government letter) - Update mapping engine, supplier invoice entries, and transaction entries - Fix report component rendering issues - Add new validation schemas and tests Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
547fd053ec
commit
6f4573f380
@@ -23,6 +23,7 @@ import {
|
||||
CreateInvoiceItemSchema,
|
||||
CreateInvoiceSchema,
|
||||
CreateCreditNoteSchema,
|
||||
MarkInvoicePaidSchema,
|
||||
// Customer schemas
|
||||
CreateCustomerSchema,
|
||||
// Supplier schemas
|
||||
@@ -423,6 +424,47 @@ describe('CreateCreditNoteSchema', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe('MarkInvoicePaidSchema', () => {
|
||||
it('accepts empty object (all fields optional)', () => {
|
||||
const result = MarkInvoicePaidSchema.safeParse({})
|
||||
expect(result.success).toBe(true)
|
||||
})
|
||||
|
||||
it('accepts payment_date', () => {
|
||||
const result = MarkInvoicePaidSchema.safeParse({ payment_date: '2024-07-15' })
|
||||
expect(result.success).toBe(true)
|
||||
})
|
||||
|
||||
it('accepts exchange_rate_difference (positive gain)', () => {
|
||||
const result = MarkInvoicePaidSchema.safeParse({ exchange_rate_difference: 200 })
|
||||
expect(result.success).toBe(true)
|
||||
})
|
||||
|
||||
it('accepts exchange_rate_difference (negative loss)', () => {
|
||||
const result = MarkInvoicePaidSchema.safeParse({ exchange_rate_difference: -300 })
|
||||
expect(result.success).toBe(true)
|
||||
})
|
||||
|
||||
it('accepts all fields together', () => {
|
||||
const result = MarkInvoicePaidSchema.safeParse({
|
||||
payment_date: '2024-07-15',
|
||||
exchange_rate_difference: 150.50,
|
||||
notes: 'Paid via Wise',
|
||||
})
|
||||
expect(result.success).toBe(true)
|
||||
})
|
||||
|
||||
it('rejects invalid payment_date format', () => {
|
||||
const result = MarkInvoicePaidSchema.safeParse({ payment_date: '15/07/2024' })
|
||||
expect(result.success).toBe(false)
|
||||
})
|
||||
|
||||
it('rejects non-number exchange_rate_difference', () => {
|
||||
const result = MarkInvoicePaidSchema.safeParse({ exchange_rate_difference: 'big gain' })
|
||||
expect(result.success).toBe(false)
|
||||
})
|
||||
})
|
||||
|
||||
// ============================================================
|
||||
// Customer schemas
|
||||
// ============================================================
|
||||
|
||||
Reference in New Issue
Block a user