A local-first personal finance app
[AI] fix: clear split parent payee (#8005)
meaqua9420c011ab766ec2
diff --git a/packages/desktop-client/src/components/transactions/TransactionsTable.test.tsx b/packages/desktop-client/src/components/transactions/TransactionsTable.test.tsxindex 287bde6434..ad567acc40 100644--- a/packages/desktop-client/src/components/transactions/TransactionsTable.test.tsx+++ b/packages/desktop-client/src/components/transactions/TransactionsTable.test.tsx@@ -1238,7 +1238,7 @@ describe('Transactions', () => {id: expect.any(String),is_parent: true,notes: 'Notes',- payee: 'alice-id',+ payee: null,reconciled: false,sort_order: 0,},diff --git a/packages/loot-core/src/shared/transactions.test.ts b/packages/loot-core/src/shared/transactions.test.tsindex 008177adfd..b67332b060 100644--- a/packages/loot-core/src/shared/transactions.test.ts+++ b/packages/loot-core/src/shared/transactions.test.ts@@ -114,7 +114,7 @@ describe('Transactions', () => {test('splitting a transaction works', () => {const transactions = [- makeTransaction({ id: 't1', amount: 5000 }),+ makeTransaction({ id: 't1', amount: 5000, payee: 'payee-id' }),makeTransaction({ amount: 3000 }),];const { data, diff } = splitTransaction(transactions, 't1');@@ -127,6 +127,7 @@ describe('Transactions', () => {{id: 't1',is_parent: true,+ payee: null,error: splitError(5000),},],@@ -136,8 +137,13 @@ describe('Transactions', () => {id: 't1',amount: 5000,error: splitError(5000),+ payee: null,+ }),+ expect.objectContaining({+ parent_id: 't1',+ amount: 0,+ payee: 'payee-id',}),- expect.objectContaining({ parent_id: 't1', amount: 0 }),expect.objectContaining({ amount: 3000 }),]);});@@ -173,6 +179,24 @@ describe('Transactions', () => {expect(data.length).toBe(6);});+ test('adding a split transaction reuses the previous child payee', () => {+ const transactions = [+ ...makeSplitTransaction({ id: 't1', amount: 2500, payee: null }, [+ { id: 't2', amount: 2000, payee: 'payee-id' },+ ]),+ ];++ const { diff } = addSplitTransaction(transactions, 't1');++ expect(diff.added).toEqual([+ expect.objectContaining({+ amount: 0,+ parent_id: 't1',+ payee: 'payee-id',+ }),+ ]);+ });+test('updating a split transaction works', () => {const transactions = [makeTransaction({ amount: 2001 }),diff --git a/packages/loot-core/src/shared/transactions.ts b/packages/loot-core/src/shared/transactions.tsindex bb9e6faded..043791ec40 100644--- a/packages/loot-core/src/shared/transactions.ts+++ b/packages/loot-core/src/shared/transactions.ts@@ -249,6 +249,7 @@ export function addSplitTransaction(trans.subtransactions?.push(makeChild(trans, {amount: 0,+ payee: prevSub?.payee ?? trans.payee,sort_order: num(prevSub && prevSub.sort_order) - 1,}),);@@ -345,6 +346,7 @@ export function splitTransaction(return {...rest,is_parent: true,+ payee: null,error: num(trans.amount) === 0 ? null : SplitTransactionError(0, trans),subtransactions: subtransactions.map(t => ({...t,diff --git a/upcoming-release-notes/8005.md b/upcoming-release-notes/8005.mdnew file mode 100644index 0000000000..7d3c505275--- /dev/null+++ b/upcoming-release-notes/8005.md@@ -0,0 +1,6 @@+---+category: Bugfixes+authors: [meaqua9420]+---++Clear the hidden parent payee when splitting transactions.