A local-first personal finance app
Start desktop split transactions with two splits instead of one (#8234)
Andy Fiddamana492453e1ccb
diff --git a/packages/desktop-client/e2e/page-models/account-page.ts b/packages/desktop-client/e2e/page-models/account-page.tsindex 0386b022a0..ea9deb3827 100644--- a/packages/desktop-client/e2e/page-models/account-page.ts+++ b/packages/desktop-client/e2e/page-models/account-page.ts@@ -113,16 +113,19 @@ export class AccountPage {category: 'split',});+ // Splitting starts with two empty splits+ const initialSplitCount = 2;+// Child transactionsfor (let i = 0; i < transactions.length; i++) {+ if (i >= initialSplitCount) {+ await this.page.getByRole('button', { name: 'Add Split' }).click();+ }+await this._fillTransactionFields(this.newTransactionRow.nth(i + 1),transactions[i],);-- if (i + 1 < transactions.length) {- await this.page.getByRole('button', { name: 'Add Split' }).click();- }}await this.addTransactionButton.click();diff --git a/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-custom-reports-Switches-to-Area-Graph-and-checks-the-visuals-1-chromium-linux.png b/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-custom-reports-Switches-to-Area-Graph-and-checks-the-visuals-1-chromium-linux.pngindex 325b34b31f..3204796e31 100644Binary files a/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-custom-reports-Switches-to-Area-Graph-and-checks-the-visuals-1-chromium-linux.png and b/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-custom-reports-Switches-to-Area-Graph-and-checks-the-visuals-1-chromium-linux.png differdiff --git a/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-custom-reports-Switches-to-Bar-Graph-and-checks-the-visuals-2-chromium-linux.png b/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-custom-reports-Switches-to-Bar-Graph-and-checks-the-visuals-2-chromium-linux.pngindex 456639cc3e..c0864b9b23 100644Binary files a/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-custom-reports-Switches-to-Bar-Graph-and-checks-the-visuals-2-chromium-linux.png and b/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-custom-reports-Switches-to-Bar-Graph-and-checks-the-visuals-2-chromium-linux.png differdiff --git a/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-custom-reports-Switches-to-Data-Table-and-checks-the-visuals-1-chromium-linux.png b/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-custom-reports-Switches-to-Data-Table-and-checks-the-visuals-1-chromium-linux.pngindex 03ec0633a3..ac788c0c10 100644Binary files a/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-custom-reports-Switches-to-Data-Table-and-checks-the-visuals-1-chromium-linux.png and b/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-custom-reports-Switches-to-Data-Table-and-checks-the-visuals-1-chromium-linux.png differdiff --git a/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-custom-reports-Validates-that-show-labels-button-shows-the-labels-1-chromium-linux.png b/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-custom-reports-Validates-that-show-labels-button-shows-the-labels-1-chromium-linux.pngindex f32b72c9de..073793afd7 100644Binary files a/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-custom-reports-Validates-that-show-labels-button-shows-the-labels-1-chromium-linux.png and b/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-custom-reports-Validates-that-show-labels-button-shows-the-labels-1-chromium-linux.png differdiff --git a/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-custom-reports-Validates-that-show-legend-button-shows-the-legend-side-bar-1-chromium-linux.png b/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-custom-reports-Validates-that-show-legend-button-shows-the-legend-side-bar-1-chromium-linux.pngindex 40d7216f73..19eb8763ed 100644Binary files a/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-custom-reports-Validates-that-show-legend-button-shows-the-legend-side-bar-1-chromium-linux.png and b/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-custom-reports-Validates-that-show-legend-button-shows-the-legend-side-bar-1-chromium-linux.png differdiff --git a/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-custom-reports-Validates-that-show-summary-button-shows-the-summary-1-chromium-linux.png b/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-custom-reports-Validates-that-show-summary-button-shows-the-summary-1-chromium-linux.pngindex 8de9c03236..b589a35863 100644Binary files a/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-custom-reports-Validates-that-show-summary-button-shows-the-summary-1-chromium-linux.png and b/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-custom-reports-Validates-that-show-summary-button-shows-the-summary-1-chromium-linux.png differdiff --git a/packages/desktop-client/src/components/transactions/TransactionList.tsx b/packages/desktop-client/src/components/transactions/TransactionList.tsxindex 09d2cc8167..a065b7a880 100644--- a/packages/desktop-client/src/components/transactions/TransactionList.tsx+++ b/packages/desktop-client/src/components/transactions/TransactionList.tsx@@ -14,6 +14,7 @@ import {addSplitTransaction,applyTransactionDiff,isPreviewId,+ makeChild,realizeTempTransactions,splitTransaction,updateTransaction,@@ -497,7 +498,11 @@ export function TransactionList({const onSplit = useCallback((id: TransactionEntity['id']) => {- const changes = splitTransaction(transactionsLatest.current, id);+ const changes = splitTransaction(+ transactionsLatest.current,+ id,+ parent => [makeChild(parent), makeChild(parent)],+ );onChange(changes.newTransaction, changes.data);void saveDiffAndApply(changes.diff,diff --git a/packages/desktop-client/src/components/transactions/TransactionsTable.test.tsx b/packages/desktop-client/src/components/transactions/TransactionsTable.test.tsxindex ad567acc40..8473e48440 100644--- a/packages/desktop-client/src/components/transactions/TransactionsTable.test.tsx+++ b/packages/desktop-client/src/components/transactions/TransactionsTable.test.tsx@@ -941,10 +941,7 @@ describe('Transactions', () => {await waitForAutocomplete();await waitForAutocomplete();- await userEvent.click(- container.querySelector('[data-testid="add-split-button"]')!,- );-+ // Splitting starts with two empty splitsinput = await editNewField(container, 'debit', 1);await userEvent.clear(input);await userEvent.type(input, '45.00');diff --git a/packages/desktop-client/src/components/transactions/TransactionsTable.tsx b/packages/desktop-client/src/components/transactions/TransactionsTable.tsxindex 84e7eeb278..f2c8449dff 100644--- a/packages/desktop-client/src/components/transactions/TransactionsTable.tsx+++ b/packages/desktop-client/src/components/transactions/TransactionsTable.tsx@@ -53,6 +53,7 @@ import {groupTransaction,isPreviewId,isTemporaryId,+ makeChild,splitTransaction,ungroupTransactions,updateTransaction,@@ -3265,7 +3266,10 @@ export const TransactionTable = forwardRef(if (isTemporaryId(id)) {const { newNavigator } = latestState.current;const newTrans = latestState.current.newTransactions;- const { data, diff } = splitTransaction(newTrans, id);+ const { data, diff } = splitTransaction(newTrans, id, parent => [+ makeChild(parent),+ makeChild(parent),+ ]);setNewTransactions(data);// Jump next to "debit" field if it is emptydiff --git a/upcoming-release-notes/default-two-splits.md b/upcoming-release-notes/default-two-splits.mdnew file mode 100644index 0000000000..12924de0a0--- /dev/null+++ b/upcoming-release-notes/default-two-splits.md@@ -0,0 +1,6 @@+---+category: Enhancements+authors: [citrus-it]+---++Start split transactions in the desktop app with two empty splits instead of one, matching the mobile app.