alfjesus 3f422b9dc8 fix(bookkeeping): restore Swedish characters in seed_chart_of_accounts (#510)
* fix(bookkeeping): restore Swedish characters in seed_chart_of_accounts

  The seed function for new companies' chart of accounts was written with
  every å/ä/ö/Å/Ä/Ö stripped from its SQL string literals — 'Arets
  resultat' instead of 'Årets resultat', 'Avrakning socialavgifter'
  instead of 'Avräkning socialavgifter', 'Utgaende moms forsaljning' on
  the VAT accounts, and so on. Every new company has been getting 24
  starter rows with mangled Swedish names visible in the UI, reports,
  and SIE exports.

  SIE-imported accounts were unaffected because that path reads names
  from lib/bookkeeping/bas-data/. Only seeded rows looked wrong, which
  is why "SRU-mapped" imports rendered correctly while the seeded
  baseline did not.

  Diacritics are restored on the 24 affected names. The seed's
  K1-friendly short forms are kept ('Varuinköp', not BAS-canonical
  'Inköp av handelsvaror (gruppkonto)') — only the spelling is fixed.

  Two adjacent improvements in the same function definition:

  - sru_code is now populated on every seeded row from BAS reference
    data. Previously NULL on seeded rows, which broke SRU/INK2 tax
    filing for users who never import a SIE file.
  - SET search_path = public pins resolution inside the function body,
    closing Supabase linter 0011. This attribute was silently dropped
    when the seed was DROP/REPLACE'd in 20260330130000 and again in
    20260513120100 without re-declaring it.

  Existing companies are intentionally not backfilled. Only new
  companies created from this point see the fix.

  Verified with extended pg-test (9 cases, including the 2 pre-existing
  canaries) at supabase/migrations/__tests__/seed-chart-of-accounts.pg.test.ts.

  Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* fix(bookkeeping): address greptile review on PR #510

- NULL out sru_code for enskild_firma equity accounts (2010, 2013, 2018).
  BAS reference maps these to INK2 SRU 7221 ("Övrigt eget kapital"), but
  EF entities file NE-bilaga instead. Emitting `#SRU 2013 7221` in SIE
  exports would steer downstream tax software to report owner drawings
  as balance-sheet equity, which is wrong for sole traders.
- Re-add GRANT EXECUTE ON FUNCTION ... TO authenticated, restoring the
  privilege silently dropped by each DROP+CREATE since 20260330130000.
  Application paths via service-role bypass RLS and didn't break, but
  direct RPC calls from the authenticated role had been failing with
  permission errors since 2026-03-30.
- Test: lock in sru_code = NULL on the three EF equity rows.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* fix(migrations): rename to avoid timestamp collision with PR #508

20260516120000 was already taken by assets_and_depreciation from PR #508
once that merged to main. schema_migrations uses the timestamp as primary
key, so `supabase db reset` fails with a duplicate-key error when both
files share a version.

Bump to 20260516130000 to slot between assets_and_depreciation (120000)
and depreciation_schedules_updated_at (140000).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-06-08 09:41:39 +02:00
2026-06-08 07:37:24 +02:00
2026-06-08 07:37:24 +02:00
2026-06-05 17:26:40 +02:00
2026-05-06 11:12:02 +02:00
2026-04-22 15:33:04 +02:00
2026-05-28 15:43:48 +02:00
2026-05-22 12:22:15 +02:00

Accounted

Open-source Swedish accounting software for sole traders (enskild firma) and limited companies (aktiebolag).

License: AGPL-3.0-or-later

What is Accounted?

Accounted implements double-entry bookkeeping compliant with Swedish accounting law (Bokforingslagen). It supports the BAS 2026 chart of accounts, handles VAT declarations (momsdeklaration), SIE import/export, and enforces 7-year document retention. Built for sole traders and limited companies operating in Sweden.

Features

  • Double-entry bookkeeping -- BAS 2026 chart of accounts, draft/commit workflow, sequential voucher numbering
  • Invoicing -- Create, send, and track invoices with mixed VAT rates and PDF generation
  • Bank reconciliation -- PSD2 bank connection via Enable Banking, 4-pass automatic matching
  • VAT declaration -- SKV 4700 form mapping, per-rate breakdown, EU/export handling
  • Tax reports -- NE-bilaga, INK2, SRU export for Skatteverket
  • Supplier invoices -- Registration, payment tracking, input VAT deduction
  • Document archive -- SHA-256 integrity, 7-year retention enforcement, full archive ZIP export
  • SIE import/export -- Standard Swedish accounting interchange format
  • Extension system -- Opt-in plugins for AI categorization, receipt OCR, email, calendar, and more

Self-Hosting

git clone https://github.com/erp-mafia/gnubok.git
cd Accounted
./setup.sh              # Prompts for Supabase credentials, generates .env
docker compose up -d

You need a Supabase project and must apply the database migrations before first use. See SELF-HOSTING.md for the full step-by-step guide, including Supabase setup, auth configuration, optional features (AI, email, push notifications), and troubleshooting.

Development Setup

Prerequisites: Node.js 20+, a Supabase project.

npm install
npm run dev       # Start dev server (auto-generates extension registry)
npm test          # Run tests
npm run build     # Production build
npm run lint      # ESLint

Tech Stack

  • Framework: Next.js 16 (App Router), React 19, TypeScript (strict)
  • Database: Supabase (PostgreSQL + Row Level Security + email/password auth + TOTP MFA)
  • Styling: Tailwind CSS 4 + shadcn/ui
  • Integrations: Enable Banking (PSD2), Anthropic SDK, LangChain, OpenAI, Resend, JSZip

Documentation

  • SELF-HOSTING.md -- Full self-hosting guide (Docker, Supabase setup, migrations, optional features)
  • CLAUDE.md -- Architecture, bookkeeping engine, database conventions, extension system
  • CONTRIBUTING.md -- Development workflow, code style, pull request process
  • SECURITY.md -- Vulnerability reporting policy

Contributing

Contributions are welcome. See CONTRIBUTING.md for the full guide.

All commits require a DCO sign-off (git commit -s).

License

AGPL-3.0-or-later with an extension exception: third-party extensions that interact solely through the documented Extension API may be licensed under any terms, including proprietary. See LICENSE for details and NOTICE for third-party attributions.

S
Description
Accounted — svensk bokföringsmotor (AGPL, BAS 2026, BFL-compliant, 150+ MCP tools). Finance-kapacitet brevet ERPNext. ADR-ENGAGEMENT-001-tillägg.
Readme AGPL-3.0 56 MiB
Languages
TypeScript 93%
PLpgSQL 5.8%
JavaScript 0.4%
HTML 0.3%
MDX 0.2%
Other 0.1%