diff --git a/packages/loot-core/src/server/accounts/transaction-rules.test.ts b/packages/loot-core/src/server/accounts/transaction-rules.test.ts index d86140470184d123fbc6d194b6769f51212c39d5..367da4b576191ec3ecae0fc3662d4ccccc1724b9 100644 --- a/packages/loot-core/src/server/accounts/transaction-rules.test.ts +++ b/packages/loot-core/src/server/accounts/transaction-rules.test.ts @@ -420,23 +420,7 @@ describe('Transaction rules', () => { account, payee: lowesId, notes: '', - amount: 102, - }); - await db.insertTransaction({ - id: '6', - date: '2020-10-17', - account, - payee: krogerId, - notes: 'baz', - amount: -102, - }); - await db.insertTransaction({ - id: '7', - date: '2020-10-17', - account, - payee: krogerId, - notes: 'zaz', - amount: -101, + amount: 124, }); let transactions = await getMatchingTransactions([ @@ -454,36 +438,6 @@ describe('Transaction rules', () => { ]); expect(transactions.map(t => t.id)).toEqual(['1']); - transactions = await getMatchingTransactions([ - { field: 'amount', op: 'is', value: 102 }, - ]); - expect(transactions.map(t => t.id)).toEqual(['6', '5']); - - transactions = await getMatchingTransactions([ - { field: 'amount', op: 'isapprox', value: 102 }, - ]); - expect(transactions.map(t => t.id)).toEqual(['6', '7', '4', '5']); - - transactions = await getMatchingTransactions([ - { field: 'amount', op: 'gt', value: 102 }, - ]); - expect(transactions.map(t => t.id)).toEqual(['2', '3', '1']); - - transactions = await getMatchingTransactions([ - { field: 'amount', op: 'lt', value: 102 }, - ]); - expect(transactions.map(t => t.id)).toEqual(['7', '4']); - - transactions = await getMatchingTransactions([ - { field: 'amount', op: 'gte', value: 102 }, - ]); - expect(transactions.map(t => t.id)).toEqual(['6', '5', '2', '3', '1']); - - transactions = await getMatchingTransactions([ - { field: 'amount', op: 'lte', value: 102 }, - ]); - expect(transactions.map(t => t.id)).toEqual(['6', '7', '4', '5']); - transactions = await getMatchingTransactions([ { field: 'notes', op: 'is', value: 'FooO' }, ]); @@ -507,7 +461,7 @@ describe('Transaction rules', () => { transactions = await getMatchingTransactions([ { field: 'amount', op: 'gt', value: 300 }, ]); - expect(transactions.map(t => t.id)).toEqual(['2', '3', '1']); + expect(transactions.map(t => t.id)).toEqual(['2', '1']); transactions = await getMatchingTransactions([ { field: 'amount', op: 'gt', value: 400 }, @@ -536,7 +490,7 @@ describe('Transaction rules', () => { transactions = await getMatchingTransactions([ { field: 'date', op: 'gt', value: '2020-10-10' }, ]); - expect(transactions.map(t => t.id)).toEqual(['6', '7', '4', '5', '2', '3']); + expect(transactions.map(t => t.id)).toEqual(['4', '5', '2', '3']); // todo: isapprox }); diff --git a/packages/loot-core/src/server/accounts/transaction-rules.ts b/packages/loot-core/src/server/accounts/transaction-rules.ts index 144ae6670f6b47557975d28959763f6c1a8f350e..3119cdd69c0fb662b1a160f528a3dc08da9ee29c 100644 --- a/packages/loot-core/src/server/accounts/transaction-rules.ts +++ b/packages/loot-core/src/server/accounts/transaction-rules.ts @@ -335,25 +335,22 @@ export function conditionsToAQL(conditions, { recurDateBounds = 100 } = {}) { const apply = (field, op, value) => { if (type === 'number') { - const outflowQuery = { - $and: [ - { amount: { $lt: 0 } }, - { [field]: { $transform: '$neg', [op]: value } }, - ], - }; - const inflowQuery = { - $and: [{ amount: { $gt: 0 } }, { [field]: { [op]: value } }], - }; if (options) { if (options.outflow) { - return outflowQuery; + return { + $and: [ + { amount: { $lt: 0 } }, + { [field]: { $transform: '$neg', [op]: value } }, + ], + }; } else if (options.inflow) { - return inflowQuery; + return { + $and: [{ amount: { $gt: 0 } }, { [field]: { [op]: value } }], + }; } } - return { - $or: [outflowQuery, inflowQuery], - }; + + return { amount: { [op]: value } }; } else if (type === 'string') { return { [field]: { $transform: '$lower', [op]: value } }; } else if (type === 'date') { diff --git a/upcoming-release-notes/2803.md b/upcoming-release-notes/2803.md new file mode 100644 index 0000000000000000000000000000000000000000..aad31de33a5b1d19ce5d55808a000f8d819242c4 --- /dev/null +++ b/upcoming-release-notes/2803.md @@ -0,0 +1,6 @@ +--- +category: Bugfix +authors: [youngcw] +--- + +Revert amount filter chnage