Skip to content

TheJonaz/Booksky

Repository files navigation

Booksky

Svenska översättning längst ner ↓

Cloud-based bookkeeping for Swedish businesses, built from the ground up to the Swedish Bookkeeping Act (Bokföringslagen 1999:1078).

A lightweight general ledger with double-entry accounting, the Swedish BAS chart of accounts, and SIE 4 import/export. Posted vouchers are immutable — protected by a SHA-256 hash chain and an append-only audit log. No floats: everything is counted in öre (1/100 of a krona).


What's done

Phase Scope Status
1 Chart of accounts (BAS 2024), manual vouchers, balance & income statement, live debit/credit validation done
2 Immutability via DB triggers, SHA-256 hash chain, attachments (dedup), audit log, correcting vouchers done
3 SIE 4 import/export, PC8 (CP437) and UTF-8, round-trip tests done
4 Invoices + PDF planned
5 VAT (report + codes) planned
6 OCR / receipt scanning planned
Auth + multi-tenant, hosting template planned

Stack

Layer Tech
UI & server SvelteKit 2 / Svelte 5 (runes), adapter-node
Database PostgreSQL 16 + Drizzle ORM
Language TypeScript on Node 22
Tests node --test via tsx

Quick start

npm install
npm run db:up         # Postgres in Docker
npm run db:push       # schema + triggers
npm run db:seed       # BAS 2024 + demo company
npm run dev           # http://localhost:5173/bokföring/
npm test              # core package

Accounting principles, baked into the code

  • Money in öre. All amounts are integers (bigint in Postgres, bigint in code) — no float drift.
  • Debit = credit. validateVoucher() refuses to save an unbalanced voucher.
  • Draft → posted. Posted vouchers are locked by Postgres triggers. To change them you create a correcting voucher that reverses the original, linked via corrects_voucher_id.
  • Hash chain. Each posted voucher is hashed together with the previous one's hash (SHA-256, per series). The chain can be verified live at /bokföring/integrity.
  • Audit log. Append-only via DB trigger; shown in the voucher's detail view.

Repo layout

apps/
  web/                SvelteKit app (base path /bokföring)
    landing/          Static marketing page (served at /booksky-ui/)
    deploy/           systemd unit, Caddyfile, nginx snippet, install scripts
    server.js         prod server around the adapter-node handler
packages/
  core/               öre-based money, voucher validation, hash chain, reports, SIE
  db/                 Drizzle schema, BAS 2024 seed, Postgres client
docker-compose.yml    local Postgres on 127.0.0.1:5433

Production deploy

The app runs behind nginx via a systemd service listening on 127.0.0.1:3100. See apps/web/deploy/:

  • booksky.service — systemd unit (PORT, ORIGIN, EnvironmentFile)
  • setup-nginx.sh — idempotent script that adds a /bokföring proxy and a /booksky-ui/ static alias to an existing nginx config
  • Caddyfile — alternative if you'd rather run Caddy instead of nginx

Shortcut:

npm run build -w @booksky/web
sudo bash apps/web/deploy/setup-nginx.sh

License

Not yet decided.


Svenska

Molnbaserad bokföring för svenska företag, byggd från grunden enligt Bokföringslagen (1999:1078).

Lättviktig huvudbok med dubbel bokföring, BAS-kontoplan och SIE-import/export. Verifikationer är oföränderliga efter bokföring — säkrade med SHA-256 hash-kedja och en append-only audit-logg. Inga flyttal: allt räknas i öre.

Vad är klart

Fas Innehåll Status
1 Kontoplan (BAS 2024), manuell verifikation, balans/resultat, realtidsvalidering klart
2 Oföränderlighet via DB-triggers, SHA-256 hash-kedja, bilagor (dedup), audit-logg, rättelseverifikationer klart
3 SIE 4 import/export, PC8 (CP437) + UTF-8, round-trip-tester klart
4 Fakturor + PDF planerad
5 Moms (rapport + koder) planerad
6 OCR / kvittotolkning planerad
Auth + multi-tenant, hosting-mall planerad

Stack

Lager Teknik
UI & server SvelteKit 2 / Svelte 5 (runes), adapter-node
Databas PostgreSQL 16 + Drizzle ORM
Språk TypeScript på Node 22
Test node --test via tsx

Snabbstart

npm install
npm run db:up         # Postgres i Docker
npm run db:push       # schema + triggers
npm run db:seed       # BAS 2024 + demo-bolag
npm run dev           # http://localhost:5173/bokföring/
npm test              # core-paketet

Bokföringsprinciper i koden

  • Belopp i öre. Alla pengar är heltal (bigint i Postgres, bigint i koden) — inga flyttalsfel.
  • Debet = kredit. validateVoucher() vägrar spara obalanserade verifikationer.
  • Utkast → bokfört. Bokförda verifikationer låses av postgres-triggers. Ändras de? Nej — du skapar en rättelseverifikation som motbokar, länkad via corrects_voucher_id.
  • Hash-kedja. Varje bokförd verifikation hashas tillsammans med föregåendes (SHA-256, per serie). Kedjan kan verifieras live på /bokföring/integrity.
  • Audit-logg. Append-only via DB-trigger; visas i verifikationens detaljvy.

Struktur

apps/
  web/                SvelteKit-appen (base path /bokföring)
    landing/          Statisk hemsida (serveras på /booksky-ui/)
    deploy/           systemd-unit, Caddyfile, nginx-block, install-skript
    server.js         prod-server runt adapter-node-handlern
packages/
  core/               öre-pengar, voucher-validering, hash, rapporter, SIE
  db/                 Drizzle-schema, BAS 2024-seed, Postgres-klient
docker-compose.yml    lokal Postgres på 127.0.0.1:5433

Production-deploy

Appen körs bakom nginx via en systemd-tjänst som lyssnar på 127.0.0.1:3100. Se apps/web/deploy/:

  • booksky.service — systemd-unit (PORT, ORIGIN, EnvironmentFile)
  • setup-nginx.sh — idempotent script som lägger till /bokföring-proxy och /booksky-ui/-statisk-alias i en befintlig nginx-konfig
  • Caddyfile — alternativ om man hellre kör Caddy istället för nginx

Snabbväg:

npm run build -w @booksky/web
sudo bash apps/web/deploy/setup-nginx.sh

Licens

Ej fastställd ännu.

About

Svensk bokföringstjänst (BFL) — dubbel bokföring, BAS-kontoplan, SIE-import/export och SHA-256 hash-kedja. SvelteKit + Postgres.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors