Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Replace various enums
James Cole089514908d41
diff --git a/app/Api/V1/Controllers/Autocomplete/AccountController.php b/app/Api/V1/Controllers/Autocomplete/AccountController.phpindex 7fe5b418cf..b2ffbc7338 100644--- a/app/Api/V1/Controllers/Autocomplete/AccountController.php+++ b/app/Api/V1/Controllers/Autocomplete/AccountController.php@@ -25,6 +25,7 @@ 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;@@ -60,7 +61,7 @@ class AccountController extends Controllerreturn $next($request);});- $this->balanceTypes = [AccountType::ASSET, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE,];+ $this->balanceTypes = [AccountTypeEnum::ASSET, AccountTypeEnum::LOAN, AccountTypeEnum::DEBT, AccountTypeEnum::MORTGAGE,];}/**@@ -109,7 +110,7 @@ class AccountController extends Controller}// custom order.- $order = [AccountType::ASSET, AccountType::REVENUE, AccountType::EXPENSE];+ $order = [AccountTypeEnum::ASSET, AccountTypeEnum::REVENUE, AccountTypeEnum::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.phpindex 264c1a97a0..ccc8051ba6 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([AccountType::ASSET])->pluck('id')->toArray();+ $defaultSet = $this->repository->getAccountsByType([AccountTypeEnum::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.phpindex adba823dbc..a70cdc2832 100644--- a/app/Api/V1/Controllers/Data/DestroyController.php+++ b/app/Api/V1/Controllers/Data/DestroyController.php@@ -25,6 +25,8 @@ 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;@@ -94,70 +96,70 @@ class DestroyController extends Controllercase 'accounts':$this->destroyAccounts([- AccountType::ASSET, AccountType::DEFAULT,- AccountType::BENEFICIARY, AccountType::EXPENSE,- AccountType::REVENUE, AccountType::INITIAL_BALANCE,- AccountType::DEBT, AccountType::LOAN, AccountType::MORTGAGE, AccountType::CREDITCARD,+ AccountTypeEnum::ASSET, AccountTypeEnum::DEFAULT,+ AccountTypeEnum::BENEFICIARY, AccountTypeEnum::EXPENSE,+ AccountTypeEnum::REVENUE, AccountTypeEnum::INITIAL_BALANCE,+ AccountTypeEnum::DEBT, AccountTypeEnum::LOAN, AccountTypeEnum::MORTGAGE, AccountTypeEnum::CREDITCARD,]);break;case 'asset_accounts':$this->destroyAccounts([- AccountType::ASSET, AccountType::DEFAULT,+ AccountTypeEnum::ASSET, AccountTypeEnum::DEFAULT,]);break;case 'expense_accounts':$this->destroyAccounts([- AccountType::BENEFICIARY, AccountType::EXPENSE,+ AccountTypeEnum::BENEFICIARY, AccountTypeEnum::EXPENSE,]);break;case 'revenue_accounts':$this->destroyAccounts([- AccountType::REVENUE,+ AccountTypeEnum::REVENUE,]);break;case 'liabilities':$this->destroyAccounts([- AccountType::DEBT, AccountType::LOAN, AccountType::MORTGAGE, AccountType::CREDITCARD,+ AccountTypeEnum::DEBT, AccountTypeEnum::LOAN, AccountTypeEnum::MORTGAGE, AccountTypeEnum::CREDITCARD,]);break;case 'transactions':$this->destroyTransactions([- TransactionType::WITHDRAWAL,- TransactionType::DEPOSIT,- TransactionType::TRANSFER,- TransactionType::RECONCILIATION,- TransactionType::OPENING_BALANCE,+ TransactionTypeEnum::WITHDRAWAL,+ TransactionTypeEnum::DEPOSIT,+ TransactionTypeEnum::TRANSFER,+ TransactionTypeEnum::RECONCILIATION,+ TransactionTypeEnum::OPENING_BALANCE,]);break;case 'withdrawals':$this->destroyTransactions([- TransactionType::WITHDRAWAL,+ TransactionTypeEnum::WITHDRAWAL,]);break;case 'deposits':$this->destroyTransactions([- TransactionType::DEPOSIT,+ TransactionTypeEnum::DEPOSIT,]);break;case 'transfers':$this->destroyTransactions([- TransactionType::TRANSFER,+ TransactionTypeEnum::TRANSFER,]);break;diff --git a/app/Api/V1/Controllers/Summary/BasicController.php b/app/Api/V1/Controllers/Summary/BasicController.phpindex af1ad594f2..7be8e19850 100644--- a/app/Api/V1/Controllers/Summary/BasicController.php+++ b/app/Api/V1/Controllers/Summary/BasicController.php@@ -28,6 +28,7 @@ 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;@@ -357,7 +358,7 @@ class BasicController extends Controller/** @var NetWorthInterface $netWorthHelper */$netWorthHelper = app(NetWorthInterface::class);$netWorthHelper->setUser($user);- $allAccounts = $this->accountRepository->getActiveAccountsByType([AccountType::ASSET, AccountType::DEBT, AccountType::LOAN, AccountType::MORTGAGE]);+ $allAccounts = $this->accountRepository->getActiveAccountsByType([AccountTypeEnum::ASSET, AccountTypeEnum::DEBT, AccountTypeEnum::LOAN, AccountTypeEnum::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.phpindex be5ed5b0d8..58125dfb6d 100644--- a/app/Api/V1/Requests/Autocomplete/AutocompleteRequest.php+++ b/app/Api/V1/Requests/Autocomplete/AutocompleteRequest.php@@ -23,6 +23,7 @@ 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;@@ -49,7 +50,7 @@ class AutocompleteRequest extends FormRequest$limit = 0 === $limit ? 10 : $limit;// remove 'initial balance' from allowed types. its internal- $array = array_diff($array, [AccountType::INITIAL_BALANCE, AccountType::RECONCILIATION]);+ $array = array_diff($array, [AccountTypeEnum::INITIAL_BALANCE, AccountTypeEnum::RECONCILIATION]);return ['types' => $array,diff --git a/app/Api/V1/Requests/Data/Export/ExportRequest.php b/app/Api/V1/Requests/Data/Export/ExportRequest.phpindex 8d27d6c8ed..d06b00f0b3 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\Models\AccountType;+use FireflyIII\Enums\AccountTypeEnum;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 && AccountType::ASSET === $account->accountType->type) {+ if (null !== $account && AccountTypeEnum::ASSET === $account->accountType->type) {$accounts->push($account);}}diff --git a/app/Api/V1/Requests/Insight/GenericRequest.php b/app/Api/V1/Requests/Insight/GenericRequest.phpindex 5a10d23e7d..5f6b526ef4 100644--- a/app/Api/V1/Requests/Insight/GenericRequest.php+++ b/app/Api/V1/Requests/Insight/GenericRequest.php@@ -25,6 +25,7 @@ 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;@@ -73,7 +74,7 @@ class GenericRequest extends FormRequest/** @var Account $account */foreach ($this->accounts as $account) {$type = $account->accountType->type;- if (in_array($type, [AccountType::ASSET, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE])) {+ if (in_array($type, [AccountTypeEnum::ASSET, AccountTypeEnum::LOAN, AccountTypeEnum::DEBT, AccountTypeEnum::MORTGAGE])) {$return->push($account);}}@@ -220,7 +221,7 @@ class GenericRequest extends FormRequest/** @var Account $account */foreach ($this->accounts as $account) {$type = $account->accountType->type;- if ($type === AccountType::EXPENSE) {+ if ($type === AccountTypeEnum::EXPENSE) {$return->push($account);}}@@ -238,7 +239,7 @@ class GenericRequest extends FormRequest/** @var Account $account */foreach ($this->accounts as $account) {$type = $account->accountType->type;- if ($type === AccountType::REVENUE) {+ if ($type === AccountTypeEnum::REVENUE) {$return->push($account);}}diff --git a/app/Console/Commands/Correction/CorrectOpeningBalanceCurrencies.php b/app/Console/Commands/Correction/CorrectOpeningBalanceCurrencies.phpindex 6c5fba45c9..69b9fe7391 100644--- a/app/Console/Commands/Correction/CorrectOpeningBalanceCurrencies.php+++ b/app/Console/Commands/Correction/CorrectOpeningBalanceCurrencies.php@@ -24,6 +24,7 @@ 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;@@ -124,7 +125,7 @@ class CorrectOpeningBalanceCurrencies extends Commandforeach ($transactions as $transaction) {/** @var Account $account */$account = $transaction->account()->first();- if (null !== $account && AccountType::INITIAL_BALANCE !== $account->accountType()->first()->type) {+ if (null !== $account && AccountTypeEnum::INITIAL_BALANCE !== $account->accountType()->first()->type) {return $account;}}diff --git a/app/Console/Commands/Correction/FixAccountTypes.php b/app/Console/Commands/Correction/FixAccountTypes.phpindex 048c32d9b5..4aa84c2767 100644--- a/app/Console/Commands/Correction/FixAccountTypes.php+++ b/app/Console/Commands/Correction/FixAccountTypes.php@@ -23,6 +23,8 @@ 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;@@ -176,11 +178,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', 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):+ 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):// from an asset to a liability should be a withdrawal:- $withdrawal = TransactionType::whereType(TransactionType::WITHDRAWAL)->first();+ $withdrawal = TransactionType::whereType(TransactionTypeEnum::WITHDRAWAL)->first();$journal->transactionType()->associate($withdrawal);$journal->save();$message = sprintf('Converted transaction #%d from a transfer to a withdrawal.', $journal->id);@@ -189,11 +191,11 @@ class FixAccountTypes extends Command// check it again:$this->inspectJournal($journal);break;- 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):+ 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):// from a liability to an asset should be a deposit.- $deposit = TransactionType::whereType(TransactionType::DEPOSIT)->first();+ $deposit = TransactionType::whereType(TransactionTypeEnum::DEPOSIT)->first();$journal->transactionType()->associate($deposit);$journal->save();$message = sprintf('Converted transaction #%d from a transfer to a deposit.', $journal->id);@@ -203,11 +205,11 @@ class FixAccountTypes extends Command$this->inspectJournal($journal);break;- case sprintf('%s%s%s', TransactionType::WITHDRAWAL, AccountType::ASSET, AccountType::REVENUE):+ case sprintf('%s%s%s', TransactionTypeEnum::WITHDRAWAL, AccountTypeEnum::ASSET, AccountTypeEnum::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, AccountType::EXPENSE);+ $result = $this->factory->findOrCreate($dest->account->name, AccountTypeEnum::EXPENSE);$dest->account()->associate($result);$dest->save();$message = sprintf(@@ -218,11 +220,11 @@ class FixAccountTypes extends CommandLog::debug($message);$this->inspectJournal($journal);break;- case sprintf('%s%s%s', TransactionType::DEPOSIT, AccountType::EXPENSE, AccountType::ASSET):+ case sprintf('%s%s%s', TransactionTypeEnum::DEPOSIT, AccountTypeEnum::EXPENSE, AccountTypeEnum::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, AccountType::REVENUE);+ $result = $this->factory->findOrCreate($source->account->name, AccountTypeEnum::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.phpindex 64372c7db4..f5982fcb71 100644--- a/app/Console/Commands/Correction/FixFrontpageAccounts.php+++ b/app/Console/Commands/Correction/FixFrontpageAccounts.php@@ -24,6 +24,7 @@ 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;@@ -91,7 +92,7 @@ class FixFrontpageAccounts extends Command$accountIdInt = (int) $accountId;$account = $repository->find($accountIdInt);if (null !== $account- && in_array($account->accountType->type, [AccountType::ASSET, AccountType::DEBT, AccountType::LOAN, AccountType::MORTGAGE], true)+ && in_array($account->accountType->type, [AccountTypeEnum::ASSET, AccountTypeEnum::DEBT, AccountTypeEnum::LOAN, AccountTypeEnum::MORTGAGE], true)&& true === $account->active) {$fixed[] = $account->id;}diff --git a/app/Console/Commands/Export/ExportData.php b/app/Console/Commands/Export/ExportData.phpindex 7aea9a3df4..0a889ddf44 100644--- a/app/Console/Commands/Export/ExportData.php+++ b/app/Console/Commands/Export/ExportData.php@@ -27,6 +27,7 @@ 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;@@ -233,7 +234,7 @@ class ExportData extends Command$final = new Collection;$accounts = new Collection;$accountList = $this->option('accounts');- $types = [AccountType::ASSET, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE];+ $types = [AccountTypeEnum::ASSET, AccountTypeEnum::LOAN, AccountTypeEnum::DEBT, AccountTypeEnum::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.phpindex 0e4cf33cfb..e5d5371862 100644--- a/app/Console/Commands/Tools/ApplyRules.php+++ b/app/Console/Commands/Tools/ApplyRules.php@@ -25,6 +25,8 @@ 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;@@ -166,7 +168,7 @@ class ApplyRules extends Command$this->ruleGroupSelection = [];$this->ruleRepository = app(RuleRepositoryInterface::class);$this->ruleGroupRepository = app(RuleGroupRepositoryInterface::class);- $this->acceptedAccounts = [AccountType::DEFAULT, AccountType::DEBT, AccountType::ASSET, AccountType::LOAN, AccountType::MORTGAGE];+ $this->acceptedAccounts = [AccountTypeEnum::DEFAULT, AccountTypeEnum::DEBT, AccountTypeEnum::ASSET, AccountTypeEnum::LOAN, AccountTypeEnum::MORTGAGE];$this->groups = new Collection;}diff --git a/app/Console/Commands/Upgrade/AccountCurrencies.php b/app/Console/Commands/Upgrade/AccountCurrencies.phpindex 617fe579ad..0909fa4fc8 100644--- a/app/Console/Commands/Upgrade/AccountCurrencies.php+++ b/app/Console/Commands/Upgrade/AccountCurrencies.php@@ -26,7 +26,6 @@ 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;@@ -146,7 +145,7 @@ class AccountCurrencies extends Command{Log::debug(sprintf('Now in updateCurrenciesForUser(%s, %s)', $user->email, $systemCurrencyCode));$this->accountRepos->setUser($user);- $accounts = $this->accountRepos->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]);+ $accounts = $this->accountRepos->getAccountsByType([AccountTypeEnum::DEFAULT, AccountTypeEnum::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.phpindex d28dc36860..06bdb483f3 100644--- a/app/Console/Commands/Upgrade/CCLiabilities.php+++ b/app/Console/Commands/Upgrade/CCLiabilities.php@@ -23,6 +23,7 @@ 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;@@ -66,8 +67,8 @@ class CCLiabilities extends Command}- $ccType = AccountType::where('type', AccountType::CREDITCARD)->first();- $debtType = AccountType::where('type', AccountType::DEBT)->first();+ $ccType = AccountType::where('type', AccountTypeEnum::CREDITCARD)->first();+ $debtType = AccountType::where('type', AccountTypeEnum::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.phpindex 4dbe770611..ee50ecdbc6 100644--- a/app/Console/Commands/Upgrade/OtherCurrenciesCorrections.php+++ b/app/Console/Commands/Upgrade/OtherCurrenciesCorrections.php@@ -23,6 +23,8 @@ 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;@@ -218,23 +220,23 @@ class OtherCurrenciesCorrections extends Commandswitch ($journal->transactionType->type) {default:break;- case TransactionType::WITHDRAWAL:+ case TransactionTypeEnum::WITHDRAWAL:$lead = $journal->transactions()->where('amount', '<', 0)->first();break;- case TransactionType::DEPOSIT:+ case TransactionTypeEnum::DEPOSIT:$lead = $journal->transactions()->where('amount', '>', 0)->first();break;- case TransactionType::OPENING_BALANCE:+ case TransactionTypeEnum::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', '!=', AccountType::INITIAL_BALANCE)->first(['transactions.*']);+ )->where('account_types.type', '!=', AccountTypeEnum::INITIAL_BALANCE)->first(['transactions.*']);break;- case TransactionType::RECONCILIATION:+ case TransactionTypeEnum::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', '!=', AccountType::RECONCILIATION)->first(['transactions.*']);+ )->where('account_types.type', '!=', AccountTypeEnum::RECONCILIATION)->first(['transactions.*']);break;}diff --git a/app/Factory/AccountFactory.php b/app/Factory/AccountFactory.phpindex 2307f93b10..acee072837 100644--- a/app/Factory/AccountFactory.php+++ b/app/Factory/AccountFactory.php@@ -24,6 +24,8 @@ 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;@@ -260,7 +262,7 @@ class AccountFactory$currency = $this->getCurrency($currencyId, $currencyCode);// only asset account may have a role:- if ($account->accountType->type !== AccountType::ASSET) {+ if ($account->accountType->type !== AccountTypeEnum::ASSET) {$accountRole = '';}// only liability may have direction:@@ -281,10 +283,10 @@ class AccountFactory{$fields = $this->validFields;- if ($account->accountType->type === AccountType::ASSET) {+ if ($account->accountType->type === AccountTypeEnum::ASSET) {$fields = $this->validAssetFields;}- if ($account->accountType->type === AccountType::ASSET && 'ccAsset' === $data['account_role']) {+ if ($account->accountType->type === AccountTypeEnum::ASSET && 'ccAsset' === $data['account_role']) {$fields = $this->validCCFields;}diff --git a/app/Http/Controllers/Account/CreateController.php b/app/Http/Controllers/Account/CreateController.phpindex 9a6d8c9e5e..b055869773 100644--- a/app/Http/Controllers/Account/CreateController.php+++ b/app/Http/Controllers/Account/CreateController.php@@ -23,6 +23,7 @@ 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;@@ -151,7 +152,7 @@ class CreateController extends Controller// update preferences if necessary:$frontPage = app('preferences')->get('frontPageAccounts', [])->data;- if (AccountType::ASSET === $account->accountType->type) {+ if (AccountTypeEnum::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.phpindex 07e635b5d8..e9c0cdf0a5 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([AccountType::ASSET])->pluck('id')->toArray());+ $frontPage = app('preferences')->getFresh('frontPageAccounts', $repository->getAccountsByType([AccountTypeEnum::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.phpindex 72d37453bd..5c114fbfda 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 Controllerpublic function accounts(AccountRepositoryInterface $repository, CurrencyRepositoryInterface $currencyRepository): Response{$accounts = $repository->getAccountsByType(- [AccountType::DEFAULT, AccountType::ASSET, AccountType::DEBT, AccountType::LOAN, AccountType::MORTGAGE, AccountType::CREDITCARD]+ [AccountTypeEnum::DEFAULT, AccountTypeEnum::ASSET, AccountTypeEnum::DEBT, AccountTypeEnum::LOAN, AccountTypeEnum::MORTGAGE, AccountTypeEnum::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.phpindex 4bd8c84a9e..77fe6e7e73 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 Controllerapp('preferences')->set('currencyPreference', $currency->code);// store frontpage preferences:- $accounts = $this->repository->getAccountsByType([AccountType::ASSET])->pluck('id')->toArray();+ $accounts = $this->repository->getAccountsByType([AccountTypeEnum::ASSET])->pluck('id')->toArray();app('preferences')->set('frontPageAccounts', $accounts);// mark.diff --git a/app/Http/Controllers/PreferencesController.php b/app/Http/Controllers/PreferencesController.phpindex 737ad506bc..ed7455dd3f 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([AccountType::DEFAULT, AccountType::ASSET, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE]);+ $accounts = $repository->getAccountsByType([AccountTypeEnum::DEFAULT, AccountTypeEnum::ASSET, AccountTypeEnum::LOAN, AccountTypeEnum::DEBT, AccountTypeEnum::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, [AccountType::MORTGAGE, AccountType::DEBT, AccountType::LOAN], true)) {+ if (in_array($type, [AccountTypeEnum::MORTGAGE, AccountTypeEnum::DEBT, AccountTypeEnum::LOAN], true)) {$role = sprintf('opt_group_l_%s', $type);}diff --git a/app/Http/Controllers/ReportController.php b/app/Http/Controllers/ReportController.phpindex f964375e52..561e05e97b 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(- [AccountType::DEFAULT, AccountType::ASSET, AccountType::DEBT, AccountType::LOAN, AccountType::MORTGAGE]+ [AccountTypeEnum::DEFAULT, AccountTypeEnum::ASSET, AccountTypeEnum::DEBT, AccountTypeEnum::LOAN, AccountTypeEnum::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, [AccountType::MORTGAGE, AccountType::DEBT, AccountType::LOAN], true)) {+ if (in_array($type, [AccountTypeEnum::MORTGAGE, AccountTypeEnum::DEBT, AccountTypeEnum::LOAN], true)) {$role = sprintf('opt_group_l_%s', $type);}