accounted
← Instruktioner

Kunskap

SIE

SIE-filer vid flytt mellan bokföringsprogram.

Från Accounted · MIT

Deterministic reference for parsing, validating, generating, and troubleshooting SIE4 files.

SIE4 (Standard Import Export) is Sweden's universal accounting data interchange format. Tagged plain-text, one record per line, #LABEL prefix, space-delimited fields. .SE = export, .SI = import. Current spec: utgåva 4C (2025-08-06), which still allows only CP437 (#FORMAT PC8). SIE 5 is a separate XML format; this skill covers SIE 4.

Reference files

FileWhen to read
references/record-types.mdEvery record label and its fields, the five subtypes (1, 2, 3, 4E, 4I), field format rules, verification example, series conventions, multi-year handling, record ordering, #KSUMMA
references/encoding.mdEncoding detection, byte tables, mojibake diagnosis, per-software behaviour, normalization on import
references/validation-rules.mdCommon-error lookup, all validation rules and severities, validation order, remediation workflow, post-import issues, file diffing
references/bas-sru.mdBAS account classes, #KTYP, key accounts, SRU codes, year-end closing and IB/UB flow, #KPTYP
references/migration-and-audit-trail.mdMigrating between systems, what SIE does not carry, post-migration validation, retention and audit trail under BFL

Core invariants (never violate)

  1. Verification balance: Sum of all #TRANS amounts within a #VER block = 0.00 exactly
  2. IB/UB continuity: UB(year N, account) = IB(year N+1, account) for all balance sheet accounts (1xxx-2xxx)
  3. Result account reset: IB for income statement accounts (3xxx-9xxx) must be zero at year start
  4. #FLAGGA idempotency: 0 = not imported, 1 = already imported. Prevents double-import.
  5. Sequential numbering: Verifications within a series appear in ascending verno order
  6. Sign convention: Debit = positive, Credit = negative (in #TRANS, #IB, #UB, #RES)

Procedure for any SIE file

  1. Detect the encoding before parsing. #FORMAT PC8 is unreliable: cloud programs declare PC8 and export UTF-8. Detection order in encoding.md; skip #KSUMMA unless CP437.
  2. Check #FLAGGA. 1 means the file has already been read in: don't import it.
  3. Validate in order: structure → encoding → parsing → chart of accounts → balances → verifications → fiscal year boundaries → dimensions → KSUMMA (CP437 only). Checks and severities in validation-rules.md.
  4. Diagnose before adjusting. Any difference (unbalanced #VER, IB/UB mismatch, non-zero IB on result accounts): keep the file untouched, report the exact difference, compare with the source ledger, fix the cause, re-export. A rättelsepost only when the books themselves are wrong, in the period the error is discovered.
  5. Generating files: write CP437, every verification balanced and in ascending verno order per series, every account declared, #FLAGGA 0.

Never guess these

SituationWhyWhat to do
The file's actual encodingPC8 is declared even by UTF-8 exporters, and mojibake is silentRun the detection order in encoding.md on the raw bytes
An unbalanced verificationThe cause decides the fix; a balancing line hides a missing costCompare with the source voucher and re-export. Never add a balancing line
An IB/UB differenceIB must equal the previous year's UB (ÅRL 2:4 p.7)Diagnose per account against the source. Never adjust the opening or a closed period undiagnosed
Resetting #FLAGGA to 0It defeats the double-import guard (spec 7.4)Confirm the vouchers are not in the target, and document why
VAT codes after an importSIE carries no moms informationConfigure them manually in the target system
The series to import intoCollisions create duplicate verification numbersRemap to an unused series, document the mapping

Related skills

QuestionSkill
SRU codes and the files sent to Skatteverketswedish-sru-filing
BFL bookkeeping duties, verifikationer, archivingswedish-accounting-compliance
The closing entries behind UB and next year's IBswedish-year-end-closing
Moms codes and rules to configure after an importswedish-vat
Project dimensions (#DIM 6 / #OBJEKT) in the booksswedish-project-accounting
Årsredovisning and INK2 from the same balancesswedish-financial-reporting