[PR #5856] [CLOSED] fix(transactions): preserve split categories on merge #40598

Closed
opened 2026-04-23 13:26:13 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/actualbudget/actual/pull/5856
Author: @Golenspade
Created: 10/5/2025
Status: Closed

Base: masterHead: fix/merge-split-preserve-categories


📝 Commits (8)

  • d29be71 fix(transactions): preserve split categories when merging with imported uncategorized tx; avoid orphaned subtransactions
  • 782e487 docs: add release note for PR #5856
  • 5756f75 fix: resolve lint and typecheck errors
  • c991adf refactor: optimize subtransaction queries and test db access
  • 8879b26 [autofix.ci] apply automated fixes
  • cd46f72 Merge branch 'master' into fix/merge-split-preserve-categories
  • 89c84d9 refactor: apply code review feedback with stable branch logic
  • 90a9641 chore(release-notes): set category to Enhancements and shorten text; fix(merge): use shared deleteTransaction with grouped fetch + batchUpdateTransactions

📊 Changes

3 files changed (+170 additions, -5 deletions)

View changed files

📝 packages/loot-core/src/server/transactions/merge.test.ts (+87 -0)
📝 packages/loot-core/src/server/transactions/merge.ts (+77 -5)
upcoming-release-notes/5856.md (+6 -0)

📄 Description

When merging a split-categorized manual transaction with an uncategorized imported one, keep the split lines (including categoryId) and avoid leaving orphaned subtransactions.

Changes

  • Modified mergeTransactions to load subtransactions for both transactions being merged
  • When the kept transaction doesn't have splits but the dropped one does, transfer all subtransactions by updating their parent_id
  • Mark the kept transaction as is_parent and clear its category (parent transactions with splits shouldn't have a direct category)
  • Added comprehensive test covering this scenario

Test Plan

Added test preserves split categories when merging split transaction with uncategorized imported transaction which:

  1. Creates a manual parent transaction with 2 subtransactions (different categories)
  2. Creates an imported transaction without splits
  3. Merges them
  4. Verifies subtransactions are transferred with correct parent_id
  5. Verifies no orphaned subtransactions remain

All tests pass.

Fixes #5781


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/actualbudget/actual/pull/5856 **Author:** [@Golenspade](https://github.com/Golenspade) **Created:** 10/5/2025 **Status:** ❌ Closed **Base:** `master` ← **Head:** `fix/merge-split-preserve-categories` --- ### 📝 Commits (8) - [`d29be71`](https://github.com/actualbudget/actual/commit/d29be719dd1c2fed0db2d09b06e459fed55fe159) fix(transactions): preserve split categories when merging with imported uncategorized tx; avoid orphaned subtransactions - [`782e487`](https://github.com/actualbudget/actual/commit/782e4874e44e03c338f4af5e112c7d5207db03ac) docs: add release note for PR #5856 - [`5756f75`](https://github.com/actualbudget/actual/commit/5756f755cae854e2000abbc1a7c8fd21c6a7cd56) fix: resolve lint and typecheck errors - [`c991adf`](https://github.com/actualbudget/actual/commit/c991adf5d140f6ef5b308b44fd5ae3710a589e37) refactor: optimize subtransaction queries and test db access - [`8879b26`](https://github.com/actualbudget/actual/commit/8879b26b02480f304bc09c83401fda24eea3bff1) [autofix.ci] apply automated fixes - [`cd46f72`](https://github.com/actualbudget/actual/commit/cd46f72650ea36acc9721e71c5a3d40a77406c53) Merge branch 'master' into fix/merge-split-preserve-categories - [`89c84d9`](https://github.com/actualbudget/actual/commit/89c84d964f429cfb9bf3827c0f2605740e81edf7) refactor: apply code review feedback with stable branch logic - [`90a9641`](https://github.com/actualbudget/actual/commit/90a96418498e71dfa903cc8b1e870ba5b5571de0) chore(release-notes): set category to Enhancements and shorten text; fix(merge): use shared deleteTransaction with grouped fetch + batchUpdateTransactions ### 📊 Changes **3 files changed** (+170 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `packages/loot-core/src/server/transactions/merge.test.ts` (+87 -0) 📝 `packages/loot-core/src/server/transactions/merge.ts` (+77 -5) ➕ `upcoming-release-notes/5856.md` (+6 -0) </details> ### 📄 Description When merging a split-categorized manual transaction with an uncategorized imported one, keep the split lines (including categoryId) and avoid leaving orphaned subtransactions. ## Changes - Modified `mergeTransactions` to load subtransactions for both transactions being merged - When the kept transaction doesn't have splits but the dropped one does, transfer all subtransactions by updating their `parent_id` - Mark the kept transaction as `is_parent` and clear its category (parent transactions with splits shouldn't have a direct category) - Added comprehensive test covering this scenario ## Test Plan Added test `preserves split categories when merging split transaction with uncategorized imported transaction` which: 1. Creates a manual parent transaction with 2 subtransactions (different categories) 2. Creates an imported transaction without splits 3. Merges them 4. Verifies subtransactions are transferred with correct `parent_id` 5. Verifies no orphaned subtransactions remain All tests pass. Fixes #5781 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-23 13:26:13 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/actual#40598