Skip to content

Commit

Permalink
fix: notes is (nothing) not working
Browse files Browse the repository at this point in the history
  • Loading branch information
UnderKoen committed Dec 17, 2024
1 parent 94666a2 commit 247d79e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
3 changes: 3 additions & 0 deletions packages/loot-core/src/server/accounts/rules.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ describe('Condition', () => {

cond = new Condition('is', 'payee', null, null);
expect(cond.eval({ payee: null })).toBe(true);

cond = new Condition('is', 'notes', '', null);
expect(cond.eval({ notes: null })).toBe(true);
});

test('ops handles undefined fields', () => {
Expand Down
8 changes: 6 additions & 2 deletions packages/loot-core/src/server/accounts/rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,12 @@ export class Condition {

eval(object) {
let fieldValue = object[this.field];
const type = this.type;

if (type === 'string') {
fieldValue ??= '';
}

if (fieldValue === undefined) {
return false;
}
Expand All @@ -368,8 +374,6 @@ export class Condition {
fieldValue = fieldValue.toLowerCase();
}

const type = this.type;

if (type === 'number' && this.options) {
if (this.options.outflow) {
if (fieldValue > 0) {
Expand Down
6 changes: 6 additions & 0 deletions upcoming-release-notes/3998.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
category: Bugfix
authors: [UnderKoen]
---

Usage of notes is (nothing) on new transactions

0 comments on commit 247d79e

Please sign in to comment.