Files
accounted/package.json
T
Mattsson 9dbaebcc50 fix(invoices): ROT/RUT credit notes; verifikat amount sort, HTML underlag, source chip (#1523)
* feat(invoice-inbox): store HTML mails as underlag, expandable field editor

Body-only mails and .html attachments (including forwarded .eml bodies) no
longer dead-end as "Fel vid bearbetning": the mail body is wrapped into a
self-contained text/html document, stored through the normal upload/extract
pipeline, and extracted via a new HTML-to-text Bedrock path, so the mail
itself can serve as bookable underlag. Empty mails keep the error row,
unsupported types are still rejected, and webhook retries dedupe on
resend_email_id.

Mail HTML is attacker-controlled, so rendering is fully sandboxed: iframe
sandbox in the workspace preview and a CSP sandbox header on
/api/documents/:id/inline for text/html. The type is accepted only from the
email pipeline (EMAIL_ALLOWED_MIME_TYPES), never from manual upload.

The "Extraherade falt" rail gains an expand button opening a centered
dialog with the same autosaving field editor at a readable size (two
columns), which also gives every failed or skipped extraction a manual
fallback.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* feat(bookkeeping): sortable verifikat list headers with amount sort

- clickable sort toggles on the verifikat list headers (asc -> desc -> default)
- total_amount computed column + sort_by total/description on the list route
- failed list loads render an error card with retry, never the empty-ledger state

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* fix(import): decode bank CSV as Windows-1252 fallback in column mapping

The client read the uploaded file with file.text(), which is UTF-8-only,
so Windows-1252 exports (e.g. Handelsbanken) rendered and re-parsed with
U+FFFD in place of Swedish characters. Decode from bytes with the shared
decodeFileContent() helper, matching what the server parse route does.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* feat(bookkeeping): stackable sort keys on verifikat list headers

- shift-click adds a column as secondary/tertiary sort key (max 3), plain
  click keeps the single-key tri-state cycle
- sort_by accepts a comma-separated priority list; single tokens stay valid
- voucher tiebreak follows the last key's direction (#972 parity)
- priority numbers on stacked headers; hint text in the filter dialog

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* fix(invoices): keep ROT/RUT deduction fields positive on credit notes

Crediting an invoice with a ROT/RUT deduction failed 100% of the time:
the credit-note path negated deduction_total (and per-item
deduction_amount) like the other amounts, but both columns carry
CHECK (>= 0), so Postgres rejected the insert and the user only saw
'Kunde inte skapa kreditfaktura'.

Store the deduction fields as positive magnitudes, matching the
convention everywhere else. The stored sign is inert on credit notes:
the reversing verifikat recomputes the ROT/RUT split from the items,
and the PDF and amount-to-pay logic skip deductions on credit notes.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* refactor(transactions): share the source chip across inbox and history modes

Move SourceFilter to transaction-types.ts (widened with 'bank:other' and
'acct:<id>'), render the one toolbar ContextPicker in both view modes,
and drop the narrower duplicate chip inside TransactionHistoryList. The
history list now applies the acct:/bank:other narrowing itself and hides
skattekonto rows under any bank-side selection.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* chore(deps): bump js-yaml to 4.3.1

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* test(schema): recognize PostgREST computed columns in the migration parser

The verifikat amount sort orders by total_amount, a PostgREST computed
column (a function on the journal_entries row type, migration
20260811100000). The schema guard only modeled real columns, so
no-phantom-columns flagged the order as a phantom.

Teach the parser that a function whose only argument is a table's row
type joins that table's column set, with DROP FUNCTION retraction when
the signature names the row type.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* fix: resolve PR #1523 review findings

- journal-entries route: append the globally unique id tiebreak to every
  direct-query sort; voucher series+number repeat across fiscal years, so
  the all-years scope could duplicate or drop rows at page boundaries.
  Existing order assertions updated, new all-years tiebreak test.
- documents inline route: CSP source policy on HTML previews; sandbox
  alone still loads remote resources, letting a tracking pixel notify the
  sender on open. New route test asserts the full header.
- JournalEntryList: catch rejected list requests so loading cannot stick
  forever, and gate every post-await state write behind a request
  generation so a slow earlier request cannot overwrite the current sort.
- TransactionHistoryList: pagination follows the selected source scope
  (reachable with zero matches on the current page, hidden for the
  skattekonto scope it cannot affect).
- transactions page: bank:other picker availability derives from history
  rows too, not only the pending inbox dataset.
- DECISIONS.md: mark the superseded single-sort decision; record the
  credit-note deduction positive-magnitude invariant and its verified
  reader inventory (Swedish review flag).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* fix: guard metadata refetches behind the list request generation

fetchAttachmentCounts and fetchRattelseFlags write state after their own
awaits; a stale list request's late completion could overwrite attachment
counts and rattelse flags for rows a newer request just rendered, showing
false missing-underlag warnings. Both helpers now take the caller's
generation guard and discard stale completions, including the
attachment-counts loaded flag.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-08-11 23:12:18 +02:00

110 lines
3.7 KiB
JSON

{
"name": "erp-base",
"version": "0.1.0",
"private": true,
"license": "AGPL-3.0-or-later",
"scripts": {
"setup:extensions": "npx tsx scripts/generate-extension-registry.ts",
"skills:generate": "npx tsx scripts/generate-skill-bodies.ts",
"skills:check": "npx tsx scripts/generate-skill-bodies.ts --check",
"apiskill:generate": "npx tsx --conditions react-server scripts/api-skill/generate.ts",
"apiskill:check": "npx tsx --conditions react-server scripts/api-skill/generate.ts --check",
"crontabs:generate": "npx tsx scripts/generate-crontabs.ts",
"taxonomy:generate": "npx tsx scripts/generate-taxonomy-registry.ts",
"taxonomy:check": "npx tsx scripts/generate-taxonomy-registry.ts --check",
"validate:ixbrl": "node scripts/validate-ixbrl.mjs",
"predev": "npm run setup:extensions && node scripts/inject-public-branding.mjs",
"dev": "next dev",
"prebuild": "npm run setup:extensions && node scripts/inject-public-branding.mjs",
"build": "next build",
"start": "next start",
"lint": "eslint",
"check:guards": "node scripts/checks/no-new-antipatterns.mjs",
"validate:packs": "npx tsx scripts/validate-packs.ts",
"validate:registry": "npx tsx scripts/validate-registry.ts",
"check:lint": "node scripts/checks/no-new-lint-errors.mjs",
"test": "vitest run --project unit",
"test:pg": "vitest run --project pg-real"
},
"dependencies": {
"@anthropic-ai/bedrock-sdk": "0.29.1",
"@hookform/resolvers": "^5.4.0",
"@radix-ui/react-checkbox": "^1.3.7",
"@radix-ui/react-dialog": "^1.1.19",
"@radix-ui/react-dropdown-menu": "^2.1.20",
"@radix-ui/react-label": "^2.1.11",
"@radix-ui/react-progress": "^1.1.12",
"@radix-ui/react-select": "^2.3.3",
"@radix-ui/react-slot": "^1.2.4",
"@radix-ui/react-switch": "^1.3.3",
"@radix-ui/react-tabs": "^1.1.17",
"@radix-ui/react-toast": "^1.2.19",
"@radix-ui/react-tooltip": "^1.2.12",
"@react-pdf/renderer": "^4.5.1",
"@supabase/ssr": "^0.12.1",
"@supabase/supabase-js": "^2.110.1",
"@tailwindcss/typography": "^0.5.20",
"@types/qrcode": "^1.5.6",
"@upstash/ratelimit": "^2.0.8",
"@upstash/redis": "^1.38.0",
"@use-gesture/react": "^10.3.1",
"@vercel/speed-insights": "^2.0.0",
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
"date-fns": "^4.4.0",
"framer-motion": "^12.42.2",
"fuse.js": "^7.4.2",
"ics": "^3.12.0",
"js-yaml": "4.3.1",
"jszip": "^3.10.1",
"lucide-react": "^1.24.0",
"mailparser": "^3.9.14",
"next": "16.2.12",
"next-intl": "^4.13.2",
"next-themes": "^0.4.6",
"pdf-lib": "^1.17.1",
"posthog-js": "^1.407.3",
"posthog-node": "^5.46.1",
"qrcode": "^1.5.4",
"react": "19.2.7",
"react-dom": "19.2.7",
"react-hook-form": "^7.80.0",
"react-markdown": "^10.1.0",
"recharts": "^3.9.1",
"remark-gfm": "^4.0.1",
"resend": "^6.17.2",
"server-only": "^0.0.1",
"sharp": "^0.35.3",
"stripe": "^22.3.1",
"svix": "^1.85.0",
"swr": "^2.4.2",
"tailwind-merge": "^3.6.0",
"web-push": "^3.6.7",
"xlsx": "https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz",
"zod": "^4.4.3"
},
"devDependencies": {
"@tailwindcss/postcss": "^4",
"@types/js-yaml": "4.0.9",
"@types/mailparser": "^3.4.6",
"@types/node": "^20",
"@types/pg": "^8.20.0",
"@types/react": "^19",
"@types/react-dom": "^19",
"@types/sharp": "^0.32.0",
"@types/web-push": "^3.6.4",
"dotenv": "^17.4.2",
"eslint": "^9",
"eslint-config-next": "16.2.12",
"pg": "^8.22.0",
"tailwindcss": "^4",
"typescript": "^5",
"vitest": "^4.1.9"
},
"overrides": {
"ws": "^8.21.0",
"sharp": "^0.35.3",
"postcss": "^8.5.18"
}
}