Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Updated events, fixes #345
James Cole7ce3b8d4efbe
diff --git a/app/Events/UserIsDeleted.php b/app/Events/ConfirmedUser.phpsimilarity index 90%rename from app/Events/UserIsDeleted.phprename to app/Events/ConfirmedUser.phpindex 4312cc0178..c932675ec5 100644--- a/app/Events/UserIsDeleted.php+++ b/app/Events/ConfirmedUser.php@@ -1,6 +1,6 @@<?php/**- * UserIsDeleted.php+ * ConfirmedUser.php* Copyright (C) 2016 [email protected]** This software may be modified and distributed under the terms of the@@ -17,11 +17,11 @@ use FireflyIII\User;use Illuminate\Queue\SerializesModels;/**- * Class UserIsDeleted+ * Class ConfirmedUser** @package FireflyIII\Events*/-class UserIsDeleted extends Event+class ConfirmedUser extends Event{use SerializesModels;diff --git a/app/Events/UserIsConfirmed.php b/app/Events/RegisteredUser.phpsimilarity index 89%rename from app/Events/UserIsConfirmed.phprename to app/Events/RegisteredUser.phpindex 0da2da63b4..1f607a8ad7 100644--- a/app/Events/UserIsConfirmed.php+++ b/app/Events/RegisteredUser.php@@ -1,6 +1,6 @@<?php/**- * UserIsConfirmed.php+ * RegisteredUser.php* Copyright (C) 2016 [email protected]** This software may be modified and distributed under the terms of the@@ -17,11 +17,11 @@ use FireflyIII\User;use Illuminate\Queue\SerializesModels;/**- * Class UserIsConfirmed+ * Class RegisteredUser** @package FireflyIII\Events*/-class UserIsConfirmed extends Event+class RegisteredUser extends Event{use SerializesModels;diff --git a/app/Events/ResendConfirmation.php b/app/Events/ResendConfirmation.phpdeleted file mode 100644index cb14ea8b75..0000000000--- a/app/Events/ResendConfirmation.php+++ /dev/null@@ -1,42 +0,0 @@-<?php-/**- * ResendConfirmation.php- * Copyright (C) 2016 [email protected]- *- * This software may be modified and distributed under the terms of the- * Creative Commons Attribution-ShareAlike 4.0 International License.- *- * See the LICENSE file for details.- */--declare(strict_types = 1);--namespace FireflyIII\Events;--use FireflyIII\User;-use Illuminate\Queue\SerializesModels;--/**- * Class ResendConfirmation- *- * @package FireflyIII\Events- */-class ResendConfirmation extends Event-{- use SerializesModels;-- public $ipAddress;- public $user;-- /**- * Create a new event instance.- *- * @param User $user- * @param string $ipAddress- */- public function __construct(User $user, string $ipAddress)- {- $this->user = $user;- $this->ipAddress = $ipAddress;- }-}diff --git a/app/Events/UserRegistration.php b/app/Events/ResentConfirmation.phpsimilarity index 88%rename from app/Events/UserRegistration.phprename to app/Events/ResentConfirmation.phpindex 0af1bc833e..74a6f92c1b 100644--- a/app/Events/UserRegistration.php+++ b/app/Events/ResentConfirmation.php@@ -1,6 +1,6 @@<?php/**- * UserRegistration.php+ * ResentConfirmation.php* Copyright (C) 2016 [email protected]** This software may be modified and distributed under the terms of the@@ -17,11 +17,11 @@ use FireflyIII\User;use Illuminate\Queue\SerializesModels;/**- * Class UserRegistration+ * Class ResentConfirmation** @package FireflyIII\Events*/-class UserRegistration extends Event+class ResentConfirmation extends Event{use SerializesModels;diff --git a/app/Events/BudgetLimitStored.php b/app/Events/StoredBudgetLimit.phpsimilarity index 91%rename from app/Events/BudgetLimitStored.phprename to app/Events/StoredBudgetLimit.phpindex 3a60ceabd6..65b7be0008 100644--- a/app/Events/BudgetLimitStored.php+++ b/app/Events/StoredBudgetLimit.php@@ -1,6 +1,6 @@<?php/**- * BudgetLimitStored.php+ * StoredBudgetLimit.php* Copyright (C) 2016 [email protected]** This software may be modified and distributed under the terms of the@@ -18,11 +18,11 @@ use FireflyIII\Models\BudgetLimit;use Illuminate\Queue\SerializesModels;/**- * Class BudgetLimitStored+ * Class StoredBudgetLimit** @package FireflyIII\Events*/-class BudgetLimitStored extends Event+class StoredBudgetLimit extends Event{use SerializesModels;diff --git a/app/Events/TransactionJournalStored.php b/app/Events/StoredTransactionJournal.phpsimilarity index 88%rename from app/Events/TransactionJournalStored.phprename to app/Events/StoredTransactionJournal.phpindex 6269425485..1bc73c5f7a 100644--- a/app/Events/TransactionJournalStored.php+++ b/app/Events/StoredTransactionJournal.php@@ -1,6 +1,6 @@<?php/**- * TransactionJournalStored.php+ * StoredTransactionJournal.php* Copyright (C) 2016 [email protected]** This software may be modified and distributed under the terms of the@@ -17,11 +17,11 @@ use FireflyIII\Models\TransactionJournal;use Illuminate\Queue\SerializesModels;/**- * Class TransactionJournalStored+ * Class StoredTransactionJournal** @package FireflyIII\Events*/-class TransactionJournalStored extends Event+class StoredTransactionJournal extends Event{use SerializesModels;diff --git a/app/Events/TransactionStored.php b/app/Events/TransactionStored.phpdeleted file mode 100644index 1233ff43fd..0000000000--- a/app/Events/TransactionStored.php+++ /dev/null@@ -1,41 +0,0 @@-<?php-/**- * TransactionStored.php- * Copyright (C) 2016 [email protected]- *- * This software may be modified and distributed under the terms of the- * Creative Commons Attribution-ShareAlike 4.0 International License.- *- * See the LICENSE file for details.- */--declare(strict_types = 1);--namespace FireflyIII\Events;--use Illuminate\Queue\SerializesModels;--/**- * Class TransactionJournalStored- *- * @package FireflyIII\Events- */-class TransactionStored extends Event-{-- use SerializesModels;-- public $transaction = [];-- /**- * Create a new event instance.- *- * @param array $transaction- */- public function __construct(array $transaction)- {- //- $this->transaction = $transaction;- }--}diff --git a/app/Events/BudgetLimitUpdated.php b/app/Events/UpdatedBudgetLimit.phpsimilarity index 91%rename from app/Events/BudgetLimitUpdated.phprename to app/Events/UpdatedBudgetLimit.phpindex 596c59c8b2..3642531e75 100644--- a/app/Events/BudgetLimitUpdated.php+++ b/app/Events/UpdatedBudgetLimit.php@@ -1,6 +1,6 @@<?php/**- * BudgetLimitUpdated.php+ * UpdatedBudgetLimit.php* Copyright (C) 2016 [email protected]** This software may be modified and distributed under the terms of the@@ -18,11 +18,11 @@ use FireflyIII\Models\BudgetLimit;use Illuminate\Queue\SerializesModels;/**- * Class BudgetLimitUpdated+ * Class UpdatedBudgetLimit** @package FireflyIII\Events*/-class BudgetLimitUpdated extends Event+class UpdatedBudgetLimit extends Event{use SerializesModels;diff --git a/app/Events/TransactionJournalUpdated.php b/app/Events/UpdatedTransactionJournal.phpsimilarity index 86%rename from app/Events/TransactionJournalUpdated.phprename to app/Events/UpdatedTransactionJournal.phpindex 862fcef4db..985aa44fd7 100644--- a/app/Events/TransactionJournalUpdated.php+++ b/app/Events/UpdatedTransactionJournal.php@@ -1,6 +1,6 @@<?php/**- * TransactionJournalUpdated.php+ * UpdatedTransactionJournal.php* Copyright (C) 2016 [email protected]** This software may be modified and distributed under the terms of the@@ -17,11 +17,11 @@ use FireflyIII\Models\TransactionJournal;use Illuminate\Queue\SerializesModels;/**- * Class TransactionJournalUpdated+ * Class UpdatedTransactionJournal** @package FireflyIII\Events*/-class TransactionJournalUpdated extends Event+class UpdatedTransactionJournal extends Event{use SerializesModels;diff --git a/app/Handlers/Events/AttachUserRole.php b/app/Handlers/Events/AttachUserRole.phpdeleted file mode 100644index 15855e3391..0000000000--- a/app/Handlers/Events/AttachUserRole.php+++ /dev/null@@ -1,52 +0,0 @@-<?php-/**- * AttachUserRole.php- * Copyright (C) 2016 [email protected]- *- * This software may be modified and distributed under the terms of the- * Creative Commons Attribution-ShareAlike 4.0 International License.- *- * See the LICENSE file for details.- */--declare(strict_types = 1);--namespace FireflyIII\Handlers\Events;---use FireflyIII\Events\UserRegistration;-use FireflyIII\Repositories\User\UserRepositoryInterface;--/**- * Class AttachUserRole- *- * @package FireflyIII\Handlers\Events- */-class AttachUserRole-{- /**- * Create the event listener.- *- */- public function __construct()- {- //- }-- /**- * Handle the event.- *- * @param UserRegistration $event- */- public function handle(UserRegistration $event)- {- /** @var UserRepositoryInterface $repository */- $repository = app(UserRepositoryInterface::class);-- // first user ever?- if ($repository->count() == 1) {- $repository->attachRole($event->user, 'owner');- }- }--}diff --git a/app/Handlers/Events/BudgetLimitEventHandler.php b/app/Handlers/Events/BudgetEventHandler.phpsimilarity index 79%rename from app/Handlers/Events/BudgetLimitEventHandler.phprename to app/Handlers/Events/BudgetEventHandler.phpindex a05a752cd2..cd02a373ef 100644--- a/app/Handlers/Events/BudgetLimitEventHandler.php+++ b/app/Handlers/Events/BudgetEventHandler.php@@ -1,6 +1,6 @@<?php/**- * BudgetLimitEventHandler.php+ * BudgetEventHandler.php* Copyright (C) 2016 [email protected]** This software may be modified and distributed under the terms of the@@ -13,36 +13,30 @@ declare(strict_types = 1);namespace FireflyIII\Handlers\Events;-use FireflyIII\Events\BudgetLimitStored;-use FireflyIII\Events\BudgetLimitUpdated;++use FireflyIII\Events\StoredBudgetLimit;+use FireflyIII\Events\UpdatedBudgetLimit;use FireflyIII\Models\LimitRepetition;use Illuminate\Database\QueryException;use Log;/**- * Class BudgetLimitEventHandler+ * Handles budget related events.+ *+ * Class BudgetEventHandler** @package FireflyIII\Handlers\Events*/-class BudgetLimitEventHandler+class BudgetEventHandler{/**- * Create the event listener.+ * This method creates a new budget limit repetition when a new budget limit has been created.*- */- public function __construct()- {-- }-- /**- * In a perfect world, the store() routine should be different from the update()- * routine. It would not have to check count() == 0 because there could be NO- * limit repetitions at this point. However, the database can be wrong so we check.+ * @param StoredBudgetLimit $event*- * @param BudgetLimitStored $event+ * @return bool*/- public function store(BudgetLimitStored $event)+ public function storeRepetition(StoredBudgetLimit $event):bool{$budgetLimit = $event->budgetLimit;$end = $event->end;@@ -71,12 +65,18 @@ class BudgetLimitEventHandler}+ return true;}+/**- * @param BudgetLimitUpdated $event+ * Updates, if present the budget limit repetition part of a budget limit.+ *+ * @param UpdatedBudgetLimit $event+ *+ * @return bool*/- public function update(BudgetLimitUpdated $event)+ public function update(UpdatedBudgetLimit $event): bool{$budgetLimit = $event->budgetLimit;$end = $event->end;@@ -104,6 +104,7 @@ class BudgetLimitEventHandler$repetition->save();}- }-}+ return true;+ }+}\ No newline at end of filediff --git a/app/Handlers/Events/ConnectJournalToPiggyBank.php b/app/Handlers/Events/ConnectJournalToPiggyBank.phpdeleted file mode 100644index 1d7d75d28c..0000000000--- a/app/Handlers/Events/ConnectJournalToPiggyBank.php+++ /dev/null@@ -1,72 +0,0 @@-<?php-/**- * ConnectJournalToPiggyBank.php- * Copyright (C) 2016 [email protected]- *- * This software may be modified and distributed under the terms of the- * Creative Commons Attribution-ShareAlike 4.0 International License.- *- * See the LICENSE file for details.- */--declare(strict_types = 1);--namespace FireflyIII\Handlers\Events;--use FireflyIII\Events\TransactionJournalStored;-use FireflyIII\Models\PiggyBank;-use FireflyIII\Models\PiggyBankEvent;-use FireflyIII\Models\TransactionJournal;--/**- * Class ConnectJournalToPiggyBank- *- * @package FireflyIII\Handlers\Events- */-class ConnectJournalToPiggyBank-{-- /**- * Connect a new transaction journal to any related piggy banks.- *- * @param TransactionJournalStored $event- *- * @return bool- */- public function handle(TransactionJournalStored $event): bool- {- /** @var TransactionJournal $journal */- $journal = $event->journal;- $piggyBankId = $event->piggyBankId;-- /** @var PiggyBank $piggyBank */- $piggyBank = auth()->user()->piggyBanks()->where('piggy_banks.id', $piggyBankId)->first(['piggy_banks.*']);-- if (is_null($piggyBank)) {- return true;- }- // update piggy bank rep for date of transaction journal.- $repetition = $piggyBank->piggyBankRepetitions()->relevantOnDate($journal->date)->first();- if (is_null($repetition)) {- return true;- }-- $amount = TransactionJournal::amountPositive($journal);- // if piggy account matches source account, the amount is positive- $sources = TransactionJournal::sourceAccountList($journal)->pluck('id')->toArray();- if (in_array($piggyBank->account_id, $sources)) {- $amount = bcmul($amount, '-1');- }--- $repetition->currentamount = bcadd($repetition->currentamount, $amount);- $repetition->save();-- PiggyBankEvent::create(['piggy_bank_id' => $piggyBank->id, 'transaction_journal_id' => $journal->id, 'date' => $journal->date, 'amount' => $amount]);-- return true;-- }---}diff --git a/app/Handlers/Events/ConnectTransactionToPiggyBank.php b/app/Handlers/Events/ConnectTransactionToPiggyBank.phpdeleted file mode 100644index 8e56987a0d..0000000000--- a/app/Handlers/Events/ConnectTransactionToPiggyBank.php+++ /dev/null@@ -1,70 +0,0 @@-<?php-/**- * ConnectTransactionToPiggyBank.php- * Copyright (C) 2016 [email protected]- *- * This software may be modified and distributed under the terms of the- * Creative Commons Attribution-ShareAlike 4.0 International License.- *- * See the LICENSE file for details.- */--declare(strict_types = 1);--namespace FireflyIII\Handlers\Events;--use FireflyIII\Events\TransactionStored;-use FireflyIII\Models\PiggyBankEvent;-use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface;--/**- * Class ConnectTransactionToPiggyBank- *- * @package FireflyIII\Handlers\Events- */-class ConnectTransactionToPiggyBank-{-- /**- * Connect a new transaction journal to any related piggy banks.- *- * @param TransactionStored $event- *- * @return bool- */- public function handle(TransactionStored $event): bool- {-- /** @var PiggyBankRepositoryInterface $repository */- $repository = app(PiggyBankRepositoryInterface::class);- $transaction = $event->transaction;-- $piggyBank = $repository->find($transaction['piggy_bank_id']);-- // valid piggy:- if (is_null($piggyBank->id)) {- return true;- }- $amount = strval($transaction['amount']);- // piggy bank account something with amount:- if ($transaction['source_account_id'] == $piggyBank->account_id) {- // if the source of this transaction is the same as the piggy bank,- // the money is being removed from the piggy bank. So the- // amount must be negative:- $amount = bcmul($amount, '-1');- }-- $repetition = $piggyBank->currentRelevantRep();- // add or remove the money from the piggy bank:- $newAmount = bcadd(strval($repetition->currentamount), $amount);- $repetition->currentamount = $newAmount;- $repetition->save();-- // now generate a piggy bank event:- PiggyBankEvent::create(['piggy_bank_id' => $piggyBank->id, 'date' => $transaction['date'], 'amount' => $newAmount]);-- return true;- }---}diff --git a/app/Handlers/Events/FireRulesForStore.php b/app/Handlers/Events/FireRulesForStore.phpdeleted file mode 100644index 65cc16d67a..0000000000--- a/app/Handlers/Events/FireRulesForStore.php+++ /dev/null@@ -1,68 +0,0 @@-<?php-/**- * FireRulesForStore.php- * Copyright (C) 2016 [email protected]- *- * This software may be modified and distributed under the terms of the- * Creative Commons Attribution-ShareAlike 4.0 International License.- *- * See the LICENSE file for details.- */--declare(strict_types = 1);--namespace FireflyIII\Handlers\Events;---use FireflyIII\Events\TransactionJournalStored;-use FireflyIII\Models\Rule;-use FireflyIII\Models\RuleGroup;-use FireflyIII\Rules\Processor;-use FireflyIII\User;--/**- * Class FireRulesForStore- *- * @package FireflyIII\Handlers\Events- */-class FireRulesForStore-{-- /**- * Connect a new transaction journal to any related piggy banks.- *- * @param TransactionJournalStored $event- *- * @return bool- */- public function handle(TransactionJournalStored $event): bool- {- // get all the user's rule groups, with the rules, order by 'order'.- /** @var User $user */- $user = auth()->user();- $groups = $user->ruleGroups()->where('rule_groups.active', 1)->orderBy('order', 'ASC')->get();- //- /** @var RuleGroup $group */- foreach ($groups as $group) {- $rules = $group->rules()- ->leftJoin('rule_triggers', 'rules.id', '=', 'rule_triggers.rule_id')- ->where('rule_triggers.trigger_type', 'user_action')- ->where('rule_triggers.trigger_value', 'store-journal')- ->where('rules.active', 1)- ->get(['rules.*']);- /** @var Rule $rule */- foreach ($rules as $rule) {-- $processor = Processor::make($rule);- $processor->handleTransactionJournal($event->journal);-- if ($rule->stop_processing) {- return true;- }-- }- }-- return true;- }-}diff --git a/app/Handlers/Events/FireRulesForUpdate.php b/app/Handlers/Events/FireRulesForUpdate.phpdeleted file mode 100644index 889d1e3156..0000000000--- a/app/Handlers/Events/FireRulesForUpdate.php+++ /dev/null@@ -1,65 +0,0 @@-<?php-/**- * FireRulesForUpdate.php- * Copyright (C) 2016 [email protected]- *- * This software may be modified and distributed under the terms of the- * Creative Commons Attribution-ShareAlike 4.0 International License.- *- * See the LICENSE file for details.- */--declare(strict_types = 1);--namespace FireflyIII\Handlers\Events;--use FireflyIII\Events\TransactionJournalUpdated;-use FireflyIII\Models\Rule;-use FireflyIII\Models\RuleGroup;-use FireflyIII\Rules\Processor;-use FireflyIII\User;--/**- * Class FireRulesForUpdate- *- * @package FireflyIII\Handlers\Events- */-class FireRulesForUpdate-{- /**- * Handle the event.- *- * @param TransactionJournalUpdated $event- *- * @return bool- */- public function handle(TransactionJournalUpdated $event): bool- {- // get all the user's rule groups, with the rules, order by 'order'.- /** @var User $user */- $user = auth()->user();- $groups = $user->ruleGroups()->where('rule_groups.active', 1)->orderBy('order', 'ASC')->get();- //- /** @var RuleGroup $group */- foreach ($groups as $group) {- $rules = $group->rules()- ->leftJoin('rule_triggers', 'rules.id', '=', 'rule_triggers.rule_id')- ->where('rule_triggers.trigger_type', 'user_action')- ->where('rule_triggers.trigger_value', 'update-journal')- ->where('rules.active', 1)- ->get(['rules.*']);- /** @var Rule $rule */- foreach ($rules as $rule) {- $processor = Processor::make($rule);- $processor->handleTransactionJournal($event->journal);-- if ($rule->stop_processing) {- break;- }-- }- }-- return true;- }-}diff --git a/app/Handlers/Events/ScanForBillsAfterStore.php b/app/Handlers/Events/ScanForBillsAfterStore.phpdeleted file mode 100644index 499370eab9..0000000000--- a/app/Handlers/Events/ScanForBillsAfterStore.php+++ /dev/null@@ -1,42 +0,0 @@-<?php-/**- * ScanForBillsAfterStore.php- * Copyright (C) 2016 [email protected]- *- * This software may be modified and distributed under the terms of the- * Creative Commons Attribution-ShareAlike 4.0 International License.- *- * See the LICENSE file for details.- */--declare(strict_types = 1);--namespace FireflyIII\Handlers\Events;--use FireflyIII\Events\TransactionJournalStored;-use FireflyIII\Support\Events\BillScanner;--/**- * Class RescanJournal- *- * @package FireflyIII\Handlers\Events- */-class ScanForBillsAfterStore-{-- /**- * Scan a transaction journal for possible links to bills, right after storing.- *- * @param TransactionJournalStored $event- *- * @return bool- */- public function handle(TransactionJournalStored $event): bool- {- $journal = $event->journal;- BillScanner::scan($journal);-- return true;- }--}diff --git a/app/Handlers/Events/ScanForBillsAfterUpdate.php b/app/Handlers/Events/ScanForBillsAfterUpdate.phpdeleted file mode 100644index 11ddfee6aa..0000000000--- a/app/Handlers/Events/ScanForBillsAfterUpdate.php+++ /dev/null@@ -1,41 +0,0 @@-<?php-/**- * ScanForBillsAfterUpdate.php- * Copyright (C) 2016 [email protected]- *- * This software may be modified and distributed under the terms of the- * Creative Commons Attribution-ShareAlike 4.0 International License.- *- * See the LICENSE file for details.- */--declare(strict_types = 1);--namespace FireflyIII\Handlers\Events;--use FireflyIII\Events\TransactionJournalUpdated;-use FireflyIII\Support\Events\BillScanner;--/**- * Class RescanJournal- *- * @package FireflyIII\Handlers\Events- */-class ScanForBillsAfterUpdate-{- /**- * Scan a transaction journal for possibly related bills after it has been updated.- *- * @param TransactionJournalUpdated $event- *- * @return bool- */- public function handle(TransactionJournalUpdated $event): bool- {- $journal = $event->journal;- BillScanner::scan($journal);-- return true;- }--}diff --git a/app/Handlers/Events/SendRegistrationMail.php b/app/Handlers/Events/SendRegistrationMail.phpdeleted file mode 100644index aabb3714af..0000000000--- a/app/Handlers/Events/SendRegistrationMail.php+++ /dev/null@@ -1,69 +0,0 @@-<?php-/**- * SendRegistrationMail.php- * Copyright (C) 2016 [email protected]- *- * This software may be modified and distributed under the terms of the- * Creative Commons Attribution-ShareAlike 4.0 International License.- *- * See the LICENSE file for details.- */--declare(strict_types = 1);--namespace FireflyIII\Handlers\Events;---use FireflyIII\Events\UserRegistration;-use Illuminate\Mail\Message;-use Log;-use Mail;-use Swift_TransportException;--/**- * Class SendRegistrationMail- *- * @package FireflyIII\Handlers\Events- */-class SendRegistrationMail-{- /**- * Create the event listener.- *- */- public function __construct()- {- //- }-- /**- * Handle the event.- *- * @param UserRegistration $event- *- * @return bool- */- public function handle(UserRegistration $event): bool- {- $sendMail = env('SEND_REGISTRATION_MAIL', true);- if (!$sendMail) {- return true;- }- // get the email address- $email = $event->user->email;- $address = route('index');- $ipAddress = $event->ipAddress;- // send email.- try {- Mail::send(- ['emails.registered-html', 'emails.registered'], ['address' => $address, 'ip' => $ipAddress], function (Message $message) use ($email) {- $message->to($email, $email)->subject('Welcome to Firefly III! ');- }- );- } catch (Swift_TransportException $e) {- Log::error($e->getMessage());- }-- return true;- }-}diff --git a/app/Handlers/Events/StoredJournalEventHandler.php b/app/Handlers/Events/StoredJournalEventHandler.phpnew file mode 100644index 0000000000..1410147625--- /dev/null+++ b/app/Handlers/Events/StoredJournalEventHandler.php@@ -0,0 +1,124 @@+<?php+/**+ * StoredJournalEventHandler.php+ * Copyright (C) 2016 [email protected]+ *+ * This software may be modified and distributed under the terms of the+ * Creative Commons Attribution-ShareAlike 4.0 International License.+ *+ * See the LICENSE file for details.+ */++declare(strict_types = 1);++namespace FireflyIII\Handlers\Events;++use FireflyIII\Events\StoredTransactionJournal;+use FireflyIII\Models\PiggyBank;+use FireflyIII\Models\PiggyBankEvent;+use FireflyIII\Models\Rule;+use FireflyIII\Models\RuleGroup;+use FireflyIII\Models\TransactionJournal;+use FireflyIII\Rules\Processor;+use FireflyIII\Support\Events\BillScanner;++/**+ * Class StoredJournalEventHandler+ *+ * @package FireflyIII\Handlers\Events+ */+class StoredJournalEventHandler+{+ /**+ * This method connects a new transfer to a piggy bank.+ *+ * @param StoredTransactionJournal $event+ *+ * @return bool+ */+ public function connectToPiggyBank(StoredTransactionJournal $event): bool+ {+ /** @var TransactionJournal $journal */+ $journal = $event->journal;+ $piggyBankId = $event->piggyBankId;++ /** @var PiggyBank $piggyBank */+ $piggyBank = $journal->user()->piggyBanks()->where('piggy_banks.id', $piggyBankId)->first(['piggy_banks.*']);++ if (is_null($piggyBank)) {+ return true;+ }+ // update piggy bank rep for date of transaction journal.+ $repetition = $piggyBank->piggyBankRepetitions()->relevantOnDate($journal->date)->first();+ if (is_null($repetition)) {+ return true;+ }++ $amount = TransactionJournal::amountPositive($journal);+ // if piggy account matches source account, the amount is positive+ $sources = TransactionJournal::sourceAccountList($journal)->pluck('id')->toArray();+ if (in_array($piggyBank->account_id, $sources)) {+ $amount = bcmul($amount, '-1');+ }+++ $repetition->currentamount = bcadd($repetition->currentamount, $amount);+ $repetition->save();++ PiggyBankEvent::create(['piggy_bank_id' => $piggyBank->id, 'transaction_journal_id' => $journal->id, 'date' => $journal->date, 'amount' => $amount]);++ return true;+ }++ /**+ * This method grabs all the users rules and processes them.+ *+ * @param StoredTransactionJournal $event+ *+ * @return bool+ */+ public function processRules(StoredTransactionJournal $event): bool+ {+ // get all the user's rule groups, with the rules, order by 'order'.+ $journal = $event->journal;+ $groups = $journal->user->ruleGroups()->where('rule_groups.active', 1)->orderBy('order', 'ASC')->get();+ //+ /** @var RuleGroup $group */+ foreach ($groups as $group) {+ $rules = $group->rules()+ ->leftJoin('rule_triggers', 'rules.id', '=', 'rule_triggers.rule_id')+ ->where('rule_triggers.trigger_type', 'user_action')+ ->where('rule_triggers.trigger_value', 'store-journal')+ ->where('rules.active', 1)+ ->get(['rules.*']);+ /** @var Rule $rule */+ foreach ($rules as $rule) {++ $processor = Processor::make($rule);+ $processor->handleTransactionJournal($journal);++ if ($rule->stop_processing) {+ return true;+ }++ }+ }++ return true;+ }++ /**+ * This method calls a special bill scanner that will check if the stored journal is part of a bill.+ *+ * @param StoredTransactionJournal $event+ *+ * @return bool+ */+ public function scanBills(StoredTransactionJournal $event): bool+ {+ $journal = $event->journal;+ BillScanner::scan($journal);++ return true;+ }+}\ No newline at end of filediff --git a/app/Handlers/Events/UpdateJournalConnection.php b/app/Handlers/Events/UpdateJournalConnection.phpdeleted file mode 100644index a30f63923a..0000000000--- a/app/Handlers/Events/UpdateJournalConnection.php+++ /dev/null@@ -1,74 +0,0 @@-<?php-/**- * UpdateJournalConnection.php- * Copyright (C) 2016 [email protected]- *- * This software may be modified and distributed under the terms of the- * Creative Commons Attribution-ShareAlike 4.0 International License.- *- * See the LICENSE file for details.- */--declare(strict_types = 1);-namespace FireflyIII\Handlers\Events;--use FireflyIII\Events\TransactionJournalUpdated;-use FireflyIII\Models\PiggyBankEvent;-use FireflyIII\Models\PiggyBankRepetition;-use FireflyIII\Models\TransactionJournal;--/**- * Class UpdateJournalConnection- *- * @package FireflyIII\Handlers\Events- */-class UpdateJournalConnection-{-- /**- * Handle the event.- *- * @param TransactionJournalUpdated $event- * @SuppressWarnings(PHPMD.CyclomaticComplexity) // it's exactly 5.- *- * @return bool- */- public function handle(TransactionJournalUpdated $event):bool- {- $journal = $event->journal;-- if (!$journal->isTransfer()) {- return true;- }-- // get the event connected to this journal:- /** @var PiggyBankEvent $event */- $event = PiggyBankEvent::where('transaction_journal_id', $journal->id)->first();- if (is_null($event)) {- return false;- }- $piggyBank = $event->piggyBank()->first();- $repetition = null;- if (!is_null($piggyBank)) {- /** @var PiggyBankRepetition $repetition */- $repetition = $piggyBank->piggyBankRepetitions()->relevantOnDate($journal->date)->first();- }-- if (is_null($repetition)) {- return false;- }-- $amount = TransactionJournal::amount($journal);- $diff = bcsub($amount, $event->amount); // update current repetition-- $repetition->currentamount = bcadd($repetition->currentamount, $diff);- $repetition->save();--- $event->amount = $amount;- $event->save();-- return true;- }--}diff --git a/app/Handlers/Events/UpdatedJournalEventHandler.php b/app/Handlers/Events/UpdatedJournalEventHandler.phpnew file mode 100644index 0000000000..9626120ae1--- /dev/null+++ b/app/Handlers/Events/UpdatedJournalEventHandler.php@@ -0,0 +1,128 @@+<?php+/**+ * UpdatedJournalEventHandler.php+ * Copyright (C) 2016 [email protected]+ *+ * This software may be modified and distributed under the terms of the+ * Creative Commons Attribution-ShareAlike 4.0 International License.+ *+ * See the LICENSE file for details.+ */++declare(strict_types = 1);++namespace FireflyIII\Handlers\Events;+++use FireflyIII\Events\UpdatedTransactionJournal;+use FireflyIII\Models\PiggyBankEvent;+use FireflyIII\Models\PiggyBankRepetition;+use FireflyIII\Models\Rule;+use FireflyIII\Models\RuleGroup;+use FireflyIII\Models\TransactionJournal;+use FireflyIII\Rules\Processor;+use FireflyIII\Support\Events\BillScanner;++/**+ * Class UpdatedJournalEventHandler+ *+ * @package FireflyIII\Handlers\Events+ */+class UpdatedJournalEventHandler+{+ /**+ * This method will try to reconnect a journal to a piggy bank, updating the piggy bank repetition.+ *+ * @param UpdatedTransactionJournal $event+ *+ * @return bool+ */+ public function connectToPiggyBank(UpdatedTransactionJournal $event): bool+ {+ $journal = $event->journal;++ if (!$journal->isTransfer()) {+ return true;+ }++ // get the event connected to this journal:+ /** @var PiggyBankEvent $event */+ $event = PiggyBankEvent::where('transaction_journal_id', $journal->id)->first();+ if (is_null($event)) {+ return false;+ }+ $piggyBank = $event->piggyBank()->first();+ $repetition = null;+ if (!is_null($piggyBank)) {+ /** @var PiggyBankRepetition $repetition */+ $repetition = $piggyBank->piggyBankRepetitions()->relevantOnDate($journal->date)->first();+ }++ if (is_null($repetition)) {+ return false;+ }++ $amount = TransactionJournal::amount($journal);+ $diff = bcsub($amount, $event->amount); // update current repetition++ $repetition->currentamount = bcadd($repetition->currentamount, $diff);+ $repetition->save();+++ $event->amount = $amount;+ $event->save();++ return true;+ }++ /**+ * This method will check all the rules when a journal is updated.+ *+ * @param UpdatedTransactionJournal $event+ *+ * @return bool+ */+ public function processRules(UpdatedTransactionJournal $event):bool+ {+ // get all the user's rule groups, with the rules, order by 'order'.+ $journal = $event->journal;+ $groups = $journal->user->ruleGroups()->where('rule_groups.active', 1)->orderBy('order', 'ASC')->get();+ //+ /** @var RuleGroup $group */+ foreach ($groups as $group) {+ $rules = $group->rules()+ ->leftJoin('rule_triggers', 'rules.id', '=', 'rule_triggers.rule_id')+ ->where('rule_triggers.trigger_type', 'user_action')+ ->where('rule_triggers.trigger_value', 'update-journal')+ ->where('rules.active', 1)+ ->get(['rules.*']);+ /** @var Rule $rule */+ foreach ($rules as $rule) {+ $processor = Processor::make($rule);+ $processor->handleTransactionJournal($journal);++ if ($rule->stop_processing) {+ break;+ }++ }+ }++ return true;+ }++ /**+ * This method calls a special bill scanner that will check if the updated journal is part of a bill.+ *+ * @param UpdatedTransactionJournal $event+ *+ * @return bool+ */+ public function scanBills(UpdatedTransactionJournal $event): bool+ {+ $journal = $event->journal;+ BillScanner::scan($journal);++ return true;+ }+}\ No newline at end of filediff --git a/app/Handlers/Events/UserConfirmation.php b/app/Handlers/Events/UserConfirmation.phpdeleted file mode 100644index 439db35e75..0000000000--- a/app/Handlers/Events/UserConfirmation.php+++ /dev/null@@ -1,109 +0,0 @@-<?php-/**- * UserConfirmation.php- * Copyright (C) 2016 [email protected]- *- * This software may be modified and distributed under the terms of the- * Creative Commons Attribution-ShareAlike 4.0 International License.- *- * See the LICENSE file for details.- */--declare(strict_types = 1);--namespace FireflyIII\Handlers\Events;---use Exception;-use FireflyIII\Events\ResendConfirmation;-use FireflyIII\Events\UserRegistration;-use FireflyIII\User;-use Illuminate\Mail\Message;-use Log;-use Mail;-use Preferences;-use Swift_TransportException;--/**- * Class UserConfirmation- *- * @package FireflyIII\Handlers\Events- */-class UserConfirmation-{- /**- * Create the event listener.- *- */- public function __construct()- {- //- }-- /**- * @param ResendConfirmation $event- *- * @return bool- */- public function resendConfirmation(ResendConfirmation $event): bool- {- $user = $event->user;- $ipAddress = $event->ipAddress;- $this->doConfirm($user, $ipAddress);-- return true;- }-- /**- * Handle the event.- *- * @param UserRegistration $event- *- * @return bool- */- public function sendConfirmation(UserRegistration $event): bool- {- $user = $event->user;- $ipAddress = $event->ipAddress;- $this->doConfirm($user, $ipAddress);-- return true;- }-- /**- * @param User $user- * @param string $ipAddress- */- private function doConfirm(User $user, string $ipAddress)- {- $confirmAccount = env('MUST_CONFIRM_ACCOUNT', false);- if ($confirmAccount === false) {- Preferences::setForUser($user, 'user_confirmed', true);- Preferences::setForUser($user, 'user_confirmed_last_mail', 0);- Preferences::mark();-- return;- }- $email = $user->email;- $code = str_random(16);- $route = route('do_confirm_account', [$code]);- Preferences::setForUser($user, 'user_confirmed', false);- Preferences::setForUser($user, 'user_confirmed_last_mail', time());- Preferences::setForUser($user, 'user_confirmed_code', $code);- try {- Mail::send(- ['emails.confirm-account-html', 'emails.confirm-account'], ['route' => $route, 'ip' => $ipAddress],- function (Message $message) use ($email) {- $message->to($email, $email)->subject('Please confirm your Firefly III account');- }- );- } catch (Swift_TransportException $e) {- Log::error($e->getMessage());- } catch (Exception $e) {- Log::error($e->getMessage());- }-- return;- }--}diff --git a/app/Handlers/Events/UserEventHandler.php b/app/Handlers/Events/UserEventHandler.phpnew file mode 100644index 0000000000..2d8523e3c9--- /dev/null+++ b/app/Handlers/Events/UserEventHandler.php@@ -0,0 +1,225 @@+<?php+/**+ * UserEventHandler.php+ * Copyright (C) 2016 [email protected]+ *+ * This software may be modified and distributed under the terms of the+ * Creative Commons Attribution-ShareAlike 4.0 International License.+ *+ * See the LICENSE file for details.+ */++declare(strict_types = 1);++namespace FireflyIII\Handlers\Events;++use Exception;+use FireflyIII\Events\ConfirmedUser;+use FireflyIII\Events\RegisteredUser;+use FireflyIII\Events\ResentConfirmation;+use FireflyIII\Repositories\User\UserRepositoryInterface;+use Illuminate\Mail\Message;+use Log;+use Mail;+use Preferences;+use Session;+use Swift_TransportException;++/**+ * Class UserEventHandler+ *+ * This class responds to any events that have anything to do with the User object.+ *+ * The method name reflects what is being done. This is in the present tense.+ *+ *+ * @package FireflyIII\Handlers\Events+ */+class UserEventHandler+{++ /**+ * This method will bestow upon a user the "owner" role if he is the first user in the system.+ *+ * @param RegisteredUser $event+ *+ * @return bool+ */+ public function attachUserRole(RegisteredUser $event): bool+ {+ /** @var UserRepositoryInterface $repository */+ $repository = app(UserRepositoryInterface::class);++ // first user ever?+ if ($repository->count() === 1) {+ $repository->attachRole($event->user, 'owner');+ }++ return true;+ }++ /**+ * Handle user logout events.+ *+ * @return bool+ */+ public function onUserLogout(): bool+ {+ // dump stuff from the session:+ Session::forget('twofactor-authenticated');+ Session::forget('twofactor-authenticated-date');++ return true;+ }++ /**+ * This method will send a newly registered user a confirmation message, urging him or her to activate their account.+ *+ * @param RegisteredUser $event+ *+ * @return bool+ */+ public function sendConfirmationMessage(RegisteredUser $event): bool+ {+ $user = $event->user;+ $ipAddress = $event->ipAddress;+ $confirmAccount = env('MUST_CONFIRM_ACCOUNT', false);+ if ($confirmAccount === false) {+ Preferences::setForUser($user, 'user_confirmed', true);+ Preferences::setForUser($user, 'user_confirmed_last_mail', 0);+ Preferences::mark();++ return true;+ }+ $email = $user->email;+ $code = str_random(16);+ $route = route('do_confirm_account', [$code]);+ Preferences::setForUser($user, 'user_confirmed', false);+ Preferences::setForUser($user, 'user_confirmed_last_mail', time());+ Preferences::setForUser($user, 'user_confirmed_code', $code);+ try {+ Mail::send(+ ['emails.confirm-account-html', 'emails.confirm-account'], ['route' => $route, 'ip' => $ipAddress],+ function (Message $message) use ($email) {+ $message->to($email, $email)->subject('Please confirm your Firefly III account');+ }+ );+ } catch (Swift_TransportException $e) {+ Log::error($e->getMessage());+ } catch (Exception $e) {+ Log::error($e->getMessage());+ }++ return true;+ }++ /**+ * If the user has somehow lost his or her confirmation message, this event will send it to the user again.+ *+ * At the moment, this method is exactly the same as the ::sendConfirmationMessage method, but that will change.+ *+ * @param ResentConfirmation $event+ *+ * @return bool+ */+ function sendConfirmationMessageAgain(ResentConfirmation $event): bool+ {+ $user = $event->user;+ $ipAddress = $event->ipAddress;+ $confirmAccount = env('MUST_CONFIRM_ACCOUNT', false);+ if ($confirmAccount === false) {+ Preferences::setForUser($user, 'user_confirmed', true);+ Preferences::setForUser($user, 'user_confirmed_last_mail', 0);+ Preferences::mark();++ return true;+ }+ $email = $user->email;+ $code = str_random(16);+ $route = route('do_confirm_account', [$code]);+ Preferences::setForUser($user, 'user_confirmed', false);+ Preferences::setForUser($user, 'user_confirmed_last_mail', time());+ Preferences::setForUser($user, 'user_confirmed_code', $code);+ try {+ Mail::send(+ ['emails.confirm-account-html', 'emails.confirm-account'], ['route' => $route, 'ip' => $ipAddress],+ function (Message $message) use ($email) {+ $message->to($email, $email)->subject('Please confirm your Firefly III account');+ }+ );+ } catch (Swift_TransportException $e) {+ Log::error($e->getMessage());+ } catch (Exception $e) {+ Log::error($e->getMessage());+ }++ return true;++ }++ /**+ * This method will send the user a registration mail, welcoming him or her to Firefly III.+ * This message is only sent when the configuration of Firefly III says so.+ *+ * @param RegisteredUser $event+ *+ * @return bool+ */+ public function sendRegistrationMail(RegisteredUser $event)+ {++ $sendMail = env('SEND_REGISTRATION_MAIL', true);+ if (!$sendMail) {+ return true;+ }+ // get the email address+ $email = $event->user->email;+ $address = route('index');+ $ipAddress = $event->ipAddress;+ // send email.+ try {+ Mail::send(+ ['emails.registered-html', 'emails.registered'], ['address' => $address, 'ip' => $ipAddress], function (Message $message) use ($email) {+ $message->to($email, $email)->subject('Welcome to Firefly III! ');+ }+ );+ } catch (Swift_TransportException $e) {+ Log::error($e->getMessage());+ }++ return true;+ }++ /**+ * When the user is confirmed, this method stores the IP address of the user+ * as a preference. Since this preference cannot be edited, it is effectively hidden+ * from the user yet stored conveniently.+ *+ * @param ConfirmedUser $event+ *+ * @return bool+ */+ public function storeConfirmationIpAddress(ConfirmedUser $event): bool+ {+ Preferences::setForUser($event->user, 'confirmation_ip_address', $event->ipAddress);++ return true;+ }++ /**+ * This message stores the users IP address on registration, in much the same+ * fashion as the previous method.+ *+ * @param RegisteredUser $event+ *+ * @return bool+ */+ public function storeRegistrationIpAddress(RegisteredUser $event): bool+ {+ Preferences::setForUser($event->user, 'registration_ip_address', $event->ipAddress);++ return true;++ }++}\ No newline at end of filediff --git a/app/Handlers/Events/UserEventListener.php b/app/Handlers/Events/UserEventListener.phpdeleted file mode 100644index f81303d084..0000000000--- a/app/Handlers/Events/UserEventListener.php+++ /dev/null@@ -1,38 +0,0 @@-<?php-/**- * UserEventListener.php- * Copyright (C) 2016 [email protected]- *- * This software may be modified and distributed under the terms of the- * Creative Commons Attribution-ShareAlike 4.0 International License.- *- * See the LICENSE file for details.- */--declare(strict_types = 1);--namespace FireflyIII\Handlers\Events;--use Session;--/**- * Class UserEventListener- *- * @package FireflyIII\Handlers\Events- */-class UserEventListener-{- /**- * Handle user logout events.- *- * @return bool- */- public function onUserLogout(): bool- {- // dump stuff from the session:- Session::forget('twofactor-authenticated');- Session::forget('twofactor-authenticated-date');-- return true;- }-}diff --git a/app/Handlers/Events/UserSaveIpAddress.php b/app/Handlers/Events/UserSaveIpAddress.phpdeleted file mode 100644index 1533d84127..0000000000--- a/app/Handlers/Events/UserSaveIpAddress.php+++ /dev/null@@ -1,63 +0,0 @@-<?php-/**- * UserSaveIpAddress.php- * Copyright (C) 2016 [email protected]- *- * This software may be modified and distributed under the terms of the- * Creative Commons Attribution-ShareAlike 4.0 International License.- *- * See the LICENSE file for details.- */--declare(strict_types = 1);--namespace FireflyIII\Handlers\Events;--use FireflyIII\Events\UserIsConfirmed;-use FireflyIII\Events\UserRegistration;-use Preferences;--/**- * Class UserSaveIpAddress- *- * @package FireflyIII\Handlers\Events- */-class UserSaveIpAddress-{- /**- * Create the event listener.- *- */- public function __construct()- {- //- }-- /**- * Handle the event.- *- * @param UserIsConfirmed $event- *- * @return bool- */- public function saveFromConfirmation(UserIsConfirmed $event): bool- {- Preferences::setForUser($event->user, 'confirmation_ip_address', $event->ipAddress);-- return true;- }-- /**- * Handle the event.- *- * @param UserRegistration $event- *- * @return bool- */- public function saveFromRegistration(UserRegistration $event): bool- {- Preferences::setForUser($event->user, 'registration_ip_address', $event->ipAddress);-- return true;- }-}diff --git a/app/Http/Controllers/Auth/ConfirmationController.php b/app/Http/Controllers/Auth/ConfirmationController.phpindex 4e34c7dcb8..d99662973f 100644--- a/app/Http/Controllers/Auth/ConfirmationController.php+++ b/app/Http/Controllers/Auth/ConfirmationController.php@@ -13,8 +13,8 @@ declare(strict_types = 1);namespace FireflyIII\Http\Controllers\Auth;-use FireflyIII\Events\ResendConfirmation;-use FireflyIII\Events\UserIsConfirmed;+use FireflyIII\Events\ResentConfirmation;+use FireflyIII\Events\ConfirmedUser;use FireflyIII\Exceptions\FireflyException;use FireflyIII\Http\Controllers\Controller;use Illuminate\Http\Request;@@ -56,7 +56,7 @@ class ConfirmationController extends Controllerif ($database === $code && ($now - $time <= $maxDiff)) {// trigger user registration event:- event(new UserIsConfirmed(auth()->user(), $request->ip()));+ event(new ConfirmedUser(auth()->user(), $request->ip()));Preferences::setForUser(auth()->user(), 'user_confirmed', true);Preferences::setForUser(auth()->user(), 'user_confirmed_confirmed', time());@@ -80,7 +80,7 @@ class ConfirmationController extends Controller$owner = env('SITE_OWNER', '[email protected]');$view = 'auth.confirmation.no-resent';if ($now - $time > $maxDiff) {- event(new ResendConfirmation(auth()->user(), $request->ip()));+ event(new ResentConfirmation(auth()->user(), $request->ip()));$view = 'auth.confirmation.resent';}diff --git a/app/Http/Controllers/Auth/RegisterController.php b/app/Http/Controllers/Auth/RegisterController.phpindex bb87bd81e3..e7d6dc6692 100755--- a/app/Http/Controllers/Auth/RegisterController.php+++ b/app/Http/Controllers/Auth/RegisterController.php@@ -14,7 +14,7 @@ namespace FireflyIII\Http\Controllers\Auth;use Auth;use Config;-use FireflyIII\Events\UserRegistration;+use FireflyIII\Events\RegisteredUser;use FireflyIII\Http\Controllers\Controller;use FireflyIII\Support\Facades\FireflyConfig;use FireflyIII\User;@@ -102,7 +102,7 @@ class RegisterController extends Controller$user = $this->create($request->all());// trigger user registration event:- event(new UserRegistration($user, $request->ip()));+ event(new RegisteredUser($user, $request->ip()));Auth::login($user);diff --git a/app/Http/Controllers/ProfileController.php b/app/Http/Controllers/ProfileController.phpindex b03420b592..5d368c09f5 100644--- a/app/Http/Controllers/ProfileController.php+++ b/app/Http/Controllers/ProfileController.php@@ -13,7 +13,7 @@ declare(strict_types = 1);namespace FireflyIII\Http\Controllers;-use FireflyIII\Events\UserIsDeleted;+use FireflyIII\Events\DeletedUser;use FireflyIII\Http\Requests\DeleteAccountFormRequest;use FireflyIII\Http\Requests\ProfileFormRequest;use FireflyIII\User;@@ -116,9 +116,6 @@ class ProfileController extends Controllerreturn redirect(route('profile.delete-account'));}- // respond to deletion:- event(new UserIsDeleted(auth()->user(), $request->ip()));-// store some stuff for the future:$registration = Preferences::get('registration_ip_address')->data;$confirmation = Preferences::get('confirmation_ip_address')->data;diff --git a/app/Http/Controllers/Transaction/SingleController.php b/app/Http/Controllers/Transaction/SingleController.phpindex 23861d9ff4..e7efcd63e4 100644--- a/app/Http/Controllers/Transaction/SingleController.php+++ b/app/Http/Controllers/Transaction/SingleController.php@@ -15,8 +15,8 @@ namespace FireflyIII\Http\Controllers\Transaction;use ExpandedForm;-use FireflyIII\Events\TransactionJournalStored;-use FireflyIII\Events\TransactionJournalUpdated;+use FireflyIII\Events\StoredTransactionJournal;+use FireflyIII\Events\UpdatedTransactionJournal;use FireflyIII\Helpers\Attachments\AttachmentHelperInterface;use FireflyIII\Http\Controllers\Controller;use FireflyIII\Http\Requests\JournalFormRequest;@@ -260,7 +260,7 @@ class SingleController extends ControllerSession::flash('info', $this->attachments->getMessages()->get('attachments'));}- event(new TransactionJournalStored($journal, $data['piggy_bank_id']));+ event(new StoredTransactionJournal($journal, $data['piggy_bank_id']));Session::flash('success', strval(trans('firefly.stored_journal', ['description' => e($journal->description)])));Preferences::mark();@@ -304,7 +304,7 @@ class SingleController extends ControllerSession::flash('info', $this->attachments->getMessages()->get('attachments'));}- event(new TransactionJournalUpdated($journal));+ event(new UpdatedTransactionJournal($journal));// update, get events by date and sort DESC$type = strtolower(TransactionJournal::transactionTypeStr($journal));diff --git a/app/Http/Controllers/Transaction/SplitController.php b/app/Http/Controllers/Transaction/SplitController.phpindex 6fe08cb008..b849f810ef 100644--- a/app/Http/Controllers/Transaction/SplitController.php+++ b/app/Http/Controllers/Transaction/SplitController.php@@ -15,7 +15,7 @@ namespace FireflyIII\Http\Controllers\Transaction;use ExpandedForm;-use FireflyIII\Events\TransactionJournalUpdated;+use FireflyIII\Events\UpdatedTransactionJournal;use FireflyIII\Helpers\Attachments\AttachmentHelperInterface;use FireflyIII\Http\Controllers\Controller;use FireflyIII\Models\AccountType;@@ -132,7 +132,7 @@ class SplitController extends Controller// save attachments:$this->attachments->saveAttachmentsForModel($journal);- event(new TransactionJournalUpdated($journal));+ event(new UpdatedTransactionJournal($journal));// update, get events by date and sort DESC// flash messagesdiff --git a/app/Providers/EventServiceProvider.php b/app/Providers/EventServiceProvider.phpindex d8373a2be6..6cfb886b4c 100755--- a/app/Providers/EventServiceProvider.php+++ b/app/Providers/EventServiceProvider.php@@ -35,42 +35,50 @@ class EventServiceProvider extends ServiceProvider*/protected $listen= [- 'FireflyIII\Events\TransactionJournalUpdated' => [- 'FireflyIII\Handlers\Events\ScanForBillsAfterUpdate',- 'FireflyIII\Handlers\Events\UpdateJournalConnection',- 'FireflyIII\Handlers\Events\FireRulesForUpdate',-- ],-- 'FireflyIII\Events\BudgetLimitStored' => [- 'FireflyIII\Handlers\Events\BudgetLimitEventHandler@store',- ],- 'FireflyIII\Events\BudgetLimitUpdated' => [- 'FireflyIII\Handlers\Events\BudgetLimitEventHandler@update',- ],- 'FireflyIII\Events\TransactionStored' => [- 'FireflyIII\Handlers\Events\ConnectTransactionToPiggyBank',- ],- 'FireflyIII\Events\TransactionJournalStored' => [- 'FireflyIII\Handlers\Events\ScanForBillsAfterStore',- 'FireflyIII\Handlers\Events\ConnectJournalToPiggyBank',- 'FireflyIII\Handlers\Events\FireRulesForStore',- ],- 'Illuminate\Auth\Events\Logout' => [- 'FireflyIII\Handlers\Events\UserEventListener@onUserLogout',- ],- 'FireflyIII\Events\UserRegistration' => [- 'FireflyIII\Handlers\Events\SendRegistrationMail',- 'FireflyIII\Handlers\Events\AttachUserRole',- 'FireflyIII\Handlers\Events\UserConfirmation@sendConfirmation',- 'FireflyIII\Handlers\Events\UserSaveIpAddress@saveFromRegistration',- ],- 'FireflyIII\Events\UserIsConfirmed' => [- 'FireflyIII\Handlers\Events\UserSaveIpAddress@saveFromConfirmation',- ],- 'FireflyIII\Events\ResendConfirmation' => [- 'FireflyIII\Handlers\Events\UserConfirmation@resendConfirmation',- ],+ // new event handlers:+ 'FireflyIII\Events\ConfirmedUser' => // is a User related event.+ [+ 'FireflyIII\Handlers\Events\UserEventHandler@storeConfirmationIpAddress',+ ],+ 'FireflyIII\Events\RegisteredUser' => // is a User related event.+ [+ 'FireflyIII\Handlers\Events\UserEventHandler@sendRegistrationMail',+ 'FireflyIII\Handlers\Events\UserEventHandler@attachUserRole',+ 'FireflyIII\Handlers\Events\UserEventHandler@sendConfirmationMessage',+ 'FireflyIII\Handlers\Events\UserEventHandler@storeRegistrationIpAddress',+ ],+ 'FireflyIII\Events\ResentConfirmation' => // is a User related event.+ [+ 'FireflyIII\Handlers\Events\UserEventHandler@sendConfirmationMessageAgain',+ ],+ 'FireflyIII\Events\StoredBudgetLimit' => // is a Budget related event.+ [+ 'FireflyIII\Handlers\Events\BudgetEventHandler@storeRepetition',+ ],++ 'FireflyIII\Events\UpdatedBudgetLimit' => // is a Budget related event.+ [+ 'FireflyIII\Handlers\Events\BudgetEventHandler@updateRepetition',+ ],++ 'FireflyIII\Events\StoredTransactionJournal' => // is a Transaction Journal related event.+ [+ 'FireflyIII\Handlers\Events\StoredJournalEventHandler@scanBills',+ 'FireflyIII\Handlers\Events\StoredJournalEventHandler@connectToPiggyBank',+ 'FireflyIII\Handlers\Events\StoredJournalEventHandler@processRules',+ ],+ 'FireflyIII\Events\UpdatedTransactionJournal' => // is a Transaction Journal related event.+ [+ 'FireflyIII\Handlers\Events\UpdatedJournalEventHandler@scanBills',+ 'FireflyIII\Handlers\Events\UpdatedJournalEventHandler@connectToPiggyBank',+ 'FireflyIII\Handlers\Events\UpdatedJournalEventHandler@processRules',+ ],++ // LARAVEL EVENTS:+ 'Illuminate\Auth\Events\Logout' =>+ [+ 'FireflyIII\Handlers\Events\UserEventHandler@logoutUser',+ ],];/**@@ -83,9 +91,6 @@ class EventServiceProvider extends ServiceProviderparent::boot();$this->registerDeleteEvents();$this->registerCreateEvents();--- //}/**diff --git a/app/Repositories/Budget/BudgetRepository.php b/app/Repositories/Budget/BudgetRepository.phpindex 7d7e24dc52..b2a3440295 100644--- a/app/Repositories/Budget/BudgetRepository.php+++ b/app/Repositories/Budget/BudgetRepository.php@@ -14,8 +14,8 @@ declare(strict_types = 1);namespace FireflyIII\Repositories\Budget;use Carbon\Carbon;-use FireflyIII\Events\BudgetLimitStored;-use FireflyIII\Events\BudgetLimitUpdated;+use FireflyIII\Events\StoredBudgetLimit;+use FireflyIII\Events\UpdatedBudgetLimit;use FireflyIII\Models\Budget;use FireflyIII\Models\BudgetLimit;use FireflyIII\Models\LimitRepetition;@@ -555,7 +555,7 @@ class BudgetRepository implements BudgetRepositoryInterface$limit->save();// fire event to create or update LimitRepetition.- event(new BudgetLimitUpdated($limit, $end));+ event(new UpdatedBudgetLimit($limit, $end));return $limit;}@@ -568,7 +568,7 @@ class BudgetRepository implements BudgetRepositoryInterface$limit->repeat_freq = $repeatFreq;$limit->repeats = 0;$limit->save();- event(new BudgetLimitStored($limit, $end));+ event(new StoredBudgetLimit($limit, $end));// likewise, there should be a limit repetition to match the end datediff --git a/app/Repositories/Journal/JournalRepository.php b/app/Repositories/Journal/JournalRepository.phpindex 855e253211..a43f55186a 100644--- a/app/Repositories/Journal/JournalRepository.php+++ b/app/Repositories/Journal/JournalRepository.php@@ -14,7 +14,6 @@ declare(strict_types = 1);namespace FireflyIII\Repositories\Journal;use DB;-use FireflyIII\Events\TransactionStored;use FireflyIII\Exceptions\FireflyException;use FireflyIII\Models\Account;use FireflyIII\Models\AccountType;