DECCF · Cash Flow Modeler and Calculator

SIE import

deccf/domainpacks/sie-import creates a statement flow group from the latest balance period in a textfile input. It requires the Business account plan and finds the statement owner's accounts through their account-plan categories. The file content remains a normal input.textfile() string, so a run can supply it from the Calculator's local file picker or through deterministic.inputs in JavaScript.

When this model is opened in the Calculator, its example SIE text runs immediately. The Model inputs panel lets you replace it with a local text file. The importer discovers additional accounts from the supplied balances, so you only need to declare accounts that you want to reference explicitly in your model.

Choose a SIE text file in Model inputs. In a direct run, provide its text under the same precondition name:

The model timeline must use monthly periods and include the latest period in the file. The statement posts at that month's end. It reads the latest #OMFATTN coverage date when present, otherwise the latest #PSALDO month, and falls back to the end date of the latest #RAR year when the file has annual balances only.

The reader uses account-level #IB, #UB, #RES, and unscoped #PSALDO records. Period movements are accumulated from #IB through the selected month; at a financial-year end, #UB and #RES provide the ending values when present. Object-specific rows are skipped so the account-level totals are not counted twice. Debit balances are positive and credit balances are negative in the file. The SIE Group's format specification describes these record types and their signs.

For each SIE account code, the module registers a matching Business-plan account, reusing an existing account for the same owner when available. Discovery uses the text supplied to the run, including a textfile override. When both a known parent account and its known descendants occur in the file, their amounts are added to the parent account according to the plan's explicit hierarchy. A trailing zero alone does not establish that relationship.

If a code is absent from the plan, SIE import creates a separate account with that original number. It inherits its type and title from the nearest higher known account, or from a group with a single account type. The inherited title is placed in parentheses, for example (Sales within the country), and appears in the existing category_label output field. The imported account has its own category beneath the inherited account's category parent, so it remains distinct from other accounts with the same inherited title. This behavior belongs to SIE import; calling stdaccount() directly still requires a recognized account or category code. If no suitable parent can supply the metadata, the import reports an error.

Previous-year result and book closing

Some exports carry the previous year's closing balance accounts into the next year before transferring the previous result to equity. The importer recognizes this when the opening balances match the previous closing balances account by account, and the previous closing balances plus previous result balance to zero. It adds the missing previous result to account 2098 — Profit or loss from the previous year. Profit produces a credit; loss produces a debit. An existing imported balance on 2098 is retained and the adjustment is added to it.

Some year-end exports already include the current year's result in their balance accounts while also reporting it in #RES. When the balance accounts balance after any verified previous-year adjustment, the importer adds an equal and opposite amount to 2098. This keeps the result visible in the income statement without counting it twice in the balance sheet. parseLatestSieSnapshot() exposes that offset as bookedCurrentResultAdjustment. Result balances that are not already included in equity remain unadjusted.

parseLatestSieSnapshot() preserves the original balances and exposes the previous-year amount and source year end as openingResultAdjustment when that reconciliation succeeds. The run's account postings show each required adjustment on 2098 as part of the balanced SIE import. Unexplained differences still produce an error with the period, currency, and amount.

bookClosing() subsequently transfers the current income and expense balances to retained earnings (2091). It leaves the 2098 adjustments in equity, preventing a result that was already included in the imported balance from being counted a second time. A later closing with no further income or expenses makes no additional result transfer.

The statement sets each registered Business-plan account owned by the company to the imported snapshot, including any verified opening-result adjustment described above. The final postings must balance. The SIE currency must match the model currency; when #VALUTA is absent, the format's default SEK is used.