Merge pull request #189 from roberthorlings/feature/trigger-matches-anything

Check for triggers that match anything
This commit is contained in:
James Cole 2016-02-17 15:28:39 +01:00
commit b3e18f4e56
19 changed files with 165 additions and 0 deletions

View File

@ -36,4 +36,12 @@ class RuleTrigger extends Model
{
return $this->belongsTo('FireflyIII\Models\Rule');
}
/**
* Checks whether this trigger will match all transactions
* For example: amount > 0 or description starts with ''
*/
public function matchesAnything() {
return TriggerFactory::getTrigger($this, new TransactionJournal)->matchesAnything();
}
}

View File

@ -62,4 +62,11 @@ class AmountExactly implements TriggerInterface
return false;
}
/**
* Checks whether this trigger will match all transactions
* For example: amount > 0 or description starts with ''
* @return bool
*/
public function matchesAnything() { return false; }
}

View File

@ -62,4 +62,11 @@ class AmountLess implements TriggerInterface
return false;
}
/**
* Checks whether this trigger will match all transactions
* For example: amount > 0 or description starts with ''
* @return bool
*/
public function matchesAnything() { return false; }
}

View File

@ -62,4 +62,13 @@ class AmountMore implements TriggerInterface
return false;
}
/**
* Checks whether this trigger will match all transactions
* This happens when the trigger_value is zero
* @return bool
*/
public function matchesAnything() {
return bccomp('0', $this->trigger->trigger_value) === 0;
}
}

View File

@ -63,4 +63,13 @@ class DescriptionContains implements TriggerInterface
return false;
}
/**
* Checks whether this trigger will match all transactions
* This happens when the trigger_value is empty
* @return bool
*/
public function matchesAnything() {
return $this->trigger->trigger_value === "";
}
}

View File

@ -72,4 +72,14 @@ class DescriptionEnds implements TriggerInterface
return false;
}
/**
* Checks whether this trigger will match all transactions
* This happens when the trigger_value is empty
* @return bool
*/
public function matchesAnything() {
return $this->trigger->trigger_value === "";
}
}

View File

@ -58,4 +58,11 @@ class DescriptionIs implements TriggerInterface
return false;
}
/**
* Checks whether this trigger will match all transactions
* @return bool
*/
public function matchesAnything() { return false; }
}

View File

@ -60,4 +60,14 @@ class DescriptionStarts implements TriggerInterface
return false;
}
/**
* Checks whether this trigger will match all transactions
* This happens when the trigger_value is empty
* @return bool
*/
public function matchesAnything() {
return $this->trigger->trigger_value === "";
}
}

View File

@ -62,4 +62,14 @@ class FromAccountContains implements TriggerInterface
return false;
}
/**
* Checks whether this trigger will match all transactions
* This happens when the trigger_value is empty
* @return bool
*/
public function matchesAnything() {
return $this->trigger->trigger_value === "";
}
}

View File

@ -72,4 +72,15 @@ class FromAccountEnds implements TriggerInterface
return false;
}
/**
* Checks whether this trigger will match all transactions
* This happens when the trigger_value is empty
* @return bool
*/
public function matchesAnything() {
return $this->trigger->trigger_value === "";
}
}

View File

@ -58,4 +58,11 @@ class FromAccountIs implements TriggerInterface
return false;
}
/**
* Checks whether this trigger will match all transactions
* @return bool
*/
public function matchesAnything() { return false; }
}

View File

@ -60,4 +60,15 @@ class FromAccountStarts implements TriggerInterface
return false;
}
/**
* Checks whether this trigger will match all transactions
* This happens when the trigger_value is empty
* @return bool
*/
public function matchesAnything() {
return $this->trigger->trigger_value === "";
}
}

View File

@ -62,4 +62,15 @@ class ToAccountContains implements TriggerInterface
return false;
}
/**
* Checks whether this trigger will match all transactions
* This happens when the trigger_value is empty
* @return bool
*/
public function matchesAnything() {
return $this->trigger->trigger_value === "";
}
}

View File

@ -72,4 +72,14 @@ class ToAccountEnds implements TriggerInterface
return false;
}
/**
* Checks whether this trigger will match all transactions
* This happens when the trigger_value is empty
* @return bool
*/
public function matchesAnything() {
return $this->trigger->trigger_value === "";
}
}

View File

@ -58,4 +58,11 @@ class ToAccountIs implements TriggerInterface
return false;
}
/**
* Checks whether this trigger will match all transactions
* @return bool
*/
public function matchesAnything() { return false; }
}

View File

@ -60,4 +60,15 @@ class ToAccountStarts implements TriggerInterface
return false;
}
/**
* Checks whether this trigger will match all transactions
* This happens when the trigger_value is empty
* @return bool
*/
public function matchesAnything() {
return $this->trigger->trigger_value === "";
}
}

View File

@ -57,4 +57,11 @@ class TransactionType implements TriggerInterface
return false;
}
/**
* Checks whether this trigger will match all transactions
* @return bool
*/
public function matchesAnything() { return false; }
}

View File

@ -32,4 +32,11 @@ interface TriggerInterface
* @return bool
*/
public function triggered();
/**
* Checks whether this trigger will match all transactions
* For example: amount > 0 or description starts with ''
* @return bool
*/
public function matchesAnything();
}

View File

@ -53,4 +53,10 @@ class UserAction implements TriggerInterface
return true;
}
/**
* Checks whether this trigger will match all transactions
* @return bool
*/
public function matchesAnything() { return true; }
}