Files
accounted/lib/bookkeeping/template-prompt.ts
T
Jakob Wennberg 39e407644d feat: unified document inbox, full BAS 2026, and document-transaction matching
- Expand BAS reference from ~180 to ~1,276 accounts (full BAS Kontoplan 2026)
  with K2 exclusion flags, per-class data files, and computed SRU codes
- Evolve invoice inbox into unified document inbox handling invoices, receipts,
  and government letters with AI-powered classification (Claude Haiku Vision)
- Add multi-pass document-to-transaction matching engine with greedy assignment
  for both supplier invoices (reference/amount/date/name) and receipts
  (weighted amount/merchant/date scoring)
- Add supplier invoice matching in transaction ingest pipeline
- Inject booking template suggestions into AI extraction prompts
- Surface matched documents in swipe categorization UI with one-tap booking
- Auto-activate missing BAS accounts during SIE import against full reference
- Add K2 filter toggle in Chart of Accounts manager
- Add receipt confirmation route with BFNAR representation fields
- Add database migrations for K2 support and document matching columns
- Remove obsolete extension migration scripts

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-25 16:59:02 +01:00

32 lines
995 B
TypeScript

/**
* Template Prompt Builder
*
* Generates the booking template list section for AI extraction prompts.
* Used by both receipt-analyzer and invoice-analyzer to stay in sync.
*/
import { BOOKING_TEMPLATES } from './booking-templates'
/**
* Build the template list section for AI prompts.
* Lists all expense templates with their Swedish name, primary debit account, and VAT rate.
*/
export function buildTemplatePromptSection(): string {
const expenseTemplates = BOOKING_TEMPLATES.filter((t) => t.direction === 'expense')
const lines = expenseTemplates.map((t) => {
const vatInfo = t.vat_rate > 0 ? `moms ${t.vat_rate * 100}%` : 'momsfri'
return `- ${t.id}: ${t.name_sv} (konto ${t.debit_account}, ${vatInfo})`
})
return `BOKFÖRINGSMALLAR (välj den mest passande suggestedTemplateId):
${lines.join('\n')}`
}
/**
* Build a compact template ID list for validation.
*/
export function getValidTemplateIds(): string[] {
return BOOKING_TEMPLATES.map((t) => t.id)
}