feat(salary): let an enskild firma employ staff while blocking owner/board payroll (#797)

An enskild firma that hires staff should get the payroll module, but its owner
or board can never be on payroll (owner compensation is egna uttag / BAS 2013,
not lön).

- Migration 20260628120000 adds the enforce_ef_no_owner_employee trigger
  (BEFORE INSERT OR UPDATE OF employment_type) as the all-paths backstop.
- lib/salary/employment-rules.ts is the app-layer mirror (forbidden set kept
  byte-identical to the trigger); getCompanyEntityType() resolves the same
  company_settings -> companies precedence.
- The two UI salary routes and the v1 POST guard before insert/update for a
  clean 400 with guidance.
- Payroll nav + Lön settings now show for any employer (aktiebolag OR
  company_settings.pays_salaries), wired through the dashboard layout.

Fixes #782.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jakob Wennberg
2026-06-26 15:30:03 +02:00
committed by GitHub
co-authored by Claude Opus 4.8
parent 5bacda4839
commit 55ba66908b
13 changed files with 326 additions and 13 deletions
+1 -1
View File
@@ -1162,7 +1162,7 @@
"vacation_supplement_cba": "0.80% (common collective agreement level)",
"vacation_supplement_help": "Applied with sammalöneregeln. Can be overridden per employee.",
"info_heading": "Information",
"info_payroll_scope": "The payroll module handles salaries for aktiebolag. Enskild firma owners use eget uttag instead.",
"info_payroll_scope": "The payroll module handles salaries for your employees – tax deductions, employer contributions, vacation pay liability and the employer declaration (AGI). If you run a sole proprietorship (enskild firma), you as the owner take money out via owner's drawings (account 2013), not salary – the module is for your employees.",
"info_current_year": "<strong>Current year:</strong> 2026 — Arbetsgivaravgifter 31.42%, prisbasbelopp 59,200 SEK"
},
"settings_backup": {
+1 -1
View File
@@ -1162,7 +1162,7 @@
"vacation_supplement_cba": "0,80% (vanligt kollektivavtalsbelopp)",
"vacation_supplement_help": "Tillämpas vid sammalöneregeln. Kan ändras per anställd.",
"info_heading": "Information",
"info_payroll_scope": "Lönemodulen hanterar löner för aktiebolag. Enskild firma-ägare använder eget uttag istället.",
"info_payroll_scope": "Lönemodulen hanterar löner till dina anställda – skatteavdrag, arbetsgivaravgifter, semesterlöneskuld och arbetsgivardeklaration (AGI). Driver du enskild firma tar du som ägare ut pengar via eget uttag (konto 2013), inte lön – modulen är till för dina anställda.",
"info_current_year": "<strong>Aktuellt år:</strong> 2026 — Arbetsgivaravgifter 31,42 %, prisbasbelopp 59 200 SEK"
},
"settings_backup": {