* chore: repo-wide bloat sweep, remove dead code and fold duplicate helpers
Remove 33 dead files, ~270 unreferenced exports/types, 13 dead i18n
namespaces and 4 unused dependencies; fold byte-identical helper copies
into one canonical home each (lib/utils chunk/sleep/utcDateStamp,
lib/dates/iso, lib/invariants/uuid, lib/xml/escape, lib/reports/sru/format,
lib/pdf/number-text, lib/browser/panel-request, lib/api/v1/body +
v1ValidationError rolled out to ~55 v1 routes, booking-template schemas).
No behaviour change: v1 bodies and status codes, MCP tool schemas, DB
writes and money math are untouched. Naive ore rounding was deliberately
not swapped for roundOre; see DECISIONS.md 2026-09-02 for the full list
of things left alone on purpose.
tsc, lint, 19588 unit tests and check:guards green; antipattern baseline
ratcheted (naive-ore-round 622 -> 620, hand-rolled-invariant 115 -> 113).
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
* test(transactions): import RawTransaction from @/types after the ingest re-export removal
CI's type ratchet (check:types, full tsconfig) caught the one test file
that still imported the type through lib/transactions/ingest.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
---------
Co-authored-by: Jakob Wennberg <311770904+jakobwennberg-oss@users.noreply.github.com>
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
Intl sv-SE formats negatives with U+2212, which the bundled react-pdf Helvetica/Courier fonts cannot render, so a loss printed as a profit. lib/pdf/number-text.ts pdfNumberText maps U+2212 to an ASCII hyphen and prints negative zero unsigned; routed through financial-statement, kassaflodesanalys, reskontra, momsdeklaration, payslip (fmt, the literal Preliminar skatt sign and the calculation formula text) and operational-report templates, with content-stream regression tests. The K2/K3 arsredovisning templates keep main's formatPdfKronor from #2013.
Closes#1982
Em dashes (—) and en dashes (–) had spread across comments, docs, tests,
and a few UI strings, reading as AI-generated boilerplate rather than
house style. Replaced each with punctuation matching its context: colon
for explanatory clauses, comma for asides, plain hyphen for numeric/legal
ranges (e.g. "21-23§"), "to"/"till" for date ranges, parentheses for
paired-dash asides. messages/en.json and messages/sv.json were fixed by
hand together to keep sv/en in sync.
Left untouched where the dash is the functional subject rather than
decorative punctuation: date-range-parser.ts's separator regex,
charset-repair.ts's CP1252 byte-mapping table (and its test), the SIE
encoding mojibake docs, generic-csv.ts's minus-sign normalizer, the
agent system-prompt files that already instruct against em dashes, and
a golden iXBRL test fixture compared byte-for-byte.
Also fixes two bugs surfaced along the way: an off-by-one in
ApiKeysPanel's scope-label split (a leftover from an earlier partial
pass), and a charset-repair test that had lost the literal en-dash it
exists to verify.
Regenerated the agent atom seed migration (skills:generate) since 27
SKILL.md files changed. Added a CLAUDE.md rule against em/en dashes,
with an explicit carve-out for the functional-dash cases above.
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
* feat: add bike benefit handling and optional vacation accrual
- Introduced bike benefit (cykelförmån) with calculations for annual market value and monthly taxable value.
- Updated schemas to include new benefit types and validation rules.
- Implemented API routes for creating, updating, and deleting employee benefits.
- Enhanced salary calculation logic to accommodate new vacation rule options, including a 'none' option for no accrual.
- Added UI components for managing employee benefits, including input for bike benefit specifics.
- Created database migrations for employee benefits and updated salary line items to support new benefit types.
* chore: remove Langfuse env var checks
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* feat: enhance OAuth callback URL handling and update default scopes for Visma integration
* feat: remove trade_name field and simplify company naming in invoices
* refactor: destructure canWrite from useCanWrite for consistency across components
* feat: enhance PATCH endpoint to validate existing benefits and handle bike benefit updates
* feat: add missing label for bike benefit in salary line item types
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* feat: copy voucher, MRU booking templates, and PDF export for reports
- Add "Kopiera verifikat" action on the journal-entry detail page that
prefills a new draft with the source entry's lines, description, and
notes. Date defaults to today so locked-period posts can't happen by
accident; source_type resets to manual.
- Track per-company MRU for booking_template_library rows via a new
booking_template_usage table (fire-and-forget touch endpoint hooked
into both pickers) and sort the list most-recently-used first for
the active company.
- Generate downloadable PDFs for balansräkning and resultaträkning
using the existing @react-pdf/renderer toolchain. Adds a reusable
parameterized template and two API routes, with download buttons
on the matching report views.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* fix: address PR review feedback on copy-voucher + report PDFs
Compliance review (Swedish accounting):
- Balance-sheet PDF now refuses to render when
tillgångar ≠ eget kapital och skulder; the stale "Differens" summary
row is gone. The on-screen view still surfaces the existing
"Balanserar ej" warning so users can diagnose the imbalance before
downloading. ÅRL 3 kap / K2 / K3 require exact balance.
- Both PDF routes now 400 when the requested fiscal period cannot be
resolved — identifiable period is part of räkenskapsinformation
under BFL 7 kap.
- Income-statement PDF adds the mandatory
"Resultat efter finansiella poster" subtotal when financial items
are present, per K2/K3 uppställningsform (ÅRL bilaga 2).
- Copy-voucher flow now shows a clear banner ("Kopia av verifikat X —
nytt, fristående verifikat skapas") so users cannot mistake the copy
for a rättelse/storno.
Code review (Greptile):
- New migration adds updated_at column + trigger to
booking_template_usage (project convention; applied to the
Supabase project).
- Replace localeCompare on ISO timestamps with plain relational
comparison to avoid any locale-dependent ordering.
- UUID-format validation on the copy_from query param before it goes
into the fetch URL.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* fix: second round of Swedish compliance fixes on report PDFs
- Balance-sheet PDF imbalance check now compares rounded-to-whole-kronor
totals (SFL 22:1 convention). The previous 0.5-öre tolerance could
reject a legitimate balance sheet when accumulated floating-point
noise across hundreds of ledger lines exceeded the threshold. The
on-screen view still surfaces the öre-precise "Balanserar ej" badge
for diagnostic visibility.
- Both PDFs now carry a prominent "Arbetsutkast — ej undertecknat"
notice per ÅRL 2 kap 7 §. Prevents a downloaded PDF from being
mistaken for or filed as an approved årsredovisning.
- Income-statement PDF now follows K2/K3 uppställningsform
(ÅRL bilaga 2) by splitting class 8 into three blocks with named
subtotals: Finansiella poster (80–84), Bokslutsdispositioner (88),
Skatter (89). The summary now always shows a "Skatt på årets
resultat" row so the reader can verify the tax calculation, and
adds "Resultat efter finansiella poster" / "Bokslutsdispositioner"
subtotals when each block is present.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* fix: harden report PDFs against out-of-band filing + future BAS growth
- Append "-utkast" to downloaded PDF filenames. The filename survives the
PDF's disclaimer context — a file named balansrakning-2026-01-01.pdf
in a Downloads folder or forwarded attachment is ambiguous, whereas
balansrakning-2026-01-01-utkast.pdf makes the draft status legible
even without opening the document.
- Add a catch-all "Övriga finansiella poster" bucket in the
income-statement PDF for any class-8 section whose account prefix
isn't one of the known K2/K3 blocks (80–84 / 88 / 89). Counted in
the "Resultat efter finansiella poster" subtotal so arithmetic stays
consistent. Future-proofs the PDF against a generator change that
starts emitting 85–87 sections.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>