Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Smaller rule list
James Cole4723d9dd3034
diff --git a/app/Console/Commands/Tools/ApplyRules.php b/app/Console/Commands/Tools/ApplyRules.phpindex 8f7ddaac4e..3f78585b94 100644--- a/app/Console/Commands/Tools/ApplyRules.php+++ b/app/Console/Commands/Tools/ApplyRules.php@@ -133,7 +133,7 @@ class ApplyRules extends Command// start running rules.$this->friendlyLine(sprintf('Will apply %d rule(s) to your transaction(s).', $count));- // file the rule(s)+ // fire the rule(s)$ruleEngine->fire();$this->friendlyLine('');diff --git a/app/TransactionRules/Engine/SearchRuleEngine.php b/app/TransactionRules/Engine/SearchRuleEngine.phpindex edfb5e5776..fcd0383c93 100644--- a/app/TransactionRules/Engine/SearchRuleEngine.php+++ b/app/TransactionRules/Engine/SearchRuleEngine.php@@ -100,8 +100,16 @@ class SearchRuleEngine implements RuleEngineInterface// if rules and no rule groups, file each rule separately.if (0 !== $this->rules->count()) {app('log')->debug(sprintf('SearchRuleEngine:: found %d rule(s) to fire.', $this->rules->count()));++ /** @var Rule $rule */foreach ($this->rules as $rule) {- $this->fireRule($rule);+ $result = $this->fireRule($rule);+ if (true === $result && $rule->stop_processing) {+ app('log')->debug(sprintf('Rule #%d has triggered and executed, but calls to stop processing. Since not in the context of a group, do not stop.', $rule->id));+ }+ if (false === $result && $rule->stop_processing) {+ app('log')->debug(sprintf('Rule #%d has triggered and changed nothing, but calls to stop processing. Do not stop.', $rule->id));+ }}app('log')->debug('SearchRuleEngine:: done processing all rules!');@@ -176,7 +184,7 @@ class SearchRuleEngine implements RuleEngineInterface}// if needs no context, value is different:- $needsContext = (bool)(config(sprintf('search.operators.%s.needs_context', $ruleTrigger->trigger_type)) ?? true);+ $needsContext = (bool) (config(sprintf('search.operators.%s.needs_context', $ruleTrigger->trigger_type)) ?? true);if (false === $needsContext) {app('log')->debug(sprintf('SearchRuleEngine:: add a rule trigger (no context): %s:true', $ruleTrigger->trigger_type));$searchArray[$ruleTrigger->trigger_type][] = 'true';@@ -249,7 +257,7 @@ class SearchRuleEngine implements RuleEngineInterface$journalId = 0;foreach ($array as $triggerName => $values) {if ('journal_id' === $triggerName && is_array($values) && 1 === count($values)) {- $journalId = (int)trim($values[0] ?? '"0"', '"'); // follows format "123".+ $journalId = (int) trim($values[0] ?? '"0"', '"'); // follows format "123".app('log')->debug(sprintf('Found journal ID #%d', $journalId));}}@@ -326,7 +334,7 @@ class SearchRuleEngine implements RuleEngineInterfaceapp('log')->debug(sprintf('Total collection is now %d transactions', $total->count()));++$count;// if trigger says stop processing, do so.- if($ruleTrigger->stop_processing && $collection->count() > 0) {+ if ($ruleTrigger->stop_processing && $collection->count() > 0) {app('log')->debug('The trigger says to stop processing, so stop processing other triggers.');break;diff --git a/public/v1/js/ff/rules/index.js b/public/v1/js/ff/rules/index.jsindex cae9c524bc..be61c0853d 100644--- a/public/v1/js/ff/rules/index.js+++ b/public/v1/js/ff/rules/index.js@@ -97,6 +97,35 @@ $(function () {});+ // show rule triggers+ $('.rule-triggers-show').click(function (e) {+ var obj = $(e.currentTarget);+ $('.rule-trigger-list[data-id="' + obj.data('id') + '"]').show();+ $('.rule-triggers-show[data-id="' + obj.data('id') + '"]').hide();+ });++ $('.rule-trigger-list').each(function(i,v) {+ var obj = $(v);+ if(obj.data('count') > 2) {+ obj.hide();+ $('.rule-triggers-show[data-id="' + obj.data('id') + '"]').show();+ }+ });+ // show rule actions+ $('.rule-actions-show').click(function (e) {+ var obj = $(e.currentTarget);+ $('.rule-action-list[data-id="' + obj.data('id') + '"]').show();+ $('.rule-actions-show[data-id="' + obj.data('id') + '"]').hide();+ });++ $('.rule-action-list').each(function(i,v) {+ var obj = $(v);+ if(obj.data('count') > 1) {+ obj.hide();+ $('.rule-actions-show[data-id="' + obj.data('id') + '"]').show();+ }+ });+$('.move-group').click(moveRuleGroup);$('.duplicate-rule').click(duplicateRule);diff --git a/resources/lang/en_US/firefly.php b/resources/lang/en_US/firefly.phpindex afbc6480d4..a778c3cd0b 100644--- a/resources/lang/en_US/firefly.php+++ b/resources/lang/en_US/firefly.php@@ -721,6 +721,8 @@ return [// rules'is_not_rule_trigger' => 'Not','cannot_fire_inactive_rules' => 'You cannot execute inactive rules.',+ 'show_triggers' => 'Show triggers',+ 'show_actions' => 'Show actions','rules' => 'Rules','rule_name' => 'Name of rule','rule_triggers' => 'Rule triggers when',diff --git a/resources/views/rules/index.twig b/resources/views/rules/index.twigindex 45c50c328f..ebf96c07df 100644--- a/resources/views/rules/index.twig+++ b/resources/views/rules/index.twig@@ -125,11 +125,11 @@{% endif %}><br/>{{ rule.description|default('')|markdown }}</small>{% endif %}- <small><br/>{% if rule.strict %}<span class="text-danger">{{ 'rule_is_strict'|_ }}</span>{% else %}<span class="text-success">{{ 'rule_is_not_strict'|_ }}</span>{% endif %}</small>+ <small>({% if rule.strict %}<span class="text-danger">{{ 'rule_is_strict'|_ }}</span>{% else %}<span class="text-success">{{ 'rule_is_not_strict'|_ }}</span>{% endif %})</small></td><td class="hidden-xs">{% if rule.ruleTriggers.count() > 0 %}- <ul class="small" data-id="{{ rule.id }}">+ <ul class="small rule-trigger-list" data-count="{{ rule.ruleTriggers.count() }}" data-id="{{ rule.id }}">{% for trigger in rule.ruleTriggers %}{% if trigger.trigger_type != "user_action" %}<li@@ -146,11 +146,12 @@{% endif %}{% endfor %}</ul>+ <span class="small rule-triggers-show" style="cursor:pointer;display:none;" data-id="{{ rule.id }}">{{ 'show_triggers'|_ }}</span>{% endif %}</td><td class="hidden-xs">{% if rule.ruleActions.count() > 0 %}- <ul class="small" data-id="{{ rule.id }}">+ <ul class="small rule-action-list" data-count="{{ rule.ruleActions.count() }}" data-id="{{ rule.id }}">{% for action in rule.ruleActions %}<li{% if not rule.active %}@@ -163,6 +164,7 @@</li>{% endfor %}</ul>+ <span class="small rule-actions-show" style="cursor:pointer;display:none;" data-id="{{ rule.id }}">{{ 'show_actions'|_ }}</span>{% endif %}</td></tr>