Add/bokslut (#718)
* feat(arcim-migration): Briox provider with SIE-over-API import - Briox auth via account ID + application token (no app-level credentials); both tokens rotate on refresh and are persisted - New sie-fetcher pulls the general ledger as SIE through the provider API for Fortnox, Briox and Bjorn Lunden - Wizard stops on a failed SIE import and surfaces the real errors instead of proceeding to the misleading migrate-guard message - PROVIDER_SIE_ONLY_FORTNOX renamed to PROVIDER_SIE_NOT_SUPPORTED; new PROVIDER_TOKEN_INVALID for rejected provider credentials Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * feat(bookkeeping): per-line accruals (periodisering) on invoices and supplier invoices Defer revenue/costs per invoice line to 29xx/17xx interim accounts with automatic monthly dissolution (nightly cron + catch-up at registration), schedule cancellation on credit, year-end auto-detect exclusion for already-scheduled invoices, invoice-inbox service-period extraction for prefill, and an MCP tool to list schedules. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * feat(bokslut): iXBRL arsredovisning generation and Bolagsverket digital filing Generate the annual report as iXBRL from a generated taxonomy registry (K2 element lists, taxonomy:generate/check scripts + CI guard), expose it via the fiscal-period API, and add the bolagsverket extension for digital submission to eget utrymme with webhook-driven status tracking (submissions table + pg tests, lifecycle events, year-end wizard UI). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * test(mcp): raise origin-guard test timeout to 20s The dynamic import pulls in the full server module; the parse alone flirts with the 5s default under full-suite parallel load. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * Add new scripts and documentation for K2 AB taxonomy generation and validation - Introduced `generate-taxonomy-registry.ts` to automate the generation of the iXBRL taxonomy concept registry from official element lists and tuple models. - Added `validate-ixbrl.mjs` for validating generated iXBRL reports against the official taxonomy package using Arelle. - Included new documentation files: - `k2-ab-arsredovisning-elementlista-2024-09-12_rev20250312_sv.xlsx` - `tuple-innehallsmodell-arsredovisning-k2-2024-09-12.xlsx` - `taxonomi-paket-2024-09-12_rev20250312.zip` * Add tests for bookkeeping accruals dissolution and supplier invoices - Implement tests for the POST /api/bookkeeping/accruals/[id]/dissolve route, covering success and error scenarios. - Add tests for the DELETE /api/supplier-invoices/[id] route, including authentication checks and validation of invoice deletion conditions. - Introduce tests for the Arcim migration provider client, ensuring token handling and error classification. - Create tests for the Bolagsverket extension, validating submission role enforcement and environment settings. - Add Zod schemas for Bolagsverket response payloads to ensure proper validation. - Implement tests for MCP server's list accrual schedules, confirming registration and scope mapping. - Add consistency tests for IXBRL document generation, ensuring duplicate facts and XML escaping are handled correctly. - Introduce typed domain errors for accrual schedules to improve error handling in the service. - Add tests for resolving consent with Briox token refresh concurrency, ensuring proper token management and error handling. * fix(tests): update payload size guard comments to reflect recent changes in tool descriptions and ceiling adjustments * fix(gitattributes): mark generated JSON files in bokslut taxonomy as linguist-generated * feat(migrations): add backfill for invoices.journal_entry_id and fallback for next_voucher_number user_id * feat(bokslut): enhance compliance and financial processing features with new submission details and security measures --------- Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
8e8b63a200
commit
db8983ba9e
@@ -0,0 +1,374 @@
|
||||
#!/usr/bin/env npx tsx
|
||||
/**
|
||||
* Generate the iXBRL taxonomy concept registry from the official Bolagsverket/
|
||||
* taxonomier.se element lists in dev_docs/bokslut/taxonomi/dokumentation/.
|
||||
*
|
||||
* Why generated (not hand-authored):
|
||||
* - The element lists (xlsx) are the official mapping spec for which concepts
|
||||
* exist per delrapport, their namespace, balance (debit/credit) and period
|
||||
* type. Hand-copying ~1 300 rows guarantees drift; the registry must be
|
||||
* reproducible from the committed spec files.
|
||||
* - The September 2026 taxonomy generation replaces tuples with dimensions —
|
||||
* taxonomy versions are data, not code. New versions become new generated
|
||||
* JSON files + a new entry in lib/bokslut/ixbrl/taxonomy/entry-points.ts,
|
||||
* leaving emitters for older versions untouched.
|
||||
*
|
||||
* Sources (committed in dev_docs/bokslut/):
|
||||
* - k2-ab-arsredovisning-elementlista-2024-09-12_rev20250312_sv.xlsx
|
||||
* → one sheet per delrapport (allmän info, FB, RR, BR, noter, underskrifter…)
|
||||
* - tuple-innehallsmodell-arsredovisning-k2-2024-09-12.xlsx
|
||||
* → tuple → ordered member model with per-member "obligatorisk" flag
|
||||
* - taxonomi-paket-2024-09-12_rev20250312.zip
|
||||
* → se-comp-base-2020-12-01.xsd parsed for the fastställelseintyg concepts
|
||||
* (se-bol-base), which are not part of any element list
|
||||
*
|
||||
* Output: lib/bokslut/ixbrl/taxonomy/generated/k2-ab-2024-09-12.json
|
||||
* Deterministic: concepts sorted by name, no timestamps; --check regenerates
|
||||
* in memory and fails (exit 1) when the committed file is stale, mirroring
|
||||
* skills:check.
|
||||
*
|
||||
* Usage:
|
||||
* npx tsx scripts/generate-taxonomy-registry.ts # write registry
|
||||
* npx tsx scripts/generate-taxonomy-registry.ts --check # CI guard
|
||||
*/
|
||||
|
||||
import { createHash } from 'node:crypto'
|
||||
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs'
|
||||
import { dirname, join } from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import * as XLSX from 'xlsx'
|
||||
import JSZip from 'jszip'
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url)
|
||||
const ROOT = dirname(dirname(__filename))
|
||||
const DOC_DIR = join(ROOT, 'dev_docs', 'bokslut', 'taxonomi', 'dokumentation')
|
||||
const PACKAGE_ZIP = join(
|
||||
ROOT,
|
||||
'dev_docs',
|
||||
'bokslut',
|
||||
'taxonomi',
|
||||
'taxonomi-paket-2024-09-12_rev20250312.zip',
|
||||
)
|
||||
const ELEMENT_LIST = join(
|
||||
DOC_DIR,
|
||||
'k2-ab-arsredovisning-elementlista-2024-09-12_rev20250312_sv.xlsx',
|
||||
)
|
||||
const TUPLE_MODEL = join(
|
||||
DOC_DIR,
|
||||
'tuple-innehallsmodell-arsredovisning-k2-2024-09-12.xlsx',
|
||||
)
|
||||
const COMP_BASE_XSD_ENTRY =
|
||||
'taxonomi-paket-2024-09-12_rev20250312/xbrl.taxonomier.se/se/common/base/se-comp-base/2020-12-01/se-comp-base-2020-12-01.xsd'
|
||||
|
||||
const OUT_PATH = join(
|
||||
ROOT,
|
||||
'lib',
|
||||
'bokslut',
|
||||
'ixbrl',
|
||||
'taxonomy',
|
||||
'generated',
|
||||
'k2-ab-2024-09-12.json',
|
||||
)
|
||||
|
||||
const checkOnly = process.argv.includes('--check')
|
||||
|
||||
/** Sheet name (as it appears in the workbook) → registry section key. */
|
||||
const SHEET_SECTIONS: Record<string, string> = {
|
||||
'Allmän information': 'allman-information',
|
||||
'Förvaltningsberättelse': 'forvaltningsberattelse',
|
||||
'Kostnadsslagsindelad resultatr': 'rr-kostnadsslagsindelad',
|
||||
'Förkortad kostnadsslagsindelad': 'rr-kostnadsslagsindelad-forkortad',
|
||||
'Balansräkning': 'balansrakning',
|
||||
'Förkortad balansräkning': 'balansrakning-forkortad',
|
||||
'Kassaflödesanalys indirekt met': 'kassaflodesanalys',
|
||||
'Noter': 'noter',
|
||||
// Trailing space is present in the workbook sheet name.
|
||||
'Undertecknande av företrädare ': 'undertecknande',
|
||||
}
|
||||
|
||||
interface ConceptOut {
|
||||
/** Namespace prefix, e.g. "se-gen-base". Resolved to a URI in entry-points.ts. */
|
||||
ns: string
|
||||
/** Standardrubrik — the official presentation label. */
|
||||
label: string
|
||||
abstract: boolean
|
||||
/** XBRL datatype, e.g. "xbrli:monetaryItemType". Null for tuples. */
|
||||
dataType: string | null
|
||||
balance: 'debit' | 'credit' | null
|
||||
periodType: 'duration' | 'instant' | null
|
||||
kind: 'item' | 'tuple'
|
||||
/** Which delrapporter (sheets) list the concept. */
|
||||
sections: string[]
|
||||
}
|
||||
|
||||
interface TupleMemberOut {
|
||||
name: string
|
||||
ns: string
|
||||
required: boolean
|
||||
}
|
||||
|
||||
interface RegistryOut {
|
||||
_meta: {
|
||||
taxonomy: 'k2-ab'
|
||||
version: '2024-09-12'
|
||||
revision: '2025-03-12'
|
||||
generator: 'scripts/generate-taxonomy-registry.ts'
|
||||
sources: Record<string, string>
|
||||
conceptCount: number
|
||||
tupleCount: number
|
||||
}
|
||||
concepts: Record<string, ConceptOut>
|
||||
tuples: Record<string, { ns: string; members: TupleMemberOut[] }>
|
||||
}
|
||||
|
||||
function sha256(buf: Buffer | string): string {
|
||||
return createHash('sha256').update(buf).digest('hex')
|
||||
}
|
||||
|
||||
function cellStr(v: unknown): string | null {
|
||||
if (v === null || v === undefined) return null
|
||||
const s = String(v).trim()
|
||||
return s.length > 0 ? s : null
|
||||
}
|
||||
|
||||
function parseElementList(): Record<string, ConceptOut> {
|
||||
const wb = XLSX.read(readFileSync(ELEMENT_LIST), { type: 'buffer' })
|
||||
const concepts: Record<string, ConceptOut> = {}
|
||||
|
||||
for (const sheetName of wb.SheetNames) {
|
||||
const section = SHEET_SECTIONS[sheetName]
|
||||
if (!section) {
|
||||
throw new Error(
|
||||
`Unknown sheet "${sheetName}" in element list — add it to SHEET_SECTIONS`,
|
||||
)
|
||||
}
|
||||
const rows = XLSX.utils.sheet_to_json<unknown[]>(wb.Sheets[sheetName], {
|
||||
header: 1,
|
||||
blankrows: false,
|
||||
})
|
||||
const header = rows[0] as (string | null)[]
|
||||
const col = (label: string): number => {
|
||||
const i = header.indexOf(label)
|
||||
if (i === -1)
|
||||
throw new Error(`Column "${label}" missing on sheet "${sheetName}"`)
|
||||
return i
|
||||
}
|
||||
const iEl = col('Elementnamn')
|
||||
const iNs = col('Tillhör')
|
||||
const iLabel = col('Standardrubrik')
|
||||
const iAbstract = col('Abstrakt')
|
||||
const iDataType = col('Datatyp')
|
||||
const iBalance = col('Saldo')
|
||||
const iPeriodType = col('Periodtyp')
|
||||
const iKind = col('Typ')
|
||||
|
||||
for (let r = 1; r < rows.length; r++) {
|
||||
const row = rows[r]
|
||||
const name = cellStr(row[iEl])
|
||||
if (!name) continue
|
||||
const ns = cellStr(row[iNs])
|
||||
if (!ns) throw new Error(`Row ${r} on "${sheetName}": missing Tillhör for ${name}`)
|
||||
const balanceRaw = cellStr(row[iBalance])
|
||||
const periodRaw = cellStr(row[iPeriodType])
|
||||
const kindRaw = cellStr(row[iKind])
|
||||
const parsed: ConceptOut = {
|
||||
ns,
|
||||
label: cellStr(row[iLabel]) ?? name,
|
||||
abstract: cellStr(row[iAbstract]) === 'true',
|
||||
dataType: cellStr(row[iDataType]),
|
||||
balance:
|
||||
balanceRaw === 'debit' || balanceRaw === 'credit' ? balanceRaw : null,
|
||||
periodType:
|
||||
periodRaw === 'duration' || periodRaw === 'instant' ? periodRaw : null,
|
||||
kind: kindRaw === 'tuple' ? 'tuple' : 'item',
|
||||
sections: [section],
|
||||
}
|
||||
const existing = concepts[name]
|
||||
if (existing) {
|
||||
// Same element listed on several sheets (shared concepts). Attribute
|
||||
// mismatches would mean the spec disagrees with itself — fail loudly.
|
||||
for (const key of ['ns', 'dataType', 'balance', 'periodType', 'kind'] as const) {
|
||||
if (existing[key] !== parsed[key]) {
|
||||
throw new Error(
|
||||
`Concept ${name}: "${String(key)}" differs between sheets (${String(existing[key])} vs ${String(parsed[key])})`,
|
||||
)
|
||||
}
|
||||
}
|
||||
if (!existing.sections.includes(section)) existing.sections.push(section)
|
||||
} else {
|
||||
concepts[name] = parsed
|
||||
}
|
||||
}
|
||||
}
|
||||
return concepts
|
||||
}
|
||||
|
||||
function parseTupleModel(
|
||||
concepts: Record<string, ConceptOut>,
|
||||
): Record<string, { ns: string; members: TupleMemberOut[] }> {
|
||||
const wb = XLSX.read(readFileSync(TUPLE_MODEL), { type: 'buffer' })
|
||||
const rows = XLSX.utils.sheet_to_json<unknown[]>(wb.Sheets[wb.SheetNames[0]], {
|
||||
header: 1,
|
||||
blankrows: false,
|
||||
})
|
||||
// Row 0 is a super-header ("Obligatoriskt värde i Tuple" lives at index 12);
|
||||
// row 1 holds the real column labels.
|
||||
const header = rows[1] as (string | null)[]
|
||||
const iNs = header.indexOf('Tillhör')
|
||||
const iEl = header.indexOf('Elementnamn')
|
||||
const iKind = header.indexOf('Typ')
|
||||
const iAb = header.indexOf('AB')
|
||||
const iRequired = 12
|
||||
if (iNs === -1 || iEl === -1 || iKind === -1 || iAb === -1) {
|
||||
throw new Error('Tuple model columns moved — update parseTupleModel')
|
||||
}
|
||||
|
||||
const tuples: Record<string, { ns: string; members: TupleMemberOut[] }> = {}
|
||||
let current: { name: string; inAb: boolean } | null = null
|
||||
for (let r = 2; r < rows.length; r++) {
|
||||
const row = rows[r]
|
||||
const name = cellStr(row[iEl])
|
||||
if (!name) continue
|
||||
const kind = cellStr(row[iKind])
|
||||
const ns = cellStr(row[iNs]) ?? 'se-gaap-ext'
|
||||
if (kind === 'xbrli:tuple') {
|
||||
const inAb = cellStr(row[iAb]) === 'JA'
|
||||
current = { name, inAb }
|
||||
if (inAb) tuples[name] = { ns, members: [] }
|
||||
} else if (kind === 'xbrli:item' && current?.inAb) {
|
||||
tuples[current.name].members.push({
|
||||
name,
|
||||
ns,
|
||||
required: cellStr(row[iRequired]) === 'JA',
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// Tuples used by K2 AB must also exist as concepts (the element list carries
|
||||
// the ones that appear in the K2 AB report; the tuple model spans all
|
||||
// company forms). Members referenced but missing from the element list are
|
||||
// added as items so the registry is self-contained.
|
||||
for (const [name, t] of Object.entries(tuples)) {
|
||||
if (!concepts[name]) {
|
||||
concepts[name] = {
|
||||
ns: t.ns,
|
||||
label: name,
|
||||
abstract: false,
|
||||
dataType: null,
|
||||
balance: null,
|
||||
periodType: null,
|
||||
kind: 'tuple',
|
||||
sections: ['tuple-model'],
|
||||
}
|
||||
}
|
||||
for (const m of t.members) {
|
||||
if (!concepts[m.name]) {
|
||||
concepts[m.name] = {
|
||||
ns: m.ns,
|
||||
label: m.name,
|
||||
abstract: false,
|
||||
dataType: 'xbrli:stringItemType',
|
||||
balance: null,
|
||||
periodType: 'duration',
|
||||
kind: 'item',
|
||||
sections: ['tuple-model'],
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return tuples
|
||||
}
|
||||
|
||||
/**
|
||||
* The fastställelseintyg concepts (se-bol-base) come from Bolagsverket's
|
||||
* comp-base schema inside the taxonomy package — they are not in any element
|
||||
* list. Parse the XSD element declarations directly.
|
||||
*/
|
||||
async function parseCompBase(concepts: Record<string, ConceptOut>): Promise<void> {
|
||||
const zip = await JSZip.loadAsync(readFileSync(PACKAGE_ZIP))
|
||||
const file = zip.file(COMP_BASE_XSD_ENTRY)
|
||||
if (!file) throw new Error(`${COMP_BASE_XSD_ENTRY} missing from taxonomy package`)
|
||||
const xsd = await file.async('string')
|
||||
const decls = xsd.matchAll(/<xsd:element ([^>]*)\/>/g)
|
||||
for (const [, attrText] of decls) {
|
||||
const attr = (n: string): string | null => {
|
||||
const m = attrText.match(new RegExp(`${n}="([^"]*)"`))
|
||||
return m ? m[1] : null
|
||||
}
|
||||
const name = attr('name')
|
||||
if (!name) continue
|
||||
const subst = attr('substitutionGroup')
|
||||
const periodType = attr('xbrli:periodType')
|
||||
concepts[name] = {
|
||||
ns: 'se-bol-base',
|
||||
label: name,
|
||||
abstract: attr('abstract') === 'true',
|
||||
dataType: attr('type'),
|
||||
balance: null,
|
||||
periodType:
|
||||
periodType === 'duration' || periodType === 'instant' ? periodType : null,
|
||||
kind: subst === 'xbrli:tuple' ? 'tuple' : 'item',
|
||||
sections: ['faststallelseintyg'],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function sortedRecord<T>(rec: Record<string, T>): Record<string, T> {
|
||||
const out: Record<string, T> = {}
|
||||
for (const key of Object.keys(rec).sort()) out[key] = rec[key]
|
||||
return out
|
||||
}
|
||||
|
||||
async function buildRegistry(): Promise<string> {
|
||||
const concepts = parseElementList()
|
||||
const tuples = parseTupleModel(concepts)
|
||||
await parseCompBase(concepts)
|
||||
|
||||
const registry: RegistryOut = {
|
||||
_meta: {
|
||||
taxonomy: 'k2-ab',
|
||||
version: '2024-09-12',
|
||||
revision: '2025-03-12',
|
||||
generator: 'scripts/generate-taxonomy-registry.ts',
|
||||
sources: {
|
||||
'k2-ab-arsredovisning-elementlista-2024-09-12_rev20250312_sv.xlsx':
|
||||
sha256(readFileSync(ELEMENT_LIST)),
|
||||
'tuple-innehallsmodell-arsredovisning-k2-2024-09-12.xlsx':
|
||||
sha256(readFileSync(TUPLE_MODEL)),
|
||||
'se-comp-base-2020-12-01.xsd': COMP_BASE_XSD_ENTRY,
|
||||
},
|
||||
conceptCount: Object.keys(concepts).length,
|
||||
tupleCount: Object.keys(tuples).length,
|
||||
},
|
||||
concepts: sortedRecord(concepts),
|
||||
tuples: sortedRecord(tuples),
|
||||
}
|
||||
return JSON.stringify(registry, null, 2) + '\n'
|
||||
}
|
||||
|
||||
async function main(): Promise<void> {
|
||||
const json = await buildRegistry()
|
||||
if (checkOnly) {
|
||||
const committed = existsSync(OUT_PATH) ? readFileSync(OUT_PATH, 'utf8') : null
|
||||
if (committed !== json) {
|
||||
console.error(
|
||||
`Taxonomy registry is stale: ${OUT_PATH} does not match the element lists.\n` +
|
||||
'Run: npx tsx scripts/generate-taxonomy-registry.ts',
|
||||
)
|
||||
process.exit(1)
|
||||
}
|
||||
console.log('Taxonomy registry is up to date.')
|
||||
return
|
||||
}
|
||||
mkdirSync(dirname(OUT_PATH), { recursive: true })
|
||||
writeFileSync(OUT_PATH, json, 'utf8')
|
||||
const parsed = JSON.parse(json) as RegistryOut
|
||||
console.log(
|
||||
`Wrote ${OUT_PATH} (${parsed._meta.conceptCount} concepts, ${parsed._meta.tupleCount} tuples)`,
|
||||
)
|
||||
}
|
||||
|
||||
main().catch((err) => {
|
||||
console.error(err)
|
||||
process.exit(1)
|
||||
})
|
||||
@@ -0,0 +1,114 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* Validate a generated iXBRL årsredovisning against the official taxonomy
|
||||
* package using Arelle (https://arelle.org) — layer 2 of the validation
|
||||
* stack (layer 1 = pre-flight rules engine, layer 3 = Bolagsverket
|
||||
* `kontrollera`).
|
||||
*
|
||||
* Usage:
|
||||
* npm run validate:ixbrl -- path/to/arsredovisning.xhtml
|
||||
*
|
||||
* Arelle discovery order:
|
||||
* 1. `arelleCmdLine` on PATH (pip install arelle-release)
|
||||
* 2. `python -m arelle.CntlrCmdLine`
|
||||
* 3. docker image `arelle/arelle` (mounts the file + taxonomy package)
|
||||
*
|
||||
* Exits 0 with a notice when Arelle isn't available (CI machines without
|
||||
* Python shouldn't hard-fail), 1 on validation errors, 2 on usage errors.
|
||||
*/
|
||||
|
||||
import { spawnSync } from 'node:child_process'
|
||||
import { existsSync } from 'node:fs'
|
||||
import { resolve, dirname, basename } from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
|
||||
const ROOT = dirname(dirname(fileURLToPath(import.meta.url)))
|
||||
const TAXONOMY_PACKAGE = resolve(
|
||||
ROOT,
|
||||
'dev_docs/bokslut/taxonomi/taxonomi-paket-2024-09-12_rev20250312.zip',
|
||||
)
|
||||
|
||||
const fileArg = process.argv[2]
|
||||
if (!fileArg) {
|
||||
console.error('Usage: npm run validate:ixbrl -- <file.xhtml>')
|
||||
process.exit(2)
|
||||
}
|
||||
const file = resolve(process.cwd(), fileArg)
|
||||
if (!existsSync(file)) {
|
||||
console.error(`File not found: ${file}`)
|
||||
process.exit(2)
|
||||
}
|
||||
if (!existsSync(TAXONOMY_PACKAGE)) {
|
||||
console.error(`Taxonomy package missing: ${TAXONOMY_PACKAGE}`)
|
||||
process.exit(2)
|
||||
}
|
||||
|
||||
const ARELLE_ARGS = [
|
||||
'--file',
|
||||
file,
|
||||
'--packages',
|
||||
TAXONOMY_PACKAGE,
|
||||
'--validate',
|
||||
'--logLevel',
|
||||
'warning',
|
||||
]
|
||||
|
||||
function tryRun(cmd, args, label) {
|
||||
const probe = spawnSync(cmd, ['--version'], { encoding: 'utf8', shell: false })
|
||||
if (probe.error || probe.status !== 0) return null
|
||||
console.log(`Validating with ${label} …`)
|
||||
const run = spawnSync(cmd, args, { encoding: 'utf8', stdio: 'inherit', shell: false })
|
||||
return run.status ?? 1
|
||||
}
|
||||
|
||||
let status = tryRun('arelleCmdLine', ARELLE_ARGS, 'arelleCmdLine')
|
||||
|
||||
if (status === null) {
|
||||
const probe = spawnSync('python', ['-c', 'import arelle'], { encoding: 'utf8' })
|
||||
if (!probe.error && probe.status === 0) {
|
||||
console.log('Validating with python -m arelle.CntlrCmdLine …')
|
||||
const run = spawnSync('python', ['-m', 'arelle.CntlrCmdLine', ...ARELLE_ARGS], {
|
||||
encoding: 'utf8',
|
||||
stdio: 'inherit',
|
||||
})
|
||||
status = run.status ?? 1
|
||||
}
|
||||
}
|
||||
|
||||
if (status === null) {
|
||||
const probe = spawnSync('docker', ['--version'], { encoding: 'utf8' })
|
||||
if (!probe.error && probe.status === 0) {
|
||||
console.log('Validating with docker image arelle/arelle …')
|
||||
const run = spawnSync(
|
||||
'docker',
|
||||
[
|
||||
'run',
|
||||
'--rm',
|
||||
'-v',
|
||||
`${dirname(file)}:/data`,
|
||||
'-v',
|
||||
`${dirname(TAXONOMY_PACKAGE)}:/taxonomy`,
|
||||
'arelle/arelle',
|
||||
'--file',
|
||||
`/data/${basename(file)}`,
|
||||
'--packages',
|
||||
`/taxonomy/${basename(TAXONOMY_PACKAGE)}`,
|
||||
'--validate',
|
||||
'--logLevel',
|
||||
'warning',
|
||||
],
|
||||
{ encoding: 'utf8', stdio: 'inherit' },
|
||||
)
|
||||
status = run.status ?? 1
|
||||
}
|
||||
}
|
||||
|
||||
if (status === null) {
|
||||
console.log(
|
||||
'Arelle is not installed — skipping schema validation.\n' +
|
||||
'Install with: pip install arelle-release (or use the arelle/arelle docker image).',
|
||||
)
|
||||
process.exit(0)
|
||||
}
|
||||
|
||||
process.exit(status === 0 ? 0 : 1)
|
||||
Reference in New Issue
Block a user