diff --git a/packages/loot-core/src/server/accounts/rules.test.ts b/packages/loot-core/src/server/accounts/rules.test.ts index b0b0f24654b..88bf161ac00 100644 --- a/packages/loot-core/src/server/accounts/rules.test.ts +++ b/packages/loot-core/src/server/accounts/rules.test.ts @@ -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', () => { diff --git a/packages/loot-core/src/server/accounts/rules.ts b/packages/loot-core/src/server/accounts/rules.ts index 449590370fb..b140819fffb 100644 --- a/packages/loot-core/src/server/accounts/rules.ts +++ b/packages/loot-core/src/server/accounts/rules.ts @@ -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; } @@ -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) { diff --git a/upcoming-release-notes/3998.md b/upcoming-release-notes/3998.md new file mode 100644 index 00000000000..0a52a17bf48 --- /dev/null +++ b/upcoming-release-notes/3998.md @@ -0,0 +1,6 @@ +--- +category: Bugfix +authors: [UnderKoen] +--- + +Usage of notes is (nothing) on new transactions