Implemented filter not to return all transactions when testing filters

This commit is contained in:
Robert Horlings
2016-02-17 16:23:43 +01:00
parent 8fdc6c11e1
commit 7ec5cce2c8
3 changed files with 14 additions and 5 deletions

View File

@@ -339,7 +339,11 @@ class RuleController extends Controller
*/
public function testTriggers() {
// Create a list of triggers
$triggers = $this->getTriggerList();
$triggers = $this->getValidTriggerList();
if(count($triggers) == 0) {
return Response::json(['html' => '', 'warning' => trans('firefly.warning_no_valid_triggers') ]);
}
// We start searching for transactions. For performance reasons, there are limits
// to the search: a maximum number of results and a maximum number of transactions
@@ -370,10 +374,11 @@ class RuleController extends Controller
}
/**
* Returns a list of triggers as provided in the URL
* Returns a list of triggers as provided in the URL.
* Only returns triggers that will not match any transaction
* @return array
*/
protected function getTriggerList() {
protected function getValidTriggerList() {
$triggers = [];
$order = 1;
$data = [
@@ -395,8 +400,10 @@ class RuleController extends Controller
$ruleTrigger->trigger_value = $value;
// Store in list
$triggers[] = $ruleTrigger;
$order++;
if( !$ruleTrigger->matchesAnything() ) {
$triggers[] = $ruleTrigger;
$order++;
}
}
return $triggers;