Fortnox model
Payables aging
Accounts payable aging (leverantörsreskontra): every supplier invoice with an open balance, bucketed by days past due as of today.
- Grain
- one row per open supplier invoice
- Built from
- 1Raw tables
- 1Staging
- 1Core
- 1Analytics
- Reads from Fortnox
- supplier_invoices
- Ships as
- Weld and dbt SQL, open source on GitHub
core.fortnox.payables_aging
1-- core.fortnox.payables_aging
2-- Accounts payable aging (leverantörsreskontra): every supplier invoice with an open
3-- balance, bucketed by days past due as of today.
4--
5-- Grain: one row per open supplier invoice. A point-in-time snapshot, like
6-- receivables_aging.
7--
8-- Currency: `balance` is in the invoice currency; `balance_sek` uses the booked rate.
9-- Sign: positive is what you owe. Supplier credit notes are negative.
10
11SELECT
12 given_number,
13 supplier_invoice_number,
14 supplier_number,
15 supplier_name,
16 invoice_date,
17 due_date,
18 currency,
19 total,
20 balance,
21 total_sek,
22 balance_sek,
23 is_credit,
24 is_payment_pending,
25 DATE_DIFF(CURRENT_DATE(), due_date, DAY) AS days_past_due,
26 CASE
27 WHEN due_date IS NULL THEN 'no_due_date'
28 WHEN DATE_DIFF(CURRENT_DATE(), due_date, DAY) <= 0 THEN 'not_due'
29 WHEN DATE_DIFF(CURRENT_DATE(), due_date, DAY) <= 30 THEN '1_30'
30 WHEN DATE_DIFF(CURRENT_DATE(), due_date, DAY) <= 60 THEN '31_60'
31 WHEN DATE_DIFF(CURRENT_DATE(), due_date, DAY) <= 90 THEN '61_90'
32 ELSE 'over_90'
33 END AS aging_bucket,
34 CURRENT_DATE() AS aged_as_of
35FROM {{staging.fortnox.supplier_invoices}}
36WHERE is_booked
37 AND NOT is_cancelled
38 AND balance <> 0This model and the 2 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: `balance` is in the invoice currency; `balance_sek` uses the booked rate. Sign: positive is what you owe. Supplier credit notes are negative.
Raw tables it reads
- raw.fortnox.supplier_invoices
More Fortnox models
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.