0076aa85f8
* feat: multi-series SIE import, reusable FiscalYearSelector, library templates in picker - SIE import preserves each voucher's source series (B/C/I/V/...), essential for Fortnox migrations where series carry semantic meaning (kundfakturor, inbetalningar, etc.). Target numbering still goes through next_voucher_number per series; source (series, number) is stored in the migration mapping for BFNAR 2013:2 audit trail. - Execute route reads company_settings.default_voucher_series as the fallback for vouchers arriving without a series (SIE4I). - Extract shared FiscalYearSelector component; adopt in /reports and /bookkeeping. - Transaction TemplatePicker now surfaces user-created library templates (company + team scope) alongside the static registry, with a helper to convert simple library templates into the BookingTemplate shape. - Exclude 8999 "Årets resultat" from income statement financial section and monthly breakdown so year-end closing entries don't cancel the net result. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * test: skip Bokio SIE regression when fixtures are absent /dev_docs is gitignored (contains anonymised customer exports), so the integration test can't find its input files in CI. Gate the suite on fixture presence so it still runs locally. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix: address Greptile review feedback - convertLibraryToBookingTemplate: default entity_applicability to 'all' when the source template has no entity_type, so TemplatePicker doesn't silently hide it for companies with a set entity type. - FiscalYearSelector: fire onReady in the no-company early-return branch so consumers (e.g. ReportsPage) don't get stuck in a loading skeleton while the company context is still hydrating. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * feat: arcim inbox + smart-match extension + commit metadata Three threads, all gated off in extensions.config.json (invoice-inbox and inbox-smart-match are not in the enabled list for this PR). invoice-inbox: Gmail OAuth -> Resend Inbound (v2.0.0) - Remove gmail-scanner / gmail-helpers - Add resend-inbound.ts (webhook verify, attachment fetch) and inbox-provisioning.ts (per-company @arcim.io address with rotation) - Replace /gmail/* routes with /inbox/address and admin-only /inbox/rotate - Workspace UI: card layout + MatchBlock surfacing AI transaction matches - classify-document: tightened discount/total prompt; cap confidence at 50% when line items do not reconcile with amount_incl_vat - Manifest requires RESEND_API_KEY, RESEND_INBOUND_DOMAIN, RESEND_INBOUND_WEBHOOK_SECRET inbox-smart-match (new extension) - Event-driven AI matching of receipts to bank transactions - Listens on inbox_item.classified (match now) and transaction.synced (retro-match receipts waiting for a transaction) - Uses service-role client; processing_history append is scoped by company_id from the event payload commit metadata + audit plumbing - journal_entries gains commit_method and rubric_version columns - commit_journal_entry RPC accepts both (BFNAR 2013:2 behandlingshistorik) - processing-history PII detector strips UUID-shaped substrings before personnummer pattern matching (UUIDs were triggering false positives) - New generic inbox_item.classified event Migrations - arcim_inbox: company_inboxes table, resend_email_id, email_body_text, auto-provision trigger, drops obsolete email_connections - journal_entry_commit_metadata: new columns + updated RPC - inbox_attachment_composite: resend_attachment_id + composite unique index - inbox_smart_match: correlation_id, match_reasoning, expanded match_method CHECK, pending-match and correlation indexes Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
113 lines
3.3 KiB
TypeScript
113 lines
3.3 KiB
TypeScript
import { resolve, join } from 'path'
|
|
import { readdirSync, readFileSync } from 'fs'
|
|
|
|
/**
|
|
* Build EXTENSION_DEFINITIONS from manifest.json files so the test
|
|
* is independent of extensions.config.json.
|
|
*/
|
|
function buildDefinitionsFromManifests(): Record<string, unknown[]> {
|
|
const extensionsDir = resolve(__dirname, '../../../extensions')
|
|
const result: Record<string, unknown[]> = {}
|
|
|
|
function walk(dir: string) {
|
|
for (const entry of readdirSync(dir, { withFileTypes: true })) {
|
|
const fullPath = join(dir, entry.name)
|
|
if (entry.isDirectory()) {
|
|
walk(fullPath)
|
|
} else if (entry.name === 'manifest.json') {
|
|
const manifest = JSON.parse(readFileSync(fullPath, 'utf-8'))
|
|
const sector: string = manifest.sector
|
|
if (!result[sector]) result[sector] = []
|
|
result[sector].push({
|
|
slug: manifest.id,
|
|
sector: manifest.sector,
|
|
...manifest.definition,
|
|
})
|
|
}
|
|
}
|
|
}
|
|
|
|
walk(extensionsDir)
|
|
return result
|
|
}
|
|
|
|
vi.mock('@/lib/extensions/_generated/sector-definitions', () => ({
|
|
EXTENSION_DEFINITIONS: buildDefinitionsFromManifests(),
|
|
}))
|
|
|
|
import {
|
|
SECTORS,
|
|
getSector,
|
|
getExtensionDefinition,
|
|
getAllExtensions,
|
|
getExtensionsBySector,
|
|
} from '../sectors'
|
|
|
|
describe('sectors registry', () => {
|
|
it('should have 1 sector', () => {
|
|
expect(SECTORS.length).toBe(1)
|
|
})
|
|
|
|
it('should have 11 total extensions', () => {
|
|
expect(getAllExtensions().length).toBe(11)
|
|
})
|
|
|
|
it('should have unique slugs within each sector', () => {
|
|
for (const sector of SECTORS) {
|
|
const slugs = sector.extensions.map(e => e.slug)
|
|
const uniqueSlugs = new Set(slugs)
|
|
expect(uniqueSlugs.size).toBe(slugs.length)
|
|
}
|
|
})
|
|
|
|
it('should have at least one extension per sector', () => {
|
|
for (const sector of SECTORS) {
|
|
expect(sector.extensions.length).toBeGreaterThan(0)
|
|
}
|
|
})
|
|
|
|
it('getSector returns correct sector', () => {
|
|
const sector = getSector('general')
|
|
expect(sector).toBeDefined()
|
|
expect(sector!.slug).toBe('general')
|
|
expect(sector!.name).toBe('Generella verktyg')
|
|
})
|
|
|
|
it('getSector returns undefined for unknown slug', () => {
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
const sector = getSector('invalid' as any)
|
|
expect(sector).toBeUndefined()
|
|
})
|
|
|
|
it('getExtensionDefinition returns correct extension', () => {
|
|
const ext = getExtensionDefinition('general', 'mcp-server')
|
|
expect(ext).toBeDefined()
|
|
expect(ext!.slug).toBe('mcp-server')
|
|
expect(ext!.name).toBe('MCP-server (API)')
|
|
expect(ext!.sector).toBe('general')
|
|
})
|
|
|
|
it('getExtensionDefinition returns undefined for unknown extension', () => {
|
|
const ext = getExtensionDefinition('general', 'nonexistent')
|
|
expect(ext).toBeUndefined()
|
|
})
|
|
|
|
it('getExtensionsBySector returns extensions for a sector', () => {
|
|
const extensions = getExtensionsBySector('general')
|
|
expect(extensions.length).toBe(11)
|
|
})
|
|
|
|
it('all extensions have required fields', () => {
|
|
for (const ext of getAllExtensions()) {
|
|
expect(ext.slug).toBeTruthy()
|
|
expect(ext.name).toBeTruthy()
|
|
expect(ext.sector).toBeTruthy()
|
|
expect(ext.category).toBeTruthy()
|
|
expect(ext.description).toBeTruthy()
|
|
expect(ext.longDescription).toBeTruthy()
|
|
expect(ext.icon).toBeTruthy()
|
|
expect(ext.dataPattern).toBeTruthy()
|
|
}
|
|
})
|
|
})
|