Fortnox model

General ledger

The general ledger (huvudbok): every booked voucher row with its voucher, account and financial year. Recreates the transaction list behind Fortnox's Huvudbok report.

Grain
one row per voucher row (financial year x voucher series x voucher number x row index)
Built from
  1. 4
    Raw tables
  2. 5
    Staging
  3. 1
    Core
  4. 1
    Analytics
Reads from Fortnox
accountsfinancial_yearsvoucher_rowsvouchers
Ships as
Weld and dbt SQL, open source on GitHub
core.fortnox.general_ledger
1-- core.fortnox.general_ledger
2-- The general ledger (huvudbok): every booked voucher row with its voucher, account and
3-- financial year. Recreates the transaction list behind Fortnox's Huvudbok report.
4--
5-- Grain: one row per voucher row (financial year x voucher series x voucher number x
6-- row index). Struck-through (removed) rows are excluded, so the ledger sums to zero
7-- per voucher and in total.
8--
9-- Currency: SEK, the accounting currency of every Fortnox company.
10-- Sign: `amount` is debit minus credit. Assets and expenses are positive, liabilities,
11-- equity and revenue negative. `amount_credit_positive` flips it for revenue-style
12-- reading.
13--
14-- Dates: `transaction_date` is the voucher's bookkeeping date (bokföringsdatum).
15-- Vouchers are dated in their own financial year, so posting month and financial year
16-- always agree.
17
18SELECT
19    r.financial_year_id,
20    fy.financial_year_start,
21    fy.financial_year_end,
22    v.transaction_date,
23    DATE_TRUNC(v.transaction_date, MONTH)        AS transaction_month,
24    r.voucher_series,
25    r.voucher_number,
26    CONCAT(r.voucher_series, ' ', CAST(r.voucher_number AS STRING)) AS voucher_id,
27    r.row_index,
28    v.voucher_description,
29    r.row_description,
30    r.transaction_information,
31    r.account_number,
32    a.account_name,
33    g.statement,
34    g.report_line,
35    g.sort_order                                  AS report_line_sort_order,
36    r.debit,
37    r.credit,
38    r.amount,
39    -1 * r.amount                                 AS amount_credit_positive,
40    r.quantity,

This model and the 6 it depends on. Deploy them together; refs like {{staging.…}} resolve to the matching folders in Weld, and the dbt view uses source() and ref().

Notes

How it counts. And where it stops.

Currency: SEK, the accounting currency of every Fortnox company. Sign: `amount` is debit minus credit. Assets and expenses are positive, liabilities, equity and revenue negative. `amount_credit_positive` flips it for revenue-style reading. Dates: `transaction_date` is the voucher's bookkeeping date (bokföringsdatum). Vouchers are dated in their own financial year, so posting month and financial year always agree.

Raw tables it reads

  • raw.fortnox.accounts
  • raw.fortnox.financial_years
  • raw.fortnox.voucher_rows
  • raw.fortnox.vouchers

Put Fortnox in front
of your agents.

Connect Fortnox, deploy the models, and ask questions in Claude, Cursor or ChatGPT. Free for 14 days, no credit card.