1e91c126ff
The Transaktioner inbox lists unbooked skattekonto rows next to unbooked bank rows, but the sidebar badge and the Hem "Att göra" list counted bank rows only, so a migrated tax account waited in the inbox unseen. - lib/worklist: new category book_skattekonto with the inbox's own predicate (status = 'booked', no verifikat, not ignored); aggregate includes it in counts and total. - Hem: a "Bokföra skattekontohändelser" row under Bokför, deep-linking to /transactions?source=skatteverket. - Sidebar badge hook: the same third head-count query, summed into the /transactions badge. - DashboardNav subscribes to skattekonto_transactions realtime changes; migration adds the table to the supabase_realtime publication so a booked or ignored row drops the badge without a manual refresh. Closes #2180 Claude-Session: https://claude.ai/code/session_01QPQLwHNEiQfiCNLSMzXMiQ Co-authored-by: Jakob Wennberg <311770904+jakobwennberg-oss@users.noreply.github.com> Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
28 lines
1.0 KiB
SQL
28 lines
1.0 KiB
SQL
-- Migration: stream skattekonto_transactions changes via Supabase realtime
|
|
--
|
|
-- The sidebar "Att göra" badge now counts unbooked skattekonto rows next to
|
|
-- unbooked bank transactions (#2180), and DashboardNav listens to
|
|
-- postgres_changes on public.skattekonto_transactions so a booked or
|
|
-- ignored tax-account row drops the badge without a manual refresh, the
|
|
-- same way public.transactions already does (20260629180000).
|
|
--
|
|
-- RLS already scopes skattekonto_transactions to the user's companies, so
|
|
-- realtime only delivers rows the current user is allowed to read.
|
|
--
|
|
-- Idempotent so preview branches or partial re-applies do not fail if the
|
|
-- publication already includes the table.
|
|
DO $$
|
|
BEGIN
|
|
IF NOT EXISTS (
|
|
SELECT 1
|
|
FROM pg_publication_tables
|
|
WHERE pubname = 'supabase_realtime'
|
|
AND schemaname = 'public'
|
|
AND tablename = 'skattekonto_transactions'
|
|
) THEN
|
|
ALTER PUBLICATION supabase_realtime ADD TABLE public.skattekonto_transactions;
|
|
END IF;
|
|
END $$;
|
|
|
|
NOTIFY pgrst, 'reload schema';
|