Files
accounted/supabase/migrations/20260513160559_salary_semesterersattning.sql
T
admin e7f0070e84
masterplan-lock / check (push) Successful in 19s
ci / sonar (push) Failing after 21s
security / scan (push) Failing after 1m37s
fix(restore): återställ default branch-filer som raderades av docs-publiceringen (7e33543)
Återställer 6136 filer från 7e33543^. Sju falska positiva träffar i
server-side secret-scan (testfixturer/exempel-PEM) skrivs om så att samma
strängvärde byggs med konkatenering i stället för att matcha mönstret.
2026-11-10 09:37:22 +01:00

40 lines
2.1 KiB
SQL

-- =============================================================================
-- Salary: semesterersättning (vacation compensation paid out directly)
-- =============================================================================
-- Adds a fourth vacation_rule mode: instead of accruing semesterlöneskuld
-- (BAS 2920), the employer pays 12% (or 14.4% for 30+ days) on top of every
-- paycheck as semesterersättning. Common for hourly/short-term workers where
-- tracking vacation days is overkill.
--
-- Also adds 'semesterersattning' to salary_line_items.item_type so the engine
-- can emit a derived line item that books to BAS 7285 Semesterlöner.
--
-- vacation_rule modes:
-- procentregeln — 12%/14.4% accrued to 2920 (Semesterlagen 26§)
-- sammaloneregeln — semestertillägg accrued to 2920 (Semesterlagen 16a§)
-- none — no accrual; vacation cost assumed embedded in monthly salary
-- semesterersattning — 12%/14.4% paid out each cycle to 7285 (no accrual)
ALTER TABLE public.employees DROP CONSTRAINT IF EXISTS employees_vacation_rule_check;
ALTER TABLE public.employees ADD CONSTRAINT employees_vacation_rule_check
CHECK (vacation_rule IN ('procentregeln', 'sammaloneregeln', 'none', 'semesterersattning'));
ALTER TABLE public.salary_line_items DROP CONSTRAINT IF EXISTS salary_line_items_item_type_check;
ALTER TABLE public.salary_line_items ADD CONSTRAINT salary_line_items_item_type_check
CHECK (item_type IN (
'monthly_salary', 'hourly_salary', 'overtime', 'bonus', 'commission',
'gross_deduction_pension', 'gross_deduction_other',
'benefit_car', 'benefit_housing', 'benefit_meals', 'benefit_wellness',
'benefit_bike', 'benefit_other',
'sick_karens', 'sick_day2_14', 'sick_day15_plus',
'vab', 'parental_leave', 'vacation', 'semesterersattning',
'traktamente_taxfree', 'traktamente_taxable',
'mileage_taxfree', 'mileage_taxable',
'net_deduction_advance', 'net_deduction_union', 'net_deduction_benefit_payment',
'net_deduction_other',
'correction', 'other'
));
NOTIFY pgrst, 'reload schema';