The line of the stack at the end of "Vérifications dues à la release
suivante" now names #521 and PR #532 next to #518 and PR #531: the
procedure lives in the body of PR #532, section "Vérifications
manuelles dues (prochaine release)". Link 3 of the stack extends this
line.
Resolves#521
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- CHANGELOG.md / CHANGELOG.fr.md, Fixed / Corrigé: a profile with a
Bilan transfer, a transaction whose category is gone, or a category
under a newer one restores again; the transfers whose transaction
comes back unchanged are kept, the others unlinked and counted before
and after; a file whose references cannot be satisfied is refused;
"Rétablir la sauvegarde" reads the file before a second confirmation
and reloads on "Fermer".
- ADR 0010 amendment: RESTRICT unchanged; the restore reads, removes and
puts back the transfers whose transaction returns with the same id,
date, amount and description, and says how many it unlinks.
- docs/architecture.md: dataExportService.ts and dataRestoreService.ts
rows, useDataImport, the two passes of restoreCategories, the SREF
section, the node:sqlite tests of restore.test.ts.
- User guide and in-app docs (docs.settings.tips, appended last so that
tips[6], which REVIEW.md cites, keeps its index).
- Two comments of attachTransactions name the app's real labels.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The creation date of a restored transfer is now compared against a value
set apart from the clock, so a restore that wrote its own would show.
The file whose rows do not keep their ids now gives a duplicate id to
two rows no transfer holds: the linked rows come back unchanged in the
file, and only the renumbering by SQLite unlinks them, which the preview
must announce too.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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>