. */ declare(strict_types=1); namespace FireflyIII\Handlers\Events; use FireflyIII\Events\UpdatedTransactionGroup; use FireflyIII\Exceptions\FireflyException; use FireflyIII\Models\TransactionJournal; use FireflyIII\TransactionRules\Engine\RuleEngine; /** * Class UpdatedGroupEventHandler */ class UpdatedGroupEventHandler { /** * This method will check all the rules when a journal is updated. * * @param UpdatedTransactionGroup $updatedJournalEvent */ public function processRules(UpdatedTransactionGroup $updatedJournalEvent): void { /** @var RuleEngine $ruleEngine */ $ruleEngine = app(RuleEngine::class); $ruleEngine->setUser($updatedJournalEvent->transactionGroup->user); $ruleEngine->setAllRules(true); $ruleEngine->setTriggerMode(RuleEngine::TRIGGER_UPDATE); $journals = $updatedJournalEvent->transactionGroup->transactionJournals; /** @var TransactionJournal $journal */ foreach ($journals as $journal) { $ruleEngine->processTransactionJournal($journal); } } }