From 71d53fbda494b1b6e4181f074386ed2dac896344 Mon Sep 17 00:00:00 2001 From: James Cole Date: Wed, 13 Apr 2022 16:23:02 +0200 Subject: [PATCH] Revert "Replace various enums" This reverts commit 089514908d415943de79c4b870665fa5a0120666. --- .../Autocomplete/AccountController.php | 5 ++- .../Controllers/Chart/AccountController.php | 4 +-- .../V1/Controllers/Data/DestroyController.php | 34 +++++++++---------- .../Controllers/Summary/BasicController.php | 3 +- .../Autocomplete/AutocompleteRequest.php | 3 +- .../V1/Requests/Data/Export/ExportRequest.php | 4 +-- .../V1/Requests/Insight/GenericRequest.php | 7 ++-- .../CorrectOpeningBalanceCurrencies.php | 3 +- .../Commands/Correction/FixAccountTypes.php | 26 +++++++------- .../Correction/FixFrontpageAccounts.php | 3 +- app/Console/Commands/Export/ExportData.php | 3 +- app/Console/Commands/Tools/ApplyRules.php | 4 +-- .../Commands/Upgrade/AccountCurrencies.php | 3 +- .../Commands/Upgrade/CCLiabilities.php | 5 ++- .../Upgrade/OtherCurrenciesCorrections.php | 14 ++++---- app/Factory/AccountFactory.php | 8 ++--- .../Controllers/Account/CreateController.php | 3 +- app/Http/Controllers/HomeController.php | 4 +-- app/Http/Controllers/JavascriptController.php | 4 +-- app/Http/Controllers/NewUserController.php | 4 +-- .../Controllers/PreferencesController.php | 6 ++-- app/Http/Controllers/ReportController.php | 6 ++-- 22 files changed, 69 insertions(+), 87 deletions(-) diff --git a/app/Api/V1/Controllers/Autocomplete/AccountController.php b/app/Api/V1/Controllers/Autocomplete/AccountController.php index b2ffbc7338..7fe5b418cf 100644 --- a/app/Api/V1/Controllers/Autocomplete/AccountController.php +++ b/app/Api/V1/Controllers/Autocomplete/AccountController.php @@ -25,7 +25,6 @@ namespace FireflyIII\Api\V1\Controllers\Autocomplete; use FireflyIII\Api\V1\Controllers\Controller; use FireflyIII\Api\V1\Requests\Autocomplete\AutocompleteRequest; -use FireflyIII\Enums\AccountTypeEnum; use FireflyIII\Exceptions\FireflyException; use FireflyIII\Models\Account; use FireflyIII\Models\AccountType; @@ -61,7 +60,7 @@ class AccountController extends Controller return $next($request); } ); - $this->balanceTypes = [AccountTypeEnum::ASSET, AccountTypeEnum::LOAN, AccountTypeEnum::DEBT, AccountTypeEnum::MORTGAGE,]; + $this->balanceTypes = [AccountType::ASSET, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE,]; } /** @@ -110,7 +109,7 @@ class AccountController extends Controller } // custom order. - $order = [AccountTypeEnum::ASSET, AccountTypeEnum::REVENUE, AccountTypeEnum::EXPENSE]; + $order = [AccountType::ASSET, AccountType::REVENUE, AccountType::EXPENSE]; usort( $return, function ($a, $b) use ($order) { $pos_a = array_search($a['type'], $order); diff --git a/app/Api/V1/Controllers/Chart/AccountController.php b/app/Api/V1/Controllers/Chart/AccountController.php index ccc8051ba6..264c1a97a0 100644 --- a/app/Api/V1/Controllers/Chart/AccountController.php +++ b/app/Api/V1/Controllers/Chart/AccountController.php @@ -27,9 +27,9 @@ namespace FireflyIII\Api\V1\Controllers\Chart; use Carbon\Carbon; use FireflyIII\Api\V1\Controllers\Controller; use FireflyIII\Api\V1\Requests\Data\DateRequest; -use FireflyIII\Enums\AccountTypeEnum; use FireflyIII\Exceptions\FireflyException; use FireflyIII\Models\Account; +use FireflyIII\Models\AccountType; use FireflyIII\Repositories\Account\AccountRepositoryInterface; use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface; use FireflyIII\Support\Http\Api\ApiSupport; @@ -94,7 +94,7 @@ class AccountController extends Controller $end = $dates['end']; // user's preferences - $defaultSet = $this->repository->getAccountsByType([AccountTypeEnum::ASSET])->pluck('id')->toArray(); + $defaultSet = $this->repository->getAccountsByType([AccountType::ASSET])->pluck('id')->toArray(); $frontPage = app('preferences')->get('frontPageAccounts', $defaultSet); $default = app('amount')->getDefaultCurrency(); diff --git a/app/Api/V1/Controllers/Data/DestroyController.php b/app/Api/V1/Controllers/Data/DestroyController.php index a70cdc2832..adba823dbc 100644 --- a/app/Api/V1/Controllers/Data/DestroyController.php +++ b/app/Api/V1/Controllers/Data/DestroyController.php @@ -25,8 +25,6 @@ namespace FireflyIII\Api\V1\Controllers\Data; use FireflyIII\Api\V1\Controllers\Controller; use FireflyIII\Api\V1\Requests\Data\DestroyRequest; -use FireflyIII\Enums\AccountTypeEnum; -use FireflyIII\Enums\TransactionTypeEnum; use FireflyIII\Exceptions\FireflyException; use FireflyIII\Models\Account; use FireflyIII\Models\AccountType; @@ -96,70 +94,70 @@ class DestroyController extends Controller case 'accounts': $this->destroyAccounts( [ - AccountTypeEnum::ASSET, AccountTypeEnum::DEFAULT, - AccountTypeEnum::BENEFICIARY, AccountTypeEnum::EXPENSE, - AccountTypeEnum::REVENUE, AccountTypeEnum::INITIAL_BALANCE, - AccountTypeEnum::DEBT, AccountTypeEnum::LOAN, AccountTypeEnum::MORTGAGE, AccountTypeEnum::CREDITCARD, + AccountType::ASSET, AccountType::DEFAULT, + AccountType::BENEFICIARY, AccountType::EXPENSE, + AccountType::REVENUE, AccountType::INITIAL_BALANCE, + AccountType::DEBT, AccountType::LOAN, AccountType::MORTGAGE, AccountType::CREDITCARD, ] ); break; case 'asset_accounts': $this->destroyAccounts( [ - AccountTypeEnum::ASSET, AccountTypeEnum::DEFAULT, + AccountType::ASSET, AccountType::DEFAULT, ] ); break; case 'expense_accounts': $this->destroyAccounts( [ - AccountTypeEnum::BENEFICIARY, AccountTypeEnum::EXPENSE, + AccountType::BENEFICIARY, AccountType::EXPENSE, ] ); break; case 'revenue_accounts': $this->destroyAccounts( [ - AccountTypeEnum::REVENUE, + AccountType::REVENUE, ] ); break; case 'liabilities': $this->destroyAccounts( [ - AccountTypeEnum::DEBT, AccountTypeEnum::LOAN, AccountTypeEnum::MORTGAGE, AccountTypeEnum::CREDITCARD, + AccountType::DEBT, AccountType::LOAN, AccountType::MORTGAGE, AccountType::CREDITCARD, ] ); break; case 'transactions': $this->destroyTransactions( [ - TransactionTypeEnum::WITHDRAWAL, - TransactionTypeEnum::DEPOSIT, - TransactionTypeEnum::TRANSFER, - TransactionTypeEnum::RECONCILIATION, - TransactionTypeEnum::OPENING_BALANCE, + TransactionType::WITHDRAWAL, + TransactionType::DEPOSIT, + TransactionType::TRANSFER, + TransactionType::RECONCILIATION, + TransactionType::OPENING_BALANCE, ] ); break; case 'withdrawals': $this->destroyTransactions( [ - TransactionTypeEnum::WITHDRAWAL, + TransactionType::WITHDRAWAL, ] ); break; case 'deposits': $this->destroyTransactions( [ - TransactionTypeEnum::DEPOSIT, + TransactionType::DEPOSIT, ] ); break; case 'transfers': $this->destroyTransactions( [ - TransactionTypeEnum::TRANSFER, + TransactionType::TRANSFER, ] ); break; diff --git a/app/Api/V1/Controllers/Summary/BasicController.php b/app/Api/V1/Controllers/Summary/BasicController.php index 7be8e19850..af1ad594f2 100644 --- a/app/Api/V1/Controllers/Summary/BasicController.php +++ b/app/Api/V1/Controllers/Summary/BasicController.php @@ -28,7 +28,6 @@ use Carbon\Carbon; use Exception; use FireflyIII\Api\V1\Controllers\Controller; use FireflyIII\Api\V1\Requests\Data\DateRequest; -use FireflyIII\Enums\AccountTypeEnum; use FireflyIII\Helpers\Collector\GroupCollectorInterface; use FireflyIII\Helpers\Report\NetWorthInterface; use FireflyIII\Models\Account; @@ -358,7 +357,7 @@ class BasicController extends Controller /** @var NetWorthInterface $netWorthHelper */ $netWorthHelper = app(NetWorthInterface::class); $netWorthHelper->setUser($user); - $allAccounts = $this->accountRepository->getActiveAccountsByType([AccountTypeEnum::ASSET, AccountTypeEnum::DEBT, AccountTypeEnum::LOAN, AccountTypeEnum::MORTGAGE]); + $allAccounts = $this->accountRepository->getActiveAccountsByType([AccountType::ASSET, AccountType::DEBT, AccountType::LOAN, AccountType::MORTGAGE]); // filter list on preference of being included. $filtered = $allAccounts->filter( diff --git a/app/Api/V1/Requests/Autocomplete/AutocompleteRequest.php b/app/Api/V1/Requests/Autocomplete/AutocompleteRequest.php index 58125dfb6d..be5ed5b0d8 100644 --- a/app/Api/V1/Requests/Autocomplete/AutocompleteRequest.php +++ b/app/Api/V1/Requests/Autocomplete/AutocompleteRequest.php @@ -23,7 +23,6 @@ declare(strict_types=1); namespace FireflyIII\Api\V1\Requests\Autocomplete; -use FireflyIII\Enums\AccountTypeEnum; use FireflyIII\Models\AccountType; use FireflyIII\Support\Request\ChecksLogin; use FireflyIII\Support\Request\ConvertsDataTypes; @@ -50,7 +49,7 @@ class AutocompleteRequest extends FormRequest $limit = 0 === $limit ? 10 : $limit; // remove 'initial balance' from allowed types. its internal - $array = array_diff($array, [AccountTypeEnum::INITIAL_BALANCE, AccountTypeEnum::RECONCILIATION]); + $array = array_diff($array, [AccountType::INITIAL_BALANCE, AccountType::RECONCILIATION]); return [ 'types' => $array, diff --git a/app/Api/V1/Requests/Data/Export/ExportRequest.php b/app/Api/V1/Requests/Data/Export/ExportRequest.php index d06b00f0b3..8d27d6c8ed 100644 --- a/app/Api/V1/Requests/Data/Export/ExportRequest.php +++ b/app/Api/V1/Requests/Data/Export/ExportRequest.php @@ -24,7 +24,7 @@ declare(strict_types=1); namespace FireflyIII\Api\V1\Requests\Data\Export; use Carbon\Carbon; -use FireflyIII\Enums\AccountTypeEnum; +use FireflyIII\Models\AccountType; use FireflyIII\Repositories\Account\AccountRepositoryInterface; use FireflyIII\Support\Request\ChecksLogin; use FireflyIII\Support\Request\ConvertsDataTypes; @@ -54,7 +54,7 @@ class ExportRequest extends FormRequest $accountId = (int) $part; if (0 !== $accountId) { $account = $repository->find($accountId); - if (null !== $account && AccountTypeEnum::ASSET === $account->accountType->type) { + if (null !== $account && AccountType::ASSET === $account->accountType->type) { $accounts->push($account); } } diff --git a/app/Api/V1/Requests/Insight/GenericRequest.php b/app/Api/V1/Requests/Insight/GenericRequest.php index 5f6b526ef4..5a10d23e7d 100644 --- a/app/Api/V1/Requests/Insight/GenericRequest.php +++ b/app/Api/V1/Requests/Insight/GenericRequest.php @@ -25,7 +25,6 @@ declare(strict_types=1); namespace FireflyIII\Api\V1\Requests\Insight; use Carbon\Carbon; -use FireflyIII\Enums\AccountTypeEnum; use FireflyIII\Models\Account; use FireflyIII\Models\AccountType; use FireflyIII\Repositories\Account\AccountRepositoryInterface; @@ -74,7 +73,7 @@ class GenericRequest extends FormRequest /** @var Account $account */ foreach ($this->accounts as $account) { $type = $account->accountType->type; - if (in_array($type, [AccountTypeEnum::ASSET, AccountTypeEnum::LOAN, AccountTypeEnum::DEBT, AccountTypeEnum::MORTGAGE])) { + if (in_array($type, [AccountType::ASSET, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE])) { $return->push($account); } } @@ -221,7 +220,7 @@ class GenericRequest extends FormRequest /** @var Account $account */ foreach ($this->accounts as $account) { $type = $account->accountType->type; - if ($type === AccountTypeEnum::EXPENSE) { + if ($type === AccountType::EXPENSE) { $return->push($account); } } @@ -239,7 +238,7 @@ class GenericRequest extends FormRequest /** @var Account $account */ foreach ($this->accounts as $account) { $type = $account->accountType->type; - if ($type === AccountTypeEnum::REVENUE) { + if ($type === AccountType::REVENUE) { $return->push($account); } } diff --git a/app/Console/Commands/Correction/CorrectOpeningBalanceCurrencies.php b/app/Console/Commands/Correction/CorrectOpeningBalanceCurrencies.php index 69b9fe7391..6c5fba45c9 100644 --- a/app/Console/Commands/Correction/CorrectOpeningBalanceCurrencies.php +++ b/app/Console/Commands/Correction/CorrectOpeningBalanceCurrencies.php @@ -24,7 +24,6 @@ declare(strict_types=1); namespace FireflyIII\Console\Commands\Correction; -use FireflyIII\Enums\AccountTypeEnum; use FireflyIII\Models\Account; use FireflyIII\Models\AccountType; use FireflyIII\Models\Transaction; @@ -125,7 +124,7 @@ class CorrectOpeningBalanceCurrencies extends Command foreach ($transactions as $transaction) { /** @var Account $account */ $account = $transaction->account()->first(); - if (null !== $account && AccountTypeEnum::INITIAL_BALANCE !== $account->accountType()->first()->type) { + if (null !== $account && AccountType::INITIAL_BALANCE !== $account->accountType()->first()->type) { return $account; } } diff --git a/app/Console/Commands/Correction/FixAccountTypes.php b/app/Console/Commands/Correction/FixAccountTypes.php index 4aa84c2767..048c32d9b5 100644 --- a/app/Console/Commands/Correction/FixAccountTypes.php +++ b/app/Console/Commands/Correction/FixAccountTypes.php @@ -23,8 +23,6 @@ declare(strict_types=1); namespace FireflyIII\Console\Commands\Correction; -use FireflyIII\Enums\AccountTypeEnum; -use FireflyIII\Enums\TransactionTypeEnum; use FireflyIII\Exceptions\FireflyException; use FireflyIII\Factory\AccountFactory; use FireflyIII\Models\AccountType; @@ -178,11 +176,11 @@ class FixAccountTypes extends Command $combination = sprintf('%s%s%s', $type, $source->account->accountType->type, $dest->account->accountType->type); switch ($combination) { - case sprintf('%s%s%s', TransactionTypeEnum::TRANSFER, AccountTypeEnum::ASSET, AccountTypeEnum::LOAN): - case sprintf('%s%s%s', TransactionTypeEnum::TRANSFER, AccountTypeEnum::ASSET, AccountTypeEnum::DEBT): - case sprintf('%s%s%s', TransactionTypeEnum::TRANSFER, AccountTypeEnum::ASSET, AccountTypeEnum::MORTGAGE): + case sprintf('%s%s%s', TransactionType::TRANSFER, AccountType::ASSET, AccountType::LOAN): + case sprintf('%s%s%s', TransactionType::TRANSFER, AccountType::ASSET, AccountType::DEBT): + case sprintf('%s%s%s', TransactionType::TRANSFER, AccountType::ASSET, AccountType::MORTGAGE): // from an asset to a liability should be a withdrawal: - $withdrawal = TransactionType::whereType(TransactionTypeEnum::WITHDRAWAL)->first(); + $withdrawal = TransactionType::whereType(TransactionType::WITHDRAWAL)->first(); $journal->transactionType()->associate($withdrawal); $journal->save(); $message = sprintf('Converted transaction #%d from a transfer to a withdrawal.', $journal->id); @@ -191,11 +189,11 @@ class FixAccountTypes extends Command // check it again: $this->inspectJournal($journal); break; - case sprintf('%s%s%s', TransactionTypeEnum::TRANSFER, AccountTypeEnum::LOAN, AccountTypeEnum::ASSET): - case sprintf('%s%s%s', TransactionTypeEnum::TRANSFER, AccountTypeEnum::DEBT, AccountTypeEnum::ASSET): - case sprintf('%s%s%s', TransactionTypeEnum::TRANSFER, AccountTypeEnum::MORTGAGE, AccountTypeEnum::ASSET): + case sprintf('%s%s%s', TransactionType::TRANSFER, AccountType::LOAN, AccountType::ASSET): + case sprintf('%s%s%s', TransactionType::TRANSFER, AccountType::DEBT, AccountType::ASSET): + case sprintf('%s%s%s', TransactionType::TRANSFER, AccountType::MORTGAGE, AccountType::ASSET): // from a liability to an asset should be a deposit. - $deposit = TransactionType::whereType(TransactionTypeEnum::DEPOSIT)->first(); + $deposit = TransactionType::whereType(TransactionType::DEPOSIT)->first(); $journal->transactionType()->associate($deposit); $journal->save(); $message = sprintf('Converted transaction #%d from a transfer to a deposit.', $journal->id); @@ -205,11 +203,11 @@ class FixAccountTypes extends Command $this->inspectJournal($journal); break; - case sprintf('%s%s%s', TransactionTypeEnum::WITHDRAWAL, AccountTypeEnum::ASSET, AccountTypeEnum::REVENUE): + case sprintf('%s%s%s', TransactionType::WITHDRAWAL, AccountType::ASSET, AccountType::REVENUE): // withdrawals with a revenue account as destination instead of an expense account. $this->factory->setUser($journal->user); $oldDest = $dest->account; - $result = $this->factory->findOrCreate($dest->account->name, AccountTypeEnum::EXPENSE); + $result = $this->factory->findOrCreate($dest->account->name, AccountType::EXPENSE); $dest->account()->associate($result); $dest->save(); $message = sprintf( @@ -220,11 +218,11 @@ class FixAccountTypes extends Command Log::debug($message); $this->inspectJournal($journal); break; - case sprintf('%s%s%s', TransactionTypeEnum::DEPOSIT, AccountTypeEnum::EXPENSE, AccountTypeEnum::ASSET): + case sprintf('%s%s%s', TransactionType::DEPOSIT, AccountType::EXPENSE, AccountType::ASSET): // deposits with an expense account as source instead of a revenue account. // find revenue account. $this->factory->setUser($journal->user); - $result = $this->factory->findOrCreate($source->account->name, AccountTypeEnum::REVENUE); + $result = $this->factory->findOrCreate($source->account->name, AccountType::REVENUE); $oldSource = $dest->account; $source->account()->associate($result); $source->save(); diff --git a/app/Console/Commands/Correction/FixFrontpageAccounts.php b/app/Console/Commands/Correction/FixFrontpageAccounts.php index f5982fcb71..64372c7db4 100644 --- a/app/Console/Commands/Correction/FixFrontpageAccounts.php +++ b/app/Console/Commands/Correction/FixFrontpageAccounts.php @@ -24,7 +24,6 @@ declare(strict_types=1); namespace FireflyIII\Console\Commands\Correction; -use FireflyIII\Enums\TransactionTypeEnum; use FireflyIII\Models\AccountType; use FireflyIII\Models\Preference; use FireflyIII\Repositories\Account\AccountRepositoryInterface; @@ -92,7 +91,7 @@ class FixFrontpageAccounts extends Command $accountIdInt = (int) $accountId; $account = $repository->find($accountIdInt); if (null !== $account - && in_array($account->accountType->type, [AccountTypeEnum::ASSET, AccountTypeEnum::DEBT, AccountTypeEnum::LOAN, AccountTypeEnum::MORTGAGE], true) + && in_array($account->accountType->type, [AccountType::ASSET, AccountType::DEBT, AccountType::LOAN, AccountType::MORTGAGE], true) && true === $account->active) { $fixed[] = $account->id; } diff --git a/app/Console/Commands/Export/ExportData.php b/app/Console/Commands/Export/ExportData.php index 0a889ddf44..7aea9a3df4 100644 --- a/app/Console/Commands/Export/ExportData.php +++ b/app/Console/Commands/Export/ExportData.php @@ -27,7 +27,6 @@ namespace FireflyIII\Console\Commands\Export; use Carbon\Carbon; use Exception; use FireflyIII\Console\Commands\VerifiesAccessToken; -use FireflyIII\Enums\TransactionTypeEnum; use FireflyIII\Exceptions\FireflyException; use FireflyIII\Models\Account; use FireflyIII\Models\AccountType; @@ -234,7 +233,7 @@ class ExportData extends Command $final = new Collection; $accounts = new Collection; $accountList = $this->option('accounts'); - $types = [AccountTypeEnum::ASSET, AccountTypeEnum::LOAN, AccountTypeEnum::DEBT, AccountTypeEnum::MORTGAGE]; + $types = [AccountType::ASSET, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE]; if (null !== $accountList && '' !== (string) $accountList) { $accountIds = explode(',', $accountList); $accounts = $this->accountRepository->getAccountsById($accountIds); diff --git a/app/Console/Commands/Tools/ApplyRules.php b/app/Console/Commands/Tools/ApplyRules.php index e5d5371862..0e4cf33cfb 100644 --- a/app/Console/Commands/Tools/ApplyRules.php +++ b/app/Console/Commands/Tools/ApplyRules.php @@ -25,8 +25,6 @@ namespace FireflyIII\Console\Commands\Tools; use Carbon\Carbon; use FireflyIII\Console\Commands\VerifiesAccessToken; -use FireflyIII\Enums\AccountTypeEnum; -use FireflyIII\Enums\TransactionTypeEnum; use FireflyIII\Exceptions\FireflyException; use FireflyIII\Models\AccountType; use FireflyIII\Models\Rule; @@ -168,7 +166,7 @@ class ApplyRules extends Command $this->ruleGroupSelection = []; $this->ruleRepository = app(RuleRepositoryInterface::class); $this->ruleGroupRepository = app(RuleGroupRepositoryInterface::class); - $this->acceptedAccounts = [AccountTypeEnum::DEFAULT, AccountTypeEnum::DEBT, AccountTypeEnum::ASSET, AccountTypeEnum::LOAN, AccountTypeEnum::MORTGAGE]; + $this->acceptedAccounts = [AccountType::DEFAULT, AccountType::DEBT, AccountType::ASSET, AccountType::LOAN, AccountType::MORTGAGE]; $this->groups = new Collection; } diff --git a/app/Console/Commands/Upgrade/AccountCurrencies.php b/app/Console/Commands/Upgrade/AccountCurrencies.php index 0909fa4fc8..617fe579ad 100644 --- a/app/Console/Commands/Upgrade/AccountCurrencies.php +++ b/app/Console/Commands/Upgrade/AccountCurrencies.php @@ -26,6 +26,7 @@ namespace FireflyIII\Console\Commands\Upgrade; use FireflyIII\Exceptions\FireflyException; use FireflyIII\Models\Account; use FireflyIII\Models\AccountMeta; +use FireflyIII\Models\AccountType; use FireflyIII\Models\Transaction; use FireflyIII\Models\TransactionCurrency; use FireflyIII\Repositories\Account\AccountRepositoryInterface; @@ -145,7 +146,7 @@ class AccountCurrencies extends Command { Log::debug(sprintf('Now in updateCurrenciesForUser(%s, %s)', $user->email, $systemCurrencyCode)); $this->accountRepos->setUser($user); - $accounts = $this->accountRepos->getAccountsByType([AccountTypeEnum::DEFAULT, AccountTypeEnum::ASSET]); + $accounts = $this->accountRepos->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]); // get user's currency preference: $defaultCurrencyCode = app('preferences')->getForUser($user, 'currencyPreference', $systemCurrencyCode)->data; diff --git a/app/Console/Commands/Upgrade/CCLiabilities.php b/app/Console/Commands/Upgrade/CCLiabilities.php index 06bdb483f3..d28dc36860 100644 --- a/app/Console/Commands/Upgrade/CCLiabilities.php +++ b/app/Console/Commands/Upgrade/CCLiabilities.php @@ -23,7 +23,6 @@ declare(strict_types=1); namespace FireflyIII\Console\Commands\Upgrade; -use FireflyIII\Enums\TransactionTypeEnum; use FireflyIII\Exceptions\FireflyException; use FireflyIII\Models\Account; use FireflyIII\Models\AccountType; @@ -67,8 +66,8 @@ class CCLiabilities extends Command } - $ccType = AccountType::where('type', AccountTypeEnum::CREDITCARD)->first(); - $debtType = AccountType::where('type', AccountTypeEnum::DEBT)->first(); + $ccType = AccountType::where('type', AccountType::CREDITCARD)->first(); + $debtType = AccountType::where('type', AccountType::DEBT)->first(); if (null === $ccType || null === $debtType) { $this->info('No incorrectly stored credit card liabilities.'); diff --git a/app/Console/Commands/Upgrade/OtherCurrenciesCorrections.php b/app/Console/Commands/Upgrade/OtherCurrenciesCorrections.php index ee50ecdbc6..4dbe770611 100644 --- a/app/Console/Commands/Upgrade/OtherCurrenciesCorrections.php +++ b/app/Console/Commands/Upgrade/OtherCurrenciesCorrections.php @@ -23,8 +23,6 @@ declare(strict_types=1); namespace FireflyIII\Console\Commands\Upgrade; -use FireflyIII\Enums\AccountTypeEnum; -use FireflyIII\Enums\TransactionTypeEnum; use FireflyIII\Exceptions\FireflyException; use FireflyIII\Models\Account; use FireflyIII\Models\AccountType; @@ -220,23 +218,23 @@ class OtherCurrenciesCorrections extends Command switch ($journal->transactionType->type) { default: break; - case TransactionTypeEnum::WITHDRAWAL: + case TransactionType::WITHDRAWAL: $lead = $journal->transactions()->where('amount', '<', 0)->first(); break; - case TransactionTypeEnum::DEPOSIT: + case TransactionType::DEPOSIT: $lead = $journal->transactions()->where('amount', '>', 0)->first(); break; - case TransactionTypeEnum::OPENING_BALANCE: + case TransactionType::OPENING_BALANCE: // whichever isn't an initial balance account: $lead = $journal->transactions()->leftJoin('accounts', 'transactions.account_id', '=', 'accounts.id')->leftJoin( 'account_types', 'accounts.account_type_id', '=', 'account_types.id' - )->where('account_types.type', '!=', AccountTypeEnum::INITIAL_BALANCE)->first(['transactions.*']); + )->where('account_types.type', '!=', AccountType::INITIAL_BALANCE)->first(['transactions.*']); break; - case TransactionTypeEnum::RECONCILIATION: + case TransactionType::RECONCILIATION: // whichever isn't the reconciliation account: $lead = $journal->transactions()->leftJoin('accounts', 'transactions.account_id', '=', 'accounts.id')->leftJoin( 'account_types', 'accounts.account_type_id', '=', 'account_types.id' - )->where('account_types.type', '!=', AccountTypeEnum::RECONCILIATION)->first(['transactions.*']); + )->where('account_types.type', '!=', AccountType::RECONCILIATION)->first(['transactions.*']); break; } diff --git a/app/Factory/AccountFactory.php b/app/Factory/AccountFactory.php index acee072837..2307f93b10 100644 --- a/app/Factory/AccountFactory.php +++ b/app/Factory/AccountFactory.php @@ -24,8 +24,6 @@ declare(strict_types=1); namespace FireflyIII\Factory; -use FireflyIII\Enums\AccountTypeEnum; -use FireflyIII\Enums\TransactionTypeEnum; use FireflyIII\Events\StoredAccount; use FireflyIII\Exceptions\FireflyException; use FireflyIII\Models\Account; @@ -262,7 +260,7 @@ class AccountFactory $currency = $this->getCurrency($currencyId, $currencyCode); // only asset account may have a role: - if ($account->accountType->type !== AccountTypeEnum::ASSET) { + if ($account->accountType->type !== AccountType::ASSET) { $accountRole = ''; } // only liability may have direction: @@ -283,10 +281,10 @@ class AccountFactory { $fields = $this->validFields; - if ($account->accountType->type === AccountTypeEnum::ASSET) { + if ($account->accountType->type === AccountType::ASSET) { $fields = $this->validAssetFields; } - if ($account->accountType->type === AccountTypeEnum::ASSET && 'ccAsset' === $data['account_role']) { + if ($account->accountType->type === AccountType::ASSET && 'ccAsset' === $data['account_role']) { $fields = $this->validCCFields; } diff --git a/app/Http/Controllers/Account/CreateController.php b/app/Http/Controllers/Account/CreateController.php index b055869773..9a6d8c9e5e 100644 --- a/app/Http/Controllers/Account/CreateController.php +++ b/app/Http/Controllers/Account/CreateController.php @@ -23,7 +23,6 @@ declare(strict_types=1); namespace FireflyIII\Http\Controllers\Account; -use FireflyIII\Enums\AccountTypeEnum; use FireflyIII\Exceptions\FireflyException; use FireflyIII\Helpers\Attachments\AttachmentHelperInterface; use FireflyIII\Http\Controllers\Controller; @@ -152,7 +151,7 @@ class CreateController extends Controller // update preferences if necessary: $frontPage = app('preferences')->get('frontPageAccounts', [])->data; - if (AccountTypeEnum::ASSET === $account->accountType->type) { + if (AccountType::ASSET === $account->accountType->type) { $frontPage[] = $account->id; app('preferences')->set('frontPageAccounts', $frontPage); } diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index e9c0cdf0a5..07e635b5d8 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -24,10 +24,10 @@ namespace FireflyIII\Http\Controllers; use Carbon\Carbon; use Exception; -use FireflyIII\Enums\AccountTypeEnum; use FireflyIII\Events\RequestedVersionCheckStatus; use FireflyIII\Helpers\Collector\GroupCollectorInterface; use FireflyIII\Http\Middleware\Installer; +use FireflyIII\Models\AccountType; use FireflyIII\Repositories\Account\AccountRepositoryInterface; use FireflyIII\Repositories\Bill\BillRepositoryInterface; use FireflyIII\User; @@ -115,7 +115,7 @@ class HomeController extends Controller } $subTitle = (string) trans('firefly.welcome_back'); $transactions = []; - $frontPage = app('preferences')->getFresh('frontPageAccounts', $repository->getAccountsByType([AccountTypeEnum::ASSET])->pluck('id')->toArray()); + $frontPage = app('preferences')->getFresh('frontPageAccounts', $repository->getAccountsByType([AccountType::ASSET])->pluck('id')->toArray()); /** @var Carbon $start */ $start = session('start', Carbon::now()->startOfMonth()); /** @var Carbon $end */ diff --git a/app/Http/Controllers/JavascriptController.php b/app/Http/Controllers/JavascriptController.php index 5c114fbfda..72d37453bd 100644 --- a/app/Http/Controllers/JavascriptController.php +++ b/app/Http/Controllers/JavascriptController.php @@ -23,9 +23,9 @@ declare(strict_types=1); namespace FireflyIII\Http\Controllers; use Carbon\Carbon; -use FireflyIII\Enums\AccountTypeEnum; use FireflyIII\Exceptions\FireflyException; use FireflyIII\Models\Account; +use FireflyIII\Models\AccountType; use FireflyIII\Models\TransactionCurrency; use FireflyIII\Repositories\Account\AccountRepositoryInterface; use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface; @@ -54,7 +54,7 @@ class JavascriptController extends Controller public function accounts(AccountRepositoryInterface $repository, CurrencyRepositoryInterface $currencyRepository): Response { $accounts = $repository->getAccountsByType( - [AccountTypeEnum::DEFAULT, AccountTypeEnum::ASSET, AccountTypeEnum::DEBT, AccountTypeEnum::LOAN, AccountTypeEnum::MORTGAGE, AccountTypeEnum::CREDITCARD] + [AccountType::DEFAULT, AccountType::ASSET, AccountType::DEBT, AccountType::LOAN, AccountType::MORTGAGE, AccountType::CREDITCARD] ); $preference = app('preferences')->get('currencyPreference', config('firefly.default_currency', 'EUR')); /** @noinspection NullPointerExceptionInspection */ diff --git a/app/Http/Controllers/NewUserController.php b/app/Http/Controllers/NewUserController.php index 77fe6e7e73..4bd8c84a9e 100644 --- a/app/Http/Controllers/NewUserController.php +++ b/app/Http/Controllers/NewUserController.php @@ -22,9 +22,9 @@ declare(strict_types=1); namespace FireflyIII\Http\Controllers; -use FireflyIII\Enums\AccountTypeEnum; use FireflyIII\Exceptions\FireflyException; use FireflyIII\Http\Requests\NewUserFormRequest; +use FireflyIII\Models\AccountType; use FireflyIII\Repositories\Account\AccountRepositoryInterface; use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface; use FireflyIII\Support\Http\Controllers\CreateStuff; @@ -117,7 +117,7 @@ class NewUserController extends Controller app('preferences')->set('currencyPreference', $currency->code); // store frontpage preferences: - $accounts = $this->repository->getAccountsByType([AccountTypeEnum::ASSET])->pluck('id')->toArray(); + $accounts = $this->repository->getAccountsByType([AccountType::ASSET])->pluck('id')->toArray(); app('preferences')->set('frontPageAccounts', $accounts); // mark. diff --git a/app/Http/Controllers/PreferencesController.php b/app/Http/Controllers/PreferencesController.php index ed7455dd3f..737ad506bc 100644 --- a/app/Http/Controllers/PreferencesController.php +++ b/app/Http/Controllers/PreferencesController.php @@ -22,9 +22,9 @@ declare(strict_types=1); namespace FireflyIII\Http\Controllers; -use FireflyIII\Enums\AccountTypeEnum; use FireflyIII\Exceptions\FireflyException; use FireflyIII\Models\Account; +use FireflyIII\Models\AccountType; use FireflyIII\Models\Preference; use FireflyIII\Repositories\Account\AccountRepositoryInterface; use Illuminate\Contracts\View\Factory; @@ -71,7 +71,7 @@ class PreferencesController extends Controller */ public function index(AccountRepositoryInterface $repository) { - $accounts = $repository->getAccountsByType([AccountTypeEnum::DEFAULT, AccountTypeEnum::ASSET, AccountTypeEnum::LOAN, AccountTypeEnum::DEBT, AccountTypeEnum::MORTGAGE]); + $accounts = $repository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE]); $isDocker = env('IS_DOCKER', false); // group accounts @@ -81,7 +81,7 @@ class PreferencesController extends Controller $type = $account->accountType->type; $role = sprintf('opt_group_%s', $repository->getMetaValue($account, 'account_role')); - if (in_array($type, [AccountTypeEnum::MORTGAGE, AccountTypeEnum::DEBT, AccountTypeEnum::LOAN], true)) { + if (in_array($type, [AccountType::MORTGAGE, AccountType::DEBT, AccountType::LOAN], true)) { $role = sprintf('opt_group_l_%s', $type); } diff --git a/app/Http/Controllers/ReportController.php b/app/Http/Controllers/ReportController.php index 561e05e97b..f964375e52 100644 --- a/app/Http/Controllers/ReportController.php +++ b/app/Http/Controllers/ReportController.php @@ -24,12 +24,12 @@ declare(strict_types=1); namespace FireflyIII\Http\Controllers; use Carbon\Carbon; -use FireflyIII\Enums\AccountTypeEnum; use FireflyIII\Exceptions\FireflyException; use FireflyIII\Generator\Report\ReportGeneratorFactory; use FireflyIII\Helpers\Report\ReportHelperInterface; use FireflyIII\Http\Requests\ReportFormRequest; use FireflyIII\Models\Account; +use FireflyIII\Models\AccountType; use FireflyIII\Repositories\Account\AccountRepositoryInterface; use FireflyIII\Repositories\Budget\BudgetRepositoryInterface; use FireflyIII\Support\Http\Controllers\RenderPartialViews; @@ -272,7 +272,7 @@ class ReportController extends Controller $months = $this->helper->listOfMonths($start); $customFiscalYear = app('preferences')->get('customFiscalYear', 0)->data; $accounts = $repository->getAccountsByType( - [AccountTypeEnum::DEFAULT, AccountTypeEnum::ASSET, AccountTypeEnum::DEBT, AccountTypeEnum::LOAN, AccountTypeEnum::MORTGAGE] + [AccountType::DEFAULT, AccountType::ASSET, AccountType::DEBT, AccountType::LOAN, AccountType::MORTGAGE] ); // group accounts by role: @@ -282,7 +282,7 @@ class ReportController extends Controller $type = $account->accountType->type; $role = sprintf('opt_group_%s', $repository->getMetaValue($account, 'account_role')); - if (in_array($type, [AccountTypeEnum::MORTGAGE, AccountTypeEnum::DEBT, AccountTypeEnum::LOAN], true)) { + if (in_array($type, [AccountType::MORTGAGE, AccountType::DEBT, AccountType::LOAN], true)) { $role = sprintf('opt_group_l_%s', $type); }