fix(bokforing): account search results in the booking dialog search field (#1877) (#1889)

* fix(bokforing): account search results in the booking dialog search field (#1877)

The search field in the "Bokfor transaktion" dialog only matched template
metadata, so typing an account number or name (e.g. active 5460
Forbrukningsmaterial) gave zero hits and no path to booking; the real
account search was only reachable via the discreet "Bokfor manuellt" link.

- TemplatePicker now also searches the company's active chart of accounts
  (reusing lib/bookkeeping/account-search.ts) and shows hits as a "Konton"
  result group; picking one routes into the same manual booking flow as
  "Bokfor manuellt" with the account prefilled on the counter line.
- New buildActiveAccountIndex helper indexes chart rows active-only, so
  deactivated accounts never surface as bookable results.
- searchTemplates additionally prefix-matches all-digit tokens against a
  template's business account (debit for expense, credit for income, both
  legs for transfers, AB variants included); the settlement leg is
  deliberately excluded so "1930" does not light up every template.
- Library template search prefix-matches line accounts on all-digit queries.
- Empty search results show a hint pointing at "Bokfor manuellt" for
  accounts outside the active chart; placeholder now says "Sok mall eller
  konto...". New strings in both messages/sv.json and messages/en.json.

Fixes #1877

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

* fix(bokforing): match only business lines when digit-searching library templates (#1877)

CodeRabbit review on PR #1889: the all-digit library-template match also hit
settlement and VAT lines, so searching "1930" lit up every user template with
a bank settlement leg. Restrict the predicate to business lines, mirroring
the static catalog's settlement-leg exclusion.

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

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Mattsson
2026-08-25 13:30:03 +02:00
committed by GitHub
co-authored by Claude Fable 5
parent e92365b86e
commit cd46d936f3
9 changed files with 290 additions and 37 deletions
+3
View File
@@ -3130,8 +3130,11 @@
"vat_exempt": "VAT-free",
"requires_vat_reg": "Requires VAT reg. no.",
"search_placeholder": "Search template...",
"search_placeholder_with_accounts": "Search template or account...",
"no_results": "No results",
"no_results_manual_hint": "Can't find the account? Use Bokför manuellt to search the full chart of accounts.",
"n_results": "{count} results",
"accounts_group": "Accounts",
"my_templates": "My templates",
"previous_counterparties": "Previous counterparties",
"suggested": "Suggested",
+3
View File
@@ -3130,8 +3130,11 @@
"vat_exempt": "Momsfri",
"requires_vat_reg": "Kräver momsreg.nr",
"search_placeholder": "Sök mall...",
"search_placeholder_with_accounts": "Sök mall eller konto...",
"no_results": "Inga resultat",
"no_results_manual_hint": "Hittar du inte kontot? Via Bokför manuellt kan du söka i hela kontoplanen.",
"n_results": "{count} resultat",
"accounts_group": "Konton",
"my_templates": "Mina mallar",
"previous_counterparties": "Tidigare motparter",
"suggested": "Föreslagna",