From 54f6497b9bcaa03694722889586bcf85a5558564 Mon Sep 17 00:00:00 2001 From: Yong Sheng Tan Date: Thu, 26 Oct 2023 10:59:29 +0800 Subject: [PATCH] Refresh transactions if edited tx has amount changed --- src/transactions/add-transaction-dialog.jsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/transactions/add-transaction-dialog.jsx b/src/transactions/add-transaction-dialog.jsx index 7e1f5d7..d06d4a0 100644 --- a/src/transactions/add-transaction-dialog.jsx +++ b/src/transactions/add-transaction-dialog.jsx @@ -158,7 +158,12 @@ const AddTransactionDialog = ({ endpoint([ tx ], (response) => { const minDate = dayjs.min(response.map(t => dayjs.utc(t.date))); if (transactionToEdit) { - postProcess(response, transactions.map((t) => response.find((r) => r.id === t.id) || t)); + const existing = transactions.find(({ id }) => id === tx.id); + if (existing.amount === tx.amount) { + postProcess(response, transactions.map((t) => response.find((r) => r.id === t.id) || t)); + } else { + listTransactions(selectedAccount?.id, (allTx) => postProcess(response, allTx)); + } } else if (minDate.isAfter(maxDate)) { postProcess(response, [ ...transactions, ...response ]); } else {