Skip to content

Commit

Permalink
Fix persistent split error popover (actualbudget#4225)
Browse files Browse the repository at this point in the history
* unset transaction error in db when no longer present

* note
  • Loading branch information
matt-fidd authored Jan 27, 2025
1 parent f09f4af commit 9dcd229
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1018,7 +1018,7 @@ describe('Transactions', () => {
category: undefined,
cleared: false,
date: '2017-01-01',
error: undefined,
error: null,
id: expect.any(String),
is_parent: true,
notes: 'Notes',
Expand Down
9 changes: 3 additions & 6 deletions packages/loot-core/src/shared/transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,8 @@ export function recalculateSplit(trans: TransactionEntity) {
const { error, ...rest } = trans;
return {
...rest,
...(total === num(trans.amount)
? {}
: { error: SplitTransactionError(total, trans) }),
error:
total === num(trans.amount) ? null : SplitTransactionError(total, trans),
} satisfies TransactionEntity;
}

Expand Down Expand Up @@ -313,9 +312,7 @@ export function splitTransaction(
return {
...rest,
is_parent: true,
...(num(trans.amount) === 0
? {}
: { error: SplitTransactionError(0, trans) }),
error: num(trans.amount) === 0 ? null : SplitTransactionError(0, trans),
subtransactions: subtransactions.map(t => ({
...t,
sort_order: t.sort_order || -1,
Expand Down
2 changes: 1 addition & 1 deletion packages/loot-core/src/types/models/transaction.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ export interface TransactionEntity {
type: 'SplitTransactionError';
version: 1;
difference: number;
};
} | null;
}
6 changes: 6 additions & 0 deletions upcoming-release-notes/4225.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
category: Bugfix
authors: [matt-fidd]
---

Fix persistent split error popover

0 comments on commit 9dcd229

Please sign in to comment.