A local-first personal finance app
Fix reconciled value of children of split transactions (#7453)
James Skinner8691766fb815
diff --git a/packages/desktop-client/src/components/transactions/TransactionsTable.test.tsx b/packages/desktop-client/src/components/transactions/TransactionsTable.test.tsxindex e10bc89167..7da77ab0f1 100644--- a/packages/desktop-client/src/components/transactions/TransactionsTable.test.tsx+++ b/packages/desktop-client/src/components/transactions/TransactionsTable.test.tsx@@ -1167,6 +1167,7 @@ describe('Transactions', () => {is_parent: true,notes: 'Notes',payee: 'alice-id',+ reconciled: false,sort_order: 0,},{@@ -1180,7 +1181,7 @@ describe('Transactions', () => {is_child: true,parent_id: parentId,payee: 'alice-id',- reconciled: undefined,+ reconciled: false,sort_order: -1,starting_balance_flag: null,},@@ -1195,7 +1196,7 @@ describe('Transactions', () => {is_child: true,parent_id: parentId,payee: 'alice-id',- reconciled: undefined,+ reconciled: false,sort_order: -2,starting_balance_flag: null,},diff --git a/packages/loot-core/src/mocks/index.ts b/packages/loot-core/src/mocks/index.tsindex fb0a8d5596..9b29acaf8a 100644--- a/packages/loot-core/src/mocks/index.ts+++ b/packages/loot-core/src/mocks/index.ts@@ -139,6 +139,7 @@ function _generateTransaction(date: data.date || monthUtils.currentDay(),sort_order: data.sort_order != null ? data.sort_order : 1,cleared: false,+ reconciled: false,...(data.category && { category: data.category }),};}diff --git a/packages/loot-core/src/shared/transactions.test.ts b/packages/loot-core/src/shared/transactions.test.tsindex d37e530c8f..327dd5320b 100644--- a/packages/loot-core/src/shared/transactions.test.ts+++ b/packages/loot-core/src/shared/transactions.test.ts@@ -281,6 +281,34 @@ describe('Transactions', () => {]);});+ test('unlocking a reconciled split transaction propagates to children', () => {+ const transactions = [+ makeTransaction({ amount: 2001 }),+ ...makeSplitTransaction({ id: 't1', amount: 2500, reconciled: true }, [+ { id: 't2', amount: 2000, reconciled: true },+ { id: 't3', amount: 500, reconciled: true },+ ]),+ makeTransaction({ amount: 3002 }),+ ];++ const { data, diff } = updateTransaction(transactions, {+ ...transactions.find(t => t.id === 't1')!,+ reconciled: false,+ });++ const children = data.filter(t => t.parent_id === 't1');+ expect(children).toHaveLength(2);+ expect(children.every(t => t.reconciled === false)).toBe(true);++ expect(diff.updated).toEqual(+ expect.arrayContaining([+ expect.objectContaining({ id: 't1', reconciled: false }),+ expect.objectContaining({ id: 't2', reconciled: false }),+ expect.objectContaining({ id: 't3', reconciled: false }),+ ]),+ );+ });+test('unsplitting last remaining child converts parent to regular transaction', () => {const [parent, child] = makeSplitTransaction({ id: 't1', amount: 2000, category: 'cat1' },diff --git a/packages/loot-core/src/shared/transactions.ts b/packages/loot-core/src/shared/transactions.tsindex 8648981282..f749257aef 100644--- a/packages/loot-core/src/shared/transactions.ts+++ b/packages/loot-core/src/shared/transactions.ts@@ -43,7 +43,7 @@ export function makeChild<T extends GenericTransactionEntity>(account: parent.account,date: parent.date,cleared: parent.cleared != null ? parent.cleared : null,- reconciled: 'reconciled' in data ? data.reconciled : parent.reconciled,+ reconciled: parent.reconciled != null ? parent.reconciled : null,starting_balance_flag:parent.starting_balance_flag != null? parent.starting_balance_flagdiff --git a/upcoming-release-notes/7453.md b/upcoming-release-notes/7453.mdnew file mode 100644index 0000000000..0d1ae65a43--- /dev/null+++ b/upcoming-release-notes/7453.md@@ -0,0 +1,6 @@+---+category: Bugfixes+authors: [JSkinnerUK]+---++Fixes unlocking on child split transactions