Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Added method for triggers to check whether they match all transactions
Robert Horlings7c8c82edd7b2
diff --git a/app/Rules/Triggers/AmountExactly.php b/app/Rules/Triggers/AmountExactly.phpindex 02045a42f8..998d851dd5 100644--- a/app/Rules/Triggers/AmountExactly.php+++ b/app/Rules/Triggers/AmountExactly.php@@ -62,4 +62,11 @@ class AmountExactly implements TriggerInterfacereturn false;}++ /**+ * Checks whether this trigger will match all transactions+ * For example: amount > 0 or description starts with ''+ * @return bool+ */+ public function matchesAnything() { return false; }}diff --git a/app/Rules/Triggers/AmountLess.php b/app/Rules/Triggers/AmountLess.phpindex cfad91f24b..e90428a233 100644--- a/app/Rules/Triggers/AmountLess.php+++ b/app/Rules/Triggers/AmountLess.php@@ -62,4 +62,11 @@ class AmountLess implements TriggerInterfacereturn false;}++ /**+ * Checks whether this trigger will match all transactions+ * For example: amount > 0 or description starts with ''+ * @return bool+ */+ public function matchesAnything() { return false; }}diff --git a/app/Rules/Triggers/AmountMore.php b/app/Rules/Triggers/AmountMore.phpindex a7d6711f1f..4a1376dfe7 100644--- a/app/Rules/Triggers/AmountMore.php+++ b/app/Rules/Triggers/AmountMore.php@@ -62,4 +62,13 @@ class AmountMore implements TriggerInterfacereturn 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;+ }}diff --git a/app/Rules/Triggers/DescriptionContains.php b/app/Rules/Triggers/DescriptionContains.phpindex 4e5fe8428a..a26d8628d0 100644--- a/app/Rules/Triggers/DescriptionContains.php+++ b/app/Rules/Triggers/DescriptionContains.php@@ -63,4 +63,13 @@ class DescriptionContains implements TriggerInterfacereturn 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 === "";+ }}diff --git a/app/Rules/Triggers/DescriptionEnds.php b/app/Rules/Triggers/DescriptionEnds.phpindex b71009799a..fde345df80 100644--- a/app/Rules/Triggers/DescriptionEnds.php+++ b/app/Rules/Triggers/DescriptionEnds.php@@ -72,4 +72,14 @@ class DescriptionEnds implements TriggerInterfacereturn 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 === "";+ }+}diff --git a/app/Rules/Triggers/DescriptionIs.php b/app/Rules/Triggers/DescriptionIs.phpindex 12bc48b697..2d38bc46f6 100644--- a/app/Rules/Triggers/DescriptionIs.php+++ b/app/Rules/Triggers/DescriptionIs.php@@ -58,4 +58,11 @@ class DescriptionIs implements TriggerInterfacereturn false;}++ /**+ * Checks whether this trigger will match all transactions+ * @return bool+ */+ public function matchesAnything() { return false; }+}diff --git a/app/Rules/Triggers/DescriptionStarts.php b/app/Rules/Triggers/DescriptionStarts.phpindex 9b23e1253c..2b41bad3e3 100644--- a/app/Rules/Triggers/DescriptionStarts.php+++ b/app/Rules/Triggers/DescriptionStarts.php@@ -60,4 +60,14 @@ class DescriptionStarts implements TriggerInterfacereturn 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 === "";+ }+}diff --git a/app/Rules/Triggers/FromAccountContains.php b/app/Rules/Triggers/FromAccountContains.phpindex 05badb6f7b..9da8cbd290 100644--- a/app/Rules/Triggers/FromAccountContains.php+++ b/app/Rules/Triggers/FromAccountContains.php@@ -62,4 +62,14 @@ class FromAccountContains implements TriggerInterfacereturn 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 === "";+ }+}diff --git a/app/Rules/Triggers/FromAccountEnds.php b/app/Rules/Triggers/FromAccountEnds.phpindex e4b144bb87..26927c6370 100644--- a/app/Rules/Triggers/FromAccountEnds.php+++ b/app/Rules/Triggers/FromAccountEnds.php@@ -72,4 +72,15 @@ class FromAccountEnds implements TriggerInterfacereturn 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 === "";+ }+}diff --git a/app/Rules/Triggers/FromAccountIs.php b/app/Rules/Triggers/FromAccountIs.phpindex 9fb084de93..1cdbc30521 100644--- a/app/Rules/Triggers/FromAccountIs.php+++ b/app/Rules/Triggers/FromAccountIs.php@@ -58,4 +58,11 @@ class FromAccountIs implements TriggerInterfacereturn false;}++ /**+ * Checks whether this trigger will match all transactions+ * @return bool+ */+ public function matchesAnything() { return false; }+}diff --git a/app/Rules/Triggers/FromAccountStarts.php b/app/Rules/Triggers/FromAccountStarts.phpindex 6eea3179f4..43e8f915b9 100644--- a/app/Rules/Triggers/FromAccountStarts.php+++ b/app/Rules/Triggers/FromAccountStarts.php@@ -60,4 +60,15 @@ class FromAccountStarts implements TriggerInterfacereturn 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 === "";+ }+}diff --git a/app/Rules/Triggers/ToAccountContains.php b/app/Rules/Triggers/ToAccountContains.phpindex 06d081bfac..0e291a904a 100644--- a/app/Rules/Triggers/ToAccountContains.php+++ b/app/Rules/Triggers/ToAccountContains.php@@ -62,4 +62,15 @@ class ToAccountContains implements TriggerInterfacereturn 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 === "";+ }+}diff --git a/app/Rules/Triggers/ToAccountEnds.php b/app/Rules/Triggers/ToAccountEnds.phpindex 5637df0cb6..60784e4b6f 100644--- a/app/Rules/Triggers/ToAccountEnds.php+++ b/app/Rules/Triggers/ToAccountEnds.php@@ -72,4 +72,14 @@ class ToAccountEnds implements TriggerInterfacereturn 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 === "";+ }}diff --git a/app/Rules/Triggers/ToAccountIs.php b/app/Rules/Triggers/ToAccountIs.phpindex 1eb9f5623e..f11fdf272f 100644--- a/app/Rules/Triggers/ToAccountIs.php+++ b/app/Rules/Triggers/ToAccountIs.php@@ -58,4 +58,11 @@ class ToAccountIs implements TriggerInterfacereturn false;}++ /**+ * Checks whether this trigger will match all transactions+ * @return bool+ */+ public function matchesAnything() { return false; }+}diff --git a/app/Rules/Triggers/ToAccountStarts.php b/app/Rules/Triggers/ToAccountStarts.phpindex 446a592d29..bf0ca5f5d7 100644--- a/app/Rules/Triggers/ToAccountStarts.php+++ b/app/Rules/Triggers/ToAccountStarts.php@@ -60,4 +60,15 @@ class ToAccountStarts implements TriggerInterfacereturn 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 === "";+ }+}diff --git a/app/Rules/Triggers/TransactionType.php b/app/Rules/Triggers/TransactionType.phpindex 1a96720fc8..4d46520d50 100644--- a/app/Rules/Triggers/TransactionType.php+++ b/app/Rules/Triggers/TransactionType.php@@ -57,4 +57,11 @@ class TransactionType implements TriggerInterfacereturn false;}++ /**+ * Checks whether this trigger will match all transactions+ * @return bool+ */+ public function matchesAnything() { return false; }+}diff --git a/app/Rules/Triggers/TriggerInterface.php b/app/Rules/Triggers/TriggerInterface.phpindex 074cacdd40..5a653a9d9f 100644--- a/app/Rules/Triggers/TriggerInterface.php+++ b/app/Rules/Triggers/TriggerInterface.php@@ -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();}diff --git a/app/Rules/Triggers/UserAction.php b/app/Rules/Triggers/UserAction.phpindex 917f2d8822..4e576bd573 100644--- a/app/Rules/Triggers/UserAction.php+++ b/app/Rules/Triggers/UserAction.php@@ -53,4 +53,10 @@ class UserAction implements TriggerInterfacereturn true;}+ /**+ * Checks whether this trigger will match all transactions+ * @return bool+ */+ public function matchesAnything() { return true; }+}