fix: carry the budget in SREF backups (format 3) and keep it on restore (#520) #533

Merged
maximus merged 4 commits from issue-520-restore-budget-sref3 into main 2026-11-07 18:59:04 +00:00

4 commits

Author SHA1 Message Date
le king fu
e63029e7c3 docs(state): name the manual checks of the budget in backups (#520)
All checks were successful
PR Check — Frontend / frontend (pull_request) Successful in 2m58s
The line of the stack in the checks due at the next release now names
the three links and their PRs (#531, #532, #533).

Resolves #520

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 20:26:08 -05:00
le king fu
0225705836 docs: SREF format 3, the budget in backups, ADR 0025 for the stack (#520)
All checks were successful
PR Check — Frontend / frontend (pull_request) Successful in 3m7s
- ADR 0025 "Contenu et restauration d'une sauvegarde SREF": what each
  mode carries (format 3), the ids of #518, the Bilan transfers of #521,
  the categories, the budget of a format-3 file, the fallback of formats
  1 and 2 and its accepted limit on the category id alone, the format
  given and never guessed, the refusals, and the container's version
  byte independent of format_version. ADR 0010's amendment points to it.
- docs/architecture.md: dataExportService and dataRestoreService rows,
  useDataImport and useDataExport rows, section 4 (format 3), the tests
  of restore.test.ts, the ADR index.
- User guide and in-app docs: the Import tip on the backup, the export
  feature of Settings, and a tip appended at the end of
  docs.settings.tips (index 9).
- CHANGELOG FR/EN: Fixed / Corrigé and Changed / Modifié.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 20:21:46 -05:00
le king fu
b45616fa1d test: pin the export of each mode and a recurring adjustment in backups (#520)
- useDataExport.test.ts (new): "Exporter" writes, for each mode, the
  arrays collectExportData gathers, at the format of this build; a CSV
  still starts with its id column.
- restore.test.ts: the adjustment of the test budget is recurring and
  carries a recurrence rule, so that a restore which drops either shows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-04 23:38:08 -05:00
le king fu
09c7b32dd1 fix: carry the budget in SREF backups and keep it on restore (#520)
A restore with categories (full backup, categories only, and "Restore the
backup" of the categories migration) ran DELETE FROM categories, whose
ON DELETE CASCADE took every budget line, template line and adjustment
line with it, while the backup held none: the restore succeeded and left
the budget empty.

- SREF format 3: the two modes that carry the categories now carry
  budget_entries, budget_templates (by name, with their lines) and
  adjustments (with their lines). collectExportData(mode) gathers the
  arrays of each mode for the export and for the pre-migration backup.
- Restore: the profile's budget lines, template lines and adjustment
  lines are read and taken out before DELETE FROM categories, in both
  formats, through the restore's handle. At format 3 the file's budget
  lines and adjustments replace the profile's, each file template is
  upserted by name with its lines replaced, and a template absent from
  the file keeps its header and its lines whose category comes back.
  Below format 3 the lines whose category comes back are put back as
  they were.
- The restores of the two category modes take the file's format
  (formatVersion), passed by useDataImport and applyBackup.
- Pure validation at the parse and at the head of each restore: a
  format newer than this build is refused (newerFormat), a non-integer
  or below 1 gets the malformed-file error, and at format 3 a missing
  array or a line the tables cannot hold is refused (invalidBudgetRows).
- restoreCategories writes i18n_key.
- Confirmations: willDeleteCategories and willDeleteAll name the budget,
  the counts of budget lines, templates and adjustments, and the note of
  a backup older than format 3 in the card and in the second
  confirmation of "Restore the backup"; categories.reinitializeConfirm
  names what "Re-initialize" erases.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-04 23:32:58 -05:00