This commit is contained in:
James Cole
2019-12-28 06:38:23 +01:00
parent 0d48556994
commit 47eb39b10d
2 changed files with 6 additions and 3 deletions

View File

@@ -95,7 +95,7 @@ class SelectController extends Controller
$ruleEngine = app(RuleEngine::class); $ruleEngine = app(RuleEngine::class);
$ruleEngine->setUser(auth()->user()); $ruleEngine->setUser(auth()->user());
$ruleEngine->setRulesToApply($rules); $ruleEngine->setRulesToApply($rules);
$ruleEngine->setTriggerMode(RuleEngine::TRIGGER_STORE); $ruleEngine->setTriggerMode(RuleEngine::TRIGGER_BOTH);
/** @var GroupCollectorInterface $collector */ /** @var GroupCollectorInterface $collector */
$collector = app(GroupCollectorInterface::class); $collector = app(GroupCollectorInterface::class);
@@ -127,7 +127,7 @@ class SelectController extends Controller
public function selectTransactions(Rule $rule) public function selectTransactions(Rule $rule)
{ {
// does the user have shared accounts? // does the user have shared accounts?
$first = session('first')->format('Y-m-d'); $first = session('first', Carbon::now()->subYear())->format('Y-m-d');
$today = Carbon::now()->format('Y-m-d'); $today = Carbon::now()->format('Y-m-d');
$subTitle = (string)trans('firefly.apply_rule_selection', ['title' => $rule->title]); $subTitle = (string)trans('firefly.apply_rule_selection', ['title' => $rule->title]);

View File

@@ -48,6 +48,8 @@ class RuleEngine
public const TRIGGER_STORE = 1; public const TRIGGER_STORE = 1;
/** @var int */ /** @var int */
public const TRIGGER_UPDATE = 2; public const TRIGGER_UPDATE = 2;
/** @var int */
public const TRIGGER_BOTH = 3;
/** @var bool */ /** @var bool */
private $allRules; private $allRules;
/** @var RuleGroupRepository */ /** @var RuleGroupRepository */
@@ -227,7 +229,8 @@ class RuleEngine
} }
$validTrigger = ('store-journal' === $trigger->trigger_value && self::TRIGGER_STORE === $this->triggerMode) $validTrigger = ('store-journal' === $trigger->trigger_value && self::TRIGGER_STORE === $this->triggerMode)
|| ('update-journal' === $trigger->trigger_value && self::TRIGGER_UPDATE === $this->triggerMode); || ('update-journal' === $trigger->trigger_value && self::TRIGGER_UPDATE === $this->triggerMode)
|| $this->triggerMode === self::TRIGGER_BOTH;
return $validTrigger && ($this->allRules || in_array($rule->id, $this->rulesToApply, true)) && true === $rule->active; return $validTrigger && ($this->allRules || in_array($rule->id, $this->rulesToApply, true)) && true === $rule->active;
} }