From cdad43ff32bbd16858fb250878389a6fd0375940 Mon Sep 17 00:00:00 2001 From: Julian Dominguez-Schatz <julian.dominguezschatz@gmail.com> Date: Sun, 21 Apr 2024 18:00:19 -0400 Subject: [PATCH] Improve 'Before split' section in rule splits (#2651) * Copy category from parent transaction when splitting * Rename 'Before split' -> 'Apply to all' * Add release notes * Update tests to reflect change --- packages/desktop-client/src/components/modals/EditRule.jsx | 2 +- packages/desktop-client/src/components/rules/RuleRow.tsx | 2 +- .../src/components/transactions/TransactionsTable.test.jsx | 2 ++ packages/loot-core/src/server/accounts/rules.ts | 2 +- packages/loot-core/src/shared/transactions.ts | 1 + upcoming-release-notes/2651.md | 6 ++++++ 6 files changed, 12 insertions(+), 3 deletions(-) create mode 100644 upcoming-release-notes/2651.md diff --git a/packages/desktop-client/src/components/modals/EditRule.jsx b/packages/desktop-client/src/components/modals/EditRule.jsx index ce34999b6..54b76c2cf 100644 --- a/packages/desktop-client/src/components/modals/EditRule.jsx +++ b/packages/desktop-client/src/components/modals/EditRule.jsx @@ -1020,7 +1020,7 @@ export function EditRule({ modalProps, defaultRule, onSave: originalOnSave }) { }} > {splitIndex === 0 - ? 'Before split' + ? 'Apply to all' : `Split ${splitIndex}`} </Text> {splitIndex && ( diff --git a/packages/desktop-client/src/components/rules/RuleRow.tsx b/packages/desktop-client/src/components/rules/RuleRow.tsx index 4af4d3105..6548e8fd5 100644 --- a/packages/desktop-client/src/components/rules/RuleRow.tsx +++ b/packages/desktop-client/src/components/rules/RuleRow.tsx @@ -139,7 +139,7 @@ export const RuleRow = memo( marginBottom: 6, }} > - {i ? `Split ${i}` : 'Before split'} + {i ? `Split ${i}` : 'Apply to all'} </Text> {split.actions.map((action, j) => ( <ActionExpression diff --git a/packages/desktop-client/src/components/transactions/TransactionsTable.test.jsx b/packages/desktop-client/src/components/transactions/TransactionsTable.test.jsx index d06dbd2fd..075813883 100644 --- a/packages/desktop-client/src/components/transactions/TransactionsTable.test.jsx +++ b/packages/desktop-client/src/components/transactions/TransactionsTable.test.jsx @@ -861,6 +861,7 @@ describe('Transactions', () => { { account: accounts[0].id, amount: -1000, + category: null, cleared: false, date: '2017-01-01', error: null, @@ -874,6 +875,7 @@ describe('Transactions', () => { { account: accounts[0].id, amount: -1777, + category: null, cleared: false, date: '2017-01-01', error: null, diff --git a/packages/loot-core/src/server/accounts/rules.ts b/packages/loot-core/src/server/accounts/rules.ts index 68f0d67bf..ab7ccd11d 100644 --- a/packages/loot-core/src/server/accounts/rules.ts +++ b/packages/loot-core/src/server/accounts/rules.ts @@ -622,7 +622,7 @@ export function execActions(actions: Action[], transaction) { } } - // The split index 0 is reserved for "Before split" actions. + // The split index 0 is reserved for "Apply to all" actions. // Remove that entry from the subtransactions. update.subtransactions = update.subtransactions.slice(1); diff --git a/packages/loot-core/src/shared/transactions.ts b/packages/loot-core/src/shared/transactions.ts index c4f868725..ac3b7356d 100644 --- a/packages/loot-core/src/shared/transactions.ts +++ b/packages/loot-core/src/shared/transactions.ts @@ -49,6 +49,7 @@ export function makeChild<T extends GenericTransactionEntity>( return { amount: 0, ...data, + category: 'category' in data ? data.category : parent.category, payee: 'payee' in data ? data.payee : parent.payee, id: 'id' in data ? data.id : prefix + uuidv4(), account: parent.account, diff --git a/upcoming-release-notes/2651.md b/upcoming-release-notes/2651.md new file mode 100644 index 000000000..9c642480c --- /dev/null +++ b/upcoming-release-notes/2651.md @@ -0,0 +1,6 @@ +--- +category: Enhancements +authors: [jfdoming] +--- + +Make the 'Apply to all' section (fka 'Before split') of rule splits more intuitive -- GitLab