3f422b9dc8
* fix(bookkeeping): restore Swedish characters in seed_chart_of_accounts
The seed function for new companies' chart of accounts was written with
every å/ä/ö/Å/Ä/Ö stripped from its SQL string literals — 'Arets
resultat' instead of 'Årets resultat', 'Avrakning socialavgifter'
instead of 'Avräkning socialavgifter', 'Utgaende moms forsaljning' on
the VAT accounts, and so on. Every new company has been getting 24
starter rows with mangled Swedish names visible in the UI, reports,
and SIE exports.
SIE-imported accounts were unaffected because that path reads names
from lib/bookkeeping/bas-data/. Only seeded rows looked wrong, which
is why "SRU-mapped" imports rendered correctly while the seeded
baseline did not.
Diacritics are restored on the 24 affected names. The seed's
K1-friendly short forms are kept ('Varuinköp', not BAS-canonical
'Inköp av handelsvaror (gruppkonto)') — only the spelling is fixed.
Two adjacent improvements in the same function definition:
- sru_code is now populated on every seeded row from BAS reference
data. Previously NULL on seeded rows, which broke SRU/INK2 tax
filing for users who never import a SIE file.
- SET search_path = public pins resolution inside the function body,
closing Supabase linter 0011. This attribute was silently dropped
when the seed was DROP/REPLACE'd in 20260330130000 and again in
20260513120100 without re-declaring it.
Existing companies are intentionally not backfilled. Only new
companies created from this point see the fix.
Verified with extended pg-test (9 cases, including the 2 pre-existing
canaries) at supabase/migrations/__tests__/seed-chart-of-accounts.pg.test.ts.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* fix(bookkeeping): address greptile review on PR #510
- NULL out sru_code for enskild_firma equity accounts (2010, 2013, 2018).
BAS reference maps these to INK2 SRU 7221 ("Övrigt eget kapital"), but
EF entities file NE-bilaga instead. Emitting `#SRU 2013 7221` in SIE
exports would steer downstream tax software to report owner drawings
as balance-sheet equity, which is wrong for sole traders.
- Re-add GRANT EXECUTE ON FUNCTION ... TO authenticated, restoring the
privilege silently dropped by each DROP+CREATE since 20260330130000.
Application paths via service-role bypass RLS and didn't break, but
direct RPC calls from the authenticated role had been failing with
permission errors since 2026-03-30.
- Test: lock in sru_code = NULL on the three EF equity rows.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* fix(migrations): rename to avoid timestamp collision with PR #508
20260516120000 was already taken by assets_and_depreciation from PR #508
once that merged to main. schema_migrations uses the timestamp as primary
key, so `supabase db reset` fails with a duplicate-key error when both
files share a version.
Bump to 20260516130000 to slot between assets_and_depreciation (120000)
and depreciation_schedules_updated_at (140000).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>