Simpl-Resultat/src/hooks
le king fu 737654579f feat(balance): rewrite snapshot editor reducer for holdings + dispatch on account.kind (#213)
Structural rewrite of useSnapshotEditor for N holdings per detailed account,
and switch ALL simple/detailed dispatch from category_kind to the account's
own kind. This is the state/plumbing layer; the full multi-security entry UI
(SecurityPicker, rich sub-rows) lands in #214. Simple accounts behave
identically.

Reducer state shape:
- values:   Record<accountId, string>        (simple accounts, scalar)
- holdings: Record<accountId, HoldingDraft[]> (detailed accounts, one per title)
HoldingDraft is a string-typed, editable mirror of SnapshotHoldingInput with a
stable client-side rowId for React keys. Actions: ADD_HOLDING / REMOVE_HOLDING /
SET_HOLDING_FIELD (plus existing SET_VALUE/PREFILL/RESET). The legacy priced
scalar path (SET_PRICED_FIELD / pricedValues) is removed: after migration v16
(#211) every former-priced account is kind='detailed' with one holding, so those
accounts flow through the holdings path.

Dispatch:
- LOADED hydrates detailed baskets via listHoldingsBySnapshotLine (edit) keeping
  the saved price, or getHoldingsForLatestSnapshot (new) dropping the price
  (qty-0 excluded server-side). Simple accounts keep the scalar value path.
- SnapshotLineRow / SnapshotEditor / AccountForm now gate on account.kind, not
  category_kind. category.kind survives ONLY as the suggested seed default for a
  NEW account in AccountForm.

Save: detailed accounts pass their holdings array into SnapshotLineInput.holdings
(presence marks the line detailed; value = rounded-cent SUM); simple accounts
pass a scalar value with no holdings. Blank holding rows are skipped; a partial
row throws a typed error before any DB mutation.

AccountForm: adds an entry-mode selector (defaulting to the category-mapped
kind). New accounts persist as 'simple' (CreateBalanceAccountInput carries no
kind, and the service is out of this issue's scope); converting a fresh account
to detailed + pivot date is #215. Editing locks the selector for an already-
detailed account (the detailed->simple downgrade is service-guarded).

Tests: 19 new reducer/helper unit tests (pure exports; the project has no
renderHook harness) covering ADD/REMOVE/SET_HOLDING_FIELD, LOADED-vs-PREFILL
hydration (price drop, book_cost), qty-0 already excluded upstream, the
build*Lines save builders, and the dispatch-on-account.kind regression
(detailed account under a 'simple' category).

Resolves #213.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-06 13:29:48 -04:00
..
useAdjustments.ts feat: add Budget and Adjustments pages with full functionality 2026-02-12 00:58:43 +00:00
useAuth.ts feat: Maximus Account OAuth2 PKCE + machine activation + subscription check (#51, #53) 2026-04-10 14:18:51 -04:00
useBalanceAccounts.ts feat(balance): account form vehicle field + category rename via custom_label (#203) 2026-06-01 20:50:40 -04:00
useBalanceOverview.test.ts feat(balance): add useBalanceOverview hook 2026-04-25 16:06:38 -04:00
useBalanceOverview.ts feat(balance): chart vehicle/class toggle + collapsible returns (#204) 2026-06-01 21:05:00 -04:00
useBudget.ts refactor: inline buildPrevYearTotalMap and remove disproportionate tests (#39) 2026-03-11 13:02:47 -04:00
useCartes.test.ts feat(reports/cartes): Mensuel/YTD toggle on KPI cards + user guide section (#102) 2026-04-19 09:49:21 -04:00
useCartes.ts feat(reports/cartes): Mensuel/YTD toggle on KPI cards + user guide section (#102) 2026-04-19 09:49:21 -04:00
useCategories.ts feat: add 3rd level of category hierarchy 2026-02-25 19:54:05 -05:00
useCategoryMigration.test.ts feat(categories): add 3-step migration page + categoryMigrationService (#121) 2026-04-20 21:31:21 -04:00
useCategoryMigration.ts feat(categories): add 3-step migration page + categoryMigrationService (#121) 2026-04-20 21:31:21 -04:00
useCategoryTaxonomy.ts feat(categories): add categoryTaxonomyService + useCategoryTaxonomy hook (#116) 2026-04-20 20:53:15 -04:00
useCategoryZoom.ts feat: category zoom + secure AddKeywordDialog with context menu (#74) 2026-04-14 15:09:17 -04:00
useCompare.test.ts refactor(reports/compare): unify MoM/YoY under one Actual-vs-actual mode with reference month picker (#96) 2026-04-15 14:24:11 -04:00
useCompare.ts feat(reports/highlights): default reference month to previous month + YTD current year, user-changeable (#106) 2026-04-19 08:28:30 -04:00
useDashboard.ts fix: address reviewer feedback (#31) 2026-03-10 18:53:31 -04:00
useDataExport.ts feat: add data export/import with optional AES-256-GCM encryption (#3) 2026-02-15 11:40:28 +00:00
useDataImport.ts feat: make settings data imports visible in Import History 2026-02-15 13:38:51 +00:00
useFeedback.test.ts feat: feedback hub widget in Settings Logs card (#67) 2026-04-17 14:36:26 +00:00
useFeedback.ts feat: feedback hub widget in Settings Logs card (#67) 2026-04-17 14:36:26 +00:00
useHighlights.test.ts feat(reports/highlights): default reference month to previous month + YTD current year, user-changeable (#106) 2026-04-19 08:28:30 -04:00
useHighlights.ts feat(reports/highlights): default reference month to previous month + YTD current year, user-changeable (#106) 2026-04-19 08:28:30 -04:00
useImportHistory.ts feat: 12-month budget grid, import UX improvements, confirmation dialogs (v0.2.4) 2026-02-14 12:59:11 +00:00
useImportWizard.ts feat: show transaction splits on Adjustments page + fix CSV auto-detect 2026-02-17 01:41:08 +00:00
useIsPremium.test.ts feat(prices): useIsPremium hook from license.edition 2026-04-27 08:11:23 -04:00
useIsPremium.ts feat(prices): useIsPremium hook from license.edition 2026-04-27 08:11:23 -04:00
useLicense.ts feat: license card in settings (#47) 2026-04-09 15:47:04 -04:00
useReportsPeriod.test.ts refactor: split useReports into per-domain hooks + URL-bookmarked period (#70) 2026-04-14 14:37:33 -04:00
useReportsPeriod.ts refactor: split useReports into per-domain hooks + URL-bookmarked period (#70) 2026-04-14 14:37:33 -04:00
useSnapshotEditor.test.ts feat(balance): rewrite snapshot editor reducer for holdings + dispatch on account.kind (#213) 2026-06-06 13:29:48 -04:00
useSnapshotEditor.ts feat(balance): rewrite snapshot editor reducer for holdings + dispatch on account.kind (#213) 2026-06-06 13:29:48 -04:00
useTheme.ts feat: add dark mode with famille-website-inspired warm gray palette 2026-02-13 12:28:11 +00:00
useTransactions.ts feat: add transaction split adjustments across multiple categories 2026-02-16 23:51:36 +00:00
useTrends.ts refactor: split useReports into per-domain hooks + URL-bookmarked period (#70) 2026-04-14 14:37:33 -04:00
useUpdater.ts feat: gate auto-updates behind license entitlement (#48) 2026-04-09 15:52:59 -04:00