diff --git a/packages/loot-core/src/server/accounts/rules.ts b/packages/loot-core/src/server/accounts/rules.ts index 71aab527001..846682f166a 100644 --- a/packages/loot-core/src/server/accounts/rules.ts +++ b/packages/loot-core/src/server/accounts/rules.ts @@ -12,6 +12,7 @@ import { import { sortNumbers, getApproxNumberThreshold } from '../../shared/rules'; import { recurConfigToRSchedule } from '../../shared/schedules'; import { fastSetMerge } from '../../shared/util'; +import { RuleConditionEntity } from '../../types/models'; import { RuleError } from '../errors'; import { Schedule as RSchedule } from '../util/rschedule'; @@ -637,9 +638,11 @@ export class RuleIndexer { } } -const OP_SCORES = { +const OP_SCORES: Record = { is: 10, + isNot: 10, oneOf: 9, + notOneOf: 9, isapprox: 5, isbetween: 5, gt: 1, @@ -647,6 +650,7 @@ const OP_SCORES = { lt: 1, lte: 1, contains: 0, + doesNotContain: 0, }; function computeScore(rule) { diff --git a/packages/loot-core/src/types/models/rule.d.ts b/packages/loot-core/src/types/models/rule.d.ts index fee3e047824..12549e05495 100644 --- a/packages/loot-core/src/types/models/rule.d.ts +++ b/packages/loot-core/src/types/models/rule.d.ts @@ -11,7 +11,19 @@ export interface RuleEntity { interface RuleConditionEntity { field: unknown; - op: unknown; + op: + | 'is' + | 'isNot' + | 'oneOf' + | 'notOneOf' + | 'isapprox' + | 'isbetween' + | 'gt' + | 'gte' + | 'lt' + | 'lte' + | 'contains' + | 'doesNotContain'; value: unknown; options?: unknown; conditionsOp?: unknown; diff --git a/upcoming-release-notes/1987.md b/upcoming-release-notes/1987.md new file mode 100644 index 00000000000..47fddc10e75 --- /dev/null +++ b/upcoming-release-notes/1987.md @@ -0,0 +1,6 @@ +--- +category: Bugfix +authors: [carkom] +--- + +Fix rule ranker in API.