mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-29 18:20:01 +00:00
Replace enum
This commit is contained in:
@@ -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 Controller
|
||||
if (!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);
|
||||
}
|
||||
|
@@ -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 Controller
|
||||
if (!$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))]));
|
||||
|
@@ -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>';
|
||||
}
|
||||
|
||||
|
@@ -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 = [];
|
||||
|
@@ -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 Controller
|
||||
public 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' => []];
|
||||
|
||||
|
@@ -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()));
|
||||
|
||||
|
@@ -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.
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
|
@@ -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 Controller
|
||||
private 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 Controller
|
||||
if (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 Controller
|
||||
private 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 Controller
|
||||
if (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 Controller
|
||||
private 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 Controller
|
||||
private function getAssetAccounts(): array
|
||||
{
|
||||
// make repositories
|
||||
$accountList = $this->accountRepository->getActiveAccountsByType([AccountType::ASSET]);
|
||||
$accountList = $this->accountRepository->getActiveAccountsByType([AccountTypeEnum::ASSET->value]);
|
||||
$grouped = [];
|
||||
|
||||
// group accounts:
|
||||
|
@@ -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 */
|
||||
|
Reference in New Issue
Block a user