diff --git a/packages/loot-core/src/shared/transactions.ts b/packages/loot-core/src/shared/transactions.ts index d09b945913..eb386d5116 100644 --- a/packages/loot-core/src/shared/transactions.ts +++ b/packages/loot-core/src/shared/transactions.ts @@ -78,12 +78,13 @@ export function recalculateSplit(trans: TransactionEntity) { (acc, t) => acc + num(t.amount), 0, ); + + const { error, ...rest } = trans; return { - ...trans, - error: - total === num(trans.amount) - ? undefined - : SplitTransactionError(total, trans), + ...rest, + ...(total === num(trans.amount) + ? {} + : { error: SplitTransactionError(total, trans) }), } satisfies TransactionEntity; } @@ -276,11 +277,10 @@ export function deleteTransaction( if (trans.id === id) { return null; } else if (trans.subtransactions?.length === 1) { + const { error, subtransactions, ...rest } = trans; return { - ...trans, - subtransactions: undefined, + ...rest, is_parent: false, - error: undefined, } satisfies TransactionEntity; } else { const sub = trans.subtransactions?.filter(t => t.id !== id); @@ -308,11 +308,14 @@ export function splitTransaction( makeChild(trans), ]; + const { error, ...rest } = trans; + return { - ...trans, + ...rest, is_parent: true, - error: - num(trans.amount) === 0 ? undefined : SplitTransactionError(0, trans), + ...(num(trans.amount) === 0 + ? {} + : { error: SplitTransactionError(0, trans) }), subtransactions: subtransactions.map(t => ({ ...t, sort_order: t.sort_order || -1, diff --git a/upcoming-release-notes/4186.md b/upcoming-release-notes/4186.md new file mode 100644 index 0000000000..7c5d29773b --- /dev/null +++ b/upcoming-release-notes/4186.md @@ -0,0 +1,6 @@ +--- +category: Bugfix +authors: [jfdoming] +--- + +Fix various split transaction edits not working