Swedish investment accounts
Declare a person's Swedish investment savings account (ISK) and ordinary securities account (VP) with DECCF's core accounts and balanced cashflows. The pack publishes monthly SEK facts for a separate tax calculation to consume. It does not calculate Swedish tax or import the Swedish income-tax pack.
Use it in a model
const { account, currencies, defineModel, entity, input, periods } = deccf;
const { swedishInvestmentAccounts } = modules["swedish-investment-accounts"];
const SEK = currencies.SEK;
const owner = entity.party();
const bankOpening = input.money(80_000, SEK, { ui: { label: "Opening bank balance" } });
const bank = account({
owner,
type: "asset",
category: deccf.category("assets.cash.bank"),
initial: bankOpening,
});
const timeline = periods.monthly({ from: "2026-01", count: 12 });
const deposit = input.money(2_000, SEK);
const purchase = input.money(1_500, SEK);
const dividend = input.money(25, SEK);
const accounts = swedishInvestmentAccounts({
owner,
bankAccount: bank,
timeline,
accounts: [
{
id: "isk",
type: "ISK",
opening: { cash: 5_000, securities: 40_000 },
events: [
{ id: "monthly-deposit", date: "2026-02", type: "deposit", amount: deposit },
{ id: "monthly-purchase", date: "2026-02", type: "purchase", amount: purchase },
{ id: "spring-dividend", date: "2026-04", type: "dividend", amount: dividend },
{ id: "spring-value", date: "2026-04", type: "valuation", value: 47_500 },
],
},
{ id: "vp", type: "VP", opening: { cash: 1_000, securities: 12_000 } },
],
});
return defineModel({
name: "Swedish ISK and VP account example",
currency: SEK,
timeline,
preconditions: { bankOpening, deposit, purchase, dividend },
entities: { owner },
accounts: { bank },
components: { investments: accounts.component },
metrics: {
isk_cash_sek: context => context.get(accounts.accounts.isk.cash),
isk_securities_at_cost_sek: context => context.get(accounts.accounts.isk.securities),
isk_dividends_sek: context => context.get(accounts.taxFacts.isk).dividends,
vp_cash_sek: context => context.get(accounts.accounts.vp.cash),
},
});The factory returns the component plus references for each account, posting flow, and monthly taxFacts calculation. Read the facts directly or pass them to a caller-owned adapter. Each fact record has accountId, accountType, period, currency, opening and closing cash and securities at book value, external deposits and withdrawals, realized gains and losses, dividends, interest, fees, and an optional-value pair (observedAccountValueAvailable and observedAccountValue).
Event and ledger contract
Events are declared for a valid YYYY-MM inside the fixed monthly timeline. All amounts must be non-negative SEK numbers, SEK Money, inputs, calculations, or expressions. Account IDs and event IDs are stable lowercase identifiers; event IDs are unique within an account. The owner must be the owner of the existing bank asset account.
| Event | Declaration | Ledger effect |
|---|---|---|
| Deposit | { type: "deposit", amount } | Debit brokerage cash, credit the household bank account. |
| Withdrawal | { type: "withdrawal", amount } | Debit the household bank account, credit brokerage cash. |
| Purchase | { type: "purchase", amount } | Debit securities at cost, credit brokerage cash. |
| Sale | { type: "sale", proceeds, costBasis } | Debit cash for proceeds, credit securities for cost basis, and book the difference as a realized gain or loss. |
| Dividend | { type: "dividend", amount } | Debit brokerage cash, credit dividend income. |
| Interest | { type: "interest", amount } | Debit brokerage cash, credit interest income. |
| Fee | { type: "fee", amount } | Debit fee expense, credit brokerage cash. |
| Valuation | { type: "valuation", value } | Publish an observation without changing cost-basis assets or income. |
Sales explicitly provide cost basis so the account activity remains auditable; the pack does not select securities or infer basis. External deposits and withdrawals are separate from purchases, sales, dividends and fees. The facts are accounting inputs, not a tax assessment: the selected account type does not apply an annual tax rate, tax-year threshold, or assumed yield.