Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Replace enum
James Colea8ae496fda8d
diff --git a/app/Api/V1/Requests/Autocomplete/AutocompleteRequest.php b/app/Api/V1/Requests/Autocomplete/AutocompleteRequest.phpindex 7de8af1d4b..95ec75546e 100644--- a/app/Api/V1/Requests/Autocomplete/AutocompleteRequest.php+++ b/app/Api/V1/Requests/Autocomplete/AutocompleteRequest.php@@ -24,6 +24,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;@@ -46,7 +47,7 @@ class AutocompleteRequest extends FormRequest}// remove 'initial balance' from allowed types. its internal- $array = array_diff($array, [AccountType::INITIAL_BALANCE, AccountType::RECONCILIATION]);+ $array = array_diff($array, [AccountTypeEnum::INITIAL_BALANCE->value, AccountTypeEnum::RECONCILIATION->value]);return ['types' => $array,diff --git a/app/Api/V1/Requests/Data/Export/ExportRequest.php b/app/Api/V1/Requests/Data/Export/ExportRequest.phpindex 82808d78a4..7ecc929630 100644--- a/app/Api/V1/Requests/Data/Export/ExportRequest.php+++ b/app/Api/V1/Requests/Data/Export/ExportRequest.php@@ -24,6 +24,7 @@ declare(strict_types=1);namespace FireflyIII\Api\V1\Requests\Data\Export;+use FireflyIII\Enums\AccountTypeEnum;use FireflyIII\Models\AccountType;use FireflyIII\Repositories\Account\AccountRepositoryInterface;use FireflyIII\Support\Request\ChecksLogin;@@ -55,7 +56,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->value === $account->accountType->type) {$accounts->push($account);}}diff --git a/app/Api/V1/Requests/Insight/GenericRequest.php b/app/Api/V1/Requests/Insight/GenericRequest.phpindex 893789e778..61149c8b22 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;@@ -70,7 +71,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], true)) {+ if (in_array($type, [AccountTypeEnum::ASSET->value, AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::MORTGAGE->value], true)) {$return->push($account);}}@@ -191,7 +192,7 @@ class GenericRequest extends FormRequest/** @var Account $account */foreach ($this->accounts as $account) {$type = $account->accountType->type;- if (AccountType::EXPENSE === $type) {+ if (AccountTypeEnum::EXPENSE->value === $type) {$return->push($account);}}@@ -207,7 +208,7 @@ class GenericRequest extends FormRequest/** @var Account $account */foreach ($this->accounts as $account) {$type = $account->accountType->type;- if (AccountType::REVENUE === $type) {+ if (AccountTypeEnum::REVENUE->value === $type) {$return->push($account);}}diff --git a/app/Api/V2/Controllers/Chart/CategoryController.php b/app/Api/V2/Controllers/Chart/CategoryController.phpindex af0c2d1e89..990b9de811 100644--- a/app/Api/V2/Controllers/Chart/CategoryController.php+++ b/app/Api/V2/Controllers/Chart/CategoryController.php@@ -27,6 +27,7 @@ namespace FireflyIII\Api\V2\Controllers\Chart;use Carbon\Carbon;use FireflyIII\Api\V2\Controllers\Controller;use FireflyIII\Api\V2\Request\Generic\DateRequest;+use FireflyIII\Enums\AccountTypeEnum;use FireflyIII\Enums\TransactionTypeEnum;use FireflyIII\Exceptions\FireflyException;use FireflyIII\Helpers\Collector\GroupCollectorInterface;@@ -81,7 +82,7 @@ class CategoryController extends Controller/** @var Carbon $end */$end = $this->parameters->get('end');- $accounts = $this->accountRepos->getAccountsByType([AccountType::DEBT, AccountType::LOAN, AccountType::MORTGAGE, AccountType::ASSET, AccountType::DEFAULT]);+ $accounts = $this->accountRepos->getAccountsByType([AccountTypeEnum::DEBT->value, AccountTypeEnum::LOAN->value, AccountTypeEnum::MORTGAGE->value, AccountTypeEnum::ASSET->value, AccountTypeEnum::DEFAULT->value]);$default = app('amount')->getDefaultCurrency();$converter = new ExchangeRateConverter();$currencies = [];diff --git a/app/Api/V2/Controllers/Summary/BasicController.php b/app/Api/V2/Controllers/Summary/BasicController.phpindex 4cab036873..c7875165b7 100644--- a/app/Api/V2/Controllers/Summary/BasicController.php+++ b/app/Api/V2/Controllers/Summary/BasicController.php@@ -27,6 +27,7 @@ namespace FireflyIII\Api\V2\Controllers\Summary;use Carbon\Carbon;use FireflyIII\Api\V2\Controllers\Controller;use FireflyIII\Api\V2\Request\Generic\DateRequest;+use FireflyIII\Enums\AccountTypeEnum;use FireflyIII\Enums\TransactionTypeEnum;use FireflyIII\Exceptions\FireflyException;use FireflyIII\Helpers\Collector\GroupCollectorInterface;@@ -353,7 +354,7 @@ class BasicController extends Controller$netWorthHelper = app(NetWorthInterface::class);$netWorthHelper->setUserGroup($userGroup);$allAccounts = $this->accountRepository->getActiveAccountsByType(- [AccountType::ASSET, AccountType::DEFAULT, AccountType::LOAN, AccountType::MORTGAGE, AccountType::DEBT]+ [AccountTypeEnum::ASSET->value, AccountTypeEnum::DEFAULT->value, AccountTypeEnum::LOAN->value, AccountTypeEnum::MORTGAGE->value, AccountTypeEnum::DEBT->value]);// filter list on preference of being included.diff --git a/app/Api/V2/Controllers/Summary/NetWorthController.php b/app/Api/V2/Controllers/Summary/NetWorthController.phpindex fcfdaa935f..42c886154f 100644--- a/app/Api/V2/Controllers/Summary/NetWorthController.php+++ b/app/Api/V2/Controllers/Summary/NetWorthController.php@@ -26,6 +26,7 @@ namespace FireflyIII\Api\V2\Controllers\Summary;use FireflyIII\Api\V2\Controllers\Controller;use FireflyIII\Api\V2\Request\Generic\SingleDateRequest;+use FireflyIII\Enums\AccountTypeEnum;use FireflyIII\Helpers\Report\NetWorthInterface;use FireflyIII\Models\Account;use FireflyIII\Models\AccountType;@@ -67,7 +68,7 @@ class NetWorthController extends Controllerpublic function get(SingleDateRequest $request): JsonResponse{$date = $request->getDate();- $accounts = $this->repository->getAccountsByType([AccountType::ASSET, AccountType::DEFAULT, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE]);+ $accounts = $this->repository->getAccountsByType([AccountTypeEnum::ASSET->value, AccountTypeEnum::DEFAULT->value, AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::MORTGAGE->value]);// filter list on preference of being included.$filtered = $accounts->filter(diff --git a/app/Api/V2/Request/Autocomplete/AutocompleteRequest.php b/app/Api/V2/Request/Autocomplete/AutocompleteRequest.phpindex 2c44b1f737..d36bc1ee30 100644--- a/app/Api/V2/Request/Autocomplete/AutocompleteRequest.php+++ b/app/Api/V2/Request/Autocomplete/AutocompleteRequest.php@@ -24,6 +24,7 @@ declare(strict_types=1);namespace FireflyIII\Api\V2\Request\Autocomplete;+use FireflyIII\Enums\AccountTypeEnum;use FireflyIII\Models\AccountType;use FireflyIII\Support\Http\Api\AccountFilter;use FireflyIII\Support\Request\ChecksLogin;@@ -65,7 +66,7 @@ class AutocompleteRequest extends FormRequest}// remove 'initial balance' from allowed types. its internal- $array['account_types'] = array_diff($array['account_types'], [AccountType::INITIAL_BALANCE, AccountType::RECONCILIATION, AccountType::CREDITCARD]);+ $array['account_types'] = array_diff($array['account_types'], [AccountTypeEnum::INITIAL_BALANCE->value, AccountTypeEnum::RECONCILIATION->value, AccountTypeEnum::CREDITCARD->value]);$array['account_types'] = $this->getAccountTypeParameter($array['account_types']);return $array;diff --git a/app/Console/Commands/Correction/CorrectsAccountTypes.php b/app/Console/Commands/Correction/CorrectsAccountTypes.phpindex 1ef490835e..66b02099b7 100644--- a/app/Console/Commands/Correction/CorrectsAccountTypes.php+++ b/app/Console/Commands/Correction/CorrectsAccountTypes.php@@ -246,12 +246,12 @@ class CorrectsAccountTypes extends Commandprivate function shouldBeTransfer(string $transactionType, string $sourceType, string $destinationType): bool{- return TransactionTypeEnum::TRANSFER->value === $transactionType && AccountType::ASSET === $sourceType && $this->isLiability($destinationType);+ return TransactionTypeEnum::TRANSFER->value === $transactionType && AccountTypeEnum::ASSET->value === $sourceType && $this->isLiability($destinationType);}private function isLiability(string $destinationType): bool{- return AccountType::LOAN === $destinationType || AccountType::DEBT === $destinationType || AccountType::MORTGAGE === $destinationType;+ return AccountTypeEnum::LOAN->value === $destinationType || AccountTypeEnum::DEBT->value === $destinationType || AccountTypeEnum::MORTGAGE->value === $destinationType;}private function makeTransfer(TransactionJournal $journal): void@@ -269,7 +269,7 @@ class CorrectsAccountTypes extends Commandprivate function shouldBeDeposit(string $transactionType, string $sourceType, string $destinationType): bool{- return TransactionTypeEnum::TRANSFER->value === $transactionType && $this->isLiability($sourceType) && AccountType::ASSET === $destinationType;+ return TransactionTypeEnum::TRANSFER->value === $transactionType && $this->isLiability($sourceType) && AccountTypeEnum::ASSET->value === $destinationType;}private function makeDeposit(TransactionJournal $journal): void@@ -287,7 +287,7 @@ class CorrectsAccountTypes extends Commandprivate function shouldGoToExpenseAccount(string $transactionType, string $sourceType, string $destinationType): bool{- return TransactionTypeEnum::WITHDRAWAL->value === $transactionType && AccountType::ASSET === $sourceType && AccountType::REVENUE === $destinationType;+ return TransactionTypeEnum::WITHDRAWAL->value === $transactionType && AccountTypeEnum::ASSET->value === $sourceType && AccountTypeEnum::REVENUE->value === $destinationType;}private function makeExpenseDestination(TransactionJournal $journal, Transaction $destination): void@@ -295,7 +295,7 @@ class CorrectsAccountTypes extends Command// withdrawals with a revenue account as destination instead of an expense account.$this->factory->setUser($journal->user);$oldDest = $destination->account;- $result = $this->factory->findOrCreate($destination->account->name, AccountType::EXPENSE);+ $result = $this->factory->findOrCreate($destination->account->name, AccountTypeEnum::EXPENSE->value);$destination->account()->associate($result);$destination->save();$message = sprintf(@@ -313,7 +313,7 @@ class CorrectsAccountTypes extends Commandprivate function shouldComeFromRevenueAccount(string $transactionType, string $sourceType, string $destinationType): bool{- return TransactionTypeEnum::DEPOSIT->value === $transactionType && AccountType::EXPENSE === $sourceType && AccountType::ASSET === $destinationType;+ return TransactionTypeEnum::DEPOSIT->value === $transactionType && AccountTypeEnum::EXPENSE->value === $sourceType && AccountTypeEnum::ASSET->value === $destinationType;}private function makeRevenueSource(TransactionJournal $journal, Transaction $source): void@@ -321,7 +321,7 @@ class CorrectsAccountTypes extends Command// 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->value);$oldSource = $source->account;$source->account()->associate($result);$source->save();diff --git a/app/Console/Commands/Correction/CorrectsFrontpageAccounts.php b/app/Console/Commands/Correction/CorrectsFrontpageAccounts.phpindex 2d3021cdf1..a985c25dfb 100644--- a/app/Console/Commands/Correction/CorrectsFrontpageAccounts.php+++ b/app/Console/Commands/Correction/CorrectsFrontpageAccounts.php@@ -25,6 +25,7 @@ declare(strict_types=1);namespace FireflyIII\Console\Commands\Correction;use FireflyIII\Console\Commands\ShowsFriendlyMessages;+use FireflyIII\Enums\AccountTypeEnum;use FireflyIII\Models\AccountType;use FireflyIII\Models\Preference;use FireflyIII\Repositories\Account\AccountRepositoryInterface;@@ -73,7 +74,7 @@ class CorrectsFrontpageAccounts 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->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::LOAN->value, AccountTypeEnum::MORTGAGE->value], true)&& true === $account->active) {$fixed[] = $account->id;}diff --git a/app/Console/Commands/Correction/CorrectsIbans.php b/app/Console/Commands/Correction/CorrectsIbans.phpindex 672fce3281..eac48c8e15 100644--- a/app/Console/Commands/Correction/CorrectsIbans.php+++ b/app/Console/Commands/Correction/CorrectsIbans.php@@ -25,6 +25,7 @@ declare(strict_types=1);namespace FireflyIII\Console\Commands\Correction;use FireflyIII\Console\Commands\ShowsFriendlyMessages;+use FireflyIII\Enums\AccountTypeEnum;use FireflyIII\Models\Account;use FireflyIII\Models\AccountType;use Illuminate\Console\Command;@@ -78,14 +79,14 @@ class CorrectsIbans extends Commandcontinue;}$type = $account->accountType->type;- if (in_array($type, [AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE], true)) {+ if (in_array($type, [AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::MORTGAGE->value], true)) {$type = 'liabilities';}if (array_key_exists($iban, $set[$userId])) {// iban already in use! two exceptions exist:if (- !(AccountType::EXPENSE === $set[$userId][$iban] && AccountType::REVENUE === $type) // allowed combination- && !(AccountType::REVENUE === $set[$userId][$iban] && AccountType::EXPENSE === $type) // also allowed combination.+ !(AccountTypeEnum::EXPENSE->value === $set[$userId][$iban] && AccountTypeEnum::REVENUE->value === $type) // allowed combination+ && !(AccountTypeEnum::REVENUE->value === $set[$userId][$iban] && AccountTypeEnum::EXPENSE->value === $type) // also allowed combination.) {$this->friendlyWarning(sprintf(diff --git a/app/Console/Commands/Correction/CorrectsOpeningBalanceCurrencies.php b/app/Console/Commands/Correction/CorrectsOpeningBalanceCurrencies.phpindex d464aa250e..0b5b8f8ffe 100644--- a/app/Console/Commands/Correction/CorrectsOpeningBalanceCurrencies.php+++ b/app/Console/Commands/Correction/CorrectsOpeningBalanceCurrencies.php@@ -25,6 +25,7 @@ declare(strict_types=1);namespace FireflyIII\Console\Commands\Correction;use FireflyIII\Console\Commands\ShowsFriendlyMessages;+use FireflyIII\Enums\AccountTypeEnum;use FireflyIII\Enums\TransactionTypeEnum;use FireflyIII\Models\Account;use FireflyIII\Models\AccountType;@@ -97,7 +98,7 @@ class CorrectsOpeningBalanceCurrencies extends Commandforeach ($transactions as $transaction) {/** @var null|Account $account */$account = $transaction->account()->first();- if (null !== $account && AccountType::INITIAL_BALANCE !== $account->accountType()->first()->type) {+ if (null !== $account && AccountTypeEnum::INITIAL_BALANCE->value !== $account->accountType()->first()->type) {return $account;}}diff --git a/app/Console/Commands/Export/ExportsData.php b/app/Console/Commands/Export/ExportsData.phpindex 97f528f7cd..f1b688660a 100644--- a/app/Console/Commands/Export/ExportsData.php+++ b/app/Console/Commands/Export/ExportsData.php@@ -27,6 +27,7 @@ namespace FireflyIII\Console\Commands\Export;use Carbon\Carbon;use FireflyIII\Console\Commands\ShowsFriendlyMessages;use FireflyIII\Console\Commands\VerifiesAccessToken;+use FireflyIII\Enums\AccountTypeEnum;use FireflyIII\Exceptions\FireflyException;use FireflyIII\Models\Account;use FireflyIII\Models\AccountType;@@ -229,7 +230,7 @@ class ExportsData extends Command$final = new Collection();$accounts = new Collection();$accountList = (string) $this->option('accounts');- $types = [AccountType::ASSET, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE];+ $types = [AccountTypeEnum::ASSET->value, AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::MORTGAGE->value];if ('' !== $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 10cf1d37f0..79e261dd51 100644--- a/app/Console/Commands/Tools/ApplyRules.php+++ b/app/Console/Commands/Tools/ApplyRules.php@@ -27,6 +27,7 @@ namespace FireflyIII\Console\Commands\Tools;use Carbon\Carbon;use FireflyIII\Console\Commands\ShowsFriendlyMessages;use FireflyIII\Console\Commands\VerifiesAccessToken;+use FireflyIII\Enums\AccountTypeEnum;use FireflyIII\Exceptions\FireflyException;use FireflyIII\Models\AccountType;use FireflyIII\Models\Rule;@@ -154,7 +155,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->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::ASSET->value, AccountTypeEnum::LOAN->value, AccountTypeEnum::MORTGAGE->value];$this->groups = new Collection();}diff --git a/app/Console/Commands/Upgrade/UpgradesAccountCurrencies.php b/app/Console/Commands/Upgrade/UpgradesAccountCurrencies.phpindex 89ef7e5b9b..51655f2467 100644--- a/app/Console/Commands/Upgrade/UpgradesAccountCurrencies.php+++ b/app/Console/Commands/Upgrade/UpgradesAccountCurrencies.php@@ -25,6 +25,7 @@ declare(strict_types=1);namespace FireflyIII\Console\Commands\Upgrade;use FireflyIII\Console\Commands\ShowsFriendlyMessages;+use FireflyIII\Enums\AccountTypeEnum;use FireflyIII\Exceptions\FireflyException;use FireflyIII\Models\Account;use FireflyIII\Models\AccountMeta;@@ -104,7 +105,7 @@ class UpgradesAccountCurrencies extends Commandprivate function updateCurrenciesForUser(User $user): void{$this->accountRepos->setUser($user);- $accounts = $this->accountRepos->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]);+ $accounts = $this->accountRepos->getAccountsByType([AccountTypeEnum::DEFAULT->value, AccountTypeEnum::ASSET->value]);// get user's currency preference:$defaultCurrency = app('amount')->getDefaultCurrencyByUserGroup($user->userGroup);diff --git a/app/Console/Commands/Upgrade/UpgradesCreditCardLiabilities.php b/app/Console/Commands/Upgrade/UpgradesCreditCardLiabilities.phpindex f8db7c06a9..7b3b8e65b1 100644--- a/app/Console/Commands/Upgrade/UpgradesCreditCardLiabilities.php+++ b/app/Console/Commands/Upgrade/UpgradesCreditCardLiabilities.php@@ -25,6 +25,7 @@ declare(strict_types=1);namespace FireflyIII\Console\Commands\Upgrade;use FireflyIII\Console\Commands\ShowsFriendlyMessages;+use FireflyIII\Enums\AccountTypeEnum;use FireflyIII\Exceptions\FireflyException;use FireflyIII\Models\Account;use FireflyIII\Models\AccountType;@@ -52,8 +53,8 @@ class UpgradesCreditCardLiabilities extends Commandreturn 0;}- $ccType = AccountType::where('type', AccountType::CREDITCARD)->first();- $debtType = AccountType::where('type', AccountType::DEBT)->first();+ $ccType = AccountType::where('type', AccountTypeEnum::CREDITCARD->value)->first();+ $debtType = AccountType::where('type', AccountTypeEnum::DEBT->value)->first();if (null === $ccType || null === $debtType) {$this->markAsExecuted();diff --git a/app/Console/Commands/Upgrade/UpgradesVariousCurrencyInformation.php b/app/Console/Commands/Upgrade/UpgradesVariousCurrencyInformation.phpindex 03ec3c329d..e811428a29 100644--- a/app/Console/Commands/Upgrade/UpgradesVariousCurrencyInformation.php+++ b/app/Console/Commands/Upgrade/UpgradesVariousCurrencyInformation.php@@ -25,6 +25,7 @@ declare(strict_types=1);namespace FireflyIII\Console\Commands\Upgrade;use FireflyIII\Console\Commands\ShowsFriendlyMessages;+use FireflyIII\Enums\AccountTypeEnum;use FireflyIII\Enums\TransactionTypeEnum;use FireflyIII\Models\Account;use FireflyIII\Models\AccountType;@@ -198,7 +199,7 @@ class UpgradesVariousCurrencyInformation extends Command'accounts.account_type_id','=','account_types.id'- )->where('account_types.type', '!=', AccountType::INITIAL_BALANCE)->first(['transactions.*']);+ )->where('account_types.type', '!=', AccountTypeEnum::INITIAL_BALANCE->value)->first(['transactions.*']);break;@@ -209,7 +210,7 @@ class UpgradesVariousCurrencyInformation extends Command'accounts.account_type_id','=','account_types.id'- )->where('account_types.type', '!=', AccountType::RECONCILIATION)->first(['transactions.*']);+ )->where('account_types.type', '!=', AccountTypeEnum::RECONCILIATION->value)->first(['transactions.*']);break;}diff --git a/app/Factory/AccountFactory.php b/app/Factory/AccountFactory.phpindex 5d6fea36e0..4148e7da13 100644--- a/app/Factory/AccountFactory.php+++ b/app/Factory/AccountFactory.php@@ -24,6 +24,7 @@ declare(strict_types=1);namespace FireflyIII\Factory;+use FireflyIII\Enums\AccountTypeEnum;use FireflyIII\Events\StoredAccount;use FireflyIII\Exceptions\FireflyException;use FireflyIII\Models\Account;@@ -242,7 +243,7 @@ class AccountFactory$currency = $this->getCurrency($currencyId, $currencyCode);// only asset account may have a role:- if (AccountType::ASSET !== $account->accountType->type) {+ if (AccountTypeEnum::ASSET->value !== $account->accountType->type) {$accountRole = '';}// only liability may have direction:@@ -258,10 +259,10 @@ class AccountFactoryprivate function storeMetaData(Account $account, array $data): void{$fields = $this->validFields;- if (AccountType::ASSET === $account->accountType->type) {+ if (AccountTypeEnum::ASSET->value === $account->accountType->type) {$fields = $this->validAssetFields;}- if (AccountType::ASSET === $account->accountType->type && 'ccAsset' === $data['account_role']) {+ if (AccountTypeEnum::ASSET->value === $account->accountType->type && 'ccAsset' === $data['account_role']) {$fields = $this->validCCFields;}diff --git a/app/Helpers/Report/NetWorth.php b/app/Helpers/Report/NetWorth.phpindex 85bb500406..c57bde60cf 100644--- a/app/Helpers/Report/NetWorth.php+++ b/app/Helpers/Report/NetWorth.php@@ -25,6 +25,7 @@ declare(strict_types=1);namespace FireflyIII\Helpers\Report;use Carbon\Carbon;+use FireflyIII\Enums\AccountTypeEnum;use FireflyIII\Exceptions\FireflyException;use FireflyIII\Models\Account;use FireflyIII\Models\AccountType;@@ -187,7 +188,7 @@ class NetWorth implements NetWorthInterfaceprivate function getAccounts(): Collection{$accounts = $this->getRepository()->getAccountsByType(- [AccountType::ASSET, AccountType::DEFAULT, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE]+ [AccountTypeEnum::ASSET->value, AccountTypeEnum::DEFAULT->value, AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::MORTGAGE->value]);$filtered = new Collection();diff --git a/app/Http/Controllers/Account/CreateController.php b/app/Http/Controllers/Account/CreateController.phpindex 20dec447c6..cf9957f670 100644--- a/app/Http/Controllers/Account/CreateController.php+++ b/app/Http/Controllers/Account/CreateController.php@@ -24,6 +24,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;@@ -149,7 +150,7 @@ class CreateController extends Controllerif (!is_array($frontpage)) {$frontpage = [];}- if (AccountType::ASSET === $account->accountType->type) {+ if (AccountTypeEnum::ASSET->value === $account->accountType->type) {$frontpage[] = $account->id;app('preferences')->set('frontpageAccounts', $frontpage);}diff --git a/app/Http/Controllers/Account/ReconcileController.php b/app/Http/Controllers/Account/ReconcileController.phpindex ded1362e59..30cecb967b 100644--- a/app/Http/Controllers/Account/ReconcileController.php+++ b/app/Http/Controllers/Account/ReconcileController.php@@ -24,6 +24,7 @@ declare(strict_types=1);namespace FireflyIII\Http\Controllers\Account;use Carbon\Carbon;+use FireflyIII\Enums\AccountTypeEnum;use FireflyIII\Enums\TransactionTypeEnum;use FireflyIII\Exceptions\DuplicateTransactionException;use FireflyIII\Exceptions\FireflyException;@@ -82,7 +83,7 @@ class ReconcileController extends Controllerif (!$this->isEditableAccount($account)) {return $this->redirectAccountToAccount($account);}- if (AccountType::ASSET !== $account->accountType->type) {+ if (AccountTypeEnum::ASSET->value !== $account->accountType->type) {session()->flash('error', (string) trans('firefly.must_be_asset_account'));return redirect(route('accounts.index', [config(sprintf('firefly.shortNamesByFullName.%s', $account->accountType->type))]));diff --git a/app/Http/Controllers/DebugController.php b/app/Http/Controllers/DebugController.phpindex a516ec784e..dcae0bd53c 100644--- a/app/Http/Controllers/DebugController.php+++ b/app/Http/Controllers/DebugController.php@@ -25,6 +25,7 @@ declare(strict_types=1);namespace FireflyIII\Http\Controllers;use Carbon\Carbon;+use FireflyIII\Enums\AccountTypeEnum;use FireflyIII\Enums\TransactionTypeEnum;use FireflyIII\Exceptions\FireflyException;use FireflyIII\Http\Middleware\IsDemoUser;@@ -352,7 +353,7 @@ class DebugController extends Controller$user = auth()->user();// has liabilities- if ($user->accounts()->accountTypeIn([AccountType::DEBT, AccountType::LOAN, AccountType::MORTGAGE])->count() > 0) {+ if ($user->accounts()->accountTypeIn([AccountTypeEnum::DEBT->value, AccountTypeEnum::LOAN->value, AccountTypeEnum::MORTGAGE->value])->count() > 0) {$flags[] = '<span title="Has liabilities">:credit_card:</span>';}diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.phpindex 72fc6ba722..af162f6f94 100644--- a/app/Http/Controllers/HomeController.php+++ b/app/Http/Controllers/HomeController.php@@ -25,6 +25,7 @@ namespace FireflyIII\Http\Controllers;use Carbon\Carbon;use Carbon\Exceptions\InvalidFormatException;+use FireflyIII\Enums\AccountTypeEnum;use FireflyIII\Events\RequestedVersionCheckStatus;use FireflyIII\Exceptions\FireflyException;use FireflyIII\Helpers\Collector\GroupCollectorInterface;@@ -145,7 +146,7 @@ class HomeController extends Controller$count = $repository->count($types);$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->value])->pluck('id')->toArray());$frontpageArray = $frontpage->data;if (!is_array($frontpageArray)) {$frontpageArray = [];diff --git a/app/Http/Controllers/JavascriptController.php b/app/Http/Controllers/JavascriptController.phpindex 7a0b271d14..8e897845b6 100644--- a/app/Http/Controllers/JavascriptController.php+++ b/app/Http/Controllers/JavascriptController.php@@ -24,6 +24,7 @@ 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;@@ -47,7 +48,7 @@ class JavascriptController extends Controllerpublic function accounts(AccountRepositoryInterface $repository): Response{$accounts = $repository->getAccountsByType(- [AccountType::DEFAULT, AccountType::ASSET, AccountType::DEBT, AccountType::LOAN, AccountType::MORTGAGE, AccountType::CREDITCARD]+ [AccountTypeEnum::DEFAULT->value, AccountTypeEnum::ASSET->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::LOAN->value, AccountTypeEnum::MORTGAGE->value, AccountTypeEnum::CREDITCARD->value]);$data = ['accounts' => []];diff --git a/app/Http/Controllers/Json/BoxController.php b/app/Http/Controllers/Json/BoxController.phpindex 13d41486e0..7bfeb9fd51 100644--- a/app/Http/Controllers/Json/BoxController.php+++ b/app/Http/Controllers/Json/BoxController.php@@ -24,6 +24,7 @@ declare(strict_types=1);namespace FireflyIII\Http\Controllers\Json;use Carbon\Carbon;+use FireflyIII\Enums\AccountTypeEnum;use FireflyIII\Enums\TransactionTypeEnum;use FireflyIII\Helpers\Collector\GroupCollectorInterface;use FireflyIII\Helpers\Report\NetWorthInterface;@@ -163,7 +164,7 @@ class BoxController extends Controller/** @var AccountRepositoryInterface $accountRepository */$accountRepository = app(AccountRepositoryInterface::class);$allAccounts = $accountRepository->getActiveAccountsByType(- [AccountType::DEFAULT, AccountType::ASSET, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE]+ [AccountTypeEnum::DEFAULT->value, AccountTypeEnum::ASSET->value, AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::MORTGAGE->value]);app('log')->debug(sprintf('Found %d accounts.', $allAccounts->count()));diff --git a/app/Http/Controllers/NewUserController.php b/app/Http/Controllers/NewUserController.phpindex 08ebad3a43..084aad756d 100644--- a/app/Http/Controllers/NewUserController.php+++ b/app/Http/Controllers/NewUserController.php@@ -23,6 +23,7 @@ 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;@@ -114,7 +115,7 @@ class NewUserController extends Controller$currencyRepository->makeDefault($currency);// store frontpage preferences:- $accounts = $this->repository->getAccountsByType([AccountType::ASSET])->pluck('id')->toArray();+ $accounts = $this->repository->getAccountsByType([AccountTypeEnum::ASSET->value])->pluck('id')->toArray();app('preferences')->set('frontpageAccounts', $accounts);// mark.diff --git a/app/Http/Controllers/PreferencesController.php b/app/Http/Controllers/PreferencesController.phpindex 702eb0bd62..aebf9edcc9 100644--- a/app/Http/Controllers/PreferencesController.php+++ b/app/Http/Controllers/PreferencesController.php@@ -23,6 +23,7 @@ declare(strict_types=1);namespace FireflyIII\Http\Controllers;+use FireflyIII\Enums\AccountTypeEnum;use FireflyIII\Events\Preferences\UserGroupChangedDefaultCurrency;use FireflyIII\Events\Test\UserTestNotificationChannel;use FireflyIII\Exceptions\FireflyException;@@ -70,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->value, AccountTypeEnum::ASSET->value, AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::MORTGAGE->value]);$isDocker = env('IS_DOCKER', false);$groupedAccounts = [];@@ -79,7 +80,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->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::LOAN->value], true)) {$role = sprintf('opt_group_l_%s', $type);}diff --git a/app/Http/Controllers/ReportController.php b/app/Http/Controllers/ReportController.phpindex eabef2d1c4..1f0cb1875b 100644--- a/app/Http/Controllers/ReportController.php+++ b/app/Http/Controllers/ReportController.php@@ -24,6 +24,7 @@ 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;@@ -242,7 +243,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->value, AccountTypeEnum::ASSET->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::LOAN->value, AccountTypeEnum::MORTGAGE->value]);// group accounts by role:@@ -253,7 +254,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->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::LOAN->value], true)) {$role = sprintf('opt_group_l_%s', $type);}diff --git a/app/Http/Controllers/Transaction/ConvertController.php b/app/Http/Controllers/Transaction/ConvertController.phpindex 7c265526b0..25b37ca913 100644--- a/app/Http/Controllers/Transaction/ConvertController.php+++ b/app/Http/Controllers/Transaction/ConvertController.php@@ -24,6 +24,7 @@ declare(strict_types=1);namespace FireflyIII\Http\Controllers\Transaction;use Exception;+use FireflyIII\Enums\AccountTypeEnum;use FireflyIII\Enums\TransactionTypeEnum;use FireflyIII\Events\UpdatedTransactionGroup;use FireflyIII\Exceptions\FireflyException;@@ -140,9 +141,9 @@ class ConvertController extends Controllerprivate function getValidDepositSources(): array{// make repositories- $liabilityTypes = [AccountType::MORTGAGE, AccountType::DEBT, AccountType::CREDITCARD, AccountType::LOAN];+ $liabilityTypes = [AccountTypeEnum::MORTGAGE->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::CREDITCARD->value, AccountTypeEnum::LOAN->value];$accountList = $this->accountRepository- ->getActiveAccountsByType([AccountType::REVENUE, AccountType::CASH, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE])+ ->getActiveAccountsByType([AccountTypeEnum::REVENUE->value, AccountTypeEnum::CASH->value, AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::MORTGAGE->value]);$grouped = [];@@ -159,11 +160,11 @@ class ConvertController extends Controllerif (in_array($account->accountType->type, $liabilityTypes, true)) {$role = 'l_'.$account->accountType->type;}- if (AccountType::CASH === $account->accountType->type) {+ if (AccountTypeEnum::CASH->value === $account->accountType->type) {$role = 'cash_account';$name = sprintf('(%s)', trans('firefly.cash'));}- if (AccountType::REVENUE === $account->accountType->type) {+ if (AccountTypeEnum::REVENUE->value === $account->accountType->type) {$role = 'revenue_account';}@@ -177,9 +178,9 @@ class ConvertController extends Controllerprivate function getValidWithdrawalDests(): array{// make repositories- $liabilityTypes = [AccountType::MORTGAGE, AccountType::DEBT, AccountType::CREDITCARD, AccountType::LOAN];+ $liabilityTypes = [AccountTypeEnum::MORTGAGE->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::CREDITCARD->value, AccountTypeEnum::LOAN->value];$accountList = $this->accountRepository->getActiveAccountsByType(- [AccountType::EXPENSE, AccountType::CASH, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE]+ [AccountTypeEnum::EXPENSE->value, AccountTypeEnum::CASH->value, AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::MORTGAGE->value]);$grouped = [];@@ -196,11 +197,11 @@ class ConvertController extends Controllerif (in_array($account->accountType->type, $liabilityTypes, true)) {$role = 'l_'.$account->accountType->type;}- if (AccountType::CASH === $account->accountType->type) {+ if (AccountTypeEnum::CASH->value === $account->accountType->type) {$role = 'cash_account';$name = sprintf('(%s)', trans('firefly.cash'));}- if (AccountType::EXPENSE === $account->accountType->type) {+ if (AccountTypeEnum::EXPENSE->value === $account->accountType->type) {$role = 'expense_account';}@@ -217,7 +218,7 @@ class ConvertController extends Controllerprivate function getLiabilities(): array{// make repositories- $accountList = $this->accountRepository->getActiveAccountsByType([AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE]);+ $accountList = $this->accountRepository->getActiveAccountsByType([AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::MORTGAGE->value]);$grouped = [];// group accounts:@@ -239,7 +240,7 @@ class ConvertController extends Controllerprivate function getAssetAccounts(): array{// make repositories- $accountList = $this->accountRepository->getActiveAccountsByType([AccountType::ASSET]);+ $accountList = $this->accountRepository->getActiveAccountsByType([AccountTypeEnum::ASSET->value]);$grouped = [];// group accounts:diff --git a/app/Http/Controllers/Transaction/MassController.php b/app/Http/Controllers/Transaction/MassController.phpindex 795a7f5a9b..2d0a5b4125 100644--- a/app/Http/Controllers/Transaction/MassController.php+++ b/app/Http/Controllers/Transaction/MassController.php@@ -24,6 +24,7 @@ declare(strict_types=1);namespace FireflyIII\Http\Controllers\Transaction;use Carbon\Carbon;+use FireflyIII\Enums\AccountTypeEnum;use FireflyIII\Enums\TransactionTypeEnum;use FireflyIII\Events\UpdatedTransactionGroup;use FireflyIII\Exceptions\FireflyException;@@ -132,7 +133,7 @@ class MassController extends Controller$withdrawalSources = $accountRepository->getAccountsByType($array);// valid deposit destinations:- $array = config(sprintf('firefly.source_dests.%s.%s', TransactionTypeEnum::DEPOSIT->value, AccountType::REVENUE));+ $array = config(sprintf('firefly.source_dests.%s.%s', TransactionTypeEnum::DEPOSIT->value, AccountTypeEnum::REVENUE->value));$depositDestinations = $accountRepository->getAccountsByType($array);/** @var BudgetRepositoryInterface $budgetRepository */diff --git a/app/Models/Account.php b/app/Models/Account.phpindex eede2e7f38..e195b3f130 100644--- a/app/Models/Account.php+++ b/app/Models/Account.php@@ -23,6 +23,7 @@ declare(strict_types=1);namespace FireflyIII\Models;+use FireflyIII\Enums\AccountTypeEnum;use FireflyIII\Support\Models\ReturnsIntegerIdTrait;use FireflyIII\Support\Models\ReturnsIntegerUserIdTrait;use FireflyIII\User;@@ -131,7 +132,7 @@ class Account extends Model{$name = $this->name;- if (AccountType::CASH === $this->accountType->type) {+ if (AccountTypeEnum::CASH->value === $this->accountType->type) {return '';}diff --git a/app/Repositories/Account/AccountRepository.php b/app/Repositories/Account/AccountRepository.phpindex f31df2b747..05267d6b5b 100644--- a/app/Repositories/Account/AccountRepository.php+++ b/app/Repositories/Account/AccountRepository.php@@ -24,6 +24,7 @@ declare(strict_types=1);namespace FireflyIII\Repositories\Account;use Carbon\Carbon;+use FireflyIII\Enums\AccountTypeEnum;use FireflyIII\Enums\TransactionTypeEnum;use FireflyIII\Exceptions\FireflyException;use FireflyIII\Factory\AccountFactory;@@ -228,7 +229,7 @@ class AccountRepository implements AccountRepositoryInterfacepublic function getCashAccount(): Account{/** @var AccountType $type */- $type = AccountType::where('type', AccountType::CASH)->first();+ $type = AccountType::where('type', AccountTypeEnum::CASH->value)->first();/** @var AccountFactory $factory */$factory = app(AccountFactory::class);@@ -348,14 +349,14 @@ class AccountRepository implements AccountRepositoryInterface*/public function getReconciliation(Account $account): ?Account{- if (AccountType::ASSET !== $account->accountType->type) {+ if (AccountTypeEnum::ASSET->value !== $account->accountType->type) {throw new FireflyException(sprintf('%s is not an asset account.', $account->name));}$currency = $this->getAccountCurrency($account) ?? app('amount')->getDefaultCurrency();$name = trans('firefly.reconciliation_account_name', ['name' => $account->name, 'currency' => $currency->code]);/** @var AccountType $type */- $type = AccountType::where('type', AccountType::RECONCILIATION)->first();+ $type = AccountType::where('type', AccountTypeEnum::RECONCILIATION->value)->first();/** @var null|Account $current */$current = $this->user->accounts()->where('account_type_id', $type->id)@@ -369,7 +370,7 @@ class AccountRepository implements AccountRepositoryInterface$data = ['account_type_id' => null,- 'account_type_name' => AccountType::RECONCILIATION,+ 'account_type_name' => AccountTypeEnum::RECONCILIATION->value,'active' => true,'name' => $name,'currency_id' => $currency->id,@@ -444,18 +445,18 @@ class AccountRepository implements AccountRepositoryInterfacepublic function isLiability(Account $account): bool{- return in_array($account->accountType->type, [AccountType::CREDITCARD, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE], true);+ return in_array($account->accountType->type, [AccountTypeEnum::CREDITCARD->value, AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::MORTGAGE->value], true);}public function maxOrder(string $type): int{$sets = [- AccountType::ASSET => [AccountType::DEFAULT, AccountType::ASSET],- AccountType::EXPENSE => [AccountType::EXPENSE, AccountType::BENEFICIARY],- AccountType::REVENUE => [AccountType::REVENUE],- AccountType::LOAN => [AccountType::LOAN, AccountType::DEBT, AccountType::CREDITCARD, AccountType::MORTGAGE],- AccountType::DEBT => [AccountType::LOAN, AccountType::DEBT, AccountType::CREDITCARD, AccountType::MORTGAGE],- AccountType::MORTGAGE => [AccountType::LOAN, AccountType::DEBT, AccountType::CREDITCARD, AccountType::MORTGAGE],+ AccountTypeEnum::ASSET->value => [AccountTypeEnum::DEFAULT->value, AccountTypeEnum::ASSET->value],+ AccountTypeEnum::EXPENSE->value => [AccountTypeEnum::EXPENSE->value, AccountTypeEnum::BENEFICIARY->value],+ AccountTypeEnum::REVENUE->value => [AccountTypeEnum::REVENUE->value],+ AccountTypeEnum::LOAN->value => [AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::CREDITCARD->value, AccountTypeEnum::MORTGAGE->value],+ AccountTypeEnum::DEBT->value => [AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::CREDITCARD->value, AccountTypeEnum::MORTGAGE->value],+ AccountTypeEnum::MORTGAGE->value => [AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::CREDITCARD->value, AccountTypeEnum::MORTGAGE->value],];if (array_key_exists(ucfirst($type), $sets)) {$order = (int) $this->getAccountsByType($sets[ucfirst($type)])->max('order');@@ -463,7 +464,7 @@ class AccountRepository implements AccountRepositoryInterfacereturn $order;}- $specials = [AccountType::CASH, AccountType::INITIAL_BALANCE, AccountType::IMPORT, AccountType::RECONCILIATION];+ $specials = [AccountTypeEnum::CASH->value, AccountTypeEnum::INITIAL_BALANCE->value, AccountTypeEnum::IMPORT->value, AccountTypeEnum::RECONCILIATION->value];$order = (int) $this->getAccountsByType($specials)->max('order');app('log')->debug(sprintf('Return max order of "%s" set (specials!): %d', $type, $order));@@ -473,7 +474,7 @@ class AccountRepository implements AccountRepositoryInterfacepublic function getAccountsByType(array $types, ?array $sort = []): Collection{- $res = array_intersect([AccountType::ASSET, AccountType::MORTGAGE, AccountType::LOAN, AccountType::DEBT], $types);+ $res = array_intersect([AccountTypeEnum::ASSET->value, AccountTypeEnum::MORTGAGE->value, AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value], $types);$query = $this->user->accounts();if (0 !== count($types)) {$query->accountTypeIn($types);@@ -531,11 +532,11 @@ class AccountRepository implements AccountRepositoryInterfacepublic function resetAccountOrder(): void{$sets = [- [AccountType::DEFAULT, AccountType::ASSET],- // [AccountType::EXPENSE, AccountType::BENEFICIARY],- // [AccountType::REVENUE],- [AccountType::LOAN, AccountType::DEBT, AccountType::CREDITCARD, AccountType::MORTGAGE],- // [AccountType::CASH, AccountType::INITIAL_BALANCE, AccountType::IMPORT, AccountType::RECONCILIATION],+ [AccountTypeEnum::DEFAULT->value, AccountTypeEnum::ASSET->value],+ // [AccountTypeEnum::EXPENSE->value, AccountTypeEnum::BENEFICIARY->value],+ // [AccountTypeEnum::REVENUE->value],+ [AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::CREDITCARD->value, AccountTypeEnum::MORTGAGE->value],+ // [AccountTypeEnum::CASH->value, AccountTypeEnum::INITIAL_BALANCE->value, AccountTypeEnum::IMPORT->value, AccountTypeEnum::RECONCILIATION->value],];foreach ($sets as $set) {$list = $this->getAccountsByType($set);@@ -555,7 +556,7 @@ class AccountRepository implements AccountRepositoryInterface}}// reset the rest to zero.- $all = [AccountType::DEFAULT, AccountType::ASSET, AccountType::LOAN, AccountType::DEBT, AccountType::CREDITCARD, AccountType::MORTGAGE];+ $all = [AccountTypeEnum::DEFAULT->value, AccountTypeEnum::ASSET->value, AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::CREDITCARD->value, AccountTypeEnum::MORTGAGE->value];$this->user->accounts()->leftJoin('account_types', 'account_types.id', '=', 'accounts.account_type_id')->whereNotIn('account_types.type', $all)->update(['order' => 0])diff --git a/app/Repositories/UserGroups/Account/AccountRepository.php b/app/Repositories/UserGroups/Account/AccountRepository.phpindex bc66665c98..7035f82b24 100644--- a/app/Repositories/UserGroups/Account/AccountRepository.php+++ b/app/Repositories/UserGroups/Account/AccountRepository.php@@ -24,6 +24,7 @@ declare(strict_types=1);namespace FireflyIII\Repositories\UserGroups\Account;+use FireflyIII\Enums\AccountTypeEnum;use FireflyIII\Models\Account;use FireflyIII\Models\AccountMeta;use FireflyIII\Models\AccountType;@@ -287,8 +288,8 @@ class AccountRepository implements AccountRepositoryInterfacepublic function resetAccountOrder(): void{$sets = [- [AccountType::DEFAULT, AccountType::ASSET],- [AccountType::LOAN, AccountType::DEBT, AccountType::CREDITCARD, AccountType::MORTGAGE],+ [AccountTypeEnum::DEFAULT->value, AccountTypeEnum::ASSET->value],+ [AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::CREDITCARD->value, AccountTypeEnum::MORTGAGE->value],];foreach ($sets as $set) {$list = $this->getAccountsByType($set);@@ -308,7 +309,7 @@ class AccountRepository implements AccountRepositoryInterface}}// reset the rest to zero.- $all = [AccountType::DEFAULT, AccountType::ASSET, AccountType::LOAN, AccountType::DEBT, AccountType::CREDITCARD, AccountType::MORTGAGE];+ $all = [AccountTypeEnum::DEFAULT->value, AccountTypeEnum::ASSET->value, AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::CREDITCARD->value, AccountTypeEnum::MORTGAGE->value];$this->user->accounts()->leftJoin('account_types', 'account_types.id', '=', 'accounts.account_type_id')->whereNotIn('account_types.type', $all)->update(['order' => 0])@@ -318,7 +319,7 @@ class AccountRepository implements AccountRepositoryInterfacepublic function getAccountsByType(array $types, ?array $sort = [], ?array $filters = []): Collection{$sortable = ['name', 'active']; // TODO yes this is a duplicate array.- $res = array_intersect([AccountType::ASSET, AccountType::MORTGAGE, AccountType::LOAN, AccountType::DEBT], $types);+ $res = array_intersect([AccountTypeEnum::ASSET->value, AccountTypeEnum::MORTGAGE->value, AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value], $types);$query = $this->userGroup->accounts();if (0 !== count($types)) {$query->accountTypeIn($types);diff --git a/app/Rules/IsAssetAccountId.php b/app/Rules/IsAssetAccountId.phpindex 20e2458fae..273a5b3f26 100644--- a/app/Rules/IsAssetAccountId.php+++ b/app/Rules/IsAssetAccountId.php@@ -23,6 +23,7 @@ declare(strict_types=1);namespace FireflyIII\Rules;+use FireflyIII\Enums\AccountTypeEnum;use FireflyIII\Models\Account;use FireflyIII\Models\AccountType;use Illuminate\Contracts\Validation\ValidationRule;@@ -46,7 +47,7 @@ class IsAssetAccountId implements ValidationRulereturn;}- if (AccountType::ASSET !== $account->accountType->type && AccountType::DEFAULT !== $account->accountType->type) {+ if (AccountTypeEnum::ASSET->value !== $account->accountType->type && AccountTypeEnum::DEFAULT->value !== $account->accountType->type) {$fail('validation.no_asset_account')->translate();}}diff --git a/app/Rules/UniqueAccountNumber.php b/app/Rules/UniqueAccountNumber.phpindex e2e22592ca..a45a8d0467 100644--- a/app/Rules/UniqueAccountNumber.php+++ b/app/Rules/UniqueAccountNumber.php@@ -24,6 +24,7 @@ declare(strict_types=1);namespace FireflyIII\Rules;+use FireflyIII\Enums\AccountTypeEnum;use FireflyIII\Models\Account;use FireflyIII\Models\AccountMeta;use FireflyIII\Models\AccountType;@@ -49,13 +50,13 @@ class UniqueAccountNumber implements ValidationRule$this->expectedType = $expectedType;// a very basic fix to make sure we get the correct account type:if ('expense' === $expectedType) {- $this->expectedType = AccountType::EXPENSE;+ $this->expectedType = AccountTypeEnum::EXPENSE->value;}if ('revenue' === $expectedType) {- $this->expectedType = AccountType::REVENUE;+ $this->expectedType = AccountTypeEnum::REVENUE->value;}if ('asset' === $expectedType) {- $this->expectedType = AccountType::ASSET;+ $this->expectedType = AccountTypeEnum::ASSET->value;}app('log')->debug(sprintf('Expected type is "%s"', $this->expectedType));}@@ -106,20 +107,20 @@ class UniqueAccountNumber implements ValidationRuleprivate function getMaxOccurrences(): array{$maxCounts = [- AccountType::ASSET => 0,- AccountType::EXPENSE => 0,- AccountType::REVENUE => 0,+ AccountTypeEnum::ASSET->value => 0,+ AccountTypeEnum::EXPENSE->value => 0,+ AccountTypeEnum::REVENUE->value => 0,];- if ('expense' === $this->expectedType || AccountType::EXPENSE === $this->expectedType) {+ if ('expense' === $this->expectedType || AccountTypeEnum::EXPENSE->value === $this->expectedType) {// IBAN should be unique amongst expense and asset accounts.// may appear once in revenue accounts- $maxCounts[AccountType::REVENUE] = 1;+ $maxCounts[AccountTypeEnum::REVENUE->value] = 1;}- if ('revenue' === $this->expectedType || AccountType::REVENUE === $this->expectedType) {+ if ('revenue' === $this->expectedType || AccountTypeEnum::REVENUE->value === $this->expectedType) {// IBAN should be unique amongst revenue and asset accounts.// may appear once in expense accounts- $maxCounts[AccountType::EXPENSE] = 1;+ $maxCounts[AccountTypeEnum::EXPENSE->value] = 1;}return $maxCounts;diff --git a/app/Rules/UniqueIban.php b/app/Rules/UniqueIban.phpindex 4991d0f37a..5f2116dcad 100644--- a/app/Rules/UniqueIban.php+++ b/app/Rules/UniqueIban.php@@ -24,6 +24,7 @@ declare(strict_types=1);namespace FireflyIII\Rules;+use FireflyIII\Enums\AccountTypeEnum;use FireflyIII\Models\Account;use FireflyIII\Models\AccountType;use FireflyIII\Support\Facades\Steam;@@ -50,16 +51,16 @@ class UniqueIban implements ValidationRule$this->expectedTypes = [$expectedType];// a very basic fix to make sure we get the correct account type:if ('expense' === $expectedType) {- $this->expectedTypes = [AccountType::EXPENSE];+ $this->expectedTypes = [AccountTypeEnum::EXPENSE->value];}if ('revenue' === $expectedType) {- $this->expectedTypes = [AccountType::REVENUE];+ $this->expectedTypes = [AccountTypeEnum::REVENUE->value];}if ('asset' === $expectedType) {- $this->expectedTypes = [AccountType::ASSET];+ $this->expectedTypes = [AccountTypeEnum::ASSET->value];}if ('liabilities' === $expectedType) {- $this->expectedTypes = [AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE];+ $this->expectedTypes = [AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::MORTGAGE->value];}}@@ -123,21 +124,21 @@ class UniqueIban implements ValidationRuleprivate function getMaxOccurrences(): array{$maxCounts = [- AccountType::ASSET => 0,- AccountType::EXPENSE => 0,- AccountType::REVENUE => 0,+ AccountTypeEnum::ASSET->value => 0,+ AccountTypeEnum::EXPENSE->value => 0,+ AccountTypeEnum::REVENUE->value => 0,'liabilities' => 0,];- if (in_array('expense', $this->expectedTypes, true) || in_array(AccountType::EXPENSE, $this->expectedTypes, true)) {+ if (in_array('expense', $this->expectedTypes, true) || in_array(AccountTypeEnum::EXPENSE->value, $this->expectedTypes, true)) {// IBAN should be unique amongst expense and asset accounts.// may appear once in revenue accounts- $maxCounts[AccountType::REVENUE] = 1;+ $maxCounts[AccountTypeEnum::REVENUE->value] = 1;}- if (in_array('revenue', $this->expectedTypes, true) || in_array(AccountType::REVENUE, $this->expectedTypes, true)) {+ if (in_array('revenue', $this->expectedTypes, true) || in_array(AccountTypeEnum::REVENUE->value, $this->expectedTypes, true)) {// IBAN should be unique amongst revenue and asset accounts.// may appear once in expense accounts- $maxCounts[AccountType::EXPENSE] = 1;+ $maxCounts[AccountTypeEnum::EXPENSE->value] = 1;}return $maxCounts;@@ -147,7 +148,7 @@ class UniqueIban implements ValidationRule{$typesArray = [$type];if ('liabilities' === $type) {- $typesArray = [AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE];+ $typesArray = [AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::MORTGAGE->value];}$query= auth()->user()diff --git a/app/Services/Internal/Support/AccountServiceTrait.php b/app/Services/Internal/Support/AccountServiceTrait.phpindex 868ffd8b27..863ceb1224 100644--- a/app/Services/Internal/Support/AccountServiceTrait.php+++ b/app/Services/Internal/Support/AccountServiceTrait.php@@ -25,6 +25,7 @@ declare(strict_types=1);namespace FireflyIII\Services\Internal\Support;use Carbon\Carbon;+use FireflyIII\Enums\AccountTypeEnum;use FireflyIII\Exceptions\DuplicateTransactionException;use FireflyIII\Exceptions\FireflyException;use FireflyIII\Factory\AccountMetaFactory;@@ -96,7 +97,7 @@ trait AccountServiceTraitpublic function updateMetaData(Account $account, array $data): void{$fields = $this->validFields;- if (AccountType::ASSET === $account->accountType->type) {+ if (AccountTypeEnum::ASSET->value === $account->accountType->type) {$fields = $this->validAssetFields;}@@ -119,11 +120,11 @@ trait AccountServiceTrait}// only asset account may have a role:- if (AccountType::ASSET !== $account->accountType->type) {+ if (AccountTypeEnum::ASSET->value !== $account->accountType->type) {$data['account_role'] = '';}- if (AccountType::ASSET === $account->accountType->type && 'ccAsset' === $data['account_role']) {+ if (AccountTypeEnum::ASSET->value === $account->accountType->type && 'ccAsset' === $data['account_role']) {$fields = $this->validCCFields;}diff --git a/app/Services/Internal/Support/JournalServiceTrait.php b/app/Services/Internal/Support/JournalServiceTrait.phpindex e16b956267..a98436f2a5 100644--- a/app/Services/Internal/Support/JournalServiceTrait.php+++ b/app/Services/Internal/Support/JournalServiceTrait.php@@ -24,6 +24,7 @@ declare(strict_types=1);namespace FireflyIII\Services\Internal\Support;+use FireflyIII\Enums\AccountTypeEnum;use FireflyIII\Enums\TransactionTypeEnum;use FireflyIII\Exceptions\FireflyException;use FireflyIII\Factory\AccountMetaFactory;@@ -258,7 +259,7 @@ trait JournalServiceTrait}if (null === $account) {// final attempt, create it.- if (AccountType::ASSET === $preferredType) {+ if (AccountTypeEnum::ASSET->value === $preferredType) {throw new FireflyException(sprintf('TransactionFactory: Cannot create asset account with these values: %s', json_encode($data)));}// fix name of account if only IBAN is given:@@ -312,7 +313,7 @@ trait JournalServiceTrait{// return cash account.if (null === $account && '' === (string) $data['name']- && in_array(AccountType::CASH, $types, true)) {+ && in_array(AccountTypeEnum::CASH->value, $types, true)) {$account = $this->accountRepository->getCashAccount();}app('log')->debug('Cannot return cash account, return input instead.');diff --git a/app/Services/Internal/Support/RecurringTransactionTrait.php b/app/Services/Internal/Support/RecurringTransactionTrait.phpindex e9ba8437f0..0b0c21a0d7 100644--- a/app/Services/Internal/Support/RecurringTransactionTrait.php+++ b/app/Services/Internal/Support/RecurringTransactionTrait.php@@ -24,6 +24,7 @@ declare(strict_types=1);namespace FireflyIII\Services\Internal\Support;+use FireflyIII\Enums\AccountTypeEnum;use FireflyIII\Exceptions\FireflyException;use FireflyIII\Factory\AccountFactory;use FireflyIII\Factory\BillFactory;@@ -189,7 +190,7 @@ trait RecurringTransactionTrait}// maybe we can create it? Try to avoid LOAN and other asset types.- $cannotCreate = [AccountType::ASSET, AccountType::DEBT, AccountType::LOAN, AccountType::MORTGAGE, AccountType::CREDITCARD];+ $cannotCreate = [AccountTypeEnum::ASSET->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::LOAN->value, AccountTypeEnum::MORTGAGE->value, AccountTypeEnum::CREDITCARD->value];/** @var AccountFactory $factory */$factory = app(AccountFactory::class);diff --git a/app/Services/Internal/Update/AccountUpdateService.php b/app/Services/Internal/Update/AccountUpdateService.phpindex 44b0a89d51..eddea89eec 100644--- a/app/Services/Internal/Update/AccountUpdateService.php+++ b/app/Services/Internal/Update/AccountUpdateService.php@@ -24,6 +24,7 @@ declare(strict_types=1);namespace FireflyIII\Services\Internal\Update;+use FireflyIII\Enums\AccountTypeEnum;use FireflyIII\Events\UpdatedAccount;use FireflyIII\Exceptions\FireflyException;use FireflyIII\Models\Account;@@ -153,7 +154,7 @@ class AccountUpdateService{$type = $account->accountType->type;- return in_array($type, [AccountType::DEBT, AccountType::LOAN, AccountType::MORTGAGE], true);+ return in_array($type, [AccountTypeEnum::DEBT->value, AccountTypeEnum::LOAN->value, AccountTypeEnum::MORTGAGE->value], true);}private function getAccountType(string $type): AccountType@@ -171,7 +172,7 @@ class AccountUpdateService}// skip if not of orderable type.$type = $account->accountType->type;- if (!in_array($type, [AccountType::ASSET, AccountType::MORTGAGE, AccountType::LOAN, AccountType::DEBT], true)) {+ if (!in_array($type, [AccountTypeEnum::ASSET->value, AccountTypeEnum::MORTGAGE->value, AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value], true)) {app('log')->debug('Will not change order of this account.');return $account;@@ -180,9 +181,9 @@ class AccountUpdateService$oldOrder = $account->order;$newOrder = $data['order'];app('log')->debug(sprintf('Order is set to be updated from %s to %s', $oldOrder, $newOrder));- $list = $this->getTypeIds([AccountType::MORTGAGE, AccountType::LOAN, AccountType::DEBT]);- if (AccountType::ASSET === $type) {- $list = $this->getTypeIds([AccountType::ASSET]);+ $list = $this->getTypeIds([AccountTypeEnum::MORTGAGE->value, AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value]);+ if (AccountTypeEnum::ASSET->value === $type) {+ $list = $this->getTypeIds([AccountTypeEnum::ASSET->value]);}if ($newOrder > $oldOrder) {diff --git a/app/Support/Binder/AccountList.php b/app/Support/Binder/AccountList.phpindex 79c8d65575..6628fdb6d5 100644--- a/app/Support/Binder/AccountList.php+++ b/app/Support/Binder/AccountList.php@@ -23,6 +23,7 @@ declare(strict_types=1);namespace FireflyIII\Support\Binder;+use FireflyIII\Enums\AccountTypeEnum;use FireflyIII\Models\AccountType;use Illuminate\Routing\Route;use Illuminate\Support\Collection;@@ -44,7 +45,7 @@ class AccountList implements BinderInterface/** @var Collection $collection */$collection = auth()->user()->accounts()->leftJoin('account_types', 'account_types.id', '=', 'accounts.account_type_id')- ->whereIn('account_types.type', [AccountType::ASSET, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE])+ ->whereIn('account_types.type', [AccountTypeEnum::ASSET->value, AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::MORTGAGE->value])->orderBy('accounts.name', 'ASC')->get(['accounts.*']);diff --git a/app/Support/Form/AccountForm.php b/app/Support/Form/AccountForm.phpindex 912861010d..2bfb98b673 100644--- a/app/Support/Form/AccountForm.php+++ b/app/Support/Form/AccountForm.php@@ -47,7 +47,7 @@ class AccountForm*/public function activeDepositDestinations(string $name, mixed $value = null, ?array $options = null): string{- $types = [AccountType::MORTGAGE, AccountType::DEBT, AccountType::CREDITCARD, AccountType::LOAN, AccountType::REVENUE];+ $types = [AccountTypeEnum::MORTGAGE->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::CREDITCARD->value, AccountTypeEnum::LOAN->value, AccountTypeEnum::REVENUE->value];$repository = $this->getAccountRepository();$grouped = $this->getAccountsGrouped($types, $repository);$cash = $repository->getCashAccount();@@ -63,7 +63,7 @@ class AccountForm$repository = $this->getAccountRepository();}$accountList = $repository->getActiveAccountsByType($types);- $liabilityTypes = [AccountType::MORTGAGE, AccountType::DEBT, AccountType::CREDITCARD, AccountType::LOAN];+ $liabilityTypes = [AccountTypeEnum::MORTGAGE->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::CREDITCARD->value, AccountTypeEnum::LOAN->value];$grouped = [];/** @var Account $account */@@ -74,10 +74,10 @@ class AccountForm}if ('' === $role) {$role = 'no_account_type';- if (AccountType::EXPENSE === $account->accountType->type) {+ if (AccountTypeEnum::EXPENSE->value === $account->accountType->type) {$role = 'expense_account';}- if (AccountType::REVENUE === $account->accountType->type) {+ if (AccountTypeEnum::REVENUE->value === $account->accountType->type) {$role = 'revenue_account';}}@@ -93,7 +93,7 @@ class AccountForm*/public function activeWithdrawalDestinations(string $name, mixed $value = null, ?array $options = null): string{- $types = [AccountType::MORTGAGE, AccountType::DEBT, AccountType::CREDITCARD, AccountType::LOAN, AccountType::EXPENSE];+ $types = [AccountTypeEnum::MORTGAGE->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::CREDITCARD->value, AccountTypeEnum::LOAN->value, AccountTypeEnum::EXPENSE->value];$repository = $this->getAccountRepository();$grouped = $this->getAccountsGrouped($types, $repository);@@ -118,7 +118,7 @@ class AccountForm$selected = request()->old($name) ?? [];// get all asset accounts:- $types = [AccountType::ASSET, AccountType::DEFAULT, AccountType::LOAN, AccountType::MORTGAGE, AccountType::DEBT];+ $types = [AccountTypeEnum::ASSET->value, AccountTypeEnum::DEFAULT->value, AccountTypeEnum::LOAN->value, AccountTypeEnum::MORTGAGE->value, AccountTypeEnum::DEBT->value];$grouped = $this->getAccountsGrouped($types);unset($options['class']);@@ -168,7 +168,7 @@ class AccountForm*/public function longAccountList(string $name, $value = null, ?array $options = null): string{- $types = [AccountType::ASSET, AccountType::DEFAULT, AccountType::MORTGAGE, AccountType::DEBT, AccountType::LOAN];+ $types = [AccountTypeEnum::ASSET->value, AccountTypeEnum::DEFAULT->value, AccountTypeEnum::MORTGAGE->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::LOAN->value];$grouped = $this->getAccountsGrouped($types);return $this->select($name, $grouped, $value, $options);diff --git a/app/Support/Http/Api/AccountFilter.php b/app/Support/Http/Api/AccountFilter.phpindex 75c69eb13f..9bfcbc350b 100644--- a/app/Support/Http/Api/AccountFilter.php+++ b/app/Support/Http/Api/AccountFilter.php@@ -36,53 +36,53 @@ trait AccountFilter= ['all' => [AccountTypeEnum::DEFAULT->value,- AccountType::CASH,- AccountType::ASSET,- AccountType::EXPENSE,- AccountType::REVENUE,- AccountType::INITIAL_BALANCE,- AccountType::BENEFICIARY,- AccountType::IMPORT,- AccountType::RECONCILIATION,- AccountType::LOAN,- AccountType::DEBT,- AccountType::MORTGAGE,+ AccountTypeEnum::CASH->value,+ AccountTypeEnum::ASSET->value,+ AccountTypeEnum::EXPENSE->value,+ AccountTypeEnum::REVENUE->value,+ AccountTypeEnum::INITIAL_BALANCE->value,+ AccountTypeEnum::BENEFICIARY->value,+ AccountTypeEnum::IMPORT->value,+ AccountTypeEnum::RECONCILIATION->value,+ AccountTypeEnum::LOAN->value,+ AccountTypeEnum::DEBT->value,+ AccountTypeEnum::MORTGAGE->value,],- 'asset' => [AccountType::DEFAULT, AccountType::ASSET],- 'cash' => [AccountType::CASH],- 'expense' => [AccountType::EXPENSE, AccountType::BENEFICIARY],- 'revenue' => [AccountType::REVENUE],- 'special' => [AccountType::CASH, AccountType::INITIAL_BALANCE, AccountType::IMPORT, AccountType::RECONCILIATION],- 'hidden' => [AccountType::INITIAL_BALANCE, AccountType::IMPORT, AccountType::RECONCILIATION],- 'liability' => [AccountType::DEBT, AccountType::LOAN, AccountType::MORTGAGE, AccountType::CREDITCARD],- 'liabilities' => [AccountType::DEBT, AccountType::LOAN, AccountType::MORTGAGE, AccountType::CREDITCARD],- AccountType::DEFAULT => [AccountType::DEFAULT],- AccountType::CASH => [AccountType::CASH],- AccountType::ASSET => [AccountType::ASSET],- AccountType::EXPENSE => [AccountType::EXPENSE],- AccountType::REVENUE => [AccountType::REVENUE],- AccountType::INITIAL_BALANCE => [AccountType::INITIAL_BALANCE],- AccountType::BENEFICIARY => [AccountType::BENEFICIARY],- AccountType::IMPORT => [AccountType::IMPORT],- AccountType::RECONCILIATION => [AccountType::RECONCILIATION],- AccountType::LOAN => [AccountType::LOAN],- AccountType::MORTGAGE => [AccountType::MORTGAGE],- AccountType::DEBT => [AccountType::DEBT],- AccountType::CREDITCARD => [AccountType::CREDITCARD],- 'default account' => [AccountType::DEFAULT],- 'cash account' => [AccountType::CASH],- 'asset account' => [AccountType::ASSET],- 'expense account' => [AccountType::EXPENSE],- 'revenue account' => [AccountType::REVENUE],- 'initial balance account' => [AccountType::INITIAL_BALANCE],- 'reconciliation' => [AccountType::RECONCILIATION],- 'loan' => [AccountType::LOAN],- 'mortgage' => [AccountType::MORTGAGE],- 'debt' => [AccountType::DEBT],- 'credit card' => [AccountType::CREDITCARD],- 'credit-card' => [AccountType::CREDITCARD],- 'creditcard' => [AccountType::CREDITCARD],- 'cc' => [AccountType::CREDITCARD],+ 'asset' => [AccountTypeEnum::DEFAULT->value, AccountTypeEnum::ASSET->value],+ 'cash' => [AccountTypeEnum::CASH->value],+ 'expense' => [AccountTypeEnum::EXPENSE->value, AccountTypeEnum::BENEFICIARY->value],+ 'revenue' => [AccountTypeEnum::REVENUE->value],+ 'special' => [AccountTypeEnum::CASH->value, AccountTypeEnum::INITIAL_BALANCE->value, AccountTypeEnum::IMPORT->value, AccountTypeEnum::RECONCILIATION->value],+ 'hidden' => [AccountTypeEnum::INITIAL_BALANCE->value, AccountTypeEnum::IMPORT->value, AccountTypeEnum::RECONCILIATION->value],+ 'liability' => [AccountTypeEnum::DEBT->value, AccountTypeEnum::LOAN->value, AccountTypeEnum::MORTGAGE->value, AccountTypeEnum::CREDITCARD->value],+ 'liabilities' => [AccountTypeEnum::DEBT->value, AccountTypeEnum::LOAN->value, AccountTypeEnum::MORTGAGE->value, AccountTypeEnum::CREDITCARD->value],+ AccountTypeEnum::DEFAULT->value => [AccountTypeEnum::DEFAULT->value],+ AccountTypeEnum::CASH->value => [AccountTypeEnum::CASH->value],+ AccountTypeEnum::ASSET->value => [AccountTypeEnum::ASSET->value],+ AccountTypeEnum::EXPENSE->value => [AccountTypeEnum::EXPENSE->value],+ AccountTypeEnum::REVENUE->value => [AccountTypeEnum::REVENUE->value],+ AccountTypeEnum::INITIAL_BALANCE->value => [AccountTypeEnum::INITIAL_BALANCE->value],+ AccountTypeEnum::BENEFICIARY->value => [AccountTypeEnum::BENEFICIARY->value],+ AccountTypeEnum::IMPORT->value => [AccountTypeEnum::IMPORT->value],+ AccountTypeEnum::RECONCILIATION->value => [AccountTypeEnum::RECONCILIATION->value],+ AccountTypeEnum::LOAN->value => [AccountTypeEnum::LOAN->value],+ AccountTypeEnum::MORTGAGE->value => [AccountTypeEnum::MORTGAGE->value],+ AccountTypeEnum::DEBT->value => [AccountTypeEnum::DEBT->value],+ AccountTypeEnum::CREDITCARD->value => [AccountTypeEnum::CREDITCARD->value],+ 'default account' => [AccountTypeEnum::DEFAULT->value],+ 'cash account' => [AccountTypeEnum::CASH->value],+ 'asset account' => [AccountTypeEnum::ASSET->value],+ 'expense account' => [AccountTypeEnum::EXPENSE->value],+ 'revenue account' => [AccountTypeEnum::REVENUE->value],+ 'initial balance account' => [AccountTypeEnum::INITIAL_BALANCE->value],+ 'reconciliation' => [AccountTypeEnum::RECONCILIATION->value],+ 'loan' => [AccountTypeEnum::LOAN->value],+ 'mortgage' => [AccountTypeEnum::MORTGAGE->value],+ 'debt' => [AccountTypeEnum::DEBT->value],+ 'credit card' => [AccountTypeEnum::CREDITCARD->value],+ 'credit-card' => [AccountTypeEnum::CREDITCARD->value],+ 'creditcard' => [AccountTypeEnum::CREDITCARD->value],+ 'cc' => [AccountTypeEnum::CREDITCARD->value],];/**diff --git a/app/Support/Http/Api/CollectsAccountsFromFilter.php b/app/Support/Http/Api/CollectsAccountsFromFilter.phpindex e2738c7108..8dd2be7a53 100644--- a/app/Support/Http/Api/CollectsAccountsFromFilter.php+++ b/app/Support/Http/Api/CollectsAccountsFromFilter.php@@ -24,6 +24,7 @@ declare(strict_types=1);namespace FireflyIII\Support\Http\Api;+use FireflyIII\Enums\AccountTypeEnum;use FireflyIII\Models\AccountType;use Illuminate\Support\Collection;@@ -52,7 +53,7 @@ trait CollectsAccountsFromFilter}// if no preselected, but no accounts:if ('empty' === $queryParameters['preselected'] && 0 === $collection->count()) {- $defaultSet = $this->repository->getAccountsByType([AccountType::ASSET, AccountType::DEFAULT])->pluck('id')->toArray();+ $defaultSet = $this->repository->getAccountsByType([AccountTypeEnum::ASSET->value, AccountTypeEnum::DEFAULT->value])->pluck('id')->toArray();$frontpage = app('preferences')->get('frontpageAccounts', $defaultSet);if (!(is_array($frontpage->data) && count($frontpage->data) > 0)) {@@ -65,13 +66,13 @@ trait CollectsAccountsFromFilter// both options are overruled by "preselected"if ('all' === $queryParameters['preselected']) {- return $this->repository->getAccountsByType([AccountType::ASSET, AccountType::DEFAULT, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE]);+ return $this->repository->getAccountsByType([AccountTypeEnum::ASSET->value, AccountTypeEnum::DEFAULT->value, AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::MORTGAGE->value]);}if ('assets' === $queryParameters['preselected']) {- return $this->repository->getAccountsByType([AccountType::ASSET, AccountType::DEFAULT]);+ return $this->repository->getAccountsByType([AccountTypeEnum::ASSET->value, AccountTypeEnum::DEFAULT->value]);}if ('liabilities' === $queryParameters['preselected']) {- return $this->repository->getAccountsByType([AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE]);+ return $this->repository->getAccountsByType([AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::MORTGAGE->value]);}return $collection;diff --git a/app/Support/Http/Controllers/AugumentData.php b/app/Support/Http/Controllers/AugumentData.phpindex 9290d9e562..01c046d227 100644--- a/app/Support/Http/Controllers/AugumentData.php+++ b/app/Support/Http/Controllers/AugumentData.php@@ -25,6 +25,7 @@ declare(strict_types=1);namespace FireflyIII\Support\Http\Controllers;use Carbon\Carbon;+use FireflyIII\Enums\AccountTypeEnum;use FireflyIII\Enums\TransactionTypeEnum;use FireflyIII\Helpers\Collector\GroupCollectorInterface;use FireflyIII\Models\Account;@@ -59,7 +60,7 @@ trait AugumentData$collection = new Collection();$collection->push($expenseAccount);- $revenue = $repository->findByName($expenseAccount->name, [AccountType::REVENUE]);+ $revenue = $repository->findByName($expenseAccount->name, [AccountTypeEnum::REVENUE->value]);if (null !== $revenue) {$collection->push($revenue);}@@ -106,7 +107,7 @@ trait AugumentData{/** @var AccountRepositoryInterface $repository */$repository = app(AccountRepositoryInterface::class);- $accounts = $repository->getAccountsByType([AccountType::ASSET, AccountType::DEFAULT, AccountType::EXPENSE, AccountType::CASH]);+ $accounts = $repository->getAccountsByType([AccountTypeEnum::ASSET->value, AccountTypeEnum::DEFAULT->value, AccountTypeEnum::EXPENSE->value, AccountTypeEnum::CASH->value]);$grouped = $accounts->groupBy('id')->toArray();$return = [];foreach ($accountIds as $combinedId) {diff --git a/app/Support/Http/Controllers/ModelInformation.php b/app/Support/Http/Controllers/ModelInformation.phpindex d1a96aa307..dfff32f1c4 100644--- a/app/Support/Http/Controllers/ModelInformation.php+++ b/app/Support/Http/Controllers/ModelInformation.php@@ -78,13 +78,13 @@ trait ModelInformation// types of liability:/** @var AccountType $debt */- $debt = $repository->getAccountTypeByType(AccountType::DEBT);+ $debt = $repository->getAccountTypeByType(AccountTypeEnum::DEBT->value);/** @var AccountType $loan */- $loan = $repository->getAccountTypeByType(AccountType::LOAN);+ $loan = $repository->getAccountTypeByType(AccountTypeEnum::LOAN->value);/** @var AccountType $mortgage */- $mortgage = $repository->getAccountTypeByType(AccountType::MORTGAGE);+ $mortgage = $repository->getAccountTypeByType(AccountTypeEnum::MORTGAGE->value);$liabilityTypes = [$debt->id => (string) trans(sprintf('firefly.account_type_%s', AccountTypeEnum::DEBT->value)),$loan->id => (string) trans(sprintf('firefly.account_type_%s', AccountTypeEnum::LOAN->value)),diff --git a/app/Support/Http/Controllers/RenderPartialViews.php b/app/Support/Http/Controllers/RenderPartialViews.phpindex b4764dd024..07cc47d2dc 100644--- a/app/Support/Http/Controllers/RenderPartialViews.php+++ b/app/Support/Http/Controllers/RenderPartialViews.php@@ -24,6 +24,7 @@ declare(strict_types=1);namespace FireflyIII\Support\Http\Controllers;+use FireflyIII\Enums\AccountTypeEnum;use FireflyIII\Exceptions\FireflyException;use FireflyIII\Helpers\Report\PopupReportInterface;use FireflyIII\Models\Account;@@ -192,8 +193,8 @@ trait RenderPartialViews{/** @var AccountRepositoryInterface $repository */$repository = app(AccountRepositoryInterface::class);- $expense = $repository->getActiveAccountsByType([AccountType::EXPENSE, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE]);- $revenue = $repository->getActiveAccountsByType([AccountType::REVENUE, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE]);+ $expense = $repository->getActiveAccountsByType([AccountTypeEnum::EXPENSE->value, AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::MORTGAGE->value]);+ $revenue = $repository->getActiveAccountsByType([AccountTypeEnum::REVENUE->value, AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::MORTGAGE->value]);$set = [];/** @var Account $account */diff --git a/app/Support/Http/Controllers/UserNavigation.php b/app/Support/Http/Controllers/UserNavigation.phpindex f974d320b8..47ce038d6c 100644--- a/app/Support/Http/Controllers/UserNavigation.php+++ b/app/Support/Http/Controllers/UserNavigation.php@@ -24,6 +24,7 @@ declare(strict_types=1);namespace FireflyIII\Support\Http\Controllers;+use FireflyIII\Enums\AccountTypeEnum;use FireflyIII\Enums\TransactionTypeEnum;use FireflyIII\Models\Account;use FireflyIII\Models\AccountType;@@ -61,7 +62,7 @@ trait UserNavigation*/final protected function isEditableAccount(Account $account): bool{- $editable = [AccountType::EXPENSE, AccountType::REVENUE, AccountType::ASSET, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE];+ $editable = [AccountTypeEnum::EXPENSE->value, AccountTypeEnum::REVENUE->value, AccountTypeEnum::ASSET->value, AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::MORTGAGE->value];$type = $account->accountType->type;return in_array($type, $editable, true);@@ -86,7 +87,7 @@ trait UserNavigationfinal protected function redirectAccountToAccount(Account $account){$type = $account->accountType->type;- if (AccountType::RECONCILIATION === $type || AccountType::INITIAL_BALANCE === $type || AccountType::LIABILITY_CREDIT === $type) {+ if (AccountTypeEnum::RECONCILIATION->value === $type || AccountTypeEnum::INITIAL_BALANCE->value === $type || AccountTypeEnum::LIABILITY_CREDIT->value === $type) {// reconciliation must be stored somewhere in this account's transactions./** @var null|Transaction $transaction */@@ -128,7 +129,7 @@ trait UserNavigation}// prefer redirect to everything but expense and revenue:$transactions = $journal->transactions;- $ignore = [AccountType::REVENUE, AccountType::EXPENSE, AccountType::RECONCILIATION, AccountType::INITIAL_BALANCE];+ $ignore = [AccountTypeEnum::REVENUE->value, AccountTypeEnum::EXPENSE->value, AccountTypeEnum::RECONCILIATION->value, AccountTypeEnum::INITIAL_BALANCE->value];/** @var Transaction $transaction */foreach ($transactions as $transaction) {diff --git a/app/Support/Search/OperatorQuerySearch.php b/app/Support/Search/OperatorQuerySearch.phpindex 8683d4e289..50dbff217a 100644--- a/app/Support/Search/OperatorQuerySearch.php+++ b/app/Support/Search/OperatorQuerySearch.php@@ -25,6 +25,7 @@ declare(strict_types=1);namespace FireflyIII\Support\Search;use Carbon\Carbon;+use FireflyIII\Enums\AccountTypeEnum;use FireflyIII\Enums\SearchDirection;use FireflyIII\Enums\StringPosition;use FireflyIII\Exceptions\FireflyException;@@ -1938,7 +1939,7 @@ class OperatorQuerySearch implements SearchInterfaceapp('log')->debug(sprintf('searchAccount("%s", %s, %s)', $value, $stringPosition->name, $searchDirection->name));// search direction (default): for source accounts- $searchTypes = [AccountType::ASSET, AccountType::MORTGAGE, AccountType::LOAN, AccountType::DEBT, AccountType::REVENUE];+ $searchTypes = [AccountTypeEnum::ASSET->value, AccountTypeEnum::MORTGAGE->value, AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::REVENUE->value];$collectorMethod = 'setSourceAccounts';if ($prohibited) {$collectorMethod = 'excludeSourceAccounts';@@ -1947,7 +1948,7 @@ class OperatorQuerySearch implements SearchInterface// search direction: for destination accountsif (SearchDirection::DESTINATION === $searchDirection) { // destination// destination can be- $searchTypes = [AccountType::ASSET, AccountType::MORTGAGE, AccountType::LOAN, AccountType::DEBT, AccountType::EXPENSE];+ $searchTypes = [AccountTypeEnum::ASSET->value, AccountTypeEnum::MORTGAGE->value, AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::EXPENSE->value];$collectorMethod = 'setDestinationAccounts';if ($prohibited) {$collectorMethod = 'excludeDestinationAccounts';@@ -1955,7 +1956,7 @@ class OperatorQuerySearch implements SearchInterface}// either account could be:if (SearchDirection::BOTH === $searchDirection) {- $searchTypes = [AccountType::ASSET, AccountType::MORTGAGE, AccountType::LOAN, AccountType::DEBT, AccountType::EXPENSE, AccountType::REVENUE];+ $searchTypes = [AccountTypeEnum::ASSET->value, AccountTypeEnum::MORTGAGE->value, AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::EXPENSE->value, AccountTypeEnum::REVENUE->value];$collectorMethod = 'setAccounts';if ($prohibited) {$collectorMethod = 'excludeAccounts';@@ -2018,7 +2019,7 @@ class OperatorQuerySearch implements SearchInterfaceapp('log')->debug(sprintf('searchAccountNr(%s, %d, %d)', $value, $searchDirection->name, $stringPosition->name));// search direction (default): for source accounts- $searchTypes = [AccountType::ASSET, AccountType::MORTGAGE, AccountType::LOAN, AccountType::DEBT, AccountType::REVENUE];+ $searchTypes = [AccountTypeEnum::ASSET->value, AccountTypeEnum::MORTGAGE->value, AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::REVENUE->value];$collectorMethod = 'setSourceAccounts';if (true === $prohibited) {$collectorMethod = 'excludeSourceAccounts';@@ -2027,7 +2028,7 @@ class OperatorQuerySearch implements SearchInterface// search direction: for destination accountsif (SearchDirection::DESTINATION === $searchDirection) {// destination can be- $searchTypes = [AccountType::ASSET, AccountType::MORTGAGE, AccountType::LOAN, AccountType::DEBT, AccountType::EXPENSE];+ $searchTypes = [AccountTypeEnum::ASSET->value, AccountTypeEnum::MORTGAGE->value, AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::EXPENSE->value];$collectorMethod = 'setDestinationAccounts';if (true === $prohibited) {$collectorMethod = 'excludeDestinationAccounts';@@ -2036,7 +2037,7 @@ class OperatorQuerySearch implements SearchInterface// either account could be:if (SearchDirection::BOTH === $searchDirection) {- $searchTypes = [AccountType::ASSET, AccountType::MORTGAGE, AccountType::LOAN, AccountType::DEBT, AccountType::EXPENSE, AccountType::REVENUE];+ $searchTypes = [AccountTypeEnum::ASSET->value, AccountTypeEnum::MORTGAGE->value, AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::EXPENSE->value, AccountTypeEnum::REVENUE->value];$collectorMethod = 'setAccounts';if (true === $prohibited) {$collectorMethod = 'excludeAccounts';diff --git a/app/Support/Twig/TransactionGroupTwig.php b/app/Support/Twig/TransactionGroupTwig.phpindex bb60458ad2..c43e75bc31 100644--- a/app/Support/Twig/TransactionGroupTwig.php+++ b/app/Support/Twig/TransactionGroupTwig.php@@ -25,6 +25,7 @@ declare(strict_types=1);namespace FireflyIII\Support\Twig;use Carbon\Carbon;+use FireflyIII\Enums\AccountTypeEnum;use FireflyIII\Enums\TransactionTypeEnum;use FireflyIII\Models\AccountType;use FireflyIII\Models\Transaction;@@ -103,12 +104,12 @@ class TransactionGroupTwig extends AbstractExtension}// opening balance and it comes from initial balance? its expense.- if (TransactionTypeEnum::OPENING_BALANCE->value === $transactionType && AccountType::INITIAL_BALANCE !== $sourceType) {+ if (TransactionTypeEnum::OPENING_BALANCE->value === $transactionType && AccountTypeEnum::INITIAL_BALANCE->value !== $sourceType) {$amount = bcmul($amount, '-1');}// reconciliation and it comes from reconciliation?- if (TransactionTypeEnum::RECONCILIATION->value === $transactionType && AccountType::RECONCILIATION !== $sourceType) {+ if (TransactionTypeEnum::RECONCILIATION->value === $transactionType && AccountTypeEnum::RECONCILIATION->value !== $sourceType) {$amount = bcmul($amount, '-1');}diff --git a/app/TransactionRules/Actions/ConvertToDeposit.php b/app/TransactionRules/Actions/ConvertToDeposit.phpindex 341a302149..d4a82febee 100644--- a/app/TransactionRules/Actions/ConvertToDeposit.php+++ b/app/TransactionRules/Actions/ConvertToDeposit.php@@ -24,6 +24,7 @@ declare(strict_types=1);namespace FireflyIII\TransactionRules\Actions;+use FireflyIII\Enums\AccountTypeEnum;use FireflyIII\Enums\TransactionTypeEnum;use FireflyIII\Events\Model\Rule\RuleActionFailedOnArray;use FireflyIII\Events\TriggeredAuditLog;@@ -148,7 +149,7 @@ class ConvertToDeposit implements ActionInterface$validTypes = config('firefly.expected_source_types.source.Deposit');$opposingAccount = $repository->findByName($opposingName, $validTypes);if (null === $opposingAccount) {- $opposingAccount = $factory->findOrCreate($opposingName, AccountType::REVENUE);+ $opposingAccount = $factory->findOrCreate($opposingName, AccountTypeEnum::REVENUE->value);}app('log')->debug(sprintf('ConvertToDeposit. Action value is "%s", new opposing name is "%s"', $actionValue, $opposingAccount->name));@@ -236,7 +237,7 @@ class ConvertToDeposit implements ActionInterface$validTypes = config('firefly.expected_source_types.source.Deposit');$opposingAccount = $repository->findByName($opposingName, $validTypes);if (null === $opposingAccount) {- $opposingAccount = $factory->findOrCreate($opposingName, AccountType::REVENUE);+ $opposingAccount = $factory->findOrCreate($opposingName, AccountTypeEnum::REVENUE->value);}app('log')->debug(sprintf('ConvertToDeposit. Action value is "%s", revenue name is "%s"', $actionValue, $opposingAccount->name));diff --git a/app/TransactionRules/Actions/ConvertToWithdrawal.php b/app/TransactionRules/Actions/ConvertToWithdrawal.phpindex 11590cf8b7..67edc3783d 100644--- a/app/TransactionRules/Actions/ConvertToWithdrawal.php+++ b/app/TransactionRules/Actions/ConvertToWithdrawal.php@@ -24,6 +24,7 @@ declare(strict_types=1);namespace FireflyIII\TransactionRules\Actions;+use FireflyIII\Enums\AccountTypeEnum;use FireflyIII\Enums\TransactionTypeEnum;use FireflyIII\Events\Model\Rule\RuleActionFailedOnArray;use FireflyIII\Events\TriggeredAuditLog;@@ -142,7 +143,7 @@ class ConvertToWithdrawal implements ActionInterface$validTypes = config('firefly.expected_source_types.destination.Withdrawal');$opposingAccount = $repository->findByName($opposingName, $validTypes);if (null === $opposingAccount) {- $opposingAccount = $factory->findOrCreate($opposingName, AccountType::EXPENSE);+ $opposingAccount = $factory->findOrCreate($opposingName, AccountTypeEnum::EXPENSE->value);}app('log')->debug(sprintf('ConvertToWithdrawal. Action value is "%s", expense name is "%s"', $actionValue, $opposingName));@@ -228,7 +229,7 @@ class ConvertToWithdrawal implements ActionInterface$validTypes = config('firefly.expected_source_types.destination.Withdrawal');$opposingAccount = $repository->findByName($opposingName, $validTypes);if (null === $opposingAccount) {- $opposingAccount = $factory->findOrCreate($opposingName, AccountType::EXPENSE);+ $opposingAccount = $factory->findOrCreate($opposingName, AccountTypeEnum::EXPENSE->value);}app('log')->debug(sprintf('ConvertToWithdrawal. Action value is "%s", destination name is "%s"', $actionValue, $opposingName));diff --git a/app/Validation/Account/DepositValidation.php b/app/Validation/Account/DepositValidation.phpindex 961e709503..0f9336e2b9 100644--- a/app/Validation/Account/DepositValidation.php+++ b/app/Validation/Account/DepositValidation.php@@ -24,6 +24,7 @@ declare(strict_types=1);namespace FireflyIII\Validation\Account;+use FireflyIII\Enums\AccountTypeEnum;use FireflyIII\Models\Account;use FireflyIII\Models\AccountType;@@ -173,7 +174,7 @@ trait DepositValidation// set the source to be a (dummy) revenue account.$account = new Account();- $accountType = AccountType::whereType(AccountType::REVENUE)->first();+ $accountType = AccountType::whereType(AccountTypeEnum::REVENUE->value)->first();$account->accountType = $accountType;$this->setSource($account);}diff --git a/app/Validation/Account/LiabilityValidation.php b/app/Validation/Account/LiabilityValidation.phpindex f3fc714c9d..4c08694ecf 100644--- a/app/Validation/Account/LiabilityValidation.php+++ b/app/Validation/Account/LiabilityValidation.php@@ -24,6 +24,7 @@ declare(strict_types=1);namespace FireflyIII\Validation\Account;+use FireflyIII\Enums\AccountTypeEnum;use FireflyIII\Models\Account;use FireflyIII\Models\AccountType;@@ -43,7 +44,7 @@ trait LiabilityValidation// if the ID is not null the source account should be a dummy account of the type liability credit.// the ID of the destination must belong to a liability.if (null !== $accountId) {- if (AccountType::LIABILITY_CREDIT !== $this->source?->accountType?->type) {+ if (AccountTypeEnum::LIABILITY_CREDIT->value !== $this->source?->accountType?->type) {app('log')->error('Source account is not a liability.');return false;@@ -104,7 +105,7 @@ trait LiabilityValidationapp('log')->error('Array has a name, return true.');// set the source to be a (dummy) revenue account.$account = new Account();- $accountType = AccountType::whereType(AccountType::LIABILITY_CREDIT)->first();+ $accountType = AccountType::whereType(AccountTypeEnum::LIABILITY_CREDIT->value)->first();$account->accountType = $accountType;$this->setSource($account);}diff --git a/app/Validation/Account/OBValidation.php b/app/Validation/Account/OBValidation.phpindex 30c2e65cb2..dcc174c4c7 100644--- a/app/Validation/Account/OBValidation.php+++ b/app/Validation/Account/OBValidation.php@@ -24,6 +24,7 @@ declare(strict_types=1);namespace FireflyIII\Validation\Account;+use FireflyIII\Enums\AccountTypeEnum;use FireflyIII\Models\Account;use FireflyIII\Models\AccountType;@@ -126,7 +127,7 @@ trait OBValidation$account = new Account();/** @var AccountType $accountType */- $accountType = AccountType::whereType(AccountType::INITIAL_BALANCE)->first();+ $accountType = AccountType::whereType(AccountTypeEnum::INITIAL_BALANCE->value)->first();$account->accountType = $accountType;$this->setSource($account);}diff --git a/app/Validation/Account/WithdrawalValidation.php b/app/Validation/Account/WithdrawalValidation.phpindex 630d8f8b66..c2b758e917 100644--- a/app/Validation/Account/WithdrawalValidation.php+++ b/app/Validation/Account/WithdrawalValidation.php@@ -24,6 +24,7 @@ declare(strict_types=1);namespace FireflyIII\Validation\Account;+use FireflyIII\Enums\AccountTypeEnum;use FireflyIII\Models\Account;use FireflyIII\Models\AccountType;@@ -39,7 +40,7 @@ trait WithdrawalValidation$accountIban = array_key_exists('iban', $array) ? $array['iban'] : null;app('log')->debug('Now in validateGenericSource', $array);// source can be any of the following types.- $validTypes = [AccountType::ASSET, AccountType::REVENUE, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE];+ $validTypes = [AccountTypeEnum::ASSET->value, AccountTypeEnum::REVENUE->value, AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::MORTGAGE->value];if (null === $accountId && null === $accountName && null === $accountIban && false === $this->canCreateTypes($validTypes)) {// if both values are NULL we return TRUE// because we assume the user doesn't want to submit / change anything.diff --git a/app/Validation/FireflyValidator.php b/app/Validation/FireflyValidator.phpindex 5c5a19f9a7..7fd93ac714 100644--- a/app/Validation/FireflyValidator.php+++ b/app/Validation/FireflyValidator.php@@ -23,6 +23,7 @@ declare(strict_types=1);namespace FireflyIII\Validation;+use FireflyIII\Enums\AccountTypeEnum;use FireflyIII\Exceptions\FireflyException;use FireflyIII\Models\Account;use FireflyIII\Models\AccountMeta;@@ -316,12 +317,12 @@ class FireflyValidator extends Validator$account = $repository->findByName($value,[- AccountType::DEFAULT,- AccountType::ASSET,- AccountType::LOAN,- AccountType::DEBT,- AccountType::MORTGAGE,- AccountType::CREDITCARD,+ AccountTypeEnum::DEFAULT->value,+ AccountTypeEnum::ASSET->value,+ AccountTypeEnum::LOAN->value,+ AccountTypeEnum::DEBT->value,+ AccountTypeEnum::MORTGAGE->value,+ AccountTypeEnum::CREDITCARD->value,]);diff --git a/app/Validation/TransactionValidation.php b/app/Validation/TransactionValidation.phpindex df16bfceae..4e5f390861 100644--- a/app/Validation/TransactionValidation.php+++ b/app/Validation/TransactionValidation.php@@ -24,6 +24,7 @@ declare(strict_types=1);namespace FireflyIII\Validation;+use FireflyIII\Enums\AccountTypeEnum;use FireflyIII\Enums\TransactionTypeEnum;use FireflyIII\Exceptions\FireflyException;use FireflyIII\Models\Account;@@ -308,7 +309,7 @@ trait TransactionValidation{$type = $account->accountType->type;- return AccountType::ASSET === $type;+ return AccountTypeEnum::ASSET->value === $type;}private function hasForeignCurrencyInfo(array $transaction): bool