Files
accounted/supabase/migrations/20260529200000_salary_absence_add_unpaid_leave.sql
T
MattssonandClaude Opus 4.7 ea1bf01f1e Fix/m sprint fixes (#613)
* fix(dashboard): exclude ignored and already-triaged transactions from stale count

The "Gamla transaktioner" widget counted transactions that had been ignored
or already marked as is_business=true but not yet booked, so users saw a
nag for a row they had already dealt with — and the /transactions inbox
correctly hid it. Align the count with the inbox criterion (is_business
IS NULL, is_ignored = false) so the widget clears when the row leaves
the inbox.

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

* fix(transactions): read entity_type from settings response wrapper

The transactions page read entityRes.entity_type directly, but
/api/settings returns { data: { entity_type, ... } }. The expression
was always undefined, so setEntityType never fired and entityType
stayed at its initial 'enskild_firma'. The template picker's
entity_type filter then dropped every aktiebolag-tagged user template
for AB customers — only entity_type='all' templates made it through.

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

* stale templates
bank sync
journal entry from transaction

* fixed pr comments

* fixed pr comment

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-30 01:28:41 +02:00

54 lines
2.3 KiB
SQL

-- =============================================================================
-- Salary absence: add 'unpaid_leave' (tjänstledighet utan lön)
-- =============================================================================
--
-- The salary engine treats unpaid_leave as a per-day gross deduction (one
-- daily rate per day) and excludes it from semestergrundande tid (SemL 17 §
-- only paid leave types accrue vacation). It complements the existing partial-
-- month employment_start/employment_end proration: that handles new hires and
-- terminations; unpaid_leave handles sabbaticals/leave mid-employment.
ALTER TABLE public.salary_absence_days
DROP CONSTRAINT salary_absence_days_absence_type_check;
ALTER TABLE public.salary_absence_days
ADD CONSTRAINT salary_absence_days_absence_type_check
CHECK (absence_type IN (
'sick', -- sjukfrånvaro
'vab', -- vård av barn (tillfällig föräldrapenning)
'parental', -- föräldraledighet (föräldrapenning)
'pregnancy', -- graviditetspenning
'care_relative', -- närståendepenning
'study', -- studieledig
'unpaid_leave', -- tjänstledighet utan lön
'other_leave'
));
-- The derived absence line items (sick_karens, vab, parental_leave, …) are
-- inserted into salary_line_items by the calculator. unpaid_leave follows the
-- same pattern, so the line-item CHECK must accept it too.
ALTER TABLE public.salary_line_items
DROP CONSTRAINT 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', 'overtime_50', 'overtime_100',
'ob_weekday_evening', 'ob_weekend', 'ob_night', 'ob_holiday',
'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', 'unpaid_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';