Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Clean up config.
James Cole0063cab6903b
diff --git a/app/Api/V1/Controllers/Models/Transaction/DestroyController.php b/app/Api/V1/Controllers/Models/Transaction/DestroyController.phpindex 5ab715051c..89b52cc7cf 100644--- a/app/Api/V1/Controllers/Models/Transaction/DestroyController.php+++ b/app/Api/V1/Controllers/Models/Transaction/DestroyController.php@@ -25,9 +25,6 @@ declare(strict_types=1);namespace FireflyIII\Api\V1\Controllers\Models\Transaction;use FireflyIII\Api\V1\Controllers\Controller;-use FireflyIII\Events\UpdatedAccount;-use FireflyIII\Models\Account;-use FireflyIII\Models\Transaction;use FireflyIII\Models\TransactionGroup;use FireflyIII\Models\TransactionJournal;use FireflyIII\Repositories\Journal\JournalRepositoryInterface;@@ -53,9 +50,9 @@ class DestroyController extends Controllerparent::__construct();$this->middleware(function ($request, $next) {/** @var User $admin */- $admin = auth()->user();+ $admin = auth()->user();- $this->repository = app(JournalRepositoryInterface::class);+ $this->repository = app(JournalRepositoryInterface::class);$this->repository->setUser($admin);$this->groupRepository = app(TransactionGroupRepository::class);diff --git a/app/Events/TriggeredAuditLog.php b/app/Events/TriggeredAuditLog.phpdeleted file mode 100644index b13ee5ef03..0000000000--- a/app/Events/TriggeredAuditLog.php+++ /dev/null@@ -1,49 +0,0 @@-<?php--/*- * TriggeredAuditLog.php- * Copyright (c) 2022 [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\Events;--use Illuminate\Database\Eloquent\Model;-use Illuminate\Queue\SerializesModels;--/**- * Class TriggeredAuditLog- */-class TriggeredAuditLog extends Event-{- use SerializesModels;-- /**- * Create a new event instance.- *- * @SuppressWarnings("PHPMD.ExcessiveParameterList")- */- public function __construct(- public Model $changer,- public Model $auditable,- public string $field,- public mixed $before,- public mixed $after- ) {}-}diff --git a/app/Events/UpdatedAccount.php b/app/Events/UpdatedAccount.phpdeleted file mode 100644index 2203915030..0000000000--- a/app/Events/UpdatedAccount.php+++ /dev/null@@ -1,43 +0,0 @@-<?php--/*- * UpdatedAccount.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/>.- */--declare(strict_types=1);--namespace FireflyIII\Events;--use FireflyIII\Models\Account;-use Illuminate\Queue\SerializesModels;--/**- * Class UpdatedAccount- */-class UpdatedAccount extends Event-{- use SerializesModels;-- /**- * Create a new event instance.- */- public function __construct(- public Account $account- ) {}-}diff --git a/app/Handlers/Observer/BillObserver.php b/app/Handlers/Observer/BillObserver.phpindex 6b8fb62a87..ec2cddb509 100644--- a/app/Handlers/Observer/BillObserver.php+++ b/app/Handlers/Observer/BillObserver.php@@ -39,18 +39,6 @@ class BillObserver$this->updatePrimaryCurrencyAmount($bill);}- public function deleting(Bill $bill): void- {- $repository = app(AttachmentRepositoryInterface::class);- $repository->setUser($bill->user);-- /** @var Attachment $attachment */- foreach ($bill->attachments()->get() as $attachment) {- $repository->destroy($attachment);- }- $bill->notes()->delete();- }-public function updated(Bill $bill): void{// Log::debug('Observe "updated" of a bill.');diff --git a/app/Http/Controllers/Transaction/DeleteController.php b/app/Http/Controllers/Transaction/DeleteController.phpindex efa6e18450..076f66aaba 100644--- a/app/Http/Controllers/Transaction/DeleteController.php+++ b/app/Http/Controllers/Transaction/DeleteController.php@@ -24,12 +24,8 @@ declare(strict_types=1);namespace FireflyIII\Http\Controllers\Transaction;-use FireflyIII\Events\UpdatedAccount;use FireflyIII\Http\Controllers\Controller;-use FireflyIII\Models\Account;-use FireflyIII\Models\Transaction;use FireflyIII\Models\TransactionGroup;-use FireflyIII\Models\TransactionJournal;use FireflyIII\Repositories\TransactionGroup\TransactionGroupRepositoryInterface;use FireflyIII\Support\Facades\Preferences;use FireflyIII\Support\Facades\Steam;@@ -56,7 +52,7 @@ class DeleteController extends Controller// translations:$this->middleware(function ($request, $next) {- app('view')->share('title', (string) trans('firefly.transactions'));+ app('view')->share('title', (string)trans('firefly.transactions'));app('view')->share('mainTitleIcon', 'fa-exchange');$this->repository = app(TransactionGroupRepositoryInterface::class);@@ -68,7 +64,7 @@ class DeleteController extends Controller/*** Shows the form that allows a user to delete a transaction journal.*/- public function delete(TransactionGroup $group): Factory|Redirector|RedirectResponse|View+ public function delete(TransactionGroup $group): Factory | Redirector | RedirectResponse | View{if (!$this->isEditableGroup($group)) {return $this->redirectGroupToAccount($group);@@ -76,12 +72,12 @@ class DeleteController extends ControllerLog::debug(sprintf('Start of delete view for group #%d', $group->id));- $journal = $group->transactionJournals->first();+ $journal = $group->transactionJournals->first();if (null === $journal) {throw new NotFoundHttpException();}$objectType = strtolower($journal->transaction_type_type ?? $journal->transactionType->type);- $subTitle = (string) trans('firefly.delete_'.$objectType, ['description' => $group->title ?? $journal->description]);+ $subTitle = (string)trans('firefly.delete_' . $objectType, ['description' => $group->title ?? $journal->description]);$previous = Steam::getSafePreviousUrl();// put previous url in sessionLog::debug('Will try to remember previous URL');@@ -99,19 +95,19 @@ class DeleteController extends Controller/*** Actually destroys the journal.*/- public function destroy(TransactionGroup $group): Redirector|RedirectResponse+ public function destroy(TransactionGroup $group): Redirector | RedirectResponse{Log::debug(sprintf('Now in %s(#%d).', __METHOD__, $group->id));if (!$this->isEditableGroup($group)) {return $this->redirectGroupToAccount($group);}- $journal = $group->transactionJournals->first();+ $journal = $group->transactionJournals->first();if (null === $journal) {throw new NotFoundHttpException();}$objectType = strtolower($journal->transaction_type_type ?? $journal->transactionType->type);- session()->flash('success', (string) trans('firefly.deleted_'.strtolower($objectType), ['description' => $group->title ?? $journal->description]));+ session()->flash('success', (string)trans('firefly.deleted_' . strtolower($objectType), ['description' => $group->title ?? $journal->description]));$this->repository->destroy($group);Preferences::mark();diff --git a/app/Rules/UniqueAccountNumber.php b/app/Rules/UniqueAccountNumber.phpindex 412fba5465..d8219cfdc8 100644--- a/app/Rules/UniqueAccountNumber.php+++ b/app/Rules/UniqueAccountNumber.php@@ -45,7 +45,7 @@ class UniqueAccountNumber implements ValidationRuleprivate readonly ?Account $account,private ?string $expectedType) {- app('log')->debug('Constructed UniqueAccountNumber');+ Log::debug('Constructed UniqueAccountNumber');// a very basic fix to make sure we get the correct account type:if ('expense' === $this->expectedType) {$this->expectedType = AccountTypeEnum::EXPENSE->value;diff --git a/app/Services/Internal/Destroy/BillDestroyService.php b/app/Services/Internal/Destroy/BillDestroyService.phpindex b5a6a2c233..04bedb9b1c 100644--- a/app/Services/Internal/Destroy/BillDestroyService.php+++ b/app/Services/Internal/Destroy/BillDestroyService.php@@ -24,7 +24,9 @@ declare(strict_types=1);namespace FireflyIII\Services\Internal\Destroy;+use FireflyIII\Models\Attachment;use FireflyIII\Models\Bill;+use FireflyIII\Repositories\Attachment\AttachmentRepositoryInterface;/*** Class BillDestroyService@@ -33,6 +35,16 @@ class BillDestroyService{public function destroy(Bill $bill): void{+ $repository = app(AttachmentRepositoryInterface::class);+ $repository->setUser($bill->user);++ /** @var Attachment $attachment */+ foreach ($bill->attachments()->get() as $attachment) {+ $repository->destroy($attachment);+ }+ $bill->notes()->delete();++$bill->delete();}}diff --git a/app/Services/Internal/Update/AccountUpdateService.php b/app/Services/Internal/Update/AccountUpdateService.phpindex fe586541be..6dce8b30c6 100644--- a/app/Services/Internal/Update/AccountUpdateService.php+++ b/app/Services/Internal/Update/AccountUpdateService.php@@ -26,7 +26,6 @@ namespace FireflyIII\Services\Internal\Update;use FireflyIII\Enums\AccountTypeEnum;use FireflyIII\Events\Model\Account\UpdatedExistingAccount;-use FireflyIII\Events\UpdatedAccount;use FireflyIII\Exceptions\FireflyException;use FireflyIII\Models\Account;use FireflyIII\Models\AccountType;@@ -47,11 +46,11 @@ class AccountUpdateServiceuse AccountServiceTrait;protected AccountRepositoryInterface $accountRepository;- protected array $validAssetFields;- protected array $validCCFields;- protected array $validFields;- private array $canHaveOpeningBalance;- private User $user;+ protected array $validAssetFields;+ protected array $validCCFields;+ protected array $validFields;+ private array $canHaveOpeningBalance;+ private User $user;/*** Constructor.@@ -80,7 +79,7 @@ class AccountUpdateService// find currency, or use default currency instead.if (array_key_exists('currency_id', $data) || array_key_exists('currency_code', $data)) {- $currency = $this->getCurrency((int) ($data['currency_id'] ?? null), (string) ($data['currency_code'] ?? null));+ $currency = $this->getCurrency((int)($data['currency_id'] ?? null), (string)($data['currency_code'] ?? null));unset($data['currency_code'], $data['currency_id']);$data['currency_id'] = $currency->id;}@@ -99,7 +98,7 @@ class AccountUpdateService// update note:if (array_key_exists('notes', $data) && null !== $data['notes']) {- $this->updateNote($account, (string) $data['notes']);+ $this->updateNote($account, (string)$data['notes']);}// update preferences if inactive:@@ -125,7 +124,7 @@ class AccountUpdateService$account->active = $data['active'];}if (array_key_exists('iban', $data)) {- $account->iban = Steam::filterSpaces((string) $data['iban']);+ $account->iban = Steam::filterSpaces((string)$data['iban']);}// set liability, but account must already be a liability.@@ -137,7 +136,7 @@ class AccountUpdateService// set liability, alternative method used in v1 layout:if ($this->isLiability($account) && array_key_exists('account_type_id', $data)) {- $type = AccountType::find((int) $data['account_type_id']);+ $type = AccountType::find((int)$data['account_type_id']);if (null !== $type && in_array($type->type, config('firefly.valid_liabilities'), true)) {$account->account_type_id = $type->id;@@ -175,7 +174,7 @@ class AccountUpdateServicereturn $account;}// skip if not of orderable type.- $type = $account->accountType->type;+ $type = $account->accountType->type;if (!in_array($type,[AccountTypeEnum::ASSET->value, AccountTypeEnum::MORTGAGE->value, AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value],@@ -186,10 +185,10 @@ class AccountUpdateServicereturn $account;}// get account type ID's because a join and an update is hard:- $oldOrder = $account->order;- $newOrder = $data['order'];+ $oldOrder = $account->order;+ $newOrder = $data['order'];Log::debug(sprintf('Order is set to be updated from %s to %s', $oldOrder, $newOrder));- $list = $this->getTypeIds([AccountTypeEnum::MORTGAGE->value, AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value]);+ $list = $this->getTypeIds([AccountTypeEnum::MORTGAGE->value, AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value]);if (AccountTypeEnum::ASSET->value === $type) {$list = $this->getTypeIds([AccountTypeEnum::ASSET->value]);}@@ -201,8 +200,7 @@ class AccountUpdateService->where('accounts.order', '>', $oldOrder)->where('accounts.id', '!=', $account->id)->whereIn('accounts.account_type_id', $list)- ->decrement('order')- ;+ ->decrement('order');$account->order = $newOrder;Log::debug(sprintf('Order of account #%d ("%s") is now %d', $account->id, $account->name, $newOrder));$account->save();@@ -216,8 +214,7 @@ class AccountUpdateService->where('accounts.order', '<', $oldOrder)->where('accounts.id', '!=', $account->id)->whereIn('accounts.account_type_id', $list)- ->increment('order')- ;+ ->increment('order');$account->order = $newOrder;Log::debug(sprintf('Order of account #%d ("%s") is now %d', $account->id, $account->name, $newOrder));$account->save();@@ -251,7 +248,7 @@ class AccountUpdateService// otherwise, update or create.if (!(null === $data['latitude'] && null === $data['longitude'] && null === $data['zoom_level'])) {- $location = $this->accountRepository->getLocation($account);+ $location = $this->accountRepository->getLocation($account);if (!$location instanceof Location) {$location = new Location();$location->locatable()->associate($account);@@ -302,11 +299,11 @@ class AccountUpdateServiceif (true === $account->active) {return;}- $preference = Preferences::getForUser($account->user, 'frontpageAccounts');+ $preference = Preferences::getForUser($account->user, 'frontpageAccounts');if (null === $preference) {return;}- $array = $preference->data;+ $array = $preference->data;if (!is_array($array)) {$array = [$array];}@@ -315,9 +312,9 @@ class AccountUpdateService$removeAccountId = $account->id;$new = [];foreach ($array as $value) {- if ((int) $value !== $removeAccountId) {+ if ((int)$value !== $removeAccountId) {Log::debug(sprintf('Will include: %d', $value));- $new[] = (int) $value;+ $new[] = (int)$value;}}Log::debug('Final new array is', $new);diff --git a/mago.toml b/mago.tomlindex e641346d84..2bfdbdc801 100644--- a/mago.toml+++ b/mago.toml@@ -17,6 +17,7 @@ method-chain-breaking-style = "same_line"preserve-breaking-array-like = falsealign-assignment-like = truenull-type-hint = "null_pipe"+sort-class-methods = true[linter]integrations = ["symfony", "laravel", "phpunit"]