Skip to content

Firefly III: a personal finances manager

New events for new accounts

James Cole7fb4b2bb4014
diff --git a/app/Handlers/Events/StoredAccountEventHandler.php b/app/Handlers/Events/StoredAccountEventHandler.php
new file mode 100644
index 0000000000..5d87364a69
--- /dev/null
+++ b/app/Handlers/Events/StoredAccountEventHandler.php
@@ -0,0 +1,44 @@
+<?php
+/*
+ * StoredAccountEventHandler.php
+ * Copyright (c) 2021 [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/>.
+ */
+
+namespace FireflyIII\Handlers\Events;
+
+use FireflyIII\Events\StoredAccount;
+use FireflyIII\Services\Internal\Support\CreditRecalculateService;
+
+/**
+ * Class StoredAccountEventHandler
+ */
+class StoredAccountEventHandler
+{
+ /**
+ * @param StoredAccount $event
+ */
+ public function recalculateCredit(StoredAccount $event): void
+ {
+ $account = $event->account;
+ /** @var CreditRecalculateService $object */
+ $object = app(CreditRecalculateService::class);
+ $object->setAccount($account);
+ $object->recalculate();
+ }
+
+}
\ No newline at end of file
diff --git a/app/Handlers/Events/UpdatedAccountEventHandler.php b/app/Handlers/Events/UpdatedAccountEventHandler.php
new file mode 100644
index 0000000000..674ab383a9
--- /dev/null
+++ b/app/Handlers/Events/UpdatedAccountEventHandler.php
@@ -0,0 +1,45 @@
+<?php
+/*
+ * UpdatedAccountEventHandler.php
+ * Copyright (c) 2021 [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/>.
+ */
+
+namespace FireflyIII\Handlers\Events;
+
+
+use FireflyIII\Events\StoredAccount;
+use FireflyIII\Events\UpdatedAccount;
+use FireflyIII\Services\Internal\Support\CreditRecalculateService;
+
+/**
+ * Class UpdatedAccountEventHandler
+ */
+class UpdatedAccountEventHandler
+{
+ /**
+ * @param UpdatedAccount $event
+ */
+ public function recalculateCredit(UpdatedAccount $event): void
+ {
+ $account = $event->account;
+ /** @var CreditRecalculateService $object */
+ $object = app(CreditRecalculateService::class);
+ $object->setAccount($account);
+ $object->recalculate();
+ }
+}
\ No newline at end of file