Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Fix #853
James Coleea1d543795d0
diff --git a/app/Jobs/ExecuteRuleOnExistingTransactions.php b/app/Jobs/ExecuteRuleOnExistingTransactions.phpindex 33d7ba7d34..e1dff7ef7d 100644--- a/app/Jobs/ExecuteRuleOnExistingTransactions.php+++ b/app/Jobs/ExecuteRuleOnExistingTransactions.php@@ -20,6 +20,7 @@ use Illuminate\Contracts\Queue\ShouldQueue;use Illuminate\Queue\InteractsWithQueue;use Illuminate\Queue\SerializesModels;use Illuminate\Support\Collection;+use Log;/*** Class ExecuteRuleOnExistingTransactions@@ -128,18 +129,27 @@ class ExecuteRuleOnExistingTransactions extends Job implements ShouldQueue{// Lookup all journals that match the parameters specified$transactions = $this->collectJournals();- $processor = Processor::make($this->rule);-+ $processor = Processor::make($this->rule, true);+ $hits = 0;+ $misses = 0;+ $total = 0;// Execute the rules for each transactionforeach ($transactions as $transaction) {-- $processor->handleTransaction($transaction);-+ $total++;+ $result = $processor->handleTransaction($transaction);+ if($result) {+ $hits++;+ }+ if(!$result) {+ $misses++;+ }+ Log::info(sprintf('Current progress: %d Transactions. Hits: %d, misses: %d', $total, $hits, $misses));// Stop processing this group if the rule specifies 'stop_processing'if ($processor->getRule()->stop_processing) {break;}}+ Log::info(sprintf('Total transactions: %d. Hits: %d, misses: %d', $total, $hits, $misses));}diff --git a/app/TransactionRules/Processor.php b/app/TransactionRules/Processor.phpindex 449edea798..509b229d26 100644--- a/app/TransactionRules/Processor.php+++ b/app/TransactionRules/Processor.php@@ -40,7 +40,7 @@ final class Processorpublic $rule;/** @var Collection */public $triggers;-+ /** @var int */protected $foundTriggers = 0;/**@@ -170,9 +170,14 @@ final class Processor// get all triggers:$triggered = $this->triggered();if ($triggered) {+ Log::debug('Rule is triggered, go to actions.');if ($this->actions->count() > 0) {+ Log::debug('Has more than zero actions.');$this->actions();}+ if ($this->actions->count() === 0) {+ Log::info('Rule has no actions!');+ }return true;}diff --git a/public/js/ff/rules/index.js b/public/js/ff/rules/index.jsindex e7cfeae014..df057ce7a7 100644--- a/public/js/ff/rules/index.js+++ b/public/js/ff/rules/index.js@@ -44,12 +44,25 @@ $(function () {);function testRuleTriggers(e) {+var obj = $(e.target);var ruleId = parseInt(obj.data('id'));+ var icon = obj;+ if(obj.prop("tagName") === 'A') {+ icon = $('i', obj);+ }+ // change icon:+ icon.addClass('fa-spinner fa-spin').removeClass('fa-flask');++ var modal = $("#testTriggerModal");+ // respond to modal:+ modal.on('hide.bs.modal', function (e) {+ disableRuleSpinners();+ });// Find a list of existing transactions that match these triggers$.get('rules/test-rule/' + ruleId).done(function (data) {- var modal = $("#testTriggerModal");+// Set title and bodymodal.find(".transactions-list").html(data.html);@@ -66,11 +79,16 @@ function testRuleTriggers(e) {modal.modal();}).fail(function () {alert('Cannot get transactions for given triggers.');+ disableRuleSpinners();});return false;}+function disableRuleSpinners() {+ $('i.test_rule_triggers').removeClass('fa-spin fa-spinner').addClass('fa-flask');+}+function sortStop(event, ui) {"use strict";diff --git a/public/js/ff/rules/select-transactions.js b/public/js/ff/rules/select-transactions.jsindex 675a5fe730..32e5176bbf 100644--- a/public/js/ff/rules/select-transactions.js+++ b/public/js/ff/rules/select-transactions.js@@ -6,7 +6,7 @@* See the LICENSE file for details.*/-/** global: Modernizr */+/** global: Modernizr, askReadWarning */$(document).ready(function () {"use strict";@@ -17,4 +17,7 @@ $(document).ready(function () {});}+ $('form.form-horizontal').on('submit', function () {+ return confirm(askReadWarning);+ });});diff --git a/resources/lang/en_US/firefly.php b/resources/lang/en_US/firefly.phpindex 6d4caf22ba..e43c0c1a8a 100644--- a/resources/lang/en_US/firefly.php+++ b/resources/lang/en_US/firefly.php@@ -319,6 +319,8 @@ return ['rule_action_set_source_account' => 'Set source account to :action_value','rule_action_set_destination_account_choice' => 'Set destination account to...','rule_action_set_destination_account' => 'Set destination account to :action_value',+ 'rules_have_read_warning' => 'Have you read the warning?',+ 'apply_rule_warning' => 'Warning: running a rule(group) on a large selection of transactions could take ages, and it could time-out. If it does, the rule(group) will only be applied to an unknown subset of your transactions. This might leave your financial administration in tatters. Please be careful.',// tags'store_new_tag' => 'Store new tag',diff --git a/resources/views/rules/index.twig b/resources/views/rules/index.twigindex 4ef73d26c5..2768eb10c5 100644--- a/resources/views/rules/index.twig+++ b/resources/views/rules/index.twig@@ -107,8 +107,7 @@<td><div class="btn-group btn-group-xs test_buttons">{# show which transactions would match #}- <a href="#" class="btn btn-default test_rule_triggers" data-id="{{ rule.id }}"- title="{{ 'test_rule_triggers'|_ }}"><i data-id="{{ rule.id }}" class="fa fa-fw fa-flask"></i></a>+ <a href="#" class="btn btn-default test_rule_triggers" data-id="{{ rule.id }}" title="{{ 'test_rule_triggers'|_ }}"><i data-id="{{ rule.id }}" class="test_rule_triggers fa fa-fw fa-flask"></i></a>{# actually execute rule #}<a href="{{ route('rules.select-transactions',rule.id) }}" class="btn btn-default"diff --git a/resources/views/rules/rule-group/select-transactions.twig b/resources/views/rules/rule-group/select-transactions.twigindex f0c7c43331..ab8308df71 100644--- a/resources/views/rules/rule-group/select-transactions.twig+++ b/resources/views/rules/rule-group/select-transactions.twig@@ -21,6 +21,9 @@<p>{{ trans('firefly.apply_rule_group_selection_intro', {title: ruleGroup.title}) }}</p>+ <p class="text-danger">+ {{ 'apply_rule_warning'|_ }}+ </p><div class="row"><div class="col-lg-6 col-md-8 col-sm-12 col-xs-12">{{ ExpandedForm.date('start_date', first) }}@@ -41,6 +44,9 @@</form>{% endblock %}{% block scripts %}+ <script type="text/javascript">+ var askReadWarning = "{{ trans('firefly.rules_have_read_warning')|escape('js') }}";+ </script><script type="text/javascript" src="js/lib/modernizr-custom.js?v={{ FF_VERSION }}"></script><script type="text/javascript" src="js/lib/jquery-ui.min.js?v={{ FF_VERSION }}"></script><script type="text/javascript" src="js/ff/rules/select-transactions.js?v={{ FF_VERSION }}"></script>diff --git a/resources/views/rules/rule/select-transactions.twig b/resources/views/rules/rule/select-transactions.twigindex 4429c48338..a98ea000e0 100644--- a/resources/views/rules/rule/select-transactions.twig+++ b/resources/views/rules/rule/select-transactions.twig@@ -21,6 +21,9 @@<p>{{ trans('firefly.apply_rule_selection_intro', {title: rule.title}) }}</p>+ <p class="text-danger">+ {{ 'apply_rule_warning'|_ }}+ </p><div class="row"><div class="col-lg-6 col-md-8 col-sm-12 col-xs-12">{{ ExpandedForm.date('start_date', first) }}@@ -41,6 +44,9 @@</form>{% endblock %}{% block scripts %}+ <script type="text/javascript">+ var askReadWarning = "{{ trans('firefly.rules_have_read_warning')|escape('js') }}";+ </script><script type="text/javascript" src="js/lib/modernizr-custom.js?v={{ FF_VERSION }}"></script><script type="text/javascript" src="js/lib/jquery-ui.min.js?v={{ FF_VERSION }}"></script><script type="text/javascript" src="js/ff/rules/select-transactions.js?v={{ FF_VERSION }}"></script>