fix: a split's offset line follows its parent when it is recategorized (#454) #515

Merged
maximus merged 4 commits from issue-454-split-offset-follows-parent into main 2026-10-30 00:38:49 +00:00

4 commits

Author SHA1 Message Date
le king fu
1fad948f92 docs(state): manual check of the offset line of a split (#454)
All checks were successful
PR Check — Frontend / frontend (pull_request) Successful in 2m29s
One sub-bullet at the end of "Vérifications dues à la release suivante":
the procedure is in the body of PR #515.

Resolves #454

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 22:20:50 -04:00
le king fu
e130c346c5 test: pin the amount condition of isOffsetChild under a parent of zero (#454)
All checks were successful
PR Check — Frontend / frontend (pull_request) Successful in 2m30s
The mutation pass left one mutation green: without `child.amount !== 0`,
every existing case still failed on the sign test. Only under a parent
of zero does a child of zero pass it (Math.sign(0) === -Math.sign(0),
since 0 === -0); the test now covers that case.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 22:14:49 -04:00
le king fu
ef35573947 docs: the offset line of a split in the architecture, ADR 0022 and changelogs (#454)
- docs/architecture.md: splitOffsetService.ts in the services table
  (23 rows) and its callers in the rows of transactionService.ts and
  categorizationService.ts; 29 services (ls src/services/*.ts without
  tests) and 21 pure utilities (splitOffset.ts) in the tree.
- CLAUDE.md: "29 services métier" in the tree (that line only).
- ADR 0022: updateTransactionCategory notifies after its COMMIT, once
  the lock is released, and not after a ROLLBACK.
- CHANGELOG.md / CHANGELOG.fr.md: one Fixed / Corrigé entry.

Resolves #454

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 22:13:15 -04:00
le king fu
6db898b7ae fix: a split's offset line follows its parent when it is recategorized (#454)
Recategorizing a split transaction moved the parent only: its offset
line, which cancels in the parent's category the part sent to other
categories, stayed in the former category. Every report adds all rows,
so a transaction of -120 with -50 split to B, moved from A to C, left
+50 in A and -120 in C instead of -70 in C. The keyword path had the
same defect, and its preview also offered the children of a split,
which it then recategorized alone.

- src/utils/splitOffset.ts: isOffsetChild(parent, child), the rule the
  split window already used, extracted and freed from the category: the
  parent's description, the sign opposite to the parent's, a non-zero
  amount (decision D1: no role column, no migration).
- src/services/splitOffsetService.ts: propagateCategoryToOffsets(db,
  parentId, categoryId) gives the parent's new category to the offset
  line, whatever its current category (decision D2: an offset left in a
  former category is repaired at the parent's next change). It runs on
  the caller's transaction handle: no BEGIN/COMMIT, no getDb(), no
  notification. Nothing for an unknown id, a transaction that is not
  split, or a child (children carry is_split = 1 too). Its own module:
  transactionService.ts already imports categorizationService.ts.
- updateTransactionCategory now runs in withTransaction, with its own
  BEGIN, the parent's UPDATE (unchanged, toSqlFlag), the propagation and
  COMMIT, or ROLLBACK and rethrow; it notifies after the COMMIT only.
- previewKeywordMatches offers rows without a parent only; the keyword
  loop's UPDATE skips a child (AND parent_transaction_id IS NULL),
  counts rowsAffected, and propagates for each id before the COMMIT.
- SplitAdjustmentModal leaves out the child isOffsetChild recognizes,
  so an offset left in a former category is no longer shown as a row.

Tests: the regression test of transactionService.test.ts fails on main
(no UPDATE of the offset); the tests of #390 and #396 now find the
parent's UPDATE by its SQL and answer the reads of the propagation.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 22:13:08 -04:00