Simpl-Resultat/src
le king fu 23079da609 fix: restore a profile holding a Bilan transfer, a missing category or a category under a newer one (#521)
Three foreign keys stopped a restore on "FOREIGN KEY constraint failed",
the whole restore rolled back:

- (a) balance_account_transfers.transaction_id is ON DELETE RESTRICT
  (ADR 0010): the DELETE FROM transactions of both transaction modes,
  and so "Rétablir la sauvegarde", failed as soon as one transfer
  existed. Inside the restore's transaction, each transfer is now read
  with the date, amount and description of its transaction, then the
  table is emptied; once the transactions are back, the transfers whose
  transaction returns with the same id, date, amount and description
  are put back as they were (id, account, direction, notes, creation
  date), and the others are unlinked.
- (b) a transaction whose category the profile no longer holds (after
  "Réinitialiser", another restore, or another profile's file) failed
  its insert: it now comes back without a category, manual flag at 0,
  and one Journal line gives their number, nothing else.
- (c) restoreCategories inserted by id against parent_id, so a category
  under a newer one, or a loop, failed. Every category now goes in with
  parent_id NULL, and a second pass sets the parents.

The three restores return a RestoreOutcome { unlinkedTransfers,
uncategorizedTransactions } through runRestore<T> (categories only:
zeros). previewUnlinkedTransfers counts, outside any transaction and by
the same rule, the transfers a restore would unlink.
validateImportedCategoryReferences (pure, dataExportService.ts) refuses,
at the parse and at the head of the two restores that write categories,
a file whose parent_id, keyword or supplier names a category it does
not hold (danglingCategoryReference), before anything is deleted.

The "Gestion des données" card announces the transfers to unlink in its
confirmation and gives the real number after the restore (IMPORT_SUCCESS
carries the outcome). restoreFromBackup is split into readBackup (read,
decrypt, parse, count) and applyBackup (restore, preferences, a
RestoreResult with the outcome): "Rétablir la sauvegarde" reads the file
(after the PIN when encrypted) before a second confirmation, ends on
"Sauvegarde rétablie", and reloads the app on "Fermer" only.

Regression test in src/__integration__/restore.test.ts (real services
on node:sqlite, consolidated_schema.sql, foreign keys on): red on the
base for the three causes, green here.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-04 22:32:49 -05:00
..
__fixtures__ feat(onboarding): create_sample_import_folders command, sample CSV templates and detection test (#354) 2026-10-03 19:50:41 -04:00
__integration__ fix: restore a profile holding a Bilan transfer, a missing category or a category under a newer one (#521) 2026-11-04 22:32:49 -05:00
components fix: restore a profile holding a Bilan transfer, a missing category or a category under a newer one (#521) 2026-11-04 22:32:49 -05:00
contexts feat(onboarding): visit steps, eight rows, "Got it" and one-time initialization 2026-10-13 21:32:20 -04:00
data feat(categories): add v1 IPC seed, i18n keys, and migration v8 (#115) 2026-04-19 16:41:55 -04:00
hooks fix: restore a profile holding a Bilan transfer, a missing category or a category under a newer one (#521) 2026-11-04 22:32:49 -05:00
i18n fix: restore a profile holding a Bilan transfer, a missing category or a category under a newer one (#521) 2026-11-04 22:32:49 -05:00
pages test: share texts and move the last local find copies onto src/test/elementTree.ts (#495) 2026-10-26 20:12:04 -04:00
services fix: restore a profile holding a Bilan transfer, a missing category or a category under a newer one (#521) 2026-11-04 22:32:49 -05:00
shared test: pin the UTM label of each product page button (#525) 2026-11-02 21:57:24 -05:00
test test: share texts and move the last local find copies onto src/test/elementTree.ts (#495) 2026-10-26 20:12:04 -04:00
utils feat: open the Reports on « Cette année » and let « Tout » reach every date (#479) 2026-10-27 23:04:27 -04:00
App.tsx fix: replace the home and profile folders exactly in the Journal (#497) 2026-10-26 21:24:35 -04:00
main.tsx fix: replace the home and profile folders exactly in the Journal (#497) 2026-10-26 21:24:35 -04:00
styles.contrast.test.ts fix(onboarding): give the focus ring back to the highlighted control 2026-10-08 21:05:30 -04:00
styles.css fix(onboarding): give the focus ring back to the highlighted control 2026-10-08 21:05:30 -04:00
vite-env.d.ts Initial project scaffold: Tauri v2 + React + TypeScript + TailwindCSS v4 2026-02-07 11:05:11 +00:00