Skip to content

Commit

Permalink
unset transaction error in db when no longer present
Browse files Browse the repository at this point in the history
  • Loading branch information
matt-fidd committed Jan 23, 2025
1 parent 1f5e5d4 commit 11af23e
Show file tree
Hide file tree
Showing 3 changed files with 5 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;
}

0 comments on commit 11af23e

Please sign in to comment.