From d6ec9830dff95b1fa869b57604ccc892e97113bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Falc=C3=B3n?= Date: Fri, 26 Jun 2026 19:59:44 +0200 Subject: [PATCH] feat(transactions): refine new transaction form layout and balance toggle (#597) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## What Three tweaks to the **Add Transaction** form: 1. **Account selector moved to the top** of the create form, above the date field. 2. **"Update account balance" checkbox hidden for connected accounts** (accounts with a `banking_connection_id`). Their balance is kept in sync by the banking connection, so the submit also skips the balance update for them. 3. **Amount placeholder** now shows a negative example `-25.00` instead of `0.00`. ## Testing - Added a unit test covering that the checkbox is hidden for a connected account. - `bun run test edit-transaction-dialog` — 5 passed. - `bun run format` / `bun run lint` clean (only a pre-existing warning in `chart.tsx`). --- .../edit-transaction-dialog.test.tsx | 26 ++++ .../transactions/edit-transaction-dialog.tsx | 117 ++++++++++-------- 2 files changed, 88 insertions(+), 55 deletions(-) diff --git a/resources/js/components/transactions/edit-transaction-dialog.test.tsx b/resources/js/components/transactions/edit-transaction-dialog.test.tsx index bd4fcccb..d4814261 100644 --- a/resources/js/components/transactions/edit-transaction-dialog.test.tsx +++ b/resources/js/components/transactions/edit-transaction-dialog.test.tsx @@ -222,9 +222,35 @@ describe('EditTransactionDialog', () => { onOpenChange={vi.fn()} onSuccess={vi.fn()} mode="create" + initialAccountId="account-1" />, ); expect(screen.getByRole('checkbox')).toBeChecked(); }); + + it('hides "update account balance" for a connected account', () => { + const connectedAccount = { + ...checkingAccount, + id: 'account-connected', + banking_connection_id: 'connection-1', + }; + + render( + , + ); + + expect(screen.queryByRole('checkbox')).not.toBeInTheDocument(); + }); }); diff --git a/resources/js/components/transactions/edit-transaction-dialog.tsx b/resources/js/components/transactions/edit-transaction-dialog.tsx index 9a88590f..1dcf4f9f 100644 --- a/resources/js/components/transactions/edit-transaction-dialog.tsx +++ b/resources/js/components/transactions/edit-transaction-dialog.tsx @@ -354,7 +354,11 @@ export function EditTransactionDialog({ ? finalLabelIds : undefined, }, - { updateBalance: updateAccountBalance }, + { + updateBalance: selectedAccount.banking_connection_id + ? false + : updateAccountBalance, + }, ); const updatedCategory = finalCategoryId @@ -523,6 +527,42 @@ export function EditTransactionDialog({
+ {mode === 'create' && ( +
+ + {__('Account')} + + +
+ )} +
-
- - handleUpdateBalanceChange( - checked === true, - ) - } - disabled={isSubmitting} - /> + {!selectedAccount?.banking_connection_id && ( +
+ + handleUpdateBalanceChange( + checked === true, + ) + } + disabled={isSubmitting} + /> - - {__('Update account balance')} - -
+ + {__('Update account balance')} + +
+ )} ) : (
@@ -720,42 +763,6 @@ export function EditTransactionDialog({ )}
- {mode === 'create' && ( -
- - {__('Account')} - - -
- )} -
{__('Category')}