c74b19df1b
* feat(reconciliation): close the bank-feed loop on voucher links and re-tag mis-typed opening balances
Two related fixes to bank reconciliation correctness:
1. Auto-reconcile on voucher link. Linking an invoice or supplier invoice to
an existing voucher previously advanced only the invoice — the bank
transaction that paid it kept sitting in the Transactions inbox with a null
journal_entry_id. linkInvoiceToVoucher / linkSupplierInvoiceToVoucher now
call autoReconcileTransactionForLinkedVoucher (lib/reconciliation), which
links the bank transaction to the same verifikat when exactly one unbooked
line matches it. Best-effort and post-commit: a failure here never fails the
link. The result surfaces reconciledTransactionId; the inbox row leaves the
list and the UI shows link_success_tx_reconciled.
2. Re-tag mis-typed opening balances. getReconciliationStatus and the GL-line
matching RPCs identify a cash account's ingående balans solely by
journal_entries.source_type='opening_balance'. Companies migrated from other
systems often booked the bank IB as an ordinary voucher (source_type
'import' or 'manual'), so it was never excluded and surfaced as a phantom
reconciliation difference equal to the opening balance. Adds:
- migration mark_entry_as_opening_balance: a GUC-gated carve-out in the
immutability trigger plus a SECURITY DEFINER RPC that validates the entry
(balance-sheet lines only, dated on a fiscal-period boundary), flips the
source_type, and writes an audit row — no blanket data sweep.
- POST /api/reconciliation/bank/mark-opening-balance + MarkOpeningBalanceSchema.
- BankReconciliationView action to trigger it from the IB diff.
The gnubok_create_voucher executor now accepts a typed is_opening_balance flag
and derives source_type='opening_balance' only after validating class 1/2 lines
on the period start, so new IBs land correctly typed.
Covered by lib/reconciliation auto-reconcile tests, voucher-executors tests,
and a mark-entry-as-opening-balance pg-real test.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* chore: rebrand gnubok → Accounted and prune swarm agent skills
Product rebrand and skills housekeeping. No runtime behaviour change.
Rebrand: replace user-visible "gnubok" with "Accounted" across docs, READMEs,
in-code comments, doc-site content, MCP skill/resource prose, and the
gnubok-mcp package description. The MCP resource URI scheme is moved gnubok://
→ Accounted:// consistently across resource registrations, the event-type
comment, and the resource/skill tests. Deliberately preserved as stable
identifiers (NOT rebranded): the gnubok-company-id cookie, gnubok_sk_ / gnubok_inv_
token prefixes, the gnubok-mcp npm bridge name, and the AGI <gem:Programnamn>
value (kept 'gnubok' per its source comment — it is the software identifier sent
to Skatteverket and must not churn across visual rebrands).
Skills: remove the 27 swarm-* agent SKILL.md atoms (no longer used; already
absent from the agent_atom_registry in prod), refresh the remaining skill docs,
add the .claude/rules/ path-scoped rule set, and regenerate the
seed_agent_atom_bodies migration + .skill-body-manifest.json via
`npm run skills:generate` so the DB-backed skill bodies match the trimmed set.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
3.7 KiB
3.7 KiB
id, tier, title, description, trigger_signals, version
| id | tier | title | description | trigger_signals | version | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| modifier/single-shareholder-ab-fmb | modifier | Aktiebolag med en aktieägare (fåmansbolag) | Aktiebolag där en fysisk person äger > 50% av kapitalet (eller där < 4 personer tillsammans äger > 50%) klassas som fåmansbolag och omfattas av 3:12-reglerna. Den enskilda ägaren är samtidigt anställd ("verksam i betydande omfattning") och styr själv balansen mellan lön och utdelning. Avgörande för ekonomin men trivialt i löpande bokföring — modifern flaggar för agenten att 3:12, gränsbelopp, K10 och löneunderlagsregeln måste vara med i rådgivningen. |
|
1 |
POC test content. Replace with deep research material before relying on this for production-quality advice.
Single-shareholder AB (fåmansbolag)
When this applies
The active company is an aktiebolag where one natural person owns > 50% of the shares. This is the most common form among Accounted's AB users. The owner is typically also a full-time anställd in the company and "verksam i betydande omfattning" — which triggers 3:12-reglerna (53 kap. IL).
This modifier composes with:
- horizontal/swedish-tax-planning — for 3:12, gränsbelopp, löneunderlag detail
- horizontal/swedish-payroll — for owner-as-employee salary mechanics
- horizontal/swedish-year-end-closing — for resultatdisposition (lön vs. utdelning)
- horizontal/swedish-financial-reporting — för K2/K3-årsredovisning
Implications
- Lön vs. utdelning: ägaren styr själv. Under gränsbeloppet beskattas utdelning som kapital (20%). Över gränsbeloppet beskattas det överskjutande som tjänsteinkomst (kommunal + statlig + arbetsgivaravgifter — högsta marginalskatt). Lön ger socialförsäkringsrätt och pension; utdelning gör det inte.
- Löneunderlagsregeln (3:12-reglernas favorit): genom att ägaren tar ut minst en viss årslön (cirka 6 IBB + 5% av total löneunderlag, max 9,6 IBB) adderas en stor del av bolagets totala lönesumma till gränsbeloppet.
- K10: ägaren ska lämna K10-blankett varje år där gränsbelopp, sparade utdelningsutrymmen och utdelningen själv redovisas.
- 2026-års 3:12-reform: vissa parametrar är reviderade (löneunderlag, förenklingsregel). Verifiera mot aktuell version av swedish-tax-planning innan konkret rådgivning.
BAS-konton
| Konto | Användning |
|---|---|
| 2091 | Balanserad vinst eller förlust (utdelningsutrymme efter bokslut) |
| 2098 | Vinst eller förlust föregående år (innan resultatdisposition) |
| 2099 | Årets resultat (innan bokslutsdisposition) |
| 2898 | Outtagen vinstutdelning till delägare |
| 2899 | Övriga skulder till delägare (t.ex. revers från ägartillskott) |
| 7210 | Lön till företagsledare (ofta separat från andra löner för K10-spår) |
| 7510 | Arbetsgivaravgifter på 7210 |
Regulatoriska kantfall
- Förbjudet lån från bolaget (21 kap. ABL): ägaren får inte låna pengar av bolaget. Bryts förbudet beskattas hela lånet som tjänsteinkomst (53 kap. IL).
- Stoppregler för uthyrning av bostad till eget bolag: marknadshyra och saklig grund krävs.
- Karens vid avstämning av karensbolag: när bolaget vilar måste det vila i 5 hela kalenderår innan ägaren kan ta ut ackumulerade gränsbelopp som kapitalinkomst utan tjänstebeskattning.
- Närståendetransaktioner: utdelning till barn/make beräknas mot ägarens K10, inte mottagarens.
References
- See
references/k10-walkthrough.mdfor a step-by-step K10 example (TODO — user to author). - See
references/loneunderlag-2026.mdfor the 2026 reformed parameters (TODO — user to author).