Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Delete unused files.
James Cole2fe93656ee6e
diff --git a/app/TransactionRules/Engine/RuleEngine.php b/app/TransactionRules/Engine/RuleEngine.phpdeleted file mode 100644index 336e4a061a..0000000000--- a/app/TransactionRules/Engine/RuleEngine.php+++ /dev/null@@ -1,233 +0,0 @@-<?php-/**- * RuleEngine.php- * Copyright (c) 2019 [email protected]- *- * This file is part of Firefly III (https://github.com/firefly-iii).- *- * This program is free software: you can redistribute it and/or modify- * it under the terms of the GNU Affero General Public License as- * published by the Free Software Foundation, either version 3 of the- * License, or (at your option) any later version.- *- * This program is distributed in the hope that it will be useful,- * but WITHOUT ANY WARRANTY; without even the implied warranty of- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- * GNU Affero General Public License for more details.- *- * You should have received a copy of the GNU Affero General Public License- * along with this program. If not, see <https://www.gnu.org/licenses/>.- */--declare(strict_types=1);--namespace FireflyIII\TransactionRules\Engine;--use FireflyIII\Exceptions\FireflyException;-use FireflyIII\Models\Rule;-use FireflyIII\Models\RuleGroup;-use FireflyIII\Models\RuleTrigger;-use FireflyIII\Models\TransactionJournal;-use FireflyIII\Repositories\RuleGroup\RuleGroupRepository;-use FireflyIII\TransactionRules\Processor;-use FireflyIII\User;-use Illuminate\Contracts\Auth\Authenticatable;-use Illuminate\Support\Collection;-use Log;--/**- * Class RuleEngine- *- * Set the user, then apply an array to setRulesToApply(array) or call addRuleIdToApply(int) or addRuleToApply(Rule).- * Then call process() to make the magic happen.- *- * @deprecated- */-class RuleEngine-{- /** @var int */- public const TRIGGER_STORE = 1;- /** @var int */- public const TRIGGER_UPDATE = 2;- /** @var int */- public const TRIGGER_BOTH = 3;- private bool $allRules;- private RuleGroupRepository $ruleGroupRepository;- private Collection $ruleGroups;- private array $rulesToApply;- private int $triggerMode;- private User $user;-- /**- * RuleEngine constructor.- */- public function __construct()- {- Log::debug('Created RuleEngine');- $this->ruleGroups = new Collection;- $this->rulesToApply = [];- $this->allRules = false;- $this->ruleGroupRepository = app(RuleGroupRepository::class);- $this->triggerMode = self::TRIGGER_STORE;- }-- /**- * @param array $journal- */- public function processJournalArray(array $journal): void- {- $journalId = $journal['id'] ?? $journal['transaction_journal_id'];- Log::debug(sprintf('Will process transaction journal #%d ("%s")', $journalId, $journal['description']));- /** @var RuleGroup $group */- foreach ($this->ruleGroups as $group) {- Log::debug(sprintf('Now at rule group #%d ("%s")', $group->id, $group->title));- $groupTriggered = false;- /** @var Rule $rule */- foreach ($group->rules as $rule) {- Log::debug(sprintf('Now at rule #%d ("%s") from rule group #%d ("%s").', $rule->id, $rule->title, $group->id, $group->title));- $ruleTriggered = false;- // if in rule selection, or group in selection or all rules, it's included.- if ($this->includeRule($rule)) {- Log::debug(sprintf('Rule #%d is included.', $rule->id));- /** @var Processor $processor */- $processor = app(Processor::class);- $ruleTriggered = false;- try {- $processor->make($rule, true);- $ruleTriggered = $processor->handleJournalArray($journal);- } catch (FireflyException $e) {- Log::error($e->getMessage());- }-- if ($ruleTriggered) {- Log::debug('The rule was triggered, so the group is as well!');- $groupTriggered = true;- }- }- if (!$this->includeRule($rule)) {- Log::debug(sprintf('Rule #%d is not included.', $rule->id));- }-- // if the rule is triggered and stop processing is true, cancel the entire group.- if ($ruleTriggered && $rule->stop_processing) {- Log::info(sprintf('Break out group #%d ("%s") because rule #%d ("%s") was triggered.', $group->id, $group->title, $rule->id, $rule->title));- break;- }- }- // if group is triggered and stop processing is true, cancel the whole thing.- if ($groupTriggered && $group->stop_processing) {- Log::info(sprintf('Break out ALL because group #%d was triggered.', $group->id));- break;- }- }- Log::debug('Done processing this transaction journal.');- }-- /**- * @param TransactionJournal $transactionJournal- */- public function processTransactionJournal(TransactionJournal $transactionJournal): void- {- Log::debug(sprintf('Will process transaction journal #%d ("%s")', $transactionJournal->id, $transactionJournal->description));- /** @var RuleGroup $group */- foreach ($this->ruleGroups as $group) {- Log::debug(sprintf('Now at rule group #%d', $group->id));- $groupTriggered = false;- /** @var Rule $rule */- foreach ($group->rules as $rule) {- Log::debug(sprintf('Now at rule #%d from rule group #%d', $rule->id, $group->id));- $ruleTriggered = false;- // if in rule selection, or group in selection or all rules, it's included.- if ($this->includeRule($rule)) {- Log::debug(sprintf('Rule #%d is included.', $rule->id));- /** @var Processor $processor */- $processor = app(Processor::class);- $ruleTriggered = false;- try {- $processor->make($rule, true);- $ruleTriggered = $processor->handleTransactionJournal($transactionJournal);- } catch (FireflyException $e) {- Log::error($e->getMessage());- }-- if ($ruleTriggered) {- Log::debug('The rule was triggered, so the group is as well!');- $groupTriggered = true;- }- }- if (!$this->includeRule($rule)) {- Log::debug(sprintf('Rule #%d is not included.', $rule->id));- }-- // if the rule is triggered and stop processing is true, cancel the entire group.- if ($ruleTriggered && $rule->stop_processing) {- Log::info(sprintf('Break out group #%d because rule #%d was triggered.', $group->id, $rule->id));- break;- }- }- // if group is triggered and stop processing is true, cancel the whole thing.- if ($groupTriggered && $group->stop_processing) {- Log::info(sprintf('Break out ALL because group #%d was triggered.', $group->id));- break;- }- }- Log::debug('Done processing this transaction journal.');- }-- /**- * @param bool $allRules- */- public function setAllRules(bool $allRules): void- {- Log::debug('RuleEngine will apply ALL rules.');- $this->allRules = $allRules;- }-- /**- * @param array $rulesToApply- */- public function setRulesToApply(array $rulesToApply): void- {- Log::debug('RuleEngine will try rules', $rulesToApply);- $this->rulesToApply = $rulesToApply;- }-- /**- * @param int $triggerMode- */- public function setTriggerMode(int $triggerMode): void- {- $this->triggerMode = $triggerMode;- }-- /**- * @param User $user- */- public function setUser(User $user): void- {- $this->user = $user;- $this->ruleGroupRepository->setUser($user);- $this->ruleGroups = $this->ruleGroupRepository->getActiveGroups();- }-- /**- * @param Rule $rule- *- * @return bool- */- private function includeRule(Rule $rule): bool- {- /** @var RuleTrigger $trigger */- $trigger = $rule->ruleTriggers()->where('trigger_type', 'user_action')->first();- if (null === $trigger) {- return false;- }-- $validTrigger = ('store-journal' === $trigger->trigger_value && self::TRIGGER_STORE === $this->triggerMode)- || ('update-journal' === $trigger->trigger_value && self::TRIGGER_UPDATE === $this->triggerMode)- || $this->triggerMode === self::TRIGGER_BOTH;-- return $validTrigger && ($this->allRules || in_array($rule->id, $this->rulesToApply, true)) && true === $rule->active;- }--}diff --git a/app/TransactionRules/Factory/TriggerFactory.php b/app/TransactionRules/Factory/TriggerFactory.phpdeleted file mode 100644index 62260fa2ab..0000000000--- a/app/TransactionRules/Factory/TriggerFactory.php+++ /dev/null@@ -1,137 +0,0 @@-<?php-/**- * TriggerFactory.php- * Copyright (c) 2019 Robert Horlings- *- * This file is part of Firefly III (https://github.com/firefly-iii).- *- * This program is free software: you can redistribute it and/or modify- * it under the terms of the GNU Affero General Public License as- * published by the Free Software Foundation, either version 3 of the- * License, or (at your option) any later version.- *- * This program is distributed in the hope that it will be useful,- * but WITHOUT ANY WARRANTY; without even the implied warranty of- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- * GNU Affero General Public License for more details.- *- * You should have received a copy of the GNU Affero General Public License- * along with this program. If not, see <https://www.gnu.org/licenses/>.- */-declare(strict_types=1);--namespace FireflyIII\TransactionRules\Factory;--use FireflyIII\Exceptions\FireflyException;-use FireflyIII\Models\RuleTrigger;-use FireflyIII\Support\Domain;-use FireflyIII\TransactionRules\Triggers\AbstractTrigger;-use FireflyIII\TransactionRules\Triggers\TriggerInterface;-use Log;--/**- * Class TriggerFactory can create triggers.- *- * @codeCoverageIgnore- */-class TriggerFactory-{- /** @var array array with trigger types */- protected static array $triggerTypes = [];-- /**- * Returns the trigger for the given type and journal. This method returns the actual implementation- * (TransactionRules/Triggers/[object]) for a given RuleTrigger (database object). If for example the database object- * contains trigger_type "description_is" with value "Rent" this method will return a corresponding- * DescriptionIs object preset to "Rent". Any transaction journal then fed to this object will- * be triggered if its description actually is "Rent".- *- * @param RuleTrigger $trigger- *- * @return AbstractTrigger- *- * @throws FireflyException- */- public static function getTrigger(RuleTrigger $trigger): AbstractTrigger- {- $triggerType = $trigger->trigger_type;-- /** @var AbstractTrigger $class */- $class = self::getTriggerClass($triggerType);- $obj = $class::makeFromTriggerValue($trigger->trigger_value);- $obj->stopProcessing = $trigger->stop_processing;-- Log::debug(sprintf('self::getTriggerClass("%s") = "%s"', $triggerType, $class));- Log::debug(sprintf('%s::makeFromTriggerValue(%s) = object of class "%s"', $class, $trigger->trigger_value, get_class($obj)));-- return $obj;- }-- /**- * This method is equal to TriggerFactory::getTrigger but accepts a textual representation of the trigger type- * (for example "description_is"), the trigger value ("Rent") and whether or not Firefly III should stop processing- * other triggers (if present) after this trigger.- *- * This method is used when the RuleTriggers from TriggerFactory::getTrigger do not exist (yet).- *- * @param string $triggerType- * @param string $triggerValue- * @param bool $stopProcessing- *- * @return AbstractTrigger- *- * @throws FireflyException- * @see TriggerFactory::getTrigger- *- */- public static function makeTriggerFromStrings(string $triggerType, string $triggerValue, bool $stopProcessing): AbstractTrigger- {- /** @var AbstractTrigger $class */- $class = self::getTriggerClass($triggerType);- $obj = $class::makeFromStrings($triggerValue, $stopProcessing);- Log::debug('Created trigger from string', ['type' => $triggerType, 'value' => $triggerValue, 'stop_processing' => $stopProcessing, 'class' => $class]);-- return $obj;- }-- /**- * Returns a map with trigger types, mapped to the class representing that type.- *- * @return array- */- protected static function getTriggerTypes(): array- {- if (0 === count(self::$triggerTypes)) {- self::$triggerTypes = Domain::getRuleTriggers();- }-- return self::$triggerTypes;- }-- /**- * Returns the class name to be used for triggers with the given name. This is a lookup function- * that will match the given trigger type (ie. "from_account_ends") to the matching class name- * (FromAccountEnds) using the configuration (firefly.php).- *- * @param string $triggerType- *- * @return string- *- * @throws FireflyException- */- private static function getTriggerClass(string $triggerType): string- {- $triggerTypes = self::getTriggerTypes();-- if (!array_key_exists($triggerType, $triggerTypes)) {- throw new FireflyException('No such trigger exists ("' . e($triggerType) . '").');- }-- $class = $triggerTypes[$triggerType];- if (!class_exists($class)) {- throw new FireflyException('Could not instantiate class for rule trigger type "' . e($triggerType) . '" (' . e($class) . ').');- }-- return $class;- }-}diff --git a/app/TransactionRules/Processor.php b/app/TransactionRules/Processor.phpdeleted file mode 100644index 8abfdcc997..0000000000--- a/app/TransactionRules/Processor.php+++ /dev/null@@ -1,340 +0,0 @@-<?php-/**- * Processor.php- * Copyright (c) 2019 [email protected]- *- * This file is part of Firefly III (https://github.com/firefly-iii).- *- * This program is free software: you can redistribute it and/or modify- * it under the terms of the GNU Affero General Public License as- * published by the Free Software Foundation, either version 3 of the- * License, or (at your option) any later version.- *- * This program is distributed in the hope that it will be useful,- * but WITHOUT ANY WARRANTY; without even the implied warranty of- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- * GNU Affero General Public License for more details.- *- * You should have received a copy of the GNU Affero General Public License- * along with this program. If not, see <https://www.gnu.org/licenses/>.- */-declare(strict_types=1);--namespace FireflyIII\TransactionRules;--use FireflyIII\Exceptions\FireflyException;-use FireflyIII\Models\Rule;-use FireflyIII\Models\RuleAction;-use FireflyIII\Models\RuleTrigger;-use FireflyIII\Models\Transaction;-use FireflyIII\Models\TransactionJournal;-use FireflyIII\TransactionRules\Actions\ActionInterface;-use FireflyIII\TransactionRules\Factory\ActionFactory;-use FireflyIII\TransactionRules\Factory\TriggerFactory;-use FireflyIII\TransactionRules\Triggers\AbstractTrigger;-use FireflyIII\TransactionRules\Triggers\UserAction;-use Illuminate\Support\Collection;-use Log;--/**- * Class Processor.- */-class Processor-{- /** @var Collection Actions to exectute */- public $actions;- /** @var TransactionJournal Journal to run them on */- public $journal;- /** @var Rule Rule that applies */- public $rule;- /** @var Collection All triggers */- public $triggers;- /** @var int Found triggers */- private $foundTriggers = 0;- /** @var bool */- private $strict = true;-- /**- * Processor constructor.- */- public function __construct()- {- $this->triggers = new Collection;- $this->actions = new Collection;- }-- /**- * Return found triggers- *- * @return int- */- public function getFoundTriggers(): int- {- return $this->foundTriggers;- }-- /**- * Set found triggers- *- * @param int $foundTriggers- */- public function setFoundTriggers(int $foundTriggers): void- {- $this->foundTriggers = $foundTriggers;- }-- /**- * Returns the rule- *- * @return Rule- */- public function getRule(): Rule- {- return $this->rule;- }-- /**- * This method will scan the given transaction journal and check if it matches the triggers found in the Processor- * If so, it will also attempt to run the given actions on the journal. It returns a bool indicating if the transaction journal- * matches all of the triggers (regardless of whether the Processor could act on it).- *- * @param array $journal- *- * @return bool- * @throws FireflyException- */- public function handleJournalArray(array $journal): bool- {-- Log::debug(sprintf('handleJournalArray for journal #%d (group #%d)', $journal['transaction_journal_id'], $journal['transaction_group_id']));-- // grab the actual journal.- $this->journal = TransactionJournal::find($journal['transaction_journal_id']);- // 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 (0 === $this->actions->count()) {- Log::info('Rule has no actions!');- }-- return true;- }-- return false;- }-- /**- * This method will scan the given transaction journal and check if it matches the triggers found in the Processor- * If so, it will also attempt to run the given actions on the journal. It returns a bool indicating if the transaction journal- * matches all of the triggers (regardless of whether the Processor could act on it).- *- * @param Transaction $transaction- *- * @return bool- * @throws FireflyException- */- public function handleTransaction(Transaction $transaction): bool- {- Log::debug(sprintf('handleTransactionJournal for journal #%d (transaction #%d)', $transaction->transaction_journal_id, $transaction->id));-- // grab the actual journal.- $journal = $transaction->transactionJournal()->first();- $this->journal = $journal;- // 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 (0 === $this->actions->count()) {- Log::info('Rule has no actions!');- }-- return true;- }-- return false;- }-- /**- * This method will scan the given transaction journal and check if it matches the triggers found in the Processor- * If so, it will also attempt to run the given actions on the journal. It returns a bool indicating if the transaction journal- * matches all of the triggers (regardless of whether the Processor could act on it).- *- * @param TransactionJournal $journal- *- * @return bool- * @throws FireflyException- */- public function handleTransactionJournal(TransactionJournal $journal): bool- {- Log::debug(sprintf('handleTransactionJournal for journal %d', $journal->id));- $this->journal = $journal;- // get all triggers:- $triggered = $this->triggered();- if ($triggered) {- if ($this->actions->count() > 0) {- $this->actions();- }-- return true;- }-- return false;- }-- /**- * @return bool- */- public function isStrict(): bool- {- return $this->strict;- }-- /**- * @param bool $strict- */- public function setStrict(bool $strict): void- {- $this->strict = $strict;- }-- /**- * This method will make a Processor that will process each transaction journal using the triggers- * and actions found in the given Rule.- *- * @param Rule $rule- * @param bool $includeActions- *- * @throws FireflyException- */- public function make(Rule $rule, bool $includeActions = null): void- {- $includeActions = $includeActions ?? true;- Log::debug(sprintf('Making new rule from Rule %d', $rule->id));- Log::debug(sprintf('Rule is strict: %s', var_export($rule->strict, true)));- $this->rule = $rule;- $this->strict = $rule->strict;- $triggerSet = $rule->ruleTriggers()->orderBy('order', 'ASC')->get();- /** @var RuleTrigger $trigger */- foreach ($triggerSet as $trigger) {- Log::debug(sprintf('Push trigger %d', $trigger->id));- $this->triggers->push(TriggerFactory::getTrigger($trigger));- }- if (true === $includeActions) {- $this->actions = $rule->ruleActions()->orderBy('order', 'ASC')->get();- }- }-- /**- * This method will make a Processor that will process each transaction journal using the given- * trigger (singular!). It can only report if the transaction journal was hit by the given trigger- * and will not be able to act on it using actions.- *- * @param string $triggerName- * @param string $triggerValue- *- * @throws FireflyException- */- public function makeFromString(string $triggerName, string $triggerValue): void- {- Log::debug(sprintf('Processor::makeFromString("%s", "%s")', $triggerName, $triggerValue));- $trigger = TriggerFactory::makeTriggerFromStrings($triggerName, $triggerValue, false);- $this->triggers->push($trigger);- }-- /**- * This method will make a Processor that will process each transaction journal using the given- * triggers. It can only report if the transaction journal was hit by the given triggers- * and will not be able to act on it using actions.- *- * The given triggers must be in the following format:- *- * [type => xx, value => yy, stop_processing => bool], [type => xx, value => yy, stop_processing => bool],- *- * @param array $triggers- *- * @throws FireflyException- */- public function makeFromStringArray(array $triggers): void- {- foreach ($triggers as $entry) {- $entry['value'] = $entry['value'] ?? '';- $trigger = TriggerFactory::makeTriggerFromStrings($entry['type'], $entry['value'], $entry['stop_processing']);- $this->triggers->push($trigger);- }-- }-- /**- * Run the actions- *- * @return void- * @throws FireflyException- */- private function actions(): void- {- /**- * @var int- * @var RuleAction $action- */- foreach ($this->actions as $action) {- /** @var ActionInterface $actionClass */- $actionClass = ActionFactory::getAction($action);- Log::debug(sprintf('Fire action %s on journal #%d', get_class($actionClass), $this->journal->id));- $actionClass->act($this->journal);- if ($action->stop_processing) {- Log::debug('Stop processing now and break.');- break;- }- }- }-- /**- * Method to check whether the current transaction would be triggered- * by the given list of triggers.- *- * @return bool- */- private function triggered(): bool- {- Log::debug('start of Processor::triggered()');- $foundTriggers = $this->getFoundTriggers();- $hitTriggers = 0;- Log::debug(sprintf('Found triggers starts at %d', $foundTriggers));- /** @var AbstractTrigger $trigger */- foreach ($this->triggers as $trigger) {- ++$foundTriggers;- Log::debug(sprintf('Now checking trigger %s with value %s', get_class($trigger), $trigger->getTriggerValue()));- /** @var AbstractTrigger $trigger */- if ($trigger->triggered($this->journal)) {- Log::debug('Is a match!');- ++$hitTriggers;- // is non-strict? then return true!- if (!$this->strict && UserAction::class !== get_class($trigger)) {- Log::debug('Rule is set as non-strict, return true!');-- return true;- }- if (!$this->strict && UserAction::class === get_class($trigger)) {- Log::debug('Rule is set as non-strict, but action was "user-action". Will not return true.');- }- }- if ($trigger->stopProcessing) {- Log::debug('Stop processing this rule and break off all triggers.');- break;- }- }- $result = ($hitTriggers === $foundTriggers && $foundTriggers > 0);- Log::debug('Result of triggered()', ['hitTriggers' => $hitTriggers, 'foundTriggers' => $foundTriggers, 'result' => $result]);-- return $result;- }-}diff --git a/app/TransactionRules/TransactionMatcher.php b/app/TransactionRules/TransactionMatcher.phpdeleted file mode 100644index a058d3572c..0000000000--- a/app/TransactionRules/TransactionMatcher.php+++ /dev/null@@ -1,347 +0,0 @@-<?php-/**- * TransactionMatcher.php- * Copyright (c) 2019 [email protected]- *- * This file is part of Firefly III (https://github.com/firefly-iii).- *- * This program is free software: you can redistribute it and/or modify- * it under the terms of the GNU Affero General Public License as- * published by the Free Software Foundation, either version 3 of the- * License, or (at your option) any later version.- *- * This program is distributed in the hope that it will be useful,- * but WITHOUT ANY WARRANTY; without even the implied warranty of- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- * GNU Affero General Public License for more details.- *- * You should have received a copy of the GNU Affero General Public License- * along with this program. If not, see <https://www.gnu.org/licenses/>.- */-declare(strict_types=1);--namespace FireflyIII\TransactionRules;--use Carbon\Carbon;-use FireflyIII\Exceptions\FireflyException;-use FireflyIII\Helpers\Collector\GroupCollectorInterface;-use FireflyIII\Models\Rule;-use FireflyIII\Models\RuleTrigger;-use FireflyIII\Models\TransactionType;-use FireflyIII\User;-use Illuminate\Support\Collection;-use Log;--/**- * Class TransactionMatcher is used to find a list of- * transaction matching a set of triggers.- * @deprecated- */-class TransactionMatcher-{- /** @var Collection Asset accounts to search in. */- private $accounts;- /** @var Carbon Start date of the matched transactions */- private $endDate;- /** @var string */- private $exactAmount;- /** @var string */- private $maxAmount;- /** @var string */- private $minAmount;- /** @var Rule The rule to apply */- private $rule;- /** @var int Maximum number of transaction to search in (for performance reasons) */- private $searchLimit;- /** @var Carbon Start date of the matched transactions */- private $startDate;- /** @var bool */- private $strict;- /** @var array Types that can be matched using this matcher */- private $transactionTypes = [TransactionType::DEPOSIT, TransactionType::WITHDRAWAL, TransactionType::TRANSFER];- /** @var int Max number of results */- private $triggeredLimit;- /** @var array List of triggers to match */- private $triggers = [];-- /**- * TransactionMatcher constructor.- */- public function __construct()- {- $this->strict = false;- $this->accounts = new Collection;- Log::debug('Created new transaction matcher');- }-- /**- * This method will search the user's transaction journal (with an upper limit of $range) for- * transaction journals matching the given rule. This is accomplished by trying to fire these- * triggers onto each transaction journal until enough matches are found ($limit).- *- * @return array- * @throws FireflyException- */- public function findTransactionsByRule(): array- {- Log::debug('Now in findTransactionsByRule()');- if (0 === count($this->rule->ruleTriggers)) {- Log::error('Rule has no triggers!');-- return [];- }-- // Variables used within the loop.- /** @var Processor $processor */- $processor = app(Processor::class);- $processor->make($this->rule, false);- $result = $this->runProcessor($processor);-- // If the list of matchingTransactions is larger than the maximum number of results- // (e.g. if a large percentage of the transactions match), truncate the list- $result = array_slice($result, 0, $this->searchLimit);-- return $result;- }-- /**- * This method will search the user's transaction journal (with an upper limit of $range) for- * transaction journals matching the given $triggers. This is accomplished by trying to fire these- * triggers onto each transaction journal until enough matches are found ($limit).- *- * @return array- * @throws FireflyException- */- public function findTransactionsByTriggers(): array- {- if (0 === count($this->triggers)) {- return new Collection;- }-- // Variables used within the loop- /** @var Processor $processor */- $processor = app(Processor::class);- $processor->makeFromStringArray($this->triggers);- $processor->setStrict($this->strict);- $result = $this->runProcessor($processor);-- // If the list of matchingTransactions is larger than the maximum number of results- // (e.g. if a large percentage of the transactions match), truncate the list- return array_slice($result, 0, $this->searchLimit);- }-- /**- * Get triggers- *- * @return array- */- public function getTriggers(): array- {- return $this->triggers;- }-- /**- * Set triggers- *- * @param array $triggers- *- * @return TransactionMatcher- */- public function setTriggers(array $triggers): TransactionMatcher- {- $this->triggers = $triggers;-- return $this;- }-- /**- * @return bool- */- public function isStrict(): bool- {- return $this->strict;- }-- /**- * @param bool $strict- */- public function setStrict(bool $strict): void- {- $this->strict = $strict;- }-- /**- * @param Collection $accounts- */- public function setAccounts(Collection $accounts): void- {- $this->accounts = $accounts;- }-- /**- * @param Carbon|null $endDate- */- public function setEndDate(Carbon $endDate = null): void- {- $this->endDate = $endDate;- }-- /**- * Set rule- *- * @param Rule $rule- */- public function setRule(Rule $rule): void- {- $this->rule = $rule;- }-- /**- * @param int $searchLimit- */- public function setSearchLimit(int $searchLimit): void- {- $this->searchLimit = $searchLimit;- }-- /**- * @param Carbon|null $startDate- */- public function setStartDate(Carbon $startDate = null): void- {- $this->startDate = $startDate;- }-- /**- * @param int $triggeredLimit- */- public function setTriggeredLimit(int $triggeredLimit): void- {- $this->triggeredLimit = $triggeredLimit;- }-- /**- *- */- private function readTriggers(): void- {- $valid = ['amount_less', 'amount_more', 'amount_exactly'];- if (null !== $this->rule) {- $allTriggers = $this->rule->ruleTriggers()->whereIn('trigger_type', $valid)->get();- /** @var RuleTrigger $trigger */- foreach ($allTriggers as $trigger) {- if ('amount_less' === $trigger->trigger_type) {- $this->maxAmount = $trigger->trigger_value;- Log::debug(sprintf('Set max amount to be %s', $trigger->trigger_value));- }- if ('amount_more' === $trigger->trigger_type) {- $this->minAmount = $trigger->trigger_value;- Log::debug(sprintf('Set min amount to be %s', $trigger->trigger_value));- }- if ('amount_exactly' === $trigger->trigger_type) {- $this->exactAmount = $trigger->trigger_value;- Log::debug(sprintf('Set exact amount to be %s', $trigger->trigger_value));- }- }- }- }-- /**- * Run the processor.- *- * @param Processor $processor- *- * @return array- */- private function runProcessor(Processor $processor): array- {- Log::debug('Now in runprocessor()');- // since we have a rule in $this->rule, we can add some of the triggers- // to the Journal Collector.- // Firefly III will then have to search through less transactions.- $this->readTriggers();-- // Start a loop to fetch batches of transactions. The loop will finish if:- // - all transactions have been fetched from the database- // - the maximum number of transactions to return has been found- // - the maximum number of transactions to search in have been searched- $pageSize = $this->searchLimit;- $processed = 0;- $page = 1;- $totalResult = [];-- Log::debug(sprintf('Search limit is %d, triggered limit is %d, so page size is %d', $this->searchLimit, $this->triggeredLimit, $pageSize));-- do {- Log::debug('Start of do-loop');- // Fetch a batch of transactions from the database-- /** @var GroupCollectorInterface $collector */- $collector = app(GroupCollectorInterface::class);-- /** @var User $user */- $user = auth()->user();-- $collector->setUser($user);-- // limit asset accounts:- if ($this->accounts->count() > 0) {- $collector->setAccounts($this->accounts);- }- if (null !== $this->startDate && null !== $this->endDate) {- $collector->setRange($this->startDate, $this->endDate);- }-- $collector->setLimit($pageSize)->setPage($page)->setTypes($this->transactionTypes);- if (null !== $this->maxAmount) {- Log::debug(sprintf('Amount must be less than %s', $this->maxAmount));- $collector->amountLess($this->maxAmount);- }- if (null !== $this->minAmount) {- Log::debug(sprintf('Amount must be more than %s', $this->minAmount));- $collector->amountMore($this->minAmount);- }- if (null !== $this->exactAmount) {- Log::debug(sprintf('Amount must be exactly %s', $this->exactAmount));- $collector->amountIs($this->exactAmount);- }-- $journals = $collector->getExtractedJournals();- Log::debug(sprintf('Found %d transaction journals to check. ', count($journals)));-- // Filter transactions that match the given triggers.- $filtered = [];- /** @var array $journal */- foreach ($journals as $journal) {- $result = $processor->handleJournalArray($journal);- if ($result) {- $filtered[] = $journal;- }- }-- Log::debug(sprintf('Found %d journals that match.', count($filtered)));-- // merge:- $totalResult = $totalResult + $filtered;- Log::debug(sprintf('Total count is now %d', count($totalResult)));-- // Update counters- ++$page;- $processed += count($journals);-- Log::debug(sprintf('Page is now %d, processed is %d', $page, $processed));-- // Check for conditions to finish the loop- $reachedEndOfList = count($journals) < 1;- $foundEnough = count($totalResult) >= $this->triggeredLimit;- $searchedEnough = ($processed >= $this->searchLimit);-- Log::debug(sprintf('reachedEndOfList: %s', var_export($reachedEndOfList, true)));- Log::debug(sprintf('foundEnough: %s', var_export($foundEnough, true)));- Log::debug(sprintf('searchedEnough: %s', var_export($searchedEnough, true)));- } while (!$reachedEndOfList && !$foundEnough && !$searchedEnough);- Log::debug('End of do-loop');-- return $totalResult;- }-}diff --git a/app/TransactionRules/Triggers/AbstractTrigger.php b/app/TransactionRules/Triggers/AbstractTrigger.phpdeleted file mode 100644index c31f96ec83..0000000000--- a/app/TransactionRules/Triggers/AbstractTrigger.php+++ /dev/null@@ -1,126 +0,0 @@-<?php-/**- * AbstractTrigger.php- * Copyright (c) 2019 [email protected]- *- * This file is part of Firefly III (https://github.com/firefly-iii).- *- * This program is free software: you can redistribute it and/or modify- * it under the terms of the GNU Affero General Public License as- * published by the Free Software Foundation, either version 3 of the- * License, or (at your option) any later version.- *- * This program is distributed in the hope that it will be useful,- * but WITHOUT ANY WARRANTY; without even the implied warranty of- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- * GNU Affero General Public License for more details.- *- * You should have received a copy of the GNU Affero General Public License- * along with this program. If not, see <https://www.gnu.org/licenses/>.- */-declare(strict_types=1);--namespace FireflyIII\TransactionRules\Triggers;--use FireflyIII\Models\RuleTrigger;-use FireflyIII\Models\TransactionJournal;--/**- * This class will be magical!- *- * Class AbstractTrigger- * @method bool triggered($object)- * @deprecated- */-abstract class AbstractTrigger-{- /** @var bool Whether to stop processing after this one is checked. */- public $stopProcessing;- /** @var string Value to check for */- protected $checkValue;- /** @var TransactionJournal Journal to check */- protected $journal;- /** @var RuleTrigger Trigger object */- protected $trigger;- /** @var string Trigger value */- protected $triggerValue;-- /**- * Make a new trigger from the value given in the string.- *- * @codeCoverageIgnore- *- * @param string $triggerValue- * @param bool $stopProcessing- *- * @return static- */- public static function makeFromStrings(string $triggerValue, bool $stopProcessing)- {- $self = new static;- $self->triggerValue = $triggerValue;- $self->stopProcessing = $stopProcessing;-- return $self;- }-- /**- * Make a new trigger from the rule trigger in the parameter- *- * @codeCoverageIgnore- *- * @param RuleTrigger $trigger- *- * @return AbstractTrigger- */- public static function makeFromTrigger(RuleTrigger $trigger): AbstractTrigger- {- $self = new static;- $self->trigger = $trigger;- $self->triggerValue = $trigger->trigger_value;- $self->stopProcessing = $trigger->stop_processing;-- return $self;- }-- /**- * Make a new trigger from a trigger value.- *- * @codeCoverageIgnore- *- * @param string $triggerValue- *- * @return AbstractTrigger- */- public static function makeFromTriggerValue(string $triggerValue): AbstractTrigger- {- $self = new static;- $self->triggerValue = $triggerValue;-- return $self;- }-- /**- * Returns trigger- *- * @codeCoverageIgnore- *- * @return RuleTrigger- */- public function getTrigger(): RuleTrigger- {- return $this->trigger;- }-- /**- * Returns trigger value- *- * @codeCoverageIgnore- *- * @return string- */- public function getTriggerValue(): string- {- return $this->triggerValue;- }-}diff --git a/app/TransactionRules/Triggers/AmountExactly.php b/app/TransactionRules/Triggers/AmountExactly.phpdeleted file mode 100644index 6dc60a6296..0000000000--- a/app/TransactionRules/Triggers/AmountExactly.php+++ /dev/null@@ -1,87 +0,0 @@-<?php-/**- * AmountExactly.php- * Copyright (c) 2019 [email protected]- *- * This file is part of Firefly III (https://github.com/firefly-iii).- *- * This program is free software: you can redistribute it and/or modify- * it under the terms of the GNU Affero General Public License as- * published by the Free Software Foundation, either version 3 of the- * License, or (at your option) any later version.- *- * This program is distributed in the hope that it will be useful,- * but WITHOUT ANY WARRANTY; without even the implied warranty of- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- * GNU Affero General Public License for more details.- *- * You should have received a copy of the GNU Affero General Public License- * along with this program. If not, see <https://www.gnu.org/licenses/>.- */-declare(strict_types=1);--namespace FireflyIII\TransactionRules\Triggers;--use FireflyIII\Models\TransactionJournal;-use FireflyIII\Repositories\Journal\JournalRepositoryInterface;-use Log;--/**- * Class AmountExactly.- * @deprecated- */-final class AmountExactly extends AbstractTrigger implements TriggerInterface-{- /**- * A trigger is said to "match anything", or match any given transaction,- * when the trigger value is very vague or has no restrictions. Easy examples- * are the "AmountMore"-trigger combined with an amount of 0: any given transaction- * has an amount of more than zero! Other examples are all the "Description"-triggers- * which have hard time handling empty trigger values such as "" or "*" (wild cards).- *- * If the user tries to create such a trigger, this method MUST return true so Firefly III- * can stop the storing / updating the trigger. If the trigger is in any way restrictive- * (even if it will still include 99.9% of the users transactions), this method MUST return- * false.- *- * @param mixed $value- *- * @return bool- */- public static function willMatchEverything($value = null): bool- {- if (null !== $value) {- return false;- }- Log::error(sprintf('Cannot use %s with a null value.', self::class));-- return true;- }-- /**- * When the amount is exactly X.- *- * @param TransactionJournal $journal- *- * @return bool- */- public function triggered(TransactionJournal $journal): bool- {- /** @var JournalRepositoryInterface $repos */- $repos = app(JournalRepositoryInterface::class);- $repos->setUser($journal->user);--- $amount = $journal->destination_amount ?? $repos->getJournalTotal($journal);- $compare = $this->triggerValue;- $result = bccomp($amount, $compare);- if (0 === $result) {- Log::debug(sprintf('RuleTrigger AmountExactly for journal #%d: %f matches %f exactly, so return true', $journal->id, $amount, $compare));-- return true;- }- Log::debug(sprintf('RuleTrigger AmountExactly for journal #%d: %f matches %f NOT exactly, so return false', $journal->id, $amount, $compare));-- return false;- }-}diff --git a/app/TransactionRules/Triggers/AmountLess.php b/app/TransactionRules/Triggers/AmountLess.phpdeleted file mode 100644index a20bd264e5..0000000000--- a/app/TransactionRules/Triggers/AmountLess.php+++ /dev/null@@ -1,87 +0,0 @@-<?php-/**- * AmountLess.php- * Copyright (c) 2019 [email protected]- *- * This file is part of Firefly III (https://github.com/firefly-iii).- *- * This program is free software: you can redistribute it and/or modify- * it under the terms of the GNU Affero General Public License as- * published by the Free Software Foundation, either version 3 of the- * License, or (at your option) any later version.- *- * This program is distributed in the hope that it will be useful,- * but WITHOUT ANY WARRANTY; without even the implied warranty of- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- * GNU Affero General Public License for more details.- *- * You should have received a copy of the GNU Affero General Public License- * along with this program. If not, see <https://www.gnu.org/licenses/>.- */-declare(strict_types=1);--namespace FireflyIII\TransactionRules\Triggers;--use FireflyIII\Models\TransactionJournal;-use FireflyIII\Repositories\Journal\JournalRepositoryInterface;-use Log;--/**- * Class AmountLess.- * @deprecated- */-final class AmountLess extends AbstractTrigger implements TriggerInterface-{- /**- * A trigger is said to "match anything", or match any given transaction,- * when the trigger value is very vague or has no restrictions. Easy examples- * are the "AmountMore"-trigger combined with an amount of 0: any given transaction- * has an amount of more than zero! Other examples are all the "Description"-triggers- * which have hard time handling empty trigger values such as "" or "*" (wild cards).- *- * If the user tries to create such a trigger, this method MUST return true so Firefly III- * can stop the storing / updating the trigger. If the trigger is in any way restrictive- * (even if it will still include 99.9% of the users transactions), this method MUST return- * false.- *- * @param mixed $value- *- * @return bool- */- public static function willMatchEverything($value = null): bool- {- if (null !== $value) {- return false;- }- Log::error(sprintf('Cannot use %s with a null value.', self::class));-- return true;- }-- /**- * Returns true when amount is less than X.- *- * @param TransactionJournal $journal- *- * @return bool- */- public function triggered(TransactionJournal $journal): bool- {- /** @var JournalRepositoryInterface $repos */- $repos = app(JournalRepositoryInterface::class);- $repos->setUser($journal->user);-- $amount = $journal->destination_amount ?? $repos->getJournalTotal($journal);- $compare = $this->triggerValue;- $result = bccomp($amount, $compare);- if ($result === -1) {- Log::debug(sprintf('RuleTrigger AmountLess for journal #%d: %f is less than %f, so return true', $journal->id, $amount, $compare));-- return true;- }-- Log::debug(sprintf('RuleTrigger AmountLess for journal #%d: %f is NOT less than %f, so return false', $journal->id, $amount, $compare));-- return false;- }-}diff --git a/app/TransactionRules/Triggers/AmountMore.php b/app/TransactionRules/Triggers/AmountMore.phpdeleted file mode 100644index a23ad04ddf..0000000000--- a/app/TransactionRules/Triggers/AmountMore.php+++ /dev/null@@ -1,93 +0,0 @@-<?php-/**- * AmountMore.php- * Copyright (c) 2019 [email protected]- *- * This file is part of Firefly III (https://github.com/firefly-iii).- *- * This program is free software: you can redistribute it and/or modify- * it under the terms of the GNU Affero General Public License as- * published by the Free Software Foundation, either version 3 of the- * License, or (at your option) any later version.- *- * This program is distributed in the hope that it will be useful,- * but WITHOUT ANY WARRANTY; without even the implied warranty of- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- * GNU Affero General Public License for more details.- *- * You should have received a copy of the GNU Affero General Public License- * along with this program. If not, see <https://www.gnu.org/licenses/>.- */-declare(strict_types=1);--namespace FireflyIII\TransactionRules\Triggers;--use FireflyIII\Models\TransactionJournal;-use FireflyIII\Repositories\Journal\JournalRepositoryInterface;-use Log;--/**- * Class AmountMore.- * @deprecated- */-final class AmountMore extends AbstractTrigger implements TriggerInterface-{- /**- * A trigger is said to "match anything", or match any given transaction,- * when the trigger value is very vague or has no restrictions. Easy examples- * are the "AmountMore"-trigger combined with an amount of 0: any given transaction- * has an amount of more than zero! Other examples are all the "Description"-triggers- * which have hard time handling empty trigger values such as "" or "*" (wild cards).- *- * If the user tries to create such a trigger, this method MUST return true so Firefly III- * can stop the storing / updating the trigger. If the trigger is in any way restrictive- * (even if it will still include 99.9% of the users transactions), this method MUST return- * false.- *- * @param mixed $value- *- * @return bool- */- public static function willMatchEverything($value = null): bool- {- if (null !== $value) {- $res = 0 === bccomp('0', (string)$value);- if (true === $res) {- Log::error(sprintf('Cannot use %s with a value equal to 0.', self::class));- }-- return $res;- }-- Log::error(sprintf('Cannot use %s with a null value.', self::class));-- return true;- }-- /**- * Returns true when amount is more than X.- *- * @param TransactionJournal $journal- *- * @return bool- */- public function triggered(TransactionJournal $journal): bool- {- /** @var JournalRepositoryInterface $repos */- $repos = app(JournalRepositoryInterface::class);- $repos->setUser($journal->user);-- $amount = $journal->destination_amount ?? $repos->getJournalTotal($journal);- $compare = $this->triggerValue;- $result = bccomp($amount, $compare);- if (1 === $result) {- Log::debug(sprintf('RuleTrigger AmountMore for journal #%d: %f is more than %f, so return true', $journal->id, $amount, $compare));-- return true;- }-- Log::debug(sprintf('RuleTrigger AmountMore for journal #%d: %f is NOT more than %f, so return false', $journal->id, $amount, $compare));-- return false;- }-}diff --git a/app/TransactionRules/Triggers/BudgetIs.php b/app/TransactionRules/Triggers/BudgetIs.phpdeleted file mode 100644index 7a9b91ef54..0000000000--- a/app/TransactionRules/Triggers/BudgetIs.php+++ /dev/null@@ -1,83 +0,0 @@-<?php-/**- * BudgetIs.php- * Copyright (c) 2019 [email protected]- *- * This file is part of Firefly III (https://github.com/firefly-iii).- *- * This program is free software: you can redistribute it and/or modify- * it under the terms of the GNU Affero General Public License as- * published by the Free Software Foundation, either version 3 of the- * License, or (at your option) any later version.- *- * This program is distributed in the hope that it will be useful,- * but WITHOUT ANY WARRANTY; without even the implied warranty of- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- * GNU Affero General Public License for more details.- *- * You should have received a copy of the GNU Affero General Public License- * along with this program. If not, see <https://www.gnu.org/licenses/>.- */-declare(strict_types=1);--namespace FireflyIII\TransactionRules\Triggers;--use FireflyIII\Models\TransactionJournal;-use Log;--/**- * Class BudgetIs.- * @deprecated- */-final class BudgetIs extends AbstractTrigger implements TriggerInterface-{- /**- * A trigger is said to "match anything", or match any given transaction,- * when the trigger value is very vague or has no restrictions. Easy examples- * are the "AmountMore"-trigger combined with an amount of 0: any given transaction- * has an amount of more than zero! Other examples are all the "Description"-triggers- * which have hard time handling empty trigger values such as "" or "*" (wild cards).- *- * If the user tries to create such a trigger, this method MUST return true so Firefly III- * can stop the storing / updating the trigger. If the trigger is in any way restrictive- * (even if it will still include 99.9% of the users transactions), this method MUST return- * false.- *- * @param mixed $value- *- * @return bool- */- public static function willMatchEverything($value = null): bool- {- if (null !== $value) {- return false;- }- Log::error(sprintf('Cannot use %s with a null value.', self::class));-- return true;- }-- /**- * Returns true when budget is X.- *- * @param TransactionJournal $journal- *- * @return bool- */- public function triggered(TransactionJournal $journal): bool- {- $budget = $journal->budgets()->first();- if (null !== $budget) {- $name = strtolower($budget->name);- // match on journal:- if ($name === strtolower($this->triggerValue)) {- Log::debug(sprintf('RuleTrigger BudgetIs for journal #%d: "%s" is "%s", return true.', $journal->id, $name, $this->triggerValue));-- return true;- }- }- Log::debug(sprintf('RuleTrigger BudgetIs for journal #%d: does not have budget "%s", return false.', $journal->id, $this->triggerValue));-- return false;- }-}diff --git a/app/TransactionRules/Triggers/CategoryIs.php b/app/TransactionRules/Triggers/CategoryIs.phpdeleted file mode 100644index 54b22d80f5..0000000000--- a/app/TransactionRules/Triggers/CategoryIs.php+++ /dev/null@@ -1,83 +0,0 @@-<?php-/**- * CategoryIs.php- * Copyright (c) 2019 [email protected]- *- * This file is part of Firefly III (https://github.com/firefly-iii).- *- * This program is free software: you can redistribute it and/or modify- * it under the terms of the GNU Affero General Public License as- * published by the Free Software Foundation, either version 3 of the- * License, or (at your option) any later version.- *- * This program is distributed in the hope that it will be useful,- * but WITHOUT ANY WARRANTY; without even the implied warranty of- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- * GNU Affero General Public License for more details.- *- * You should have received a copy of the GNU Affero General Public License- * along with this program. If not, see <https://www.gnu.org/licenses/>.- */-declare(strict_types=1);--namespace FireflyIII\TransactionRules\Triggers;--use FireflyIII\Models\TransactionJournal;-use Log;--/**- * Class CategoryIs.- * @deprecated- */-final class CategoryIs extends AbstractTrigger implements TriggerInterface-{- /**- * A trigger is said to "match anything", or match any given transaction,- * when the trigger value is very vague or has no restrictions. Easy examples- * are the "AmountMore"-trigger combined with an amount of 0: any given transaction- * has an amount of more than zero! Other examples are all the "Description"-triggers- * which have hard time handling empty trigger values such as "" or "*" (wild cards).- *- * If the user tries to create such a trigger, this method MUST return true so Firefly III- * can stop the storing / updating the trigger. If the trigger is in any way restrictive- * (even if it will still include 99.9% of the users transactions), this method MUST return- * false.- *- * @param mixed $value- *- * @return bool- */- public static function willMatchEverything($value = null): bool- {- if (null !== $value) {- return false;- }- Log::error(sprintf('Cannot use %s with a null value.', self::class));-- return true;- }-- /**- * Returns true when category is X.- *- * @param TransactionJournal $journal- *- * @return bool- */- public function triggered(TransactionJournal $journal): bool- {- $category = $journal->categories()->first();- if (null !== $category) {- $name = strtolower($category->name);- // match on journal:- if ($name === strtolower($this->triggerValue)) {- Log::debug(sprintf('RuleTrigger CategoryIs for journal #%d: "%s" is "%s", return true.', $journal->id, $name, $this->triggerValue));-- return true;- }- }- Log::debug(sprintf('RuleTrigger CategoryIs for journal #%d: does not have category "%s", return false.', $journal->id, $this->triggerValue));-- return false;- }-}diff --git a/app/TransactionRules/Triggers/CurrencyIs.php b/app/TransactionRules/Triggers/CurrencyIs.phpdeleted file mode 100644index 1b64a0b36a..0000000000--- a/app/TransactionRules/Triggers/CurrencyIs.php+++ /dev/null@@ -1,100 +0,0 @@-<?php-/**- * CurrencyIs.php- * Copyright (c) 2019 [email protected]- *- * This file is part of Firefly III (https://github.com/firefly-iii).- *- * This program is free software: you can redistribute it and/or modify- * it under the terms of the GNU Affero General Public License as- * published by the Free Software Foundation, either version 3 of the- * License, or (at your option) any later version.- *- * This program is distributed in the hope that it will be useful,- * but WITHOUT ANY WARRANTY; without even the implied warranty of- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- * GNU Affero General Public License for more details.- *- * You should have received a copy of the GNU Affero General Public License- * along with this program. If not, see <https://www.gnu.org/licenses/>.- */-declare(strict_types=1);--namespace FireflyIII\TransactionRules\Triggers;--use FireflyIII\Models\Transaction;-use FireflyIII\Models\TransactionJournal;-use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;-use Log;--/**- * Class CurrencyIs.- * @deprecated- */-final class CurrencyIs extends AbstractTrigger implements TriggerInterface-{- /**- * A trigger is said to "match anything", or match any given transaction,- * when the trigger value is very vague or has no restrictions. Easy examples- * are the "AmountMore"-trigger combined with an amount of 0: any given transaction- * has an amount of more than zero! Other examples are all the "Description"-triggers- * which have hard time handling empty trigger values such as "" or "*" (wild cards).- *- * If the user tries to create such a trigger, this method MUST return true so Firefly III- * can stop the storing / updating the trigger. If the trigger is in any way restrictive- * (even if it will still include 99.9% of the users transactions), this method MUST return- * false.- *- * @param mixed $value- *- * @return bool- */- public static function willMatchEverything($value = null): bool- {- if (null !== $value) {- return false;- }-- Log::error(sprintf('Cannot use %s with a null value.', self::class));-- return true;- }-- /**- * Returns true when description is X- *- * @param TransactionJournal $journal- *- * @return bool- */- public function triggered(TransactionJournal $journal): bool- {- /** @var CurrencyRepositoryInterface $repository */- $repository = app(CurrencyRepositoryInterface::class);-- // if currency name contains " ("- if (0 === strpos($this->triggerValue, ' (')) {- $parts = explode(' (', $this->triggerValue);- $this->triggerValue = $parts[0];- }-- $currency = $repository->findByNameNull($this->triggerValue);- $hit = true;- if (null !== $currency) {- /** @var Transaction $transaction */- foreach ($journal->transactions as $transaction) {- if ((int)$transaction->transaction_currency_id !== (int)$currency->id) {- Log::debug(- sprintf(- 'Trigger CurrencyIs: Transaction #%d in journal #%d uses currency %d instead of sought for #%d. No hit!',- $transaction->id, $journal->id, $transaction->transaction_currency_id, $currency->id- )- );- $hit = false;- }- }- }-- return $hit;- }-}diff --git a/app/TransactionRules/Triggers/DateAfter.php b/app/TransactionRules/Triggers/DateAfter.phpdeleted file mode 100644index 4ef221109d..0000000000--- a/app/TransactionRules/Triggers/DateAfter.php+++ /dev/null@@ -1,135 +0,0 @@-<?php-/**- * DateAfter.php- * Copyright (c) 2019 [email protected]- *- * This file is part of Firefly III (https://github.com/firefly-iii).- *- * This program is free software: you can redistribute it and/or modify- * it under the terms of the GNU Affero General Public License as- * published by the Free Software Foundation, either version 3 of the- * License, or (at your option) any later version.- *- * This program is distributed in the hope that it will be useful,- * but WITHOUT ANY WARRANTY; without even the implied warranty of- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- * GNU Affero General Public License for more details.- *- * You should have received a copy of the GNU Affero General Public License- * along with this program. If not, see <https://www.gnu.org/licenses/>.- */-declare(strict_types=1);--namespace FireflyIII\TransactionRules\Triggers;--use Carbon\Carbon;-use FireflyIII\Exceptions\FireflyException;-use FireflyIII\Models\TransactionJournal;-use FireflyIII\Support\ParseDateString;-use Log;--/**- * Class DateAfter.- * @deprecated- */-final class DateAfter extends AbstractTrigger implements TriggerInterface-{- /**- * A trigger is said to "match anything", or match any given transaction,- * when the trigger value is very vague or has no restrictions. Easy examples- * are the "AmountMore"-trigger combined with an amount of 0: any given transaction- * has an amount of more than zero! Other examples are all the "Description"-triggers- * which have hard time handling empty trigger values such as "" or "*" (wild cards).- *- * If the user tries to create such a trigger, this method MUST return true so Firefly III- * can stop the storing / updating the trigger. If the trigger is in any way restrictive- * (even if it will still include 99.9% of the users transactions), this method MUST return- * false.- *- * @param mixed $value- *- * @return bool- */- public static function willMatchEverything($value = null): bool- {- if (null !== $value) {- return false;- }- Log::error(sprintf('Cannot use %s with a null value.', self::class));-- return true;- }-- /**- * Returns true when category is X.- *- * @param TransactionJournal $journal- *- * @return bool- */- public function triggered(TransactionJournal $journal): bool- {- /** @var Carbon $date */- $date = $journal->date;- Log::debug(sprintf('Found date on journal: %s', $date->format('Y-m-d')));- $dateParser = new ParseDateString();--- try {- $ruleDate = $dateParser->parseDate($this->triggerValue);- } catch (FireflyException $e) {- Log::error('Cannot execute rule trigger.');- Log::error($e->getMessage());-- return false;- }- $isDateRange = $dateParser->isDateRange($this->triggerValue);- if (false === $isDateRange && $date->isAfter($ruleDate)) {- Log::debug(- sprintf(- '%s is after %s, so return true.',- $date->format('Y-m-d H:i:s'),- $ruleDate->format('Y-m-d H:i:s'),- )- );-- return true;- }- // could be a date range.- if ($isDateRange) {- Log::debug(sprintf('Date value is "%s", representing a range.', $this->triggerValue));- $range = $dateParser->parseRange($this->triggerValue, $date);- if ($date->isAfter($range['end'])) {- Log::debug(- sprintf(- '%s is after [%s/%s], so return true.',- $date->format('Y-m-d H:i:s'),- $range['start']->format('Y-m-d H:i:s'),- $range['end']->format('Y-m-d H:i:s'),- )- );-- return true;- }- Log::debug(- sprintf(- '%s is NOT after [%s/%s], so return false.',- $date->format('Y-m-d H:i:s'),- $range['start']->format('Y-m-d H:i:s'),- $range['end']->format('Y-m-d H:i:s'),- )- );- return false;- }-- Log::debug(- sprintf(- '%s is NOT after %s, so return true.',- $date->format('Y-m-d H:i:s'),- $ruleDate->format('Y-m-d H:i:s'),- )- );-- return false;- }-}diff --git a/app/TransactionRules/Triggers/DateBefore.php b/app/TransactionRules/Triggers/DateBefore.phpdeleted file mode 100644index a45e16386e..0000000000--- a/app/TransactionRules/Triggers/DateBefore.php+++ /dev/null@@ -1,139 +0,0 @@-<?php-/**- * DateBefore.php- * Copyright (c) 2019 [email protected]- *- * This file is part of Firefly III (https://github.com/firefly-iii).- *- * This program is free software: you can redistribute it and/or modify- * it under the terms of the GNU Affero General Public License as- * published by the Free Software Foundation, either version 3 of the- * License, or (at your option) any later version.- *- * This program is distributed in the hope that it will be useful,- * but WITHOUT ANY WARRANTY; without even the implied warranty of- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- * GNU Affero General Public License for more details.- *- * You should have received a copy of the GNU Affero General Public License- * along with this program. If not, see <https://www.gnu.org/licenses/>.- */-declare(strict_types=1);--namespace FireflyIII\TransactionRules\Triggers;--use Carbon\Carbon;-use FireflyIII\Exceptions\FireflyException;-use FireflyIII\Models\TransactionJournal;-use FireflyIII\Support\ParseDateString;-use Log;--/**- * Class DateBefore.- * @deprecated- */-final class DateBefore extends AbstractTrigger implements TriggerInterface-{- /**- * A trigger is said to "match anything", or match any given transaction,- * when the trigger value is very vague or has no restrictions. Easy examples- * are the "AmountMore"-trigger combined with an amount of 0: any given transaction- * has an amount of more than zero! Other examples are all the "Description"-triggers- * which have hard time handling empty trigger values such as "" or "*" (wild cards).- *- * If the user tries to create such a trigger, this method MUST return true so Firefly III- * can stop the storing / updating the trigger. If the trigger is in any way restrictive- * (even if it will still include 99.9% of the users transactions), this method MUST return- * false.- *- * @param mixed $value- *- * @return bool- */- public static function willMatchEverything($value = null): bool- {- if (null !== $value) {- return false;- }- Log::error(sprintf('Cannot use %s with a null value.', self::class));-- return true;- }-- /**- * Returns true when category is X.- *- * @param TransactionJournal $journal- *- * @return bool- */- public function triggered(TransactionJournal $journal): bool- {- /** @var Carbon $date */- $date = $journal->date;- Log::debug(sprintf('Found date on journal: %s', $date->format('Y-m-d')));- $dateParser = new ParseDateString();--- try {- $ruleDate = $dateParser->parseDate($this->triggerValue);- } catch (FireflyException $e) {- Log::error('Cannot execute rule trigger.');- Log::error($e->getMessage());-- return false;- }- $isDateRange = $dateParser->isDateRange($this->triggerValue);-- if (false === $isDateRange && $date->isBefore($ruleDate)) {- Log::debug(- sprintf(- '%s is before %s, so return true.',- $date->format('Y-m-d H:i:s'),- $ruleDate->format('Y-m-d H:i:s'),- )- );-- return true;- }-- // could be a date range.- if ($isDateRange) {- Log::debug(sprintf('Date value is "%s", representing a range.', $this->triggerValue));- $range = $dateParser->parseRange($this->triggerValue, $date);- if ($date->isBefore($range['start'])) {- Log::debug(- sprintf(- '%s is before [%s/%s], so return true.',- $date->format('Y-m-d H:i:s'),- $range['start']->format('Y-m-d H:i:s'),- $range['end']->format('Y-m-d H:i:s'),- )- );-- return true;- }- Log::debug(- sprintf(- '%s is NOT before [%s/%s], so return false.',- $date->format('Y-m-d H:i:s'),- $range['start']->format('Y-m-d H:i:s'),- $range['end']->format('Y-m-d H:i:s'),- )- );- return false;- }---- Log::debug(- sprintf(- '%s is NOT before %s, so return true.',- $date->format('Y-m-d H:i:s'),- $ruleDate->format('Y-m-d H:i:s'),- )- );-- return false;- }-}diff --git a/app/TransactionRules/Triggers/DateIs.php b/app/TransactionRules/Triggers/DateIs.phpdeleted file mode 100644index e3c493169b..0000000000--- a/app/TransactionRules/Triggers/DateIs.php+++ /dev/null@@ -1,138 +0,0 @@-<?php-/**- * DateIs.php- * Copyright (c) 2019 [email protected]- *- * This file is part of Firefly III (https://github.com/firefly-iii).- *- * This program is free software: you can redistribute it and/or modify- * it under the terms of the GNU Affero General Public License as- * published by the Free Software Foundation, either version 3 of the- * License, or (at your option) any later version.- *- * This program is distributed in the hope that it will be useful,- * but WITHOUT ANY WARRANTY; without even the implied warranty of- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- * GNU Affero General Public License for more details.- *- * You should have received a copy of the GNU Affero General Public License- * along with this program. If not, see <https://www.gnu.org/licenses/>.- */-declare(strict_types=1);--namespace FireflyIII\TransactionRules\Triggers;--use Carbon\Carbon;-use FireflyIII\Exceptions\FireflyException;-use FireflyIII\Models\TransactionJournal;-use FireflyIII\Support\ParseDateString;-use Log;--/**- * Class DateIs.- * @deprecated- */-final class DateIs extends AbstractTrigger implements TriggerInterface-{- /**- * A trigger is said to "match anything", or match any given transaction,- * when the trigger value is very vague or has no restrictions. Easy examples- * are the "AmountMore"-trigger combined with an amount of 0: any given transaction- * has an amount of more than zero! Other examples are all the "Description"-triggers- * which have hard time handling empty trigger values such as "" or "*" (wild cards).- *- * If the user tries to create such a trigger, this method MUST return true so Firefly III- * can stop the storing / updating the trigger. If the trigger is in any way restrictive- * (even if it will still include 99.9% of the users transactions), this method MUST return- * false.- *- * @param mixed $value- *- * @return bool- */- public static function willMatchEverything($value = null): bool- {- if (null !== $value) {- return false;- }- Log::error(sprintf('Cannot use %s with a null value.', self::class));-- return true;- }-- /**- * Returns true when category is X.- *- * @param TransactionJournal $journal- *- * @return bool- */- public function triggered(TransactionJournal $journal): bool- {- /** @var Carbon $date */- $date = $journal->date;- Log::debug(sprintf('Found date on journal: %s', $date->format('Y-m-d')));- $dateParser = new ParseDateString();--- try {- $ruleDate = $dateParser->parseDate($this->triggerValue);- } catch (FireflyException $e) {- Log::error('Cannot execute rule trigger.');- Log::error($e->getMessage());-- return false;- }- $isDateRange = $dateParser->isDateRange($this->triggerValue);-- if (false === $isDateRange && $ruleDate->isSameDay($date)) {- Log::debug(- sprintf(- '%s is on the same day as %s, so return true.',- $date->format('Y-m-d H:i:s'),- $ruleDate->format('Y-m-d H:i:s'),- )- );-- return true;- }-- // could be a date range.- if ($isDateRange) {- Log::debug(sprintf('Date value is "%s", representing a range.', $this->triggerValue));- $range = $dateParser->parseRange($this->triggerValue, $date);- if ($date->isAfter($range['start']) && $date->isBefore($range['end'])) {- Log::debug(- sprintf(- '%s is between [%s/%s], so return true.',- $date->format('Y-m-d H:i:s'),- $range['start']->format('Y-m-d H:i:s'),- $range['end']->format('Y-m-d H:i:s'),- )- );-- return true;- }- Log::debug(- sprintf(- '%s is NOT between [%s/%s], so return false.',- $date->format('Y-m-d H:i:s'),- $range['start']->format('Y-m-d H:i:s'),- $range['end']->format('Y-m-d H:i:s'),- )- );-- return false;- }-- Log::debug(- sprintf(- '%s is NOT on the same day as %s, so return true.',- $date->format('Y-m-d H:i:s'),- $ruleDate->format('Y-m-d H:i:s'),- )- );-- return false;- }-}diff --git a/app/TransactionRules/Triggers/DescriptionContains.php b/app/TransactionRules/Triggers/DescriptionContains.phpdeleted file mode 100644index 11f89d01cc..0000000000--- a/app/TransactionRules/Triggers/DescriptionContains.php+++ /dev/null@@ -1,88 +0,0 @@-<?php-/**- * DescriptionContains.php- * Copyright (c) 2019 [email protected]- *- * This file is part of Firefly III (https://github.com/firefly-iii).- *- * This program is free software: you can redistribute it and/or modify- * it under the terms of the GNU Affero General Public License as- * published by the Free Software Foundation, either version 3 of the- * License, or (at your option) any later version.- *- * This program is distributed in the hope that it will be useful,- * but WITHOUT ANY WARRANTY; without even the implied warranty of- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- * GNU Affero General Public License for more details.- *- * You should have received a copy of the GNU Affero General Public License- * along with this program. If not, see <https://www.gnu.org/licenses/>.- */-declare(strict_types=1);--namespace FireflyIII\TransactionRules\Triggers;--use FireflyIII\Models\TransactionJournal;-use Log;--/**- * Class DescriptionContains.- * @deprecated- */-final class DescriptionContains extends AbstractTrigger implements TriggerInterface-{- /**- * A trigger is said to "match anything", or match any given transaction,- * when the trigger value is very vague or has no restrictions. Easy examples- * are the "AmountMore"-trigger combined with an amount of 0: any given transaction- * has an amount of more than zero! Other examples are all the "Description"-triggers- * which have hard time handling empty trigger values such as "" or "*" (wild cards).- *- * If the user tries to create such a trigger, this method MUST return true so Firefly III- * can stop the storing / updating the trigger. If the trigger is in any way restrictive- * (even if it will still include 99.9% of the users transactions), this method MUST return- * false.- *- * @param mixed $value- *- * @return bool- */- public static function willMatchEverything($value = null): bool- {- if (null !== $value) {- $res = '' === (string)$value;- if (true === $res) {- Log::error(sprintf('Cannot use %s with "" as a value.', self::class));- }-- return $res;- }-- Log::error(sprintf('Cannot use %s with a null value.', self::class));-- return true;- }-- /**- * Returns true when description contains X- *- * @param TransactionJournal $journal- *- * @return bool- */- public function triggered(TransactionJournal $journal): bool- {- $search = strtolower($this->triggerValue);- $source = strtolower($journal->description ?? '');- $strpos = stripos($source, $search);- if (!(false === $strpos)) {- Log::debug(sprintf('RuleTrigger DescriptionContains for journal #%d: "%s" contains "%s", return true.', $journal->id, $source, $search));-- return true;- }-- Log::debug(sprintf('RuleTrigger DescriptionContains for journal #%d: "%s" does NOT contain "%s", return false.', $journal->id, $source, $search));-- return false;- }-}diff --git a/app/TransactionRules/Triggers/DescriptionEnds.php b/app/TransactionRules/Triggers/DescriptionEnds.phpdeleted file mode 100644index d276d9aa81..0000000000--- a/app/TransactionRules/Triggers/DescriptionEnds.php+++ /dev/null@@ -1,100 +0,0 @@-<?php-/**- * DescriptionEnds.php- * Copyright (c) 2019 [email protected]- *- * This file is part of Firefly III (https://github.com/firefly-iii).- *- * This program is free software: you can redistribute it and/or modify- * it under the terms of the GNU Affero General Public License as- * published by the Free Software Foundation, either version 3 of the- * License, or (at your option) any later version.- *- * This program is distributed in the hope that it will be useful,- * but WITHOUT ANY WARRANTY; without even the implied warranty of- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- * GNU Affero General Public License for more details.- *- * You should have received a copy of the GNU Affero General Public License- * along with this program. If not, see <https://www.gnu.org/licenses/>.- */-declare(strict_types=1);--namespace FireflyIII\TransactionRules\Triggers;--use FireflyIII\Models\TransactionJournal;-use Log;--/**- * Class DescriptionEnds.- * @deprecated- */-final class DescriptionEnds extends AbstractTrigger implements TriggerInterface-{- /**- * A trigger is said to "match anything", or match any given transaction,- * when the trigger value is very vague or has no restrictions. Easy examples- * are the "AmountMore"-trigger combined with an amount of 0: any given transaction- * has an amount of more than zero! Other examples are all the "Description"-triggers- * which have hard time handling empty trigger values such as "" or "*" (wild cards).- *- * If the user tries to create such a trigger, this method MUST return true so Firefly III- * can stop the storing / updating the trigger. If the trigger is in any way restrictive- * (even if it will still include 99.9% of the users transactions), this method MUST return- * false.- *- * @param mixed $value- *- * @return bool- */- public static function willMatchEverything($value = null): bool- {- if (null !== $value) {- $res = '' === (string)$value;- if (true === $res) {- Log::error(sprintf('Cannot use %s with "" as a value.', self::class));- }-- return $res;- }-- Log::error(sprintf('Cannot use %s with a null value.', self::class));-- return true;- }-- /**- * Returns true when description ends with X- *- * @param TransactionJournal $journal- *- * @return bool- */- public function triggered(TransactionJournal $journal): bool- {- $description = strtolower($journal->description ?? '');- $descriptionLength = strlen($description);- $search = strtolower($this->triggerValue);- $searchLength = strlen($search);-- // if the string to search for is longer than the description,- // return false.- if ($searchLength > $descriptionLength) {- Log::debug(sprintf('RuleTrigger DescriptionEnds for journal #%d: "%s" does not end with "%s", return false.', $journal->id, $description, $search));-- return false;- }-- $part = substr($description, $searchLength * -1);-- if ($part === $search) {- Log::debug(sprintf('RuleTrigger DescriptionEnds for journal #%d: "%s" ends with "%s", return true.', $journal->id, $description, $search));-- return true;- }-- Log::debug(sprintf('RuleTrigger DescriptionEnds for journal #%d: "%s" does not end with "%s", return false.', $journal->id, $description, $search));-- return false;- }-}diff --git a/app/TransactionRules/Triggers/DescriptionIs.php b/app/TransactionRules/Triggers/DescriptionIs.phpdeleted file mode 100644index 486a4c4b2a..0000000000--- a/app/TransactionRules/Triggers/DescriptionIs.php+++ /dev/null@@ -1,83 +0,0 @@-<?php-/**- * DescriptionIs.php- * Copyright (c) 2019 [email protected]- *- * This file is part of Firefly III (https://github.com/firefly-iii).- *- * This program is free software: you can redistribute it and/or modify- * it under the terms of the GNU Affero General Public License as- * published by the Free Software Foundation, either version 3 of the- * License, or (at your option) any later version.- *- * This program is distributed in the hope that it will be useful,- * but WITHOUT ANY WARRANTY; without even the implied warranty of- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- * GNU Affero General Public License for more details.- *- * You should have received a copy of the GNU Affero General Public License- * along with this program. If not, see <https://www.gnu.org/licenses/>.- */-declare(strict_types=1);--namespace FireflyIII\TransactionRules\Triggers;--use FireflyIII\Models\TransactionJournal;-use Log;--/**- * Class DescriptionIs.- * @deprecated- */-final class DescriptionIs extends AbstractTrigger implements TriggerInterface-{- /**- * A trigger is said to "match anything", or match any given transaction,- * when the trigger value is very vague or has no restrictions. Easy examples- * are the "AmountMore"-trigger combined with an amount of 0: any given transaction- * has an amount of more than zero! Other examples are all the "Description"-triggers- * which have hard time handling empty trigger values such as "" or "*" (wild cards).- *- * If the user tries to create such a trigger, this method MUST return true so Firefly III- * can stop the storing / updating the trigger. If the trigger is in any way restrictive- * (even if it will still include 99.9% of the users transactions), this method MUST return- * false.- *- * @param mixed $value- *- * @return bool- */- public static function willMatchEverything($value = null): bool- {- if (null !== $value) {- return false;- }-- Log::error(sprintf('Cannot use %s with a null value.', self::class));-- return true;- }-- /**- * Returns true when description is X- *- * @param TransactionJournal $journal- *- * @return bool- */- public function triggered(TransactionJournal $journal): bool- {- $description = strtolower($journal->description ?? '');- $search = strtolower($this->triggerValue);-- if ($description === $search) {- Log::debug(sprintf('RuleTrigger DescriptionIs for journal #%d: "%s" is "%s", return true.', $journal->id, $description, $search));-- return true;- }-- Log::debug(sprintf('RuleTrigger DescriptionIs for journal #%d: "%s" is NOT "%s", return false.', $journal->id, $description, $search));-- return false;- }-}diff --git a/app/TransactionRules/Triggers/DescriptionStarts.php b/app/TransactionRules/Triggers/DescriptionStarts.phpdeleted file mode 100644index 0fd250c72c..0000000000--- a/app/TransactionRules/Triggers/DescriptionStarts.php+++ /dev/null@@ -1,90 +0,0 @@-<?php-/**- * DescriptionStarts.php- * Copyright (c) 2019 [email protected]- *- * This file is part of Firefly III (https://github.com/firefly-iii).- *- * This program is free software: you can redistribute it and/or modify- * it under the terms of the GNU Affero General Public License as- * published by the Free Software Foundation, either version 3 of the- * License, or (at your option) any later version.- *- * This program is distributed in the hope that it will be useful,- * but WITHOUT ANY WARRANTY; without even the implied warranty of- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- * GNU Affero General Public License for more details.- *- * You should have received a copy of the GNU Affero General Public License- * along with this program. If not, see <https://www.gnu.org/licenses/>.- */-declare(strict_types=1);--namespace FireflyIII\TransactionRules\Triggers;--use FireflyIII\Models\TransactionJournal;-use Log;--/**- * Class DescriptionStarts.- * @deprecated- */-final class DescriptionStarts extends AbstractTrigger implements TriggerInterface-{- /**- * A trigger is said to "match anything", or match any given transaction,- * when the trigger value is very vague or has no restrictions. Easy examples- * are the "AmountMore"-trigger combined with an amount of 0: any given transaction- * has an amount of more than zero! Other examples are all the "Description"-triggers- * which have hard time handling empty trigger values such as "" or "*" (wild cards).- *- * If the user tries to create such a trigger, this method MUST return true so Firefly III- * can stop the storing / updating the trigger. If the trigger is in any way restrictive- * (even if it will still include 99.9% of the users transactions), this method MUST return- * false.- *- * @param mixed $value- *- * @return bool- */- public static function willMatchEverything($value = null): bool- {- if (null !== $value) {- $res = '' === (string)$value;- if (true === $res) {- Log::error(sprintf('Cannot use %s with "" as a value.', self::class));- }-- return $res;- }-- Log::error(sprintf('Cannot use %s with a null value.', self::class));-- return true;- }-- /**- * Returns true when description starts with X- *- * @param TransactionJournal $journal- *- * @return bool- */- public function triggered(TransactionJournal $journal): bool- {- $description = strtolower($journal->description ?? '');- $search = strtolower($this->triggerValue);-- $part = substr($description, 0, strlen($search));-- if ($part === $search) {- Log::debug(sprintf('RuleTrigger DescriptionStarts for journal #%d: "%s" starts with "%s", return true.', $journal->id, $description, $search));-- return true;- }-- Log::debug(sprintf('RuleTrigger DescriptionStarts for journal #%d: "%s" does not start with "%s", return false.', $journal->id, $description, $search));-- return false;- }-}diff --git a/app/TransactionRules/Triggers/ForeignCurrencyIs.php b/app/TransactionRules/Triggers/ForeignCurrencyIs.phpdeleted file mode 100644index d5c71618ad..0000000000--- a/app/TransactionRules/Triggers/ForeignCurrencyIs.php+++ /dev/null@@ -1,100 +0,0 @@-<?php-/**- * ForeignCurrencyIs.php- * Copyright (c) 2019 [email protected]- *- * This file is part of Firefly III (https://github.com/firefly-iii).- *- * This program is free software: you can redistribute it and/or modify- * it under the terms of the GNU Affero General Public License as- * published by the Free Software Foundation, either version 3 of the- * License, or (at your option) any later version.- *- * This program is distributed in the hope that it will be useful,- * but WITHOUT ANY WARRANTY; without even the implied warranty of- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- * GNU Affero General Public License for more details.- *- * You should have received a copy of the GNU Affero General Public License- * along with this program. If not, see <https://www.gnu.org/licenses/>.- */-declare(strict_types=1);--namespace FireflyIII\TransactionRules\Triggers;--use FireflyIII\Models\Transaction;-use FireflyIII\Models\TransactionJournal;-use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;-use Log;--/**- * Class ForeignCurrencyIs.- * @deprecated- */-final class ForeignCurrencyIs extends AbstractTrigger implements TriggerInterface-{- /**- * A trigger is said to "match anything", or match any given transaction,- * when the trigger value is very vague or has no restrictions. Easy examples- * are the "AmountMore"-trigger combined with an amount of 0: any given transaction- * has an amount of more than zero! Other examples are all the "Description"-triggers- * which have hard time handling empty trigger values such as "" or "*" (wild cards).- *- * If the user tries to create such a trigger, this method MUST return true so Firefly III- * can stop the storing / updating the trigger. If the trigger is in any way restrictive- * (even if it will still include 99.9% of the users transactions), this method MUST return- * false.- *- * @param mixed $value- *- * @return bool- */- public static function willMatchEverything($value = null): bool- {- if (null !== $value) {- return false;- }-- Log::error(sprintf('Cannot use %s with a null value.', self::class));-- return true;- }-- /**- * Returns true when description is X- *- * @param TransactionJournal $journal- *- * @return bool- */- public function triggered(TransactionJournal $journal): bool- {- /** @var CurrencyRepositoryInterface $repository */- $repository = app(CurrencyRepositoryInterface::class);-- // if currency name contains " ("- if (0 === strpos($this->triggerValue, ' (')) {- $parts = explode(' (', $this->triggerValue);- $this->triggerValue = $parts[0];- }-- $currency = $repository->findByNameNull($this->triggerValue);- $hit = true;- if (null !== $currency) {- /** @var Transaction $transaction */- foreach ($journal->transactions as $transaction) {- if ((int)$transaction->foreign_currency_id !== (int)$currency->id) {- Log::debug(- sprintf(- 'Trigger ForeignCurrencyIs: Transaction #%d in journal #%d uses currency %d instead of sought for #%d. No hit!',- $transaction->id, $journal->id, $transaction->foreign_currency_id, $currency->id- )- );- $hit = false;- }- }- }-- return $hit;- }-}diff --git a/app/TransactionRules/Triggers/FromAccountContains.php b/app/TransactionRules/Triggers/FromAccountContains.phpdeleted file mode 100644index 2241b9fc09..0000000000--- a/app/TransactionRules/Triggers/FromAccountContains.php+++ /dev/null@@ -1,100 +0,0 @@-<?php-/**- * FromAccountContains.php- * Copyright (c) 2019 [email protected]- *- * This file is part of Firefly III (https://github.com/firefly-iii).- *- * This program is free software: you can redistribute it and/or modify- * it under the terms of the GNU Affero General Public License as- * published by the Free Software Foundation, either version 3 of the- * License, or (at your option) any later version.- *- * This program is distributed in the hope that it will be useful,- * but WITHOUT ANY WARRANTY; without even the implied warranty of- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- * GNU Affero General Public License for more details.- *- * You should have received a copy of the GNU Affero General Public License- * along with this program. If not, see <https://www.gnu.org/licenses/>.- */-declare(strict_types=1);--namespace FireflyIII\TransactionRules\Triggers;--use FireflyIII\Models\TransactionJournal;-use FireflyIII\Repositories\Journal\JournalRepositoryInterface;-use Log;--/**- * Class FromAccountContains.- * @deprecated- */-final class FromAccountContains extends AbstractTrigger implements TriggerInterface-{- /**- * A trigger is said to "match anything", or match any given transaction,- * when the trigger value is very vague or has no restrictions. Easy examples- * are the "AmountMore"-trigger combined with an amount of 0: any given transaction- * has an amount of more than zero! Other examples are all the "Description"-triggers- * which have hard time handling empty trigger values such as "" or "*" (wild cards).- *- * If the user tries to create such a trigger, this method MUST return true so Firefly III- * can stop the storing / updating the trigger. If the trigger is in any way restrictive- * (even if it will still include 99.9% of the users transactions), this method MUST return- * false.- *- * @param mixed $value- *- * @return bool- */- public static function willMatchEverything($value = null): bool- {- if (null !== $value) {- $res = '' === (string)$value;- if (true === $res) {- Log::error(sprintf('Cannot use %s with "" as a value.', self::class));- }-- return $res;- }- Log::error(sprintf('Cannot use %s with a null value.', self::class));-- return true;- }-- /**- * Returns true when from-account contains X- *- * @param TransactionJournal $journal- *- * @return bool- */- public function triggered(TransactionJournal $journal): bool- {- /** @var JournalRepositoryInterface $repository */- $repository = app(JournalRepositoryInterface::class);- $source = $repository->getSourceAccount($journal);- $strpos = stripos($source->name, $this->triggerValue);-- if (!(false === $strpos)) {- Log::debug(- sprintf(- 'RuleTrigger %s for journal #%d: "%s" contains "%s", return true.',- get_class($this), $journal->id, $source->name, $this->triggerValue- )- );-- return true;- }-- Log::debug(- sprintf(- 'RuleTrigger %s for journal #%d: "%s" does not contain "%s", return false.',- get_class($this), $journal->id, $source->name, $this->triggerValue- )- );-- return false;- }-}diff --git a/app/TransactionRules/Triggers/FromAccountEnds.php b/app/TransactionRules/Triggers/FromAccountEnds.phpdeleted file mode 100644index 35149ad7a0..0000000000--- a/app/TransactionRules/Triggers/FromAccountEnds.php+++ /dev/null@@ -1,116 +0,0 @@-<?php-/**- * FromAccountEnds.php- * Copyright (c) 2019 [email protected]- *- * This file is part of Firefly III (https://github.com/firefly-iii).- *- * This program is free software: you can redistribute it and/or modify- * it under the terms of the GNU Affero General Public License as- * published by the Free Software Foundation, either version 3 of the- * License, or (at your option) any later version.- *- * This program is distributed in the hope that it will be useful,- * but WITHOUT ANY WARRANTY; without even the implied warranty of- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- * GNU Affero General Public License for more details.- *- * You should have received a copy of the GNU Affero General Public License- * along with this program. If not, see <https://www.gnu.org/licenses/>.- */-declare(strict_types=1);--namespace FireflyIII\TransactionRules\Triggers;--use FireflyIII\Models\TransactionJournal;-use FireflyIII\Repositories\Journal\JournalRepositoryInterface;-use Log;--/**- * Class FromAccountEnds.- * @deprecated- */-final class FromAccountEnds extends AbstractTrigger implements TriggerInterface-{- /**- * A trigger is said to "match anything", or match any given transaction,- * when the trigger value is very vague or has no restrictions. Easy examples- * are the "AmountMore"-trigger combined with an amount of 0: any given transaction- * has an amount of more than zero! Other examples are all the "Description"-triggers- * which have hard time handling empty trigger values such as "" or "*" (wild cards).- *- * If the user tries to create such a trigger, this method MUST return true so Firefly III- * can stop the storing / updating the trigger. If the trigger is in any way restrictive- * (even if it will still include 99.9% of the users transactions), this method MUST return- * false.- *- * @param mixed $value- *- * @return bool- */- public static function willMatchEverything($value = null): bool- {- if (null !== $value) {- $res = '' === (string)$value;- if (true === $res) {- Log::error(sprintf('Cannot use %s with "" as a value.', self::class));- }-- return $res;- }- Log::error(sprintf('Cannot use %s with a null value.', self::class));-- return true;- }-- /**- * Returns true when from account ends with X- *- * @param TransactionJournal $journal- *- * @return bool- */- public function triggered(TransactionJournal $journal): bool- {- /** @var JournalRepositoryInterface $repository */- $repository = app(JournalRepositoryInterface::class);- $source = $repository->getSourceAccount($journal);- $nameLength = strlen($source->name);- $search = $this->triggerValue;- $searchLength = strlen($search);- $part = substr($source->name, $searchLength * -1);-- // if the string to search for is longer than the account name,- // it will never be in the account name.- if ($searchLength > $nameLength) {- Log::debug(- sprintf(- 'RuleTrigger %s for journal #%d: "%s" does not end with "%s", return false.',- get_class($this), $journal->id, $source->name, $search- )- );-- return false;- }-- if (strtolower($part) === strtolower($search)) {- Log::debug(- sprintf(- 'RuleTrigger %s for journal #%d: "%s" ends with "%s", return true.',- get_class($this), $journal->id, $source->name, $search- )- );-- return true;- }-- Log::debug(- sprintf(- 'RuleTrigger %s for journal #%d: "%s" does not end with "%s", return false.',- get_class($this), $journal->id, $source->name, $search- )- );-- return false;- }-}diff --git a/app/TransactionRules/Triggers/FromAccountIs.php b/app/TransactionRules/Triggers/FromAccountIs.phpdeleted file mode 100644index 19ffb41fa0..0000000000--- a/app/TransactionRules/Triggers/FromAccountIs.php+++ /dev/null@@ -1,92 +0,0 @@-<?php-/**- * FromAccountIs.php- * Copyright (c) 2019 [email protected]- *- * This file is part of Firefly III (https://github.com/firefly-iii).- *- * This program is free software: you can redistribute it and/or modify- * it under the terms of the GNU Affero General Public License as- * published by the Free Software Foundation, either version 3 of the- * License, or (at your option) any later version.- *- * This program is distributed in the hope that it will be useful,- * but WITHOUT ANY WARRANTY; without even the implied warranty of- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- * GNU Affero General Public License for more details.- *- * You should have received a copy of the GNU Affero General Public License- * along with this program. If not, see <https://www.gnu.org/licenses/>.- */-declare(strict_types=1);--namespace FireflyIII\TransactionRules\Triggers;--use FireflyIII\Models\TransactionJournal;-use FireflyIII\Repositories\Journal\JournalRepositoryInterface;-use Log;--/**- * Class FromAccountIs.- * @deprecated- */-final class FromAccountIs extends AbstractTrigger implements TriggerInterface-{- /**- * A trigger is said to "match anything", or match any given transaction,- * when the trigger value is very vague or has no restrictions. Easy examples- * are the "AmountMore"-trigger combined with an amount of 0: any given transaction- * has an amount of more than zero! Other examples are all the "Description"-triggers- * which have hard time handling empty trigger values such as "" or "*" (wild cards).- *- * If the user tries to create such a trigger, this method MUST return true so Firefly III- * can stop the storing / updating the trigger. If the trigger is in any way restrictive- * (even if it will still include 99.9% of the users transactions), this method MUST return- * false.- *- * @param mixed $value- *- * @return bool- */- public static function willMatchEverything($value = null): bool- {- if (null !== $value) {- $res = '' === (string)$value;- if (true === $res) {- Log::error(sprintf('Cannot use %s with "" as a value.', self::class));- }-- return $res;- }- Log::error(sprintf('Cannot use %s with a null value.', self::class));-- return true;- }-- /**- * Returns true when from-account is X.- *- * @param TransactionJournal $journal- *- * @return bool- */- public function triggered(TransactionJournal $journal): bool- {- /** @var JournalRepositoryInterface $repository */- $repository = app(JournalRepositoryInterface::class);- $source = $repository->getSourceAccount($journal);- $search = strtolower($this->triggerValue);-- if (strtolower($source->name) === $search) {- Log::debug(sprintf('RuleTrigger %s for journal #%d: "%s" is "%s", return true.',- get_class($this), $journal->id, $source->name, $search));-- return true;- }-- Log::debug(sprintf('RuleTrigger %s for journal #%d: "%s" is NOT "%s", return false.',- get_class($this), $journal->id, $source->name, $search));-- return false;- }-}diff --git a/app/TransactionRules/Triggers/FromAccountNumberContains.php b/app/TransactionRules/Triggers/FromAccountNumberContains.phpdeleted file mode 100644index 0b45f88d5c..0000000000--- a/app/TransactionRules/Triggers/FromAccountNumberContains.php+++ /dev/null@@ -1,101 +0,0 @@-<?php-/**- * FromAccountContains.php- * Copyright (c) 2019 [email protected]- *- * This file is part of Firefly III (https://github.com/firefly-iii).- *- * This program is free software: you can redistribute it and/or modify- * it under the terms of the GNU Affero General Public License as- * published by the Free Software Foundation, either version 3 of the- * License, or (at your option) any later version.- *- * This program is distributed in the hope that it will be useful,- * but WITHOUT ANY WARRANTY; without even the implied warranty of- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- * GNU Affero General Public License for more details.- *- * You should have received a copy of the GNU Affero General Public License- * along with this program. If not, see <https://www.gnu.org/licenses/>.- */-declare(strict_types=1);--namespace FireflyIII\TransactionRules\Triggers;--use FireflyIII\Models\TransactionJournal;-use FireflyIII\Repositories\Journal\JournalRepositoryInterface;-use Log;--/**- * Class FromAccountContains.- * @deprecated- */-final class FromAccountNumberContains extends AbstractTrigger implements TriggerInterface-{- /**- * A trigger is said to "match anything", or match any given transaction,- * when the trigger value is very vague or has no restrictions. Easy examples- * are the "AmountMore"-trigger combined with an amount of 0: any given transaction- * has an amount of more than zero! Other examples are all the "Description"-triggers- * which have hard time handling empty trigger values such as "" or "*" (wild cards).- *- * If the user tries to create such a trigger, this method MUST return true so Firefly III- * can stop the storing / updating the trigger. If the trigger is in any way restrictive- * (even if it will still include 99.9% of the users transactions), this method MUST return- * false.- *- * @param mixed $value- *- * @return bool- */- public static function willMatchEverything($value = null): bool- {- if (null !== $value) {- $res = '' === (string)$value;- if (true === $res) {- Log::error(sprintf('Cannot use %s with "" as a value.', self::class));- }-- return $res;- }- Log::error(sprintf('Cannot use %s with a null value.', self::class));-- return true;- }-- /**- * Returns true when from-account contains X- *- * @param TransactionJournal $journal- *- * @return bool- */- public function triggered(TransactionJournal $journal): bool- {- /** @var JournalRepositoryInterface $repository */- $repository = app(JournalRepositoryInterface::class);- $source = $repository->getSourceAccount($journal);- $strpos1 = stripos((string)$source->iban, $this->triggerValue);- $strpos2 = stripos($source->account_number, $this->triggerValue);-- if (!(false === $strpos1) || !(false === $strpos2)) {- Log::debug(- sprintf(- 'RuleTrigger %s for journal #%d: "%s" or "%s" contains "%s", return true.',- get_class($this), $journal->id, (string)$source->iban, $source->account_number, $this->triggerValue- )- );-- return true;- }-- Log::debug(- sprintf(- 'RuleTrigger %s for journal #%d: "%s" and "%s" does not contain "%s", return false.',- get_class($this), $journal->id, (string)$source->iban, $source->account_number, $this->triggerValue- )- );-- return false;- }-}diff --git a/app/TransactionRules/Triggers/FromAccountNumberEnds.php b/app/TransactionRules/Triggers/FromAccountNumberEnds.phpdeleted file mode 100644index 5b05ca8e56..0000000000--- a/app/TransactionRules/Triggers/FromAccountNumberEnds.php+++ /dev/null@@ -1,105 +0,0 @@-<?php-/**- * FromAccountEnds.php- * Copyright (c) 2019 [email protected]- *- * This file is part of Firefly III (https://github.com/firefly-iii).- *- * This program is free software: you can redistribute it and/or modify- * it under the terms of the GNU Affero General Public License as- * published by the Free Software Foundation, either version 3 of the- * License, or (at your option) any later version.- *- * This program is distributed in the hope that it will be useful,- * but WITHOUT ANY WARRANTY; without even the implied warranty of- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- * GNU Affero General Public License for more details.- *- * You should have received a copy of the GNU Affero General Public License- * along with this program. If not, see <https://www.gnu.org/licenses/>.- */-declare(strict_types=1);--namespace FireflyIII\TransactionRules\Triggers;--use FireflyIII\Models\TransactionJournal;-use FireflyIII\Repositories\Journal\JournalRepositoryInterface;-use Log;--/**- * Class FromAccountNumberEnds.- * @deprecated- */-final class FromAccountNumberEnds extends AbstractTrigger implements TriggerInterface-{- /**- * A trigger is said to "match anything", or match any given transaction,- * when the trigger value is very vague or has no restrictions. Easy examples- * are the "AmountMore"-trigger combined with an amount of 0: any given transaction- * has an amount of more than zero! Other examples are all the "Description"-triggers- * which have hard time handling empty trigger values such as "" or "*" (wild cards).- *- * If the user tries to create such a trigger, this method MUST return true so Firefly III- * can stop the storing / updating the trigger. If the trigger is in any way restrictive- * (even if it will still include 99.9% of the users transactions), this method MUST return- * false.- *- * @param mixed $value- *- * @return bool- */- public static function willMatchEverything($value = null): bool- {- if (null !== $value) {- $res = '' === (string)$value;- if (true === $res) {- Log::error(sprintf('Cannot use %s with "" as a value.', self::class));- }-- return $res;- }- Log::error(sprintf('Cannot use %s with a null value.', self::class));-- return true;- }-- /**- * Returns true when from account ends with X- *- * @param TransactionJournal $journal- *- * @return bool- */- public function triggered(TransactionJournal $journal): bool- {- /** @var JournalRepositoryInterface $repository */- $repository = app(JournalRepositoryInterface::class);- $source = $repository->getSourceAccount($journal);- $search = strtolower($this->triggerValue);- $searchLength = strlen($search);-- $part1 = substr((string)$source->iban, $searchLength * -1);- $part2 = substr($source->account_number, $searchLength * -1);-- if (strtolower($part1) === $search- || strtolower($part2) === $search) {- Log::debug(- sprintf(- 'RuleTrigger %s for journal #%d: "%s" or "%s" ends with "%s", return true.',- get_class($this), $journal->id, $part1, $part2, $search- )- );-- return true;- }-- Log::debug(- sprintf(- 'RuleTrigger %s for journal #%d: "%s" and "%s" do not end with "%s", return false.',- get_class($this), $journal->id, $part1, $part2, $search- )- );-- return false;- }-}diff --git a/app/TransactionRules/Triggers/FromAccountNumberIs.php b/app/TransactionRules/Triggers/FromAccountNumberIs.phpdeleted file mode 100644index c5f54938ad..0000000000--- a/app/TransactionRules/Triggers/FromAccountNumberIs.php+++ /dev/null@@ -1,100 +0,0 @@-<?php-/**- * FromAccountNumberIs.php- * Copyright (c) 2019 [email protected]- *- * This file is part of Firefly III (https://github.com/firefly-iii).- *- * This program is free software: you can redistribute it and/or modify- * it under the terms of the GNU Affero General Public License as- * published by the Free Software Foundation, either version 3 of the- * License, or (at your option) any later version.- *- * This program is distributed in the hope that it will be useful,- * but WITHOUT ANY WARRANTY; without even the implied warranty of- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- * GNU Affero General Public License for more details.- *- * You should have received a copy of the GNU Affero General Public License- * along with this program. If not, see <https://www.gnu.org/licenses/>.- */-declare(strict_types=1);--namespace FireflyIII\TransactionRules\Triggers;--use FireflyIII\Models\TransactionJournal;-use FireflyIII\Repositories\Journal\JournalRepositoryInterface;-use Log;--/**- * Class FromAccountNumberIs.- * @deprecated- */-final class FromAccountNumberIs extends AbstractTrigger implements TriggerInterface-{- /**- * A trigger is said to "match anything", or match any given transaction,- * when the trigger value is very vague or has no restrictions. Easy examples- * are the "AmountMore"-trigger combined with an amount of 0: any given transaction- * has an amount of more than zero! Other examples are all the "Description"-triggers- * which have hard time handling empty trigger values such as "" or "*" (wild cards).- *- * If the user tries to create such a trigger, this method MUST return true so Firefly III- * can stop the storing / updating the trigger. If the trigger is in any way restrictive- * (even if it will still include 99.9% of the users transactions), this method MUST return- * false.- *- * @param mixed $value- *- * @return bool- */- public static function willMatchEverything($value = null): bool- {- if (null !== $value) {- $res = '' === (string)$value;- if (true === $res) {- Log::error(sprintf('Cannot use %s with "" as a value.', self::class));- }-- return $res;- }- Log::error(sprintf('Cannot use %s with a null value.', self::class));-- return true;- }-- /**- * Returns true when from-account is X.- *- * @param TransactionJournal $journal- *- * @return bool- */- public function triggered(TransactionJournal $journal): bool- {- /** @var JournalRepositoryInterface $repository */- $repository = app(JournalRepositoryInterface::class);- $source = $repository->getSourceAccount($journal);- $search = strtolower($this->triggerValue);-- if (strtolower((string)$source->iban) === $search || strtolower($source->account_number) === $search) {- Log::debug(- sprintf(- 'RuleTrigger %s for journal #%d: "%s" or "%s" is "%s", return true.', $journal->id,- get_class($this), (string)$source->iban, $source->account_number, $search- )- );-- return true;- }-- Log::debug(- sprintf(- 'RuleTrigger %s for journal #%d: "%s" and "%s" are NOT "%s", return false.',- get_class($this), $journal->id, (string)$source->iban, $source->account_number, $search- )- );-- return false;- }-}diff --git a/app/TransactionRules/Triggers/FromAccountNumberStarts.php b/app/TransactionRules/Triggers/FromAccountNumberStarts.phpdeleted file mode 100644index 2ac5fdb6a9..0000000000--- a/app/TransactionRules/Triggers/FromAccountNumberStarts.php+++ /dev/null@@ -1,102 +0,0 @@-<?php-/**- * FromAccountNumberStarts.php- * Copyright (c) 2019 [email protected]- *- * This file is part of Firefly III (https://github.com/firefly-iii).- *- * This program is free software: you can redistribute it and/or modify- * it under the terms of the GNU Affero General Public License as- * published by the Free Software Foundation, either version 3 of the- * License, or (at your option) any later version.- *- * This program is distributed in the hope that it will be useful,- * but WITHOUT ANY WARRANTY; without even the implied warranty of- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- * GNU Affero General Public License for more details.- *- * You should have received a copy of the GNU Affero General Public License- * along with this program. If not, see <https://www.gnu.org/licenses/>.- */-declare(strict_types=1);--namespace FireflyIII\TransactionRules\Triggers;--use FireflyIII\Models\TransactionJournal;-use FireflyIII\Repositories\Journal\JournalRepositoryInterface;-use Log;--/**- * Class FromAccountNumberStarts.- * @deprecated- */-final class FromAccountNumberStarts extends AbstractTrigger implements TriggerInterface-{- /**- * A trigger is said to "match anything", or match any given transaction,- * when the trigger value is very vague or has no restrictions. Easy examples- * are the "AmountMore"-trigger combined with an amount of 0: any given transaction- * has an amount of more than zero! Other examples are all the "Description"-triggers- * which have hard time handling empty trigger values such as "" or "*" (wild cards).- *- * If the user tries to create such a trigger, this method MUST return true so Firefly III- * can stop the storing / updating the trigger. If the trigger is in any way restrictive- * (even if it will still include 99.9% of the users transactions), this method MUST return- * false.- *- * @param mixed $value- *- * @return bool- */- public static function willMatchEverything($value = null): bool- {- if (null !== $value) {- $res = '' === (string)$value;- if (true === $res) {- Log::error(sprintf('Cannot use %s with "" as a value.', self::class));- }-- return $res;- }- Log::error(sprintf('Cannot use %s with a null value.', self::class));-- return true;- }-- /**- * Returns true when from-account starts with X.- *- * @param TransactionJournal $journal- *- * @return bool- */- public function triggered(TransactionJournal $journal): bool- {- /** @var JournalRepositoryInterface $repository */- $repository = app(JournalRepositoryInterface::class);- $source = $repository->getSourceAccount($journal);- $search = strtolower($this->triggerValue);- $part1 = strtolower(substr((string)$source->iban, 0, strlen($search)));- $part2 = strtolower(substr($source->account_number, 0, strlen($search)));-- if ($part1 === $search || $part2 === $search) {- Log::debug(- sprintf(- 'RuleTrigger %s for journal #%d: "%s" or "%s" starts with "%s", return true.',- get_class($this), $journal->id, $part1, $part2, $search- )- );-- return true;- }-- Log::debug(- sprintf(- 'RuleTrigger %s for journal #%d: "%s" and "%s" do not start with "%s", return false.',- get_class($this), $journal->id, $part1, $part2, $search- )- );-- return false;- }-}diff --git a/app/TransactionRules/Triggers/FromAccountStarts.php b/app/TransactionRules/Triggers/FromAccountStarts.phpdeleted file mode 100644index 94bd7f1561..0000000000--- a/app/TransactionRules/Triggers/FromAccountStarts.php+++ /dev/null@@ -1,101 +0,0 @@-<?php-/**- * FromAccountStarts.php- * Copyright (c) 2019 [email protected]- *- * This file is part of Firefly III (https://github.com/firefly-iii).- *- * This program is free software: you can redistribute it and/or modify- * it under the terms of the GNU Affero General Public License as- * published by the Free Software Foundation, either version 3 of the- * License, or (at your option) any later version.- *- * This program is distributed in the hope that it will be useful,- * but WITHOUT ANY WARRANTY; without even the implied warranty of- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- * GNU Affero General Public License for more details.- *- * You should have received a copy of the GNU Affero General Public License- * along with this program. If not, see <https://www.gnu.org/licenses/>.- */-declare(strict_types=1);--namespace FireflyIII\TransactionRules\Triggers;--use FireflyIII\Models\TransactionJournal;-use FireflyIII\Repositories\Journal\JournalRepositoryInterface;-use Log;--/**- * Class FromAccountStarts.- * @deprecated- */-final class FromAccountStarts extends AbstractTrigger implements TriggerInterface-{- /**- * A trigger is said to "match anything", or match any given transaction,- * when the trigger value is very vague or has no restrictions. Easy examples- * are the "AmountMore"-trigger combined with an amount of 0: any given transaction- * has an amount of more than zero! Other examples are all the "Description"-triggers- * which have hard time handling empty trigger values such as "" or "*" (wild cards).- *- * If the user tries to create such a trigger, this method MUST return true so Firefly III- * can stop the storing / updating the trigger. If the trigger is in any way restrictive- * (even if it will still include 99.9% of the users transactions), this method MUST return- * false.- *- * @param mixed $value- *- * @return bool- */- public static function willMatchEverything($value = null): bool- {- if (null !== $value) {- $res = '' === (string)$value;- if (true === $res) {- Log::error(sprintf('Cannot use %s with "" as a value.', self::class));- }-- return $res;- }- Log::error(sprintf('Cannot use %s with a null value.', self::class));-- return true;- }-- /**- * Returns true when from-account starts with X.- *- * @param TransactionJournal $journal- *- * @return bool- */- public function triggered(TransactionJournal $journal): bool- {- /** @var JournalRepositoryInterface $repository */- $repository = app(JournalRepositoryInterface::class);- $source = $repository->getSourceAccount($journal);- $search = strtolower($this->triggerValue);- $part = strtolower(substr($source->name, 0, strlen($search)));-- if ($part === $search) {- Log::debug(- sprintf(- 'RuleTrigger %s for journal #%d: "%s" starts with "%s", return true.',- get_class($this), $journal->id, $source->name, $search- )- );-- return true;- }-- Log::debug(- sprintf(- 'RuleTrigger %s for journal #%d: "%s" does not start with "%s", return false.',- get_class($this), $journal->id, $source->name, $search- )- );-- return false;- }-}diff --git a/app/TransactionRules/Triggers/HasAnyBudget.php b/app/TransactionRules/Triggers/HasAnyBudget.phpdeleted file mode 100644index 9c8403ae6b..0000000000--- a/app/TransactionRules/Triggers/HasAnyBudget.php+++ /dev/null@@ -1,89 +0,0 @@-<?php-/**- * HasAnyBudget.php- * Copyright (c) 2019 [email protected]- *- * This file is part of Firefly III (https://github.com/firefly-iii).- *- * This program is free software: you can redistribute it and/or modify- * it under the terms of the GNU Affero General Public License as- * published by the Free Software Foundation, either version 3 of the- * License, or (at your option) any later version.- *- * This program is distributed in the hope that it will be useful,- * but WITHOUT ANY WARRANTY; without even the implied warranty of- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- * GNU Affero General Public License for more details.- *- * You should have received a copy of the GNU Affero General Public License- * along with this program. If not, see <https://www.gnu.org/licenses/>.- */-declare(strict_types=1);--namespace FireflyIII\TransactionRules\Triggers;--use FireflyIII\Models\Transaction;-use FireflyIII\Models\TransactionJournal;-use Log;--/**- * Class HasAnyBudget.- * @deprecated- */-final class HasAnyBudget extends AbstractTrigger implements TriggerInterface-{- /**- * A trigger is said to "match anything", or match any given transaction,- * when the trigger value is very vague or has no restrictions. Easy examples- * are the "AmountMore"-trigger combined with an amount of 0: any given transaction- * has an amount of more than zero! Other examples are all the "Description"-triggers- * which have hard time handling empty trigger values such as "" or "*" (wild cards).- *- * If the user tries to create such a trigger, this method MUST return true so Firefly III- * can stop the storing / updating the trigger. If the trigger is in any way restrictive- * (even if it will still include 99.9% of the users transactions), this method MUST return- * false.- *- * @param mixed $value- *- * @return bool- */- public static function willMatchEverything($value = null): bool- {- return false;- }-- /**- * Returns true when transactions have any budget- *- * @param TransactionJournal $journal- *- * @return bool- */- public function triggered(TransactionJournal $journal): bool- {- $count = $journal->budgets()->count();- if ($count > 0) {- Log::debug(sprintf('RuleTrigger HasAnyBudget for journal #%d: count is %d, return true.', $journal->id, $count));-- return true;- }-- // perhaps transactions have budget?- /** @var Transaction $transaction */- foreach ($journal->transactions()->get() as $transaction) {- $count = $transaction->budgets()->count();- if ($count > 0) {- Log::debug(- sprintf('RuleTrigger HasAnyBudget for journal #%d (transaction #%d): count is %d, return true.', $journal->id, $transaction->id, $count)- );-- return true;- }- }-- Log::debug(sprintf('RuleTrigger HasAnyBudget for journal #%d: final is false.', $journal->id));-- return false;- }-}diff --git a/app/TransactionRules/Triggers/HasAnyCategory.php b/app/TransactionRules/Triggers/HasAnyCategory.phpdeleted file mode 100644index 6d131c3559..0000000000--- a/app/TransactionRules/Triggers/HasAnyCategory.php+++ /dev/null@@ -1,89 +0,0 @@-<?php-/**- * HasAnyCategory.php- * Copyright (c) 2019 [email protected]- *- * This file is part of Firefly III (https://github.com/firefly-iii).- *- * This program is free software: you can redistribute it and/or modify- * it under the terms of the GNU Affero General Public License as- * published by the Free Software Foundation, either version 3 of the- * License, or (at your option) any later version.- *- * This program is distributed in the hope that it will be useful,- * but WITHOUT ANY WARRANTY; without even the implied warranty of- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- * GNU Affero General Public License for more details.- *- * You should have received a copy of the GNU Affero General Public License- * along with this program. If not, see <https://www.gnu.org/licenses/>.- */-declare(strict_types=1);--namespace FireflyIII\TransactionRules\Triggers;--use FireflyIII\Models\Transaction;-use FireflyIII\Models\TransactionJournal;-use Log;--/**- * Class HasAnyCategory.- * @deprecated- */-final class HasAnyCategory extends AbstractTrigger implements TriggerInterface-{- /**- * A trigger is said to "match anything", or match any given transaction,- * when the trigger value is very vague or has no restrictions. Easy examples- * are the "AmountMore"-trigger combined with an amount of 0: any given transaction- * has an amount of more than zero! Other examples are all the "Description"-triggers- * which have hard time handling empty trigger values such as "" or "*" (wild cards).- *- * If the user tries to create such a trigger, this method MUST return true so Firefly III- * can stop the storing / updating the trigger. If the trigger is in any way restrictive- * (even if it will still include 99.9% of the users transactions), this method MUST return- * false.- *- * @param mixed $value- *- * @return bool- */- public static function willMatchEverything($value = null): bool- {- return false;- }-- /**- * Returns true when journal has any category- *- * @param TransactionJournal $journal- *- * @return bool- */- public function triggered(TransactionJournal $journal): bool- {- $count = $journal->categories()->count();- if ($count > 0) {- Log::debug(sprintf('RuleTrigger HasAnyCategory for journal #%d: count is %d, return true.', $journal->id, $count));-- return true;- }-- // perhaps transactions have category?- /** @var Transaction $transaction */- foreach ($journal->transactions()->get() as $transaction) {- $count = $transaction->categories()->count();- if ($count > 0) {- Log::debug(- sprintf('RuleTrigger HasAnyCategory for journal #%d (transaction #%d): count is %d, return true.', $journal->id, $transaction->id, $count)- );-- return true;- }- }-- Log::debug(sprintf('RuleTrigger HasAnyCategory for journal #%d: count is %d, return false.', $journal->id, $count));-- return false;- }-}diff --git a/app/TransactionRules/Triggers/HasAnyTag.php b/app/TransactionRules/Triggers/HasAnyTag.phpdeleted file mode 100644index c22262b0e7..0000000000--- a/app/TransactionRules/Triggers/HasAnyTag.php+++ /dev/null@@ -1,74 +0,0 @@-<?php-/**- * HasAnyTag.php- * Copyright (c) 2019 [email protected]- *- * This file is part of Firefly III (https://github.com/firefly-iii).- *- * This program is free software: you can redistribute it and/or modify- * it under the terms of the GNU Affero General Public License as- * published by the Free Software Foundation, either version 3 of the- * License, or (at your option) any later version.- *- * This program is distributed in the hope that it will be useful,- * but WITHOUT ANY WARRANTY; without even the implied warranty of- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- * GNU Affero General Public License for more details.- *- * You should have received a copy of the GNU Affero General Public License- * along with this program. If not, see <https://www.gnu.org/licenses/>.- */-declare(strict_types=1);--namespace FireflyIII\TransactionRules\Triggers;--use FireflyIII\Models\TransactionJournal;-use Log;--/**- * Class HasAnyTag.- * @deprecated- */-final class HasAnyTag extends AbstractTrigger implements TriggerInterface-{- /**- * A trigger is said to "match anything", or match any given transaction,- * when the trigger value is very vague or has no restrictions. Easy examples- * are the "AmountMore"-trigger combined with an amount of 0: any given transaction- * has an amount of more than zero! Other examples are all the "Description"-triggers- * which have hard time handling empty trigger values such as "" or "*" (wild cards).- *- * If the user tries to create such a trigger, this method MUST return true so Firefly III- * can stop the storing / updating the trigger. If the trigger is in any way restrictive- * (even if it will still include 99.9% of the users transactions), this method MUST return- * false.- *- * @param mixed $value- *- * @return bool- */- public static function willMatchEverything($value = null): bool- {- return false;- }-- /**- * Returns true when journal has any tag- *- * @param TransactionJournal $journal- *- * @return bool- */- public function triggered(TransactionJournal $journal): bool- {- $count = $journal->tags()->count();- if ($count > 0) {- Log::debug(sprintf('RuleTrigger HasAnyTag for journal #%d: count is %d, return true.', $journal->id, $count));-- return true;- }- Log::debug(sprintf('RuleTrigger HasAnyTag for journal #%d: count is %d, return false.', $journal->id, $count));-- return false;- }-}diff --git a/app/TransactionRules/Triggers/HasAttachment.php b/app/TransactionRules/Triggers/HasAttachment.phpdeleted file mode 100644index 3dbc0934f6..0000000000--- a/app/TransactionRules/Triggers/HasAttachment.php+++ /dev/null@@ -1,84 +0,0 @@-<?php-/**- * HasAttachment.php- * Copyright (c) 2019 [email protected]- *- * This file is part of Firefly III (https://github.com/firefly-iii).- *- * This program is free software: you can redistribute it and/or modify- * it under the terms of the GNU Affero General Public License as- * published by the Free Software Foundation, either version 3 of the- * License, or (at your option) any later version.- *- * This program is distributed in the hope that it will be useful,- * but WITHOUT ANY WARRANTY; without even the implied warranty of- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- * GNU Affero General Public License for more details.- *- * You should have received a copy of the GNU Affero General Public License- * along with this program. If not, see <https://www.gnu.org/licenses/>.- */-declare(strict_types=1);--namespace FireflyIII\TransactionRules\Triggers;--use FireflyIII\Models\TransactionJournal;-use Log;--/**- * Class HasAttachment- * @deprecated- */-class HasAttachment extends AbstractTrigger implements TriggerInterface-{- /**- * A trigger is said to "match anything", or match any given transaction,- * when the trigger value is very vague or has no restrictions. Easy examples- * are the "AmountMore"-trigger combined with an amount of 0: any given transaction- * has an amount of more than zero! Other examples are all the "Description"-triggers- * which have hard time handling empty trigger values such as "" or "*" (wild cards).- *- * If the user tries to create such a trigger, this method MUST return true so Firefly III- * can stop the storing / updating the trigger. If the trigger is in any way restrictive- * (even if it will still include 99.9% of the users transactions), this method MUST return- * false.- *- * @param mixed $value- *- * @return bool- */- public static function willMatchEverything($value = null): bool- {- $value = (int)$value;-- return $value < 0;- }-- /**- * Returns true when journal has more than X attachments.- *- * @param TransactionJournal $journal- *- * @return bool- */- public function triggered(TransactionJournal $journal): bool- {- $minimum = (int)$this->triggerValue;- $attachments = $journal->attachments()->count();- if ($attachments >= $minimum) {- Log::debug(- sprintf(- 'RuleTrigger HasAttachment for journal #%d: count is %d, is more than or equal to %d, return true.',- $journal->id,- $attachments,- $minimum- )- );-- return true;- }- Log::debug(sprintf('RuleTrigger HasAttachment for journal #%d: count is %d, is less than %d, return true.', $journal->id, $attachments, $minimum));-- return false;- }-}diff --git a/app/TransactionRules/Triggers/HasNoBudget.php b/app/TransactionRules/Triggers/HasNoBudget.phpdeleted file mode 100644index 2ef1618b17..0000000000--- a/app/TransactionRules/Triggers/HasNoBudget.php+++ /dev/null@@ -1,82 +0,0 @@-<?php-/**- * HasNoBudget.php- * Copyright (c) 2019 [email protected]- *- * This file is part of Firefly III (https://github.com/firefly-iii).- *- * This program is free software: you can redistribute it and/or modify- * it under the terms of the GNU Affero General Public License as- * published by the Free Software Foundation, either version 3 of the- * License, or (at your option) any later version.- *- * This program is distributed in the hope that it will be useful,- * but WITHOUT ANY WARRANTY; without even the implied warranty of- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- * GNU Affero General Public License for more details.- *- * You should have received a copy of the GNU Affero General Public License- * along with this program. If not, see <https://www.gnu.org/licenses/>.- */-declare(strict_types=1);--namespace FireflyIII\TransactionRules\Triggers;--use FireflyIII\Models\Transaction;-use FireflyIII\Models\TransactionJournal;-use Log;--/**- * Class HasNoBudget.- * @deprecated- */-final class HasNoBudget extends AbstractTrigger implements TriggerInterface-{- /**- * A trigger is said to "match anything", or match any given transaction,- * when the trigger value is very vague or has no restrictions. Easy examples- * are the "AmountMore"-trigger combined with an amount of 0: any given transaction- * has an amount of more than zero! Other examples are all the "Description"-triggers- * which have hard time handling empty trigger values such as "" or "*" (wild cards).- *- * If the user tries to create such a trigger, this method MUST return true so Firefly III- * can stop the storing / updating the trigger. If the trigger is in any way restrictive- * (even if it will still include 99.9% of the users transactions), this method MUST return- * false.- *- * @param mixed $value- *- * @return bool- */- public static function willMatchEverything($value = null): bool- {- return false;- }-- /**- * Returns true when journal has no budget- *- * @param TransactionJournal $journal- *- * @return bool- */- public function triggered(TransactionJournal $journal): bool- {- $count = $journal->budgets()->count();-- // perhaps transactions have budget?- /** @var Transaction $transaction */- foreach ($journal->transactions()->get() as $transaction) {- $count += $transaction->budgets()->count();- }- if (0 === $count) {- Log::debug(sprintf('RuleTrigger HasNoBudget for journal #%d: count is %d, return true.', $journal->id, $count));-- return true;- }-- Log::debug(sprintf('RuleTrigger HasNoBudget for journal #%d: count is %d, return false.', $journal->id, $count));-- return false;- }-}diff --git a/app/TransactionRules/Triggers/HasNoCategory.php b/app/TransactionRules/Triggers/HasNoCategory.phpdeleted file mode 100644index 23e81621e9..0000000000--- a/app/TransactionRules/Triggers/HasNoCategory.php+++ /dev/null@@ -1,82 +0,0 @@-<?php-/**- * HasNoCategory.php- * Copyright (c) 2019 [email protected]- *- * This file is part of Firefly III (https://github.com/firefly-iii).- *- * This program is free software: you can redistribute it and/or modify- * it under the terms of the GNU Affero General Public License as- * published by the Free Software Foundation, either version 3 of the- * License, or (at your option) any later version.- *- * This program is distributed in the hope that it will be useful,- * but WITHOUT ANY WARRANTY; without even the implied warranty of- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- * GNU Affero General Public License for more details.- *- * You should have received a copy of the GNU Affero General Public License- * along with this program. If not, see <https://www.gnu.org/licenses/>.- */-declare(strict_types=1);--namespace FireflyIII\TransactionRules\Triggers;--use FireflyIII\Models\Transaction;-use FireflyIII\Models\TransactionJournal;-use Log;--/**- * Class HasNoCategory.- * @deprecated- */-final class HasNoCategory extends AbstractTrigger implements TriggerInterface-{- /**- * A trigger is said to "match anything", or match any given transaction,- * when the trigger value is very vague or has no restrictions. Easy examples- * are the "AmountMore"-trigger combined with an amount of 0: any given transaction- * has an amount of more than zero! Other examples are all the "Description"-triggers- * which have hard time handling empty trigger values such as "" or "*" (wild cards).- *- * If the user tries to create such a trigger, this method MUST return true so Firefly III- * can stop the storing / updating the trigger. If the trigger is in any way restrictive- * (even if it will still include 99.9% of the users transactions), this method MUST return- * false.- *- * @param mixed $value- *- * @return bool- */- public static function willMatchEverything($value = null): bool- {- return false;- }-- /**- * Returns true when journal has no category- *- * @param TransactionJournal $journal- *- * @return bool- */- public function triggered(TransactionJournal $journal): bool- {- $count = $journal->categories()->count();-- // perhaps transactions have category?- /** @var Transaction $transaction */- foreach ($journal->transactions()->get() as $transaction) {- $count += $transaction->categories()->count();- }-- if (0 === $count) {- Log::debug(sprintf('RuleTrigger HasNoCategory for journal #%d: count is %d, return true.', $journal->id, $count));-- return true;- }- Log::debug(sprintf('RuleTrigger HasNoCategory for journal #%d: count is %d, return false.', $journal->id, $count));-- return false;- }-}diff --git a/app/TransactionRules/Triggers/HasNoTag.php b/app/TransactionRules/Triggers/HasNoTag.phpdeleted file mode 100644index 83e4c300f5..0000000000--- a/app/TransactionRules/Triggers/HasNoTag.php+++ /dev/null@@ -1,74 +0,0 @@-<?php-/**- * HasNoTag.php- * Copyright (c) 2019 [email protected]- *- * This file is part of Firefly III (https://github.com/firefly-iii).- *- * This program is free software: you can redistribute it and/or modify- * it under the terms of the GNU Affero General Public License as- * published by the Free Software Foundation, either version 3 of the- * License, or (at your option) any later version.- *- * This program is distributed in the hope that it will be useful,- * but WITHOUT ANY WARRANTY; without even the implied warranty of- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- * GNU Affero General Public License for more details.- *- * You should have received a copy of the GNU Affero General Public License- * along with this program. If not, see <https://www.gnu.org/licenses/>.- */-declare(strict_types=1);--namespace FireflyIII\TransactionRules\Triggers;--use FireflyIII\Models\TransactionJournal;-use Log;--/**- * Class HasNoTag.- * @deprecated- */-final class HasNoTag extends AbstractTrigger implements TriggerInterface-{- /**- * A trigger is said to "match anything", or match any given transaction,- * when the trigger value is very vague or has no restrictions. Easy examples- * are the "AmountMore"-trigger combined with an amount of 0: any given transaction- * has an amount of more than zero! Other examples are all the "Description"-triggers- * which have hard time handling empty trigger values such as "" or "*" (wild cards).- *- * If the user tries to create such a trigger, this method MUST return true so Firefly III- * can stop the storing / updating the trigger. If the trigger is in any way restrictive- * (even if it will still include 99.9% of the users transactions), this method MUST return- * false.- *- * @param mixed $value- *- * @return bool- */- public static function willMatchEverything($value = null): bool- {- return false;- }-- /**- * Return true when journal has no tags.- *- * @param TransactionJournal $journal- *- * @return bool- */- public function triggered(TransactionJournal $journal): bool- {- $count = $journal->tags()->count();- if (0 === $count) {- Log::debug(sprintf('RuleTrigger HasNoTag for journal #%d: count is %d, return true.', $journal->id, $count));-- return true;- }- Log::debug(sprintf('RuleTrigger HasNoTag for journal #%d: count is %d, return false.', $journal->id, $count));-- return false;- }-}diff --git a/app/TransactionRules/Triggers/NotesAny.php b/app/TransactionRules/Triggers/NotesAny.phpdeleted file mode 100644index 9059d33227..0000000000--- a/app/TransactionRules/Triggers/NotesAny.php+++ /dev/null@@ -1,82 +0,0 @@-<?php-/**- * NotesAny.php- * Copyright (c) 2019 [email protected]- *- * This file is part of Firefly III (https://github.com/firefly-iii).- *- * This program is free software: you can redistribute it and/or modify- * it under the terms of the GNU Affero General Public License as- * published by the Free Software Foundation, either version 3 of the- * License, or (at your option) any later version.- *- * This program is distributed in the hope that it will be useful,- * but WITHOUT ANY WARRANTY; without even the implied warranty of- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- * GNU Affero General Public License for more details.- *- * You should have received a copy of the GNU Affero General Public License- * along with this program. If not, see <https://www.gnu.org/licenses/>.- */-declare(strict_types=1);--namespace FireflyIII\TransactionRules\Triggers;--use FireflyIII\Models\Note;-use FireflyIII\Models\TransactionJournal;-use Log;--/**- * Class NotesAny.- * @deprecated- */-final class NotesAny extends AbstractTrigger implements TriggerInterface-{- /**- * A trigger is said to "match anything", or match any given transaction,- * when the trigger value is very vague or has no restrictions. Easy examples- * are the "AmountMore"-trigger combined with an amount of 0: any given transaction- * has an amount of more than zero! Other examples are all the "Description"-triggers- * which have hard time handling empty trigger values such as "" or "*" (wild cards).- *- * If the user tries to create such a trigger, this method MUST return true so Firefly III- * can stop the storing / updating the trigger. If the trigger is in any way restrictive- * (even if it will still include 99.9% of the users transactions), this method MUST return- * false.- *- * @param mixed $value- *- * @return bool- */- public static function willMatchEverything($value = null): bool- {- return false;- }-- /**- * Returns true when journal has any notes- *- * @param TransactionJournal $journal- *- * @return bool- */- public function triggered(TransactionJournal $journal): bool- {- /** @var Note $note */- $note = $journal->notes()->first();- $text = '';- if (null !== $note) {- $text = $note->text;- }-- if ('' !== $text) {- Log::debug(sprintf('RuleTrigger NotesEmpty for journal #%d: strlen > 0, return true.', $journal->id));-- return true;- }-- Log::debug(sprintf('RuleTrigger NotesEmpty for journal #%d: strlen is 0, return false.', $journal->id));-- return false;- }-}diff --git a/app/TransactionRules/Triggers/NotesAre.php b/app/TransactionRules/Triggers/NotesAre.phpdeleted file mode 100644index b3153c6b04..0000000000--- a/app/TransactionRules/Triggers/NotesAre.php+++ /dev/null@@ -1,89 +0,0 @@-<?php-/**- * NotesAre.php- * Copyright (c) 2019 [email protected]- *- * This file is part of Firefly III (https://github.com/firefly-iii).- *- * This program is free software: you can redistribute it and/or modify- * it under the terms of the GNU Affero General Public License as- * published by the Free Software Foundation, either version 3 of the- * License, or (at your option) any later version.- *- * This program is distributed in the hope that it will be useful,- * but WITHOUT ANY WARRANTY; without even the implied warranty of- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- * GNU Affero General Public License for more details.- *- * You should have received a copy of the GNU Affero General Public License- * along with this program. If not, see <https://www.gnu.org/licenses/>.- */-declare(strict_types=1);--namespace FireflyIII\TransactionRules\Triggers;--use FireflyIII\Models\Note;-use FireflyIII\Models\TransactionJournal;-use Log;--/**- * Class NotesAre.- * @deprecated- */-final class NotesAre extends AbstractTrigger implements TriggerInterface-{- /**- * A trigger is said to "match anything", or match any given transaction,- * when the trigger value is very vague or has no restrictions. Easy examples- * are the "AmountMore"-trigger combined with an amount of 0: any given transaction- * has an amount of more than zero! Other examples are all the "Description"-triggers- * which have hard time handling empty trigger values such as "" or "*" (wild cards).- *- * If the user tries to create such a trigger, this method MUST return true so Firefly III- * can stop the storing / updating the trigger. If the trigger is in any way restrictive- * (even if it will still include 99.9% of the users transactions), this method MUST return- * false.- *- * @param mixed $value- *- * @return bool- */- public static function willMatchEverything($value = null): bool- {- if (null !== $value) {- return false;- }-- Log::error(sprintf('Cannot use %s with a null value.', self::class));-- return true;- }-- /**- * Returns true when notes are specifically X- *- * @param TransactionJournal $journal- *- * @return bool- */- public function triggered(TransactionJournal $journal): bool- {- /** @var Note $note */- $note = $journal->notes()->first();- $text = '';- if (null !== $note) {- $text = strtolower($note->text);- }- $search = strtolower($this->triggerValue);-- if ($text === $search && '' != $text) {- Log::debug(sprintf('RuleTrigger NotesAre for journal #%d: "%s" is "%s", return true.', $journal->id, $text, $search));-- return true;- }-- Log::debug(sprintf('RuleTrigger NotesAre for journal #%d: "%s" is NOT "%s", return false.', $journal->id, $text, $search));-- return false;- }-}diff --git a/app/TransactionRules/Triggers/NotesContain.php b/app/TransactionRules/Triggers/NotesContain.phpdeleted file mode 100644index f10a32cd12..0000000000--- a/app/TransactionRules/Triggers/NotesContain.php+++ /dev/null@@ -1,102 +0,0 @@-<?php-/**- * NotesContain.php- * Copyright (c) 2019 [email protected]- *- * This file is part of Firefly III (https://github.com/firefly-iii).- *- * This program is free software: you can redistribute it and/or modify- * it under the terms of the GNU Affero General Public License as- * published by the Free Software Foundation, either version 3 of the- * License, or (at your option) any later version.- *- * This program is distributed in the hope that it will be useful,- * but WITHOUT ANY WARRANTY; without even the implied warranty of- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- * GNU Affero General Public License for more details.- *- * You should have received a copy of the GNU Affero General Public License- * along with this program. If not, see <https://www.gnu.org/licenses/>.- */-declare(strict_types=1);--namespace FireflyIII\TransactionRules\Triggers;--use FireflyIII\Models\Note;-use FireflyIII\Models\TransactionJournal;-use Log;--/**- * Class NotesContain.- * @deprecated- */-final class NotesContain extends AbstractTrigger implements TriggerInterface-{- /**- * A trigger is said to "match anything", or match any given transaction,- * when the trigger value is very vague or has no restrictions. Easy examples- * are the "AmountMore"-trigger combined with an amount of 0: any given transaction- * has an amount of more than zero! Other examples are all the "Description"-triggers- * which have hard time handling empty trigger values such as "" or "*" (wild cards).- *- * If the user tries to create such a trigger, this method MUST return true so Firefly III- * can stop the storing / updating the trigger. If the trigger is in any way restrictive- * (even if it will still include 99.9% of the users transactions), this method MUST return- * false.- *- * @param mixed $value- *- * @return bool- */- public static function willMatchEverything($value = null): bool- {- if (null !== $value) {- $res = '' === (string)$value;- if (true === $res) {- Log::error(sprintf('Cannot use %s with "" as a value.', self::class));- }-- return $res;- }-- Log::error(sprintf('Cannot use %s with a null value.', self::class));-- return true;- }-- /**- * Returns true when notes contains X- *- * @param TransactionJournal $journal- *- * @return bool- */- public function triggered(TransactionJournal $journal): bool- {- $search = strtolower(trim($this->triggerValue));-- if ('' === $search) {- Log::debug(sprintf('RuleTrigger NotesContain for journal #%d: "%s" is empty, return false.', $journal->id, $search));-- return false;- }-- /** @var Note $note */- $note = $journal->notes()->first();- $text = '';- if (null !== $note) {- $text = strtolower($note->text);- }-- $strpos = strpos($text, $search);- if (!(false === $strpos)) {- Log::debug(sprintf('RuleTrigger NotesContain for journal #%d: "%s" contains "%s", return true.', $journal->id, $text, $search));-- return true;- }-- Log::debug(sprintf('RuleTrigger NotesContain for journal #%d: "%s" does NOT contain "%s", return false.', $journal->id, $text, $search));-- return false;- }-}diff --git a/app/TransactionRules/Triggers/NotesEmpty.php b/app/TransactionRules/Triggers/NotesEmpty.phpdeleted file mode 100644index 2e66fb6a6e..0000000000--- a/app/TransactionRules/Triggers/NotesEmpty.php+++ /dev/null@@ -1,82 +0,0 @@-<?php-/**- * NotesEmpty.php- * Copyright (c) 2019 [email protected]- *- * This file is part of Firefly III (https://github.com/firefly-iii).- *- * This program is free software: you can redistribute it and/or modify- * it under the terms of the GNU Affero General Public License as- * published by the Free Software Foundation, either version 3 of the- * License, or (at your option) any later version.- *- * This program is distributed in the hope that it will be useful,- * but WITHOUT ANY WARRANTY; without even the implied warranty of- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- * GNU Affero General Public License for more details.- *- * You should have received a copy of the GNU Affero General Public License- * along with this program. If not, see <https://www.gnu.org/licenses/>.- */-declare(strict_types=1);--namespace FireflyIII\TransactionRules\Triggers;--use FireflyIII\Models\Note;-use FireflyIII\Models\TransactionJournal;-use Log;--/**- * Class NotesEmpty.- * @deprecated- */-final class NotesEmpty extends AbstractTrigger implements TriggerInterface-{- /**- * A trigger is said to "match anything", or match any given transaction,- * when the trigger value is very vague or has no restrictions. Easy examples- * are the "AmountMore"-trigger combined with an amount of 0: any given transaction- * has an amount of more than zero! Other examples are all the "Description"-triggers- * which have hard time handling empty trigger values such as "" or "*" (wild cards).- *- * If the user tries to create such a trigger, this method MUST return true so Firefly III- * can stop the storing / updating the trigger. If the trigger is in any way restrictive- * (even if it will still include 99.9% of the users transactions), this method MUST return- * false.- *- * @param mixed $value- *- * @return bool- */- public static function willMatchEverything($value = null): bool- {- return false;- }-- /**- * Returns true when journal has no notes.- *- * @param TransactionJournal $journal- *- * @return bool- */- public function triggered(TransactionJournal $journal): bool- {- /** @var Note $note */- $note = $journal->notes()->first();- $text = '';- if (null !== $note) {- $text = $note->text;- }-- if ('' === $text) {- Log::debug(sprintf('RuleTrigger NotesEmpty for journal #%d: strlen is 0, return true.', $journal->id));-- return true;- }-- Log::debug(sprintf('RuleTrigger NotesEmpty for journal #%d: strlen > 0, return false.', $journal->id));-- return false;- }-}diff --git a/app/TransactionRules/Triggers/NotesEnd.php b/app/TransactionRules/Triggers/NotesEnd.phpdeleted file mode 100644index ff9c831884..0000000000--- a/app/TransactionRules/Triggers/NotesEnd.php+++ /dev/null@@ -1,106 +0,0 @@-<?php-/**- * NotesEnd.php- * Copyright (c) 2019 [email protected]- *- * This file is part of Firefly III (https://github.com/firefly-iii).- *- * This program is free software: you can redistribute it and/or modify- * it under the terms of the GNU Affero General Public License as- * published by the Free Software Foundation, either version 3 of the- * License, or (at your option) any later version.- *- * This program is distributed in the hope that it will be useful,- * but WITHOUT ANY WARRANTY; without even the implied warranty of- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- * GNU Affero General Public License for more details.- *- * You should have received a copy of the GNU Affero General Public License- * along with this program. If not, see <https://www.gnu.org/licenses/>.- */-declare(strict_types=1);--namespace FireflyIII\TransactionRules\Triggers;--use FireflyIII\Models\Note;-use FireflyIII\Models\TransactionJournal;-use Log;--/**- * Class NotesEnd.- * @deprecated- */-final class NotesEnd extends AbstractTrigger implements TriggerInterface-{- /**- * A trigger is said to "match anything", or match any given transaction,- * when the trigger value is very vague or has no restrictions. Easy examples- * are the "AmountMore"-trigger combined with an amount of 0: any given transaction- * has an amount of more than zero! Other examples are all the "Description"-triggers- * which have hard time handling empty trigger values such as "" or "*" (wild cards).- *- * If the user tries to create such a trigger, this method MUST return true so Firefly III- * can stop the storing / updating the trigger. If the trigger is in any way restrictive- * (even if it will still include 99.9% of the users transactions), this method MUST return- * false.- *- * @param mixed $value- *- * @return bool- */- public static function willMatchEverything($value = null): bool- {- if (null !== $value) {- $res = '' === (string)$value;- if (true === $res) {- Log::error(sprintf('Cannot use %s with "" as a value.', self::class));- }-- return $res;- }-- Log::error(sprintf('Cannot use %s with a null value.', self::class));-- return true;- }-- /**- * Returns true when notes end with X- *- * @param TransactionJournal $journal- *- * @return bool- */- public function triggered(TransactionJournal $journal): bool- {- /** @var Note $note */- $note = $journal->notes()->first();- $text = '';- if (null !== $note) {- $text = strtolower($note->text);- }- $notesLength = strlen($text);- $search = strtolower($this->triggerValue);- $searchLength = strlen($search);-- // if the string to search for is longer than the description,- // return false- if ($searchLength > $notesLength) {- Log::debug(sprintf('RuleTrigger NotesEnd for journal #%d: "%s" does not end with "%s", return false.', $journal->id, $text, $search));-- return false;- }-- $part = substr($text, $searchLength * -1);-- if ($part === $search) {- Log::debug(sprintf('RuleTrigger NotesEnd for journal #%d: "%s" ends with "%s", return true.', $journal->id, $text, $search));-- return true;- }-- Log::debug(sprintf('RuleTrigger NotesEnd for journal #%d: "%s" does not end with "%s", return false.', $journal->id, $text, $search));-- return false;- }-}diff --git a/app/TransactionRules/Triggers/NotesStart.php b/app/TransactionRules/Triggers/NotesStart.phpdeleted file mode 100644index 4f5021ce7a..0000000000--- a/app/TransactionRules/Triggers/NotesStart.php+++ /dev/null@@ -1,96 +0,0 @@-<?php-/**- * NotesStart.php- * Copyright (c) 2019 [email protected]- *- * This file is part of Firefly III (https://github.com/firefly-iii).- *- * This program is free software: you can redistribute it and/or modify- * it under the terms of the GNU Affero General Public License as- * published by the Free Software Foundation, either version 3 of the- * License, or (at your option) any later version.- *- * This program is distributed in the hope that it will be useful,- * but WITHOUT ANY WARRANTY; without even the implied warranty of- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- * GNU Affero General Public License for more details.- *- * You should have received a copy of the GNU Affero General Public License- * along with this program. If not, see <https://www.gnu.org/licenses/>.- */-declare(strict_types=1);--namespace FireflyIII\TransactionRules\Triggers;--use FireflyIII\Models\Note;-use FireflyIII\Models\TransactionJournal;-use Log;--/**- * Class NotesStart.- * @deprecated- */-final class NotesStart extends AbstractTrigger implements TriggerInterface-{- /**- * A trigger is said to "match anything", or match any given transaction,- * when the trigger value is very vague or has no restrictions. Easy examples- * are the "AmountMore"-trigger combined with an amount of 0: any given transaction- * has an amount of more than zero! Other examples are all the "Description"-triggers- * which have hard time handling empty trigger values such as "" or "*" (wild cards).- *- * If the user tries to create such a trigger, this method MUST return true so Firefly III- * can stop the storing / updating the trigger. If the trigger is in any way restrictive- * (even if it will still include 99.9% of the users transactions), this method MUST return- * false.- *- * @param mixed $value- *- * @return bool- */- public static function willMatchEverything($value = null): bool- {- if (null !== $value) {- $res = '' === (string)$value;- if (true === $res) {- Log::error(sprintf('Cannot use %s with "" as a value.', self::class));- }-- return $res;- }-- Log::error(sprintf('Cannot use %s with a null value.', self::class));-- return true;- }-- /**- * When the notes start with X.- *- * @param TransactionJournal $journal- *- * @return bool- */- public function triggered(TransactionJournal $journal): bool- {- /** @var Note $note */- $note = $journal->notes()->first();- $text = '';- if (null !== $note) {- $text = strtolower($note->text);- }- $search = strtolower($this->triggerValue);-- $part = substr($text, 0, strlen($search));-- if ($part === $search) {- Log::debug(sprintf('RuleTrigger NotesStart for journal #%d: "%s" starts with "%s", return true.', $journal->id, $text, $search));-- return true;- }-- Log::debug(sprintf('RuleTrigger NotesStart for journal #%d: "%s" does not start with "%s", return false.', $journal->id, $text, $search));-- return false;- }-}diff --git a/app/TransactionRules/Triggers/TagIs.php b/app/TransactionRules/Triggers/TagIs.phpdeleted file mode 100644index 1c019a91c0..0000000000--- a/app/TransactionRules/Triggers/TagIs.php+++ /dev/null@@ -1,85 +0,0 @@-<?php-/**- * TagIs.php- * Copyright (c) 2019 [email protected]- *- * This file is part of Firefly III (https://github.com/firefly-iii).- *- * This program is free software: you can redistribute it and/or modify- * it under the terms of the GNU Affero General Public License as- * published by the Free Software Foundation, either version 3 of the- * License, or (at your option) any later version.- *- * This program is distributed in the hope that it will be useful,- * but WITHOUT ANY WARRANTY; without even the implied warranty of- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- * GNU Affero General Public License for more details.- *- * You should have received a copy of the GNU Affero General Public License- * along with this program. If not, see <https://www.gnu.org/licenses/>.- */-declare(strict_types=1);--namespace FireflyIII\TransactionRules\Triggers;--use FireflyIII\Models\Tag;-use FireflyIII\Models\TransactionJournal;-use Log;--/**- * Class TagIs.- * @deprecated- */-final class TagIs extends AbstractTrigger implements TriggerInterface-{- /**- * A trigger is said to "match anything", or match any given transaction,- * when the trigger value is very vague or has no restrictions. Easy examples- * are the "AmountMore"-trigger combined with an amount of 0: any given transaction- * has an amount of more than zero! Other examples are all the "Description"-triggers- * which have hard time handling empty trigger values such as "" or "*" (wild cards).- *- * If the user tries to create such a trigger, this method MUST return true so Firefly III- * can stop the storing / updating the trigger. If the trigger is in any way restrictive- * (even if it will still include 99.9% of the users transactions), this method MUST return- * false.- *- * @param mixed $value- *- * @return bool- */- public static function willMatchEverything($value = null): bool- {- if (null !== $value) {- return false;- }- Log::error(sprintf('Cannot use %s with a null value.', self::class));-- return true;- }-- /**- * Returns true when tag is X.- *- * @param TransactionJournal $journal- *- * @return bool- */- public function triggered(TransactionJournal $journal): bool- {- $tags = $journal->tags()->get();- /** @var Tag $tag */- foreach ($tags as $tag) {- $name = strtolower($tag->tag);- // match on journal:- if ($name === strtolower($this->triggerValue)) {- Log::debug(sprintf('RuleTrigger TagIs for journal #%d: is tagged with "%s", return true.', $journal->id, $name));-- return true;- }- }- Log::debug(sprintf('RuleTrigger TagIs for journal #%d: is not tagged with "%s", return false.', $journal->id, $this->triggerValue));-- return false;- }-}diff --git a/app/TransactionRules/Triggers/ToAccountContains.php b/app/TransactionRules/Triggers/ToAccountContains.phpdeleted file mode 100644index 388c7a4f19..0000000000--- a/app/TransactionRules/Triggers/ToAccountContains.php+++ /dev/null@@ -1,99 +0,0 @@-<?php-/**- * ToAccountContains.php- * Copyright (c) 2019 [email protected]- *- * This file is part of Firefly III (https://github.com/firefly-iii).- *- * This program is free software: you can redistribute it and/or modify- * it under the terms of the GNU Affero General Public License as- * published by the Free Software Foundation, either version 3 of the- * License, or (at your option) any later version.- *- * This program is distributed in the hope that it will be useful,- * but WITHOUT ANY WARRANTY; without even the implied warranty of- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- * GNU Affero General Public License for more details.- *- * You should have received a copy of the GNU Affero General Public License- * along with this program. If not, see <https://www.gnu.org/licenses/>.- */-declare(strict_types=1);--namespace FireflyIII\TransactionRules\Triggers;--use FireflyIII\Models\TransactionJournal;-use FireflyIII\Repositories\Journal\JournalRepositoryInterface;-use Log;--/**- * Class ToAccountContains.- * @deprecated- */-final class ToAccountContains extends AbstractTrigger implements TriggerInterface-{- /**- * A trigger is said to "match anything", or match any given transaction,- * when the trigger value is very vague or has no restrictions. Easy examples- * are the "AmountMore"-trigger combined with an amount of 0: any given transaction- * has an amount of more than zero! Other examples are all the "Description"-triggers- * which have hard time handling empty trigger values such as "" or "*" (wild cards).- *- * If the user tries to create such a trigger, this method MUST return true so Firefly III- * can stop the storing / updating the trigger. If the trigger is in any way restrictive- * (even if it will still include 99.9% of the users transactions), this method MUST return- * false.- *- * @param mixed $value- *- * @return bool- */- public static function willMatchEverything($value = null): bool- {- if (null !== $value) {- $res = '' === (string)$value;- if (true === $res) {- Log::error(sprintf('Cannot use %s with "" as a value.', self::class));- }-- return $res;- }- Log::error(sprintf('Cannot use %s with a null value.', self::class));-- return true;- }-- /**- * Returns true when to-account contains X- * @param TransactionJournal $journal- *- * @return bool- */- public function triggered(TransactionJournal $journal): bool- {- /** @var JournalRepositoryInterface $repository */- $repository = app(JournalRepositoryInterface::class);- $dest = $repository->getDestinationAccount($journal);- $strpos = stripos($dest->name, $this->triggerValue);-- if (!(false === $strpos)) {- Log::debug(- sprintf(- 'RuleTrigger %s for journal #%d: "%s" contains "%s", return true.',- get_class($this), $journal->id, $dest->name, $this->triggerValue- )- );-- return true;- }-- Log::debug(- sprintf(- 'RuleTrigger %s for journal #%d: "%s" does not contain "%s", return false.',- get_class($this), $journal->id, $dest->name, $this->triggerValue- )- );-- return false;- }-}diff --git a/app/TransactionRules/Triggers/ToAccountEnds.php b/app/TransactionRules/Triggers/ToAccountEnds.phpdeleted file mode 100644index 95111bbce1..0000000000--- a/app/TransactionRules/Triggers/ToAccountEnds.php+++ /dev/null@@ -1,116 +0,0 @@-<?php-/**- * ToAccountEnds.php- * Copyright (c) 2019 [email protected]- *- * This file is part of Firefly III (https://github.com/firefly-iii).- *- * This program is free software: you can redistribute it and/or modify- * it under the terms of the GNU Affero General Public License as- * published by the Free Software Foundation, either version 3 of the- * License, or (at your option) any later version.- *- * This program is distributed in the hope that it will be useful,- * but WITHOUT ANY WARRANTY; without even the implied warranty of- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- * GNU Affero General Public License for more details.- *- * You should have received a copy of the GNU Affero General Public License- * along with this program. If not, see <https://www.gnu.org/licenses/>.- */-declare(strict_types=1);--namespace FireflyIII\TransactionRules\Triggers;--use FireflyIII\Models\TransactionJournal;-use FireflyIII\Repositories\Journal\JournalRepositoryInterface;-use Log;--/**- * Class ToAccountEnds.- * @deprecated- */-final class ToAccountEnds extends AbstractTrigger implements TriggerInterface-{- /**- * A trigger is said to "match anything", or match any given transaction,- * when the trigger value is very vague or has no restrictions. Easy examples- * are the "AmountMore"-trigger combined with an amount of 0: any given transaction- * has an amount of more than zero! Other examples are all the "Description"-triggers- * which have hard time handling empty trigger values such as "" or "*" (wild cards).- *- * If the user tries to create such a trigger, this method MUST return true so Firefly III- * can stop the storing / updating the trigger. If the trigger is in any way restrictive- * (even if it will still include 99.9% of the users transactions), this method MUST return- * false.- *- * @param mixed $value- *- * @return bool- */- public static function willMatchEverything($value = null): bool- {- if (null !== $value) {- $res = '' === (string)$value;- if (true === $res) {- Log::error(sprintf('Cannot use %s with "" as a value.', self::class));- }-- return $res;- }- Log::error(sprintf('Cannot use %s with a null value.', self::class));-- return true;- }-- /**- * Returns true when to-account ends with X- *- * @param TransactionJournal $journal- *- * @return bool- */- public function triggered(TransactionJournal $journal): bool- {- /** @var JournalRepositoryInterface $repository */- $repository = app(JournalRepositoryInterface::class);- $dest = $repository->getDestinationAccount($journal);- $nameLength = strlen($dest->name);- $search = $this->triggerValue;- $searchLength = strlen($search);- $part = substr($dest->name, $searchLength * -1);-- // if the string to search for is longer than the account name,- // it will never be in the account name.- if ($searchLength > $nameLength) {- Log::debug(- sprintf(- 'RuleTrigger %s for journal #%d: "%s" does not end with "%s", return false.',- get_class($this), $journal->id, $dest->name, $search- )- );-- return false;- }-- if (strtolower($part) === strtolower($search)) {- Log::debug(- sprintf(- 'RuleTrigger %s for journal #%d: "%s" ends with "%s", return true.',- get_class($this), $journal->id, $dest->name, $search- )- );-- return true;- }-- Log::debug(- sprintf(- 'RuleTrigger %s for journal #%d: "%s" does not end with "%s", return false.',- get_class($this), $journal->id, $dest->name, $search- )- );-- return false;- }-}diff --git a/app/TransactionRules/Triggers/ToAccountIs.php b/app/TransactionRules/Triggers/ToAccountIs.phpdeleted file mode 100644index 086c15d827..0000000000--- a/app/TransactionRules/Triggers/ToAccountIs.php+++ /dev/null@@ -1,93 +0,0 @@-<?php-/**- * ToAccountIs.php- * Copyright (c) 2019 [email protected]- *- * This file is part of Firefly III (https://github.com/firefly-iii).- *- * This program is free software: you can redistribute it and/or modify- * it under the terms of the GNU Affero General Public License as- * published by the Free Software Foundation, either version 3 of the- * License, or (at your option) any later version.- *- * This program is distributed in the hope that it will be useful,- * but WITHOUT ANY WARRANTY; without even the implied warranty of- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- * GNU Affero General Public License for more details.- *- * You should have received a copy of the GNU Affero General Public License- * along with this program. If not, see <https://www.gnu.org/licenses/>.- */-declare(strict_types=1);--namespace FireflyIII\TransactionRules\Triggers;--use FireflyIII\Models\Account;-use FireflyIII\Models\TransactionJournal;-use FireflyIII\Repositories\Journal\JournalRepositoryInterface;-use Log;--/**- * Class ToAccountIs.- * @deprecated- */-final class ToAccountIs extends AbstractTrigger implements TriggerInterface-{- /**- * A trigger is said to "match anything", or match any given transaction,- * when the trigger value is very vague or has no restrictions. Easy examples- * are the "AmountMore"-trigger combined with an amount of 0: any given transaction- * has an amount of more than zero! Other examples are all the "Description"-triggers- * which have hard time handling empty trigger values such as "" or "*" (wild cards).- *- * If the user tries to create such a trigger, this method MUST return true so Firefly III- * can stop the storing / updating the trigger. If the trigger is in any way restrictive- * (even if it will still include 99.9% of the users transactions), this method MUST return- * false.- *- * @param mixed $value- *- * @return bool- */- public static function willMatchEverything($value = null): bool- {- if (null !== $value) {- $res = '' === (string)$value;- if (true === $res) {- Log::error(sprintf('Cannot use %s with "" as a value.', self::class));- }-- return $res;- }- Log::error(sprintf('Cannot use %s with a null value.', self::class));-- return true;- }-- /**- * Returns true when to-account is X.- *- * @param TransactionJournal $journal- *- * @return bool- */- public function triggered(TransactionJournal $journal): bool- {- /** @var JournalRepositoryInterface $repository */- $repository = app(JournalRepositoryInterface::class);- $dest = $repository->getDestinationAccount($journal);- $search = strtolower($this->triggerValue);-- if (strtolower($dest->name) === $search) {- Log::debug(sprintf('RuleTrigger %s for journal #%d: "%s" is "%s", return true.',- get_class($this), $journal->id, $dest->name, $search));-- return true;- }-- Log::debug(sprintf('RuleTrigger %s for journal #%d: "%s" is NOT "%s", return false.',- get_class($this), $journal->id, $dest->name, $search));-- return false;- }-}diff --git a/app/TransactionRules/Triggers/ToAccountNumberContains.php b/app/TransactionRules/Triggers/ToAccountNumberContains.phpdeleted file mode 100644index ef43c78e0a..0000000000--- a/app/TransactionRules/Triggers/ToAccountNumberContains.php+++ /dev/null@@ -1,101 +0,0 @@-<?php-/**- * ToAccountNumberContains.php- * Copyright (c) 2019 [email protected]- *- * This file is part of Firefly III (https://github.com/firefly-iii).- *- * This program is free software: you can redistribute it and/or modify- * it under the terms of the GNU Affero General Public License as- * published by the Free Software Foundation, either version 3 of the- * License, or (at your option) any later version.- *- * This program is distributed in the hope that it will be useful,- * but WITHOUT ANY WARRANTY; without even the implied warranty of- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- * GNU Affero General Public License for more details.- *- * You should have received a copy of the GNU Affero General Public License- * along with this program. If not, see <https://www.gnu.org/licenses/>.- */-declare(strict_types=1);--namespace FireflyIII\TransactionRules\Triggers;--use FireflyIII\Models\TransactionJournal;-use FireflyIII\Repositories\Journal\JournalRepositoryInterface;-use Log;--/**- * Class ToAccountNumberContains.- * @deprecated- */-final class ToAccountNumberContains extends AbstractTrigger implements TriggerInterface-{- /**- * A trigger is said to "match anything", or match any given transaction,- * when the trigger value is very vague or has no restrictions. Easy examples- * are the "AmountMore"-trigger combined with an amount of 0: any given transaction- * has an amount of more than zero! Other examples are all the "Description"-triggers- * which have hard time handling empty trigger values such as "" or "*" (wild cards).- *- * If the user tries to create such a trigger, this method MUST return true so Firefly III- * can stop the storing / updating the trigger. If the trigger is in any way restrictive- * (even if it will still include 99.9% of the users transactions), this method MUST return- * false.- *- * @param mixed $value- *- * @return bool- */- public static function willMatchEverything($value = null): bool- {- if (null !== $value) {- $res = '' === (string)$value;- if (true === $res) {- Log::error(sprintf('Cannot use %s with "" as a value.', self::class));- }-- return $res;- }- Log::error(sprintf('Cannot use %s with a null value.', self::class));-- return true;- }-- /**- * Returns true when from-account contains X- *- * @param TransactionJournal $journal- *- * @return bool- */- public function triggered(TransactionJournal $journal): bool- {- /** @var JournalRepositoryInterface $repository */- $repository = app(JournalRepositoryInterface::class);- $dest = $repository->getDestinationAccount($journal);- $strpos1 = stripos((string)$dest->iban, $this->triggerValue);- $strpos2 = stripos($dest->account_number, $this->triggerValue);-- if (!(false === $strpos1) || !(false === $strpos2)) {- Log::debug(- sprintf(- 'RuleTrigger %s for journal #%d: "%s" or "%s" contains "%s", return true.',- get_class($this), $journal->id, (string)$dest->iban, $dest->account_number, $this->triggerValue- )- );-- return true;- }-- Log::debug(- sprintf(- 'RuleTrigger %s for journal #%d: "%s" and "%s" does not contain "%s", return false.',- get_class($this), $journal->id, (string)$dest->iban, $dest->account_number, $this->triggerValue- )- );-- return false;- }-}diff --git a/app/TransactionRules/Triggers/ToAccountNumberEnds.php b/app/TransactionRules/Triggers/ToAccountNumberEnds.phpdeleted file mode 100644index dc409dbd02..0000000000--- a/app/TransactionRules/Triggers/ToAccountNumberEnds.php+++ /dev/null@@ -1,105 +0,0 @@-<?php-/**- * ToAccountNumberEnds.php- * Copyright (c) 2019 [email protected]- *- * This file is part of Firefly III (https://github.com/firefly-iii).- *- * This program is free software: you can redistribute it and/or modify- * it under the terms of the GNU Affero General Public License as- * published by the Free Software Foundation, either version 3 of the- * License, or (at your option) any later version.- *- * This program is distributed in the hope that it will be useful,- * but WITHOUT ANY WARRANTY; without even the implied warranty of- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- * GNU Affero General Public License for more details.- *- * You should have received a copy of the GNU Affero General Public License- * along with this program. If not, see <https://www.gnu.org/licenses/>.- */-declare(strict_types=1);--namespace FireflyIII\TransactionRules\Triggers;--use FireflyIII\Models\TransactionJournal;-use FireflyIII\Repositories\Journal\JournalRepositoryInterface;-use Log;--/**- * Class ToAccountNumberEnds.- * @deprecated- */-final class ToAccountNumberEnds extends AbstractTrigger implements TriggerInterface-{- /**- * A trigger is said to "match anything", or match any given transaction,- * when the trigger value is very vague or has no restrictions. Easy examples- * are the "AmountMore"-trigger combined with an amount of 0: any given transaction- * has an amount of more than zero! Other examples are all the "Description"-triggers- * which have hard time handling empty trigger values such as "" or "*" (wild cards).- *- * If the user tries to create such a trigger, this method MUST return true so Firefly III- * can stop the storing / updating the trigger. If the trigger is in any way restrictive- * (even if it will still include 99.9% of the users transactions), this method MUST return- * false.- *- * @param mixed $value- *- * @return bool- */- public static function willMatchEverything($value = null): bool- {- if (null !== $value) {- $res = '' === (string)$value;- if (true === $res) {- Log::error(sprintf('Cannot use %s with "" as a value.', self::class));- }-- return $res;- }- Log::error(sprintf('Cannot use %s with a null value.', self::class));-- return true;- }-- /**- * Returns true when from account ends with X- *- * @param TransactionJournal $journal- *- * @return bool- */- public function triggered(TransactionJournal $journal): bool- {- /** @var JournalRepositoryInterface $repository */- $repository = app(JournalRepositoryInterface::class);- $dest = $repository->getDestinationAccount($journal);- $search = strtolower($this->triggerValue);- $searchLength = strlen($search);-- $part1 = substr((string)$dest->iban, $searchLength * -1);- $part2 = substr($dest->account_number, $searchLength * -1);-- if (strtolower($part1) === $search- || strtolower($part2) === $search) {- Log::debug(- sprintf(- 'RuleTrigger %s for journal #%d: "%s" or "%s" ends with "%s", return true.',- get_class($this), $journal->id, $part1, $part2, $search- )- );-- return true;- }-- Log::debug(- sprintf(- 'RuleTrigger %s for journal #%d: "%s" and "%s" do not end with "%s", return false.',- get_class($this), $journal->id, $part1, $part2, $search- )- );-- return false;- }-}diff --git a/app/TransactionRules/Triggers/ToAccountNumberIs.php b/app/TransactionRules/Triggers/ToAccountNumberIs.phpdeleted file mode 100644index 9e1a899b07..0000000000--- a/app/TransactionRules/Triggers/ToAccountNumberIs.php+++ /dev/null@@ -1,100 +0,0 @@-<?php-/**- * ToAccountNumberIs.php- * Copyright (c) 2019 [email protected]- *- * This file is part of Firefly III (https://github.com/firefly-iii).- *- * This program is free software: you can redistribute it and/or modify- * it under the terms of the GNU Affero General Public License as- * published by the Free Software Foundation, either version 3 of the- * License, or (at your option) any later version.- *- * This program is distributed in the hope that it will be useful,- * but WITHOUT ANY WARRANTY; without even the implied warranty of- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- * GNU Affero General Public License for more details.- *- * You should have received a copy of the GNU Affero General Public License- * along with this program. If not, see <https://www.gnu.org/licenses/>.- */-declare(strict_types=1);--namespace FireflyIII\TransactionRules\Triggers;--use FireflyIII\Models\TransactionJournal;-use FireflyIII\Repositories\Journal\JournalRepositoryInterface;-use Log;--/**- * Class ToAccountNumberIs.- * @deprecated- */-final class ToAccountNumberIs extends AbstractTrigger implements TriggerInterface-{- /**- * A trigger is said to "match anything", or match any given transaction,- * when the trigger value is very vague or has no restrictions. Easy examples- * are the "AmountMore"-trigger combined with an amount of 0: any given transaction- * has an amount of more than zero! Other examples are all the "Description"-triggers- * which have hard time handling empty trigger values such as "" or "*" (wild cards).- *- * If the user tries to create such a trigger, this method MUST return true so Firefly III- * can stop the storing / updating the trigger. If the trigger is in any way restrictive- * (even if it will still include 99.9% of the users transactions), this method MUST return- * false.- *- * @param mixed $value- *- * @return bool- */- public static function willMatchEverything($value = null): bool- {- if (null !== $value) {- $res = '' === (string)$value;- if (true === $res) {- Log::error(sprintf('Cannot use %s with "" as a value.', self::class));- }-- return $res;- }- Log::error(sprintf('Cannot use %s with a null value.', self::class));-- return true;- }-- /**- * Returns true when from-account is X.- *- * @param TransactionJournal $journal- *- * @return bool- */- public function triggered(TransactionJournal $journal): bool- {- /** @var JournalRepositoryInterface $repository */- $repository = app(JournalRepositoryInterface::class);- $dest = $repository->getDestinationAccount($journal);- $search = strtolower($this->triggerValue);-- if (strtolower((string)$dest->iban) === $search || strtolower($dest->account_number) === $search) {- Log::debug(- sprintf(- 'RuleTrigger %s for journal #%d: "%s" or "%s" is "%s", return true.', $journal->id,- get_class($this), (string)$dest->iban, $dest->account_number, $search- )- );-- return true;- }-- Log::debug(- sprintf(- 'RuleTrigger %s for journal #%d: "%s" and "%s" are NOT "%s", return false.',- get_class($this), $journal->id, (string)$dest->iban, $dest->account_number, $search- )- );-- return false;- }-}diff --git a/app/TransactionRules/Triggers/ToAccountNumberStarts.php b/app/TransactionRules/Triggers/ToAccountNumberStarts.phpdeleted file mode 100644index f021d6b906..0000000000--- a/app/TransactionRules/Triggers/ToAccountNumberStarts.php+++ /dev/null@@ -1,102 +0,0 @@-<?php-/**- * ToAccountNumberStarts.php- * Copyright (c) 2019 [email protected]- *- * This file is part of Firefly III (https://github.com/firefly-iii).- *- * This program is free software: you can redistribute it and/or modify- * it under the terms of the GNU Affero General Public License as- * published by the Free Software Foundation, either version 3 of the- * License, or (at your option) any later version.- *- * This program is distributed in the hope that it will be useful,- * but WITHOUT ANY WARRANTY; without even the implied warranty of- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- * GNU Affero General Public License for more details.- *- * You should have received a copy of the GNU Affero General Public License- * along with this program. If not, see <https://www.gnu.org/licenses/>.- */-declare(strict_types=1);--namespace FireflyIII\TransactionRules\Triggers;--use FireflyIII\Models\TransactionJournal;-use FireflyIII\Repositories\Journal\JournalRepositoryInterface;-use Log;--/**- * Class FromAccountNumberStarts.- * @deprecated- */-final class ToAccountNumberStarts extends AbstractTrigger implements TriggerInterface-{- /**- * A trigger is said to "match anything", or match any given transaction,- * when the trigger value is very vague or has no restrictions. Easy examples- * are the "AmountMore"-trigger combined with an amount of 0: any given transaction- * has an amount of more than zero! Other examples are all the "Description"-triggers- * which have hard time handling empty trigger values such as "" or "*" (wild cards).- *- * If the user tries to create such a trigger, this method MUST return true so Firefly III- * can stop the storing / updating the trigger. If the trigger is in any way restrictive- * (even if it will still include 99.9% of the users transactions), this method MUST return- * false.- *- * @param mixed $value- *- * @return bool- */- public static function willMatchEverything($value = null): bool- {- if (null !== $value) {- $res = '' === (string)$value;- if (true === $res) {- Log::error(sprintf('Cannot use %s with "" as a value.', self::class));- }-- return $res;- }- Log::error(sprintf('Cannot use %s with a null value.', self::class));-- return true;- }-- /**- * Returns true when from-account starts with X.- *- * @param TransactionJournal $journal- *- * @return bool- */- public function triggered(TransactionJournal $journal): bool- {- /** @var JournalRepositoryInterface $repository */- $repository = app(JournalRepositoryInterface::class);- $dest = $repository->getDestinationAccount($journal);- $search = strtolower($this->triggerValue);- $part1 = strtolower(substr((string)$dest->iban, 0, strlen($search)));- $part2 = strtolower(substr($dest->account_number, 0, strlen($search)));-- if ($part1 === $search || $part2 === $search) {- Log::debug(- sprintf(- 'RuleTrigger %s for journal #%d: "%s" or "%s" starts with "%s", return true.',- get_class($this), $journal->id, $part1, $part2, $search- )- );-- return true;- }-- Log::debug(- sprintf(- 'RuleTrigger %s for journal #%d: "%s" and "%s" do not start with "%s", return false.',- get_class($this), $journal->id, $part1, $part2, $search- )- );-- return false;- }-}diff --git a/app/TransactionRules/Triggers/ToAccountStarts.php b/app/TransactionRules/Triggers/ToAccountStarts.phpdeleted file mode 100644index 031eac2460..0000000000--- a/app/TransactionRules/Triggers/ToAccountStarts.php+++ /dev/null@@ -1,102 +0,0 @@-<?php-/**- * ToAccountStarts.php- * Copyright (c) 2019 [email protected]- *- * This file is part of Firefly III (https://github.com/firefly-iii).- *- * This program is free software: you can redistribute it and/or modify- * it under the terms of the GNU Affero General Public License as- * published by the Free Software Foundation, either version 3 of the- * License, or (at your option) any later version.- *- * This program is distributed in the hope that it will be useful,- * but WITHOUT ANY WARRANTY; without even the implied warranty of- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- * GNU Affero General Public License for more details.- *- * You should have received a copy of the GNU Affero General Public License- * along with this program. If not, see <https://www.gnu.org/licenses/>.- */-declare(strict_types=1);--namespace FireflyIII\TransactionRules\Triggers;--use FireflyIII\Models\Account;-use FireflyIII\Models\TransactionJournal;-use FireflyIII\Repositories\Journal\JournalRepositoryInterface;-use Log;--/**- * Class ToAccountStarts.- * @deprecated- */-final class ToAccountStarts extends AbstractTrigger implements TriggerInterface-{- /**- * A trigger is said to "match anything", or match any given transaction,- * when the trigger value is very vague or has no restrictions. Easy examples- * are the "AmountMore"-trigger combined with an amount of 0: any given transaction- * has an amount of more than zero! Other examples are all the "Description"-triggers- * which have hard time handling empty trigger values such as "" or "*" (wild cards).- *- * If the user tries to create such a trigger, this method MUST return true so Firefly III- * can stop the storing / updating the trigger. If the trigger is in any way restrictive- * (even if it will still include 99.9% of the users transactions), this method MUST return- * false.- *- * @param mixed $value- *- * @return bool- */- public static function willMatchEverything($value = null): bool- {- if (null !== $value) {- $res = '' === (string)$value;- if (true === $res) {- Log::error(sprintf('Cannot use %s with "" as a value.', self::class));- }-- return $res;- }- Log::error(sprintf('Cannot use %s with a null value.', self::class));-- return true;- }-- /**- * Returns true when to-account starts with X- *- * @param TransactionJournal $journal- *- * @return bool- */- public function triggered(TransactionJournal $journal): bool- {- /** @var JournalRepositoryInterface $repository */- $repository = app(JournalRepositoryInterface::class);- $dest = $repository->getDestinationAccount($journal);- $search = strtolower($this->triggerValue);- $part = strtolower(substr($dest->name, 0, strlen($search)));-- if ($part === $search) {- Log::debug(- sprintf(- 'RuleTrigger %s for journal #%d: "%s" starts with "%s", return true.',- get_class($this), $journal->id, $dest->name, $search- )- );-- return true;- }-- Log::debug(- sprintf(- 'RuleTrigger %s for journal #%d: "%s" does not start with "%s", return false.',- get_class($this), $journal->id, $dest->name, $search- )- );-- return false;- }-}diff --git a/app/TransactionRules/Triggers/TransactionType.php b/app/TransactionRules/Triggers/TransactionType.phpdeleted file mode 100644index bc83a5d290..0000000000--- a/app/TransactionRules/Triggers/TransactionType.php+++ /dev/null@@ -1,82 +0,0 @@-<?php-/**- * TransactionType.php- * Copyright (c) 2019 [email protected]- *- * This file is part of Firefly III (https://github.com/firefly-iii).- *- * This program is free software: you can redistribute it and/or modify- * it under the terms of the GNU Affero General Public License as- * published by the Free Software Foundation, either version 3 of the- * License, or (at your option) any later version.- *- * This program is distributed in the hope that it will be useful,- * but WITHOUT ANY WARRANTY; without even the implied warranty of- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- * GNU Affero General Public License for more details.- *- * You should have received a copy of the GNU Affero General Public License- * along with this program. If not, see <https://www.gnu.org/licenses/>.- */-declare(strict_types=1);--namespace FireflyIII\TransactionRules\Triggers;--use FireflyIII\Models\TransactionJournal;-use Log;--/**- * Class TransactionType.- * @deprecated- */-final class TransactionType extends AbstractTrigger implements TriggerInterface-{- /**- * A trigger is said to "match anything", or match any given transaction,- * when the trigger value is very vague or has no restrictions. Easy examples- * are the "AmountMore"-trigger combined with an amount of 0: any given transaction- * has an amount of more than zero! Other examples are all the "Description"-triggers- * which have hard time handling empty trigger values such as "" or "*" (wild cards).- *- * If the user tries to create such a trigger, this method MUST return true so Firefly III- * can stop the storing / updating the trigger. If the trigger is in any way restrictive- * (even if it will still include 99.9% of the users transactions), this method MUST return- * false.- *- * @param mixed $value- *- * @return bool- */- public static function willMatchEverything($value = null): bool- {- if (null !== $value) {- return false;- }- Log::error(sprintf('Cannot use %s with a null value.', self::class));-- return true;- }-- /**- * Return true when transaction type is X- *- * @param TransactionJournal $journal- *- * @return bool- */- public function triggered(TransactionJournal $journal): bool- {- $type = $journal->transaction_type_type ?? strtolower($journal->transactionType->type);- $search = strtolower($this->triggerValue);-- if ($type === $search) {- Log::debug(sprintf('RuleTrigger TransactionType for journal #%d: "%s" is "%s". Return true', $journal->id, $type, $search));-- return true;- }-- Log::debug(sprintf('RuleTrigger TransactionType for journal #%d: "%s" is NOT "%s". Return false', $journal->id, $type, $search));-- return false;- }-}diff --git a/app/TransactionRules/Triggers/TriggerInterface.php b/app/TransactionRules/Triggers/TriggerInterface.phpdeleted file mode 100644index 629e19cead..0000000000--- a/app/TransactionRules/Triggers/TriggerInterface.php+++ /dev/null@@ -1,59 +0,0 @@-<?php-/**- * TriggerInterface.php- * Copyright (c) 2019 [email protected]- *- * This file is part of Firefly III (https://github.com/firefly-iii).- *- * This program is free software: you can redistribute it and/or modify- * it under the terms of the GNU Affero General Public License as- * published by the Free Software Foundation, either version 3 of the- * License, or (at your option) any later version.- *- * This program is distributed in the hope that it will be useful,- * but WITHOUT ANY WARRANTY; without even the implied warranty of- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- * GNU Affero General Public License for more details.- *- * You should have received a copy of the GNU Affero General Public License- * along with this program. If not, see <https://www.gnu.org/licenses/>.- */-declare(strict_types=1);--namespace FireflyIII\TransactionRules\Triggers;--use FireflyIII\Models\TransactionJournal;--/**- * Interface TriggerInterface.- * @deprecated- */-interface TriggerInterface-{- /**- * A trigger is said to "match anything", or match any given transaction,- * when the trigger value is very vague or has no restrictions. Easy examples- * are the "AmountMore"-trigger combined with an amount of 0: any given transaction- * has an amount of more than zero! Other examples are all the "Description"-triggers- * which have hard time handling empty trigger values such as "" or "*" (wild cards).- *- * If the user tries to create such a trigger, this method MUST return true so Firefly III- * can stop the storing / updating the trigger. If the trigger is in any way restrictive- * (even if it will still include 99.9% of the users transactions), this method MUST return- * false.- *- * @param mixed $value- *- * @return bool- */- public static function willMatchEverything($value = null): bool;-- /**- * Triggers on a value and journal.- *- * @param TransactionJournal $journal- *- * @return bool- */- public function triggered(TransactionJournal $journal): bool;-}diff --git a/app/TransactionRules/Triggers/UserAction.php b/app/TransactionRules/Triggers/UserAction.phpdeleted file mode 100644index 96f5c0d1a1..0000000000--- a/app/TransactionRules/Triggers/UserAction.php+++ /dev/null@@ -1,72 +0,0 @@-<?php-/**- * UserAction.php- * Copyright (c) 2019 [email protected]- *- * This file is part of Firefly III (https://github.com/firefly-iii).- *- * This program is free software: you can redistribute it and/or modify- * it under the terms of the GNU Affero General Public License as- * published by the Free Software Foundation, either version 3 of the- * License, or (at your option) any later version.- *- * This program is distributed in the hope that it will be useful,- * but WITHOUT ANY WARRANTY; without even the implied warranty of- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- * GNU Affero General Public License for more details.- *- * You should have received a copy of the GNU Affero General Public License- * along with this program. If not, see <https://www.gnu.org/licenses/>.- */-declare(strict_types=1);--namespace FireflyIII\TransactionRules\Triggers;--use FireflyIII\Models\TransactionJournal;-use Log;--/**- * Class UserAction.- * @deprecated- */-final class UserAction extends AbstractTrigger implements TriggerInterface-{- /**- * A trigger is said to "match anything", or match any given transaction,- * when the trigger value is very vague or has no restrictions. Easy examples- * are the "AmountMore"-trigger combined with an amount of 0: any given transaction- * has an amount of more than zero! Other examples are all the "Description"-triggers- * which have hard time handling empty trigger values such as "" or "*" (wild cards).- *- * If the user tries to create such a trigger, this method MUST return true so Firefly III- * can stop the storing / updating the trigger. If the trigger is in any way restrictive- * (even if it will still include 99.9% of the users transactions), this method MUST return- * false.- *- * @param mixed $value- *- * @codeCoverageIgnore- *- * @return bool- */- public static function willMatchEverything($value = null): bool- {- return true;- }-- /**- * This trigger is always triggered, because the rule that it is a part of has been pre-selected on this condition.- *- * @param TransactionJournal $journal- *- * @codeCoverageIgnore- *- * @return bool- */- public function triggered(TransactionJournal $journal): bool- {- Log::debug(sprintf('RuleTrigger UserAction for journal %d always triggers.', $journal->id));-- return true;- }-}