From 28698cc7694c40ed182ed07e870ad4d3bd2621fb Mon Sep 17 00:00:00 2001 From: James Cole Date: Sun, 23 Aug 2020 17:00:47 +0200 Subject: [PATCH] Make sure limits exist in rule engine. --- app/Console/Commands/Tools/ApplyRules.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/Console/Commands/Tools/ApplyRules.php b/app/Console/Commands/Tools/ApplyRules.php index 27670e4ec3..3e5e2e7078 100644 --- a/app/Console/Commands/Tools/ApplyRules.php +++ b/app/Console/Commands/Tools/ApplyRules.php @@ -130,6 +130,18 @@ class ApplyRules extends Command $ruleEngine->setRules($rulesToApply); $ruleEngine->setUser($this->getUser()); + // add the accounts as filter: + $accounts = []; + foreach($this->accounts as $account) { + $accounts[] = $account->id; + } + $list = implode(',', $accounts); + $ruleEngine->addOperator(['type' => 'account_id', 'value' => $list]); + + // add the date as a filter: + $ruleEngine->addOperator(['type' => 'date_after', 'value' => $this->startDate->format('Y-m-d')]); + $ruleEngine->addOperator(['type' => 'date_before', 'value' => $this->endDate->format('Y-m-d')]); + // start running rules. $this->line(sprintf('Will apply %d rule(s) to your transaction(s).', $count));