mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2024-12-01 21:19:11 -06:00
parent
4a3c2d5d97
commit
71d53fbda4
@ -25,7 +25,6 @@ namespace FireflyIII\Api\V1\Controllers\Autocomplete;
|
||||
|
||||
use FireflyIII\Api\V1\Controllers\Controller;
|
||||
use FireflyIII\Api\V1\Requests\Autocomplete\AutocompleteRequest;
|
||||
use FireflyIII\Enums\AccountTypeEnum;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\AccountType;
|
||||
@ -61,7 +60,7 @@ class AccountController extends Controller
|
||||
return $next($request);
|
||||
}
|
||||
);
|
||||
$this->balanceTypes = [AccountTypeEnum::ASSET, AccountTypeEnum::LOAN, AccountTypeEnum::DEBT, AccountTypeEnum::MORTGAGE,];
|
||||
$this->balanceTypes = [AccountType::ASSET, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE,];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -110,7 +109,7 @@ class AccountController extends Controller
|
||||
}
|
||||
|
||||
// custom order.
|
||||
$order = [AccountTypeEnum::ASSET, AccountTypeEnum::REVENUE, AccountTypeEnum::EXPENSE];
|
||||
$order = [AccountType::ASSET, AccountType::REVENUE, AccountType::EXPENSE];
|
||||
usort(
|
||||
$return, function ($a, $b) use ($order) {
|
||||
$pos_a = array_search($a['type'], $order);
|
||||
|
@ -27,9 +27,9 @@ namespace FireflyIII\Api\V1\Controllers\Chart;
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Api\V1\Controllers\Controller;
|
||||
use FireflyIII\Api\V1\Requests\Data\DateRequest;
|
||||
use FireflyIII\Enums\AccountTypeEnum;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||
use FireflyIII\Support\Http\Api\ApiSupport;
|
||||
@ -94,7 +94,7 @@ class AccountController extends Controller
|
||||
$end = $dates['end'];
|
||||
|
||||
// user's preferences
|
||||
$defaultSet = $this->repository->getAccountsByType([AccountTypeEnum::ASSET])->pluck('id')->toArray();
|
||||
$defaultSet = $this->repository->getAccountsByType([AccountType::ASSET])->pluck('id')->toArray();
|
||||
$frontPage = app('preferences')->get('frontPageAccounts', $defaultSet);
|
||||
$default = app('amount')->getDefaultCurrency();
|
||||
|
||||
|
@ -25,8 +25,6 @@ namespace FireflyIII\Api\V1\Controllers\Data;
|
||||
|
||||
use FireflyIII\Api\V1\Controllers\Controller;
|
||||
use FireflyIII\Api\V1\Requests\Data\DestroyRequest;
|
||||
use FireflyIII\Enums\AccountTypeEnum;
|
||||
use FireflyIII\Enums\TransactionTypeEnum;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\AccountType;
|
||||
@ -96,70 +94,70 @@ class DestroyController extends Controller
|
||||
case 'accounts':
|
||||
$this->destroyAccounts(
|
||||
[
|
||||
AccountTypeEnum::ASSET, AccountTypeEnum::DEFAULT,
|
||||
AccountTypeEnum::BENEFICIARY, AccountTypeEnum::EXPENSE,
|
||||
AccountTypeEnum::REVENUE, AccountTypeEnum::INITIAL_BALANCE,
|
||||
AccountTypeEnum::DEBT, AccountTypeEnum::LOAN, AccountTypeEnum::MORTGAGE, AccountTypeEnum::CREDITCARD,
|
||||
AccountType::ASSET, AccountType::DEFAULT,
|
||||
AccountType::BENEFICIARY, AccountType::EXPENSE,
|
||||
AccountType::REVENUE, AccountType::INITIAL_BALANCE,
|
||||
AccountType::DEBT, AccountType::LOAN, AccountType::MORTGAGE, AccountType::CREDITCARD,
|
||||
]
|
||||
);
|
||||
break;
|
||||
case 'asset_accounts':
|
||||
$this->destroyAccounts(
|
||||
[
|
||||
AccountTypeEnum::ASSET, AccountTypeEnum::DEFAULT,
|
||||
AccountType::ASSET, AccountType::DEFAULT,
|
||||
]
|
||||
);
|
||||
break;
|
||||
case 'expense_accounts':
|
||||
$this->destroyAccounts(
|
||||
[
|
||||
AccountTypeEnum::BENEFICIARY, AccountTypeEnum::EXPENSE,
|
||||
AccountType::BENEFICIARY, AccountType::EXPENSE,
|
||||
]
|
||||
);
|
||||
break;
|
||||
case 'revenue_accounts':
|
||||
$this->destroyAccounts(
|
||||
[
|
||||
AccountTypeEnum::REVENUE,
|
||||
AccountType::REVENUE,
|
||||
]
|
||||
);
|
||||
break;
|
||||
case 'liabilities':
|
||||
$this->destroyAccounts(
|
||||
[
|
||||
AccountTypeEnum::DEBT, AccountTypeEnum::LOAN, AccountTypeEnum::MORTGAGE, AccountTypeEnum::CREDITCARD,
|
||||
AccountType::DEBT, AccountType::LOAN, AccountType::MORTGAGE, AccountType::CREDITCARD,
|
||||
]
|
||||
);
|
||||
break;
|
||||
case 'transactions':
|
||||
$this->destroyTransactions(
|
||||
[
|
||||
TransactionTypeEnum::WITHDRAWAL,
|
||||
TransactionTypeEnum::DEPOSIT,
|
||||
TransactionTypeEnum::TRANSFER,
|
||||
TransactionTypeEnum::RECONCILIATION,
|
||||
TransactionTypeEnum::OPENING_BALANCE,
|
||||
TransactionType::WITHDRAWAL,
|
||||
TransactionType::DEPOSIT,
|
||||
TransactionType::TRANSFER,
|
||||
TransactionType::RECONCILIATION,
|
||||
TransactionType::OPENING_BALANCE,
|
||||
]
|
||||
);
|
||||
break;
|
||||
case 'withdrawals':
|
||||
$this->destroyTransactions(
|
||||
[
|
||||
TransactionTypeEnum::WITHDRAWAL,
|
||||
TransactionType::WITHDRAWAL,
|
||||
]
|
||||
);
|
||||
break;
|
||||
case 'deposits':
|
||||
$this->destroyTransactions(
|
||||
[
|
||||
TransactionTypeEnum::DEPOSIT,
|
||||
TransactionType::DEPOSIT,
|
||||
]
|
||||
);
|
||||
break;
|
||||
case 'transfers':
|
||||
$this->destroyTransactions(
|
||||
[
|
||||
TransactionTypeEnum::TRANSFER,
|
||||
TransactionType::TRANSFER,
|
||||
]
|
||||
);
|
||||
break;
|
||||
|
@ -28,7 +28,6 @@ use Carbon\Carbon;
|
||||
use Exception;
|
||||
use FireflyIII\Api\V1\Controllers\Controller;
|
||||
use FireflyIII\Api\V1\Requests\Data\DateRequest;
|
||||
use FireflyIII\Enums\AccountTypeEnum;
|
||||
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
||||
use FireflyIII\Helpers\Report\NetWorthInterface;
|
||||
use FireflyIII\Models\Account;
|
||||
@ -358,7 +357,7 @@ class BasicController extends Controller
|
||||
/** @var NetWorthInterface $netWorthHelper */
|
||||
$netWorthHelper = app(NetWorthInterface::class);
|
||||
$netWorthHelper->setUser($user);
|
||||
$allAccounts = $this->accountRepository->getActiveAccountsByType([AccountTypeEnum::ASSET, AccountTypeEnum::DEBT, AccountTypeEnum::LOAN, AccountTypeEnum::MORTGAGE]);
|
||||
$allAccounts = $this->accountRepository->getActiveAccountsByType([AccountType::ASSET, AccountType::DEBT, AccountType::LOAN, AccountType::MORTGAGE]);
|
||||
|
||||
// filter list on preference of being included.
|
||||
$filtered = $allAccounts->filter(
|
||||
|
@ -23,7 +23,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Api\V1\Requests\Autocomplete;
|
||||
|
||||
use FireflyIII\Enums\AccountTypeEnum;
|
||||
use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\Support\Request\ChecksLogin;
|
||||
use FireflyIII\Support\Request\ConvertsDataTypes;
|
||||
@ -50,7 +49,7 @@ class AutocompleteRequest extends FormRequest
|
||||
$limit = 0 === $limit ? 10 : $limit;
|
||||
|
||||
// remove 'initial balance' from allowed types. its internal
|
||||
$array = array_diff($array, [AccountTypeEnum::INITIAL_BALANCE, AccountTypeEnum::RECONCILIATION]);
|
||||
$array = array_diff($array, [AccountType::INITIAL_BALANCE, AccountType::RECONCILIATION]);
|
||||
|
||||
return [
|
||||
'types' => $array,
|
||||
|
@ -24,7 +24,7 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Api\V1\Requests\Data\Export;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Enums\AccountTypeEnum;
|
||||
use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Support\Request\ChecksLogin;
|
||||
use FireflyIII\Support\Request\ConvertsDataTypes;
|
||||
@ -54,7 +54,7 @@ class ExportRequest extends FormRequest
|
||||
$accountId = (int) $part;
|
||||
if (0 !== $accountId) {
|
||||
$account = $repository->find($accountId);
|
||||
if (null !== $account && AccountTypeEnum::ASSET === $account->accountType->type) {
|
||||
if (null !== $account && AccountType::ASSET === $account->accountType->type) {
|
||||
$accounts->push($account);
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,6 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Api\V1\Requests\Insight;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Enums\AccountTypeEnum;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
@ -74,7 +73,7 @@ class GenericRequest extends FormRequest
|
||||
/** @var Account $account */
|
||||
foreach ($this->accounts as $account) {
|
||||
$type = $account->accountType->type;
|
||||
if (in_array($type, [AccountTypeEnum::ASSET, AccountTypeEnum::LOAN, AccountTypeEnum::DEBT, AccountTypeEnum::MORTGAGE])) {
|
||||
if (in_array($type, [AccountType::ASSET, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE])) {
|
||||
$return->push($account);
|
||||
}
|
||||
}
|
||||
@ -221,7 +220,7 @@ class GenericRequest extends FormRequest
|
||||
/** @var Account $account */
|
||||
foreach ($this->accounts as $account) {
|
||||
$type = $account->accountType->type;
|
||||
if ($type === AccountTypeEnum::EXPENSE) {
|
||||
if ($type === AccountType::EXPENSE) {
|
||||
$return->push($account);
|
||||
}
|
||||
}
|
||||
@ -239,7 +238,7 @@ class GenericRequest extends FormRequest
|
||||
/** @var Account $account */
|
||||
foreach ($this->accounts as $account) {
|
||||
$type = $account->accountType->type;
|
||||
if ($type === AccountTypeEnum::REVENUE) {
|
||||
if ($type === AccountType::REVENUE) {
|
||||
$return->push($account);
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Console\Commands\Correction;
|
||||
|
||||
use FireflyIII\Enums\AccountTypeEnum;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\Models\Transaction;
|
||||
@ -125,7 +124,7 @@ class CorrectOpeningBalanceCurrencies extends Command
|
||||
foreach ($transactions as $transaction) {
|
||||
/** @var Account $account */
|
||||
$account = $transaction->account()->first();
|
||||
if (null !== $account && AccountTypeEnum::INITIAL_BALANCE !== $account->accountType()->first()->type) {
|
||||
if (null !== $account && AccountType::INITIAL_BALANCE !== $account->accountType()->first()->type) {
|
||||
return $account;
|
||||
}
|
||||
}
|
||||
|
@ -23,8 +23,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Console\Commands\Correction;
|
||||
|
||||
use FireflyIII\Enums\AccountTypeEnum;
|
||||
use FireflyIII\Enums\TransactionTypeEnum;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Factory\AccountFactory;
|
||||
use FireflyIII\Models\AccountType;
|
||||
@ -178,11 +176,11 @@ class FixAccountTypes extends Command
|
||||
$combination = sprintf('%s%s%s', $type, $source->account->accountType->type, $dest->account->accountType->type);
|
||||
|
||||
switch ($combination) {
|
||||
case sprintf('%s%s%s', TransactionTypeEnum::TRANSFER, AccountTypeEnum::ASSET, AccountTypeEnum::LOAN):
|
||||
case sprintf('%s%s%s', TransactionTypeEnum::TRANSFER, AccountTypeEnum::ASSET, AccountTypeEnum::DEBT):
|
||||
case sprintf('%s%s%s', TransactionTypeEnum::TRANSFER, AccountTypeEnum::ASSET, AccountTypeEnum::MORTGAGE):
|
||||
case sprintf('%s%s%s', TransactionType::TRANSFER, AccountType::ASSET, AccountType::LOAN):
|
||||
case sprintf('%s%s%s', TransactionType::TRANSFER, AccountType::ASSET, AccountType::DEBT):
|
||||
case sprintf('%s%s%s', TransactionType::TRANSFER, AccountType::ASSET, AccountType::MORTGAGE):
|
||||
// from an asset to a liability should be a withdrawal:
|
||||
$withdrawal = TransactionType::whereType(TransactionTypeEnum::WITHDRAWAL)->first();
|
||||
$withdrawal = TransactionType::whereType(TransactionType::WITHDRAWAL)->first();
|
||||
$journal->transactionType()->associate($withdrawal);
|
||||
$journal->save();
|
||||
$message = sprintf('Converted transaction #%d from a transfer to a withdrawal.', $journal->id);
|
||||
@ -191,11 +189,11 @@ class FixAccountTypes extends Command
|
||||
// check it again:
|
||||
$this->inspectJournal($journal);
|
||||
break;
|
||||
case sprintf('%s%s%s', TransactionTypeEnum::TRANSFER, AccountTypeEnum::LOAN, AccountTypeEnum::ASSET):
|
||||
case sprintf('%s%s%s', TransactionTypeEnum::TRANSFER, AccountTypeEnum::DEBT, AccountTypeEnum::ASSET):
|
||||
case sprintf('%s%s%s', TransactionTypeEnum::TRANSFER, AccountTypeEnum::MORTGAGE, AccountTypeEnum::ASSET):
|
||||
case sprintf('%s%s%s', TransactionType::TRANSFER, AccountType::LOAN, AccountType::ASSET):
|
||||
case sprintf('%s%s%s', TransactionType::TRANSFER, AccountType::DEBT, AccountType::ASSET):
|
||||
case sprintf('%s%s%s', TransactionType::TRANSFER, AccountType::MORTGAGE, AccountType::ASSET):
|
||||
// from a liability to an asset should be a deposit.
|
||||
$deposit = TransactionType::whereType(TransactionTypeEnum::DEPOSIT)->first();
|
||||
$deposit = TransactionType::whereType(TransactionType::DEPOSIT)->first();
|
||||
$journal->transactionType()->associate($deposit);
|
||||
$journal->save();
|
||||
$message = sprintf('Converted transaction #%d from a transfer to a deposit.', $journal->id);
|
||||
@ -205,11 +203,11 @@ class FixAccountTypes extends Command
|
||||
$this->inspectJournal($journal);
|
||||
|
||||
break;
|
||||
case sprintf('%s%s%s', TransactionTypeEnum::WITHDRAWAL, AccountTypeEnum::ASSET, AccountTypeEnum::REVENUE):
|
||||
case sprintf('%s%s%s', TransactionType::WITHDRAWAL, AccountType::ASSET, AccountType::REVENUE):
|
||||
// withdrawals with a revenue account as destination instead of an expense account.
|
||||
$this->factory->setUser($journal->user);
|
||||
$oldDest = $dest->account;
|
||||
$result = $this->factory->findOrCreate($dest->account->name, AccountTypeEnum::EXPENSE);
|
||||
$result = $this->factory->findOrCreate($dest->account->name, AccountType::EXPENSE);
|
||||
$dest->account()->associate($result);
|
||||
$dest->save();
|
||||
$message = sprintf(
|
||||
@ -220,11 +218,11 @@ class FixAccountTypes extends Command
|
||||
Log::debug($message);
|
||||
$this->inspectJournal($journal);
|
||||
break;
|
||||
case sprintf('%s%s%s', TransactionTypeEnum::DEPOSIT, AccountTypeEnum::EXPENSE, AccountTypeEnum::ASSET):
|
||||
case sprintf('%s%s%s', TransactionType::DEPOSIT, AccountType::EXPENSE, AccountType::ASSET):
|
||||
// deposits with an expense account as source instead of a revenue account.
|
||||
// find revenue account.
|
||||
$this->factory->setUser($journal->user);
|
||||
$result = $this->factory->findOrCreate($source->account->name, AccountTypeEnum::REVENUE);
|
||||
$result = $this->factory->findOrCreate($source->account->name, AccountType::REVENUE);
|
||||
$oldSource = $dest->account;
|
||||
$source->account()->associate($result);
|
||||
$source->save();
|
||||
|
@ -24,7 +24,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Console\Commands\Correction;
|
||||
|
||||
use FireflyIII\Enums\TransactionTypeEnum;
|
||||
use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\Models\Preference;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
@ -92,7 +91,7 @@ class FixFrontpageAccounts extends Command
|
||||
$accountIdInt = (int) $accountId;
|
||||
$account = $repository->find($accountIdInt);
|
||||
if (null !== $account
|
||||
&& in_array($account->accountType->type, [AccountTypeEnum::ASSET, AccountTypeEnum::DEBT, AccountTypeEnum::LOAN, AccountTypeEnum::MORTGAGE], true)
|
||||
&& in_array($account->accountType->type, [AccountType::ASSET, AccountType::DEBT, AccountType::LOAN, AccountType::MORTGAGE], true)
|
||||
&& true === $account->active) {
|
||||
$fixed[] = $account->id;
|
||||
}
|
||||
|
@ -27,7 +27,6 @@ namespace FireflyIII\Console\Commands\Export;
|
||||
use Carbon\Carbon;
|
||||
use Exception;
|
||||
use FireflyIII\Console\Commands\VerifiesAccessToken;
|
||||
use FireflyIII\Enums\TransactionTypeEnum;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\AccountType;
|
||||
@ -234,7 +233,7 @@ class ExportData extends Command
|
||||
$final = new Collection;
|
||||
$accounts = new Collection;
|
||||
$accountList = $this->option('accounts');
|
||||
$types = [AccountTypeEnum::ASSET, AccountTypeEnum::LOAN, AccountTypeEnum::DEBT, AccountTypeEnum::MORTGAGE];
|
||||
$types = [AccountType::ASSET, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE];
|
||||
if (null !== $accountList && '' !== (string) $accountList) {
|
||||
$accountIds = explode(',', $accountList);
|
||||
$accounts = $this->accountRepository->getAccountsById($accountIds);
|
||||
|
@ -25,8 +25,6 @@ namespace FireflyIII\Console\Commands\Tools;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Console\Commands\VerifiesAccessToken;
|
||||
use FireflyIII\Enums\AccountTypeEnum;
|
||||
use FireflyIII\Enums\TransactionTypeEnum;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\Models\Rule;
|
||||
@ -168,7 +166,7 @@ class ApplyRules extends Command
|
||||
$this->ruleGroupSelection = [];
|
||||
$this->ruleRepository = app(RuleRepositoryInterface::class);
|
||||
$this->ruleGroupRepository = app(RuleGroupRepositoryInterface::class);
|
||||
$this->acceptedAccounts = [AccountTypeEnum::DEFAULT, AccountTypeEnum::DEBT, AccountTypeEnum::ASSET, AccountTypeEnum::LOAN, AccountTypeEnum::MORTGAGE];
|
||||
$this->acceptedAccounts = [AccountType::DEFAULT, AccountType::DEBT, AccountType::ASSET, AccountType::LOAN, AccountType::MORTGAGE];
|
||||
$this->groups = new Collection;
|
||||
}
|
||||
|
||||
|
@ -26,6 +26,7 @@ namespace FireflyIII\Console\Commands\Upgrade;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\AccountMeta;
|
||||
use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\Models\Transaction;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
@ -145,7 +146,7 @@ class AccountCurrencies extends Command
|
||||
{
|
||||
Log::debug(sprintf('Now in updateCurrenciesForUser(%s, %s)', $user->email, $systemCurrencyCode));
|
||||
$this->accountRepos->setUser($user);
|
||||
$accounts = $this->accountRepos->getAccountsByType([AccountTypeEnum::DEFAULT, AccountTypeEnum::ASSET]);
|
||||
$accounts = $this->accountRepos->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]);
|
||||
|
||||
// get user's currency preference:
|
||||
$defaultCurrencyCode = app('preferences')->getForUser($user, 'currencyPreference', $systemCurrencyCode)->data;
|
||||
|
@ -23,7 +23,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Console\Commands\Upgrade;
|
||||
|
||||
use FireflyIII\Enums\TransactionTypeEnum;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\AccountType;
|
||||
@ -67,8 +66,8 @@ class CCLiabilities extends Command
|
||||
}
|
||||
|
||||
|
||||
$ccType = AccountType::where('type', AccountTypeEnum::CREDITCARD)->first();
|
||||
$debtType = AccountType::where('type', AccountTypeEnum::DEBT)->first();
|
||||
$ccType = AccountType::where('type', AccountType::CREDITCARD)->first();
|
||||
$debtType = AccountType::where('type', AccountType::DEBT)->first();
|
||||
if (null === $ccType || null === $debtType) {
|
||||
$this->info('No incorrectly stored credit card liabilities.');
|
||||
|
||||
|
@ -23,8 +23,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Console\Commands\Upgrade;
|
||||
|
||||
use FireflyIII\Enums\AccountTypeEnum;
|
||||
use FireflyIII\Enums\TransactionTypeEnum;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\AccountType;
|
||||
@ -220,23 +218,23 @@ class OtherCurrenciesCorrections extends Command
|
||||
switch ($journal->transactionType->type) {
|
||||
default:
|
||||
break;
|
||||
case TransactionTypeEnum::WITHDRAWAL:
|
||||
case TransactionType::WITHDRAWAL:
|
||||
$lead = $journal->transactions()->where('amount', '<', 0)->first();
|
||||
break;
|
||||
case TransactionTypeEnum::DEPOSIT:
|
||||
case TransactionType::DEPOSIT:
|
||||
$lead = $journal->transactions()->where('amount', '>', 0)->first();
|
||||
break;
|
||||
case TransactionTypeEnum::OPENING_BALANCE:
|
||||
case TransactionType::OPENING_BALANCE:
|
||||
// whichever isn't an initial balance account:
|
||||
$lead = $journal->transactions()->leftJoin('accounts', 'transactions.account_id', '=', 'accounts.id')->leftJoin(
|
||||
'account_types', 'accounts.account_type_id', '=', 'account_types.id'
|
||||
)->where('account_types.type', '!=', AccountTypeEnum::INITIAL_BALANCE)->first(['transactions.*']);
|
||||
)->where('account_types.type', '!=', AccountType::INITIAL_BALANCE)->first(['transactions.*']);
|
||||
break;
|
||||
case TransactionTypeEnum::RECONCILIATION:
|
||||
case TransactionType::RECONCILIATION:
|
||||
// whichever isn't the reconciliation account:
|
||||
$lead = $journal->transactions()->leftJoin('accounts', 'transactions.account_id', '=', 'accounts.id')->leftJoin(
|
||||
'account_types', 'accounts.account_type_id', '=', 'account_types.id'
|
||||
)->where('account_types.type', '!=', AccountTypeEnum::RECONCILIATION)->first(['transactions.*']);
|
||||
)->where('account_types.type', '!=', AccountType::RECONCILIATION)->first(['transactions.*']);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -24,8 +24,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Factory;
|
||||
|
||||
use FireflyIII\Enums\AccountTypeEnum;
|
||||
use FireflyIII\Enums\TransactionTypeEnum;
|
||||
use FireflyIII\Events\StoredAccount;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\Account;
|
||||
@ -262,7 +260,7 @@ class AccountFactory
|
||||
$currency = $this->getCurrency($currencyId, $currencyCode);
|
||||
|
||||
// only asset account may have a role:
|
||||
if ($account->accountType->type !== AccountTypeEnum::ASSET) {
|
||||
if ($account->accountType->type !== AccountType::ASSET) {
|
||||
$accountRole = '';
|
||||
}
|
||||
// only liability may have direction:
|
||||
@ -283,10 +281,10 @@ class AccountFactory
|
||||
{
|
||||
|
||||
$fields = $this->validFields;
|
||||
if ($account->accountType->type === AccountTypeEnum::ASSET) {
|
||||
if ($account->accountType->type === AccountType::ASSET) {
|
||||
$fields = $this->validAssetFields;
|
||||
}
|
||||
if ($account->accountType->type === AccountTypeEnum::ASSET && 'ccAsset' === $data['account_role']) {
|
||||
if ($account->accountType->type === AccountType::ASSET && 'ccAsset' === $data['account_role']) {
|
||||
$fields = $this->validCCFields;
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Http\Controllers\Account;
|
||||
|
||||
use FireflyIII\Enums\AccountTypeEnum;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Helpers\Attachments\AttachmentHelperInterface;
|
||||
use FireflyIII\Http\Controllers\Controller;
|
||||
@ -152,7 +151,7 @@ class CreateController extends Controller
|
||||
|
||||
// update preferences if necessary:
|
||||
$frontPage = app('preferences')->get('frontPageAccounts', [])->data;
|
||||
if (AccountTypeEnum::ASSET === $account->accountType->type) {
|
||||
if (AccountType::ASSET === $account->accountType->type) {
|
||||
$frontPage[] = $account->id;
|
||||
app('preferences')->set('frontPageAccounts', $frontPage);
|
||||
}
|
||||
|
@ -24,10 +24,10 @@ namespace FireflyIII\Http\Controllers;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Exception;
|
||||
use FireflyIII\Enums\AccountTypeEnum;
|
||||
use FireflyIII\Events\RequestedVersionCheckStatus;
|
||||
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
||||
use FireflyIII\Http\Middleware\Installer;
|
||||
use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
|
||||
use FireflyIII\User;
|
||||
@ -115,7 +115,7 @@ class HomeController extends Controller
|
||||
}
|
||||
$subTitle = (string) trans('firefly.welcome_back');
|
||||
$transactions = [];
|
||||
$frontPage = app('preferences')->getFresh('frontPageAccounts', $repository->getAccountsByType([AccountTypeEnum::ASSET])->pluck('id')->toArray());
|
||||
$frontPage = app('preferences')->getFresh('frontPageAccounts', $repository->getAccountsByType([AccountType::ASSET])->pluck('id')->toArray());
|
||||
/** @var Carbon $start */
|
||||
$start = session('start', Carbon::now()->startOfMonth());
|
||||
/** @var Carbon $end */
|
||||
|
@ -23,9 +23,9 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Http\Controllers;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Enums\AccountTypeEnum;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||
@ -54,7 +54,7 @@ class JavascriptController extends Controller
|
||||
public function accounts(AccountRepositoryInterface $repository, CurrencyRepositoryInterface $currencyRepository): Response
|
||||
{
|
||||
$accounts = $repository->getAccountsByType(
|
||||
[AccountTypeEnum::DEFAULT, AccountTypeEnum::ASSET, AccountTypeEnum::DEBT, AccountTypeEnum::LOAN, AccountTypeEnum::MORTGAGE, AccountTypeEnum::CREDITCARD]
|
||||
[AccountType::DEFAULT, AccountType::ASSET, AccountType::DEBT, AccountType::LOAN, AccountType::MORTGAGE, AccountType::CREDITCARD]
|
||||
);
|
||||
$preference = app('preferences')->get('currencyPreference', config('firefly.default_currency', 'EUR'));
|
||||
/** @noinspection NullPointerExceptionInspection */
|
||||
|
@ -22,9 +22,9 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Http\Controllers;
|
||||
|
||||
use FireflyIII\Enums\AccountTypeEnum;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Http\Requests\NewUserFormRequest;
|
||||
use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||
use FireflyIII\Support\Http\Controllers\CreateStuff;
|
||||
@ -117,7 +117,7 @@ class NewUserController extends Controller
|
||||
app('preferences')->set('currencyPreference', $currency->code);
|
||||
|
||||
// store frontpage preferences:
|
||||
$accounts = $this->repository->getAccountsByType([AccountTypeEnum::ASSET])->pluck('id')->toArray();
|
||||
$accounts = $this->repository->getAccountsByType([AccountType::ASSET])->pluck('id')->toArray();
|
||||
app('preferences')->set('frontPageAccounts', $accounts);
|
||||
|
||||
// mark.
|
||||
|
@ -22,9 +22,9 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Http\Controllers;
|
||||
|
||||
use FireflyIII\Enums\AccountTypeEnum;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\Models\Preference;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use Illuminate\Contracts\View\Factory;
|
||||
@ -71,7 +71,7 @@ class PreferencesController extends Controller
|
||||
*/
|
||||
public function index(AccountRepositoryInterface $repository)
|
||||
{
|
||||
$accounts = $repository->getAccountsByType([AccountTypeEnum::DEFAULT, AccountTypeEnum::ASSET, AccountTypeEnum::LOAN, AccountTypeEnum::DEBT, AccountTypeEnum::MORTGAGE]);
|
||||
$accounts = $repository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE]);
|
||||
$isDocker = env('IS_DOCKER', false);
|
||||
|
||||
// group accounts
|
||||
@ -81,7 +81,7 @@ class PreferencesController extends Controller
|
||||
$type = $account->accountType->type;
|
||||
$role = sprintf('opt_group_%s', $repository->getMetaValue($account, 'account_role'));
|
||||
|
||||
if (in_array($type, [AccountTypeEnum::MORTGAGE, AccountTypeEnum::DEBT, AccountTypeEnum::LOAN], true)) {
|
||||
if (in_array($type, [AccountType::MORTGAGE, AccountType::DEBT, AccountType::LOAN], true)) {
|
||||
$role = sprintf('opt_group_l_%s', $type);
|
||||
}
|
||||
|
||||
|
@ -24,12 +24,12 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Http\Controllers;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Enums\AccountTypeEnum;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Generator\Report\ReportGeneratorFactory;
|
||||
use FireflyIII\Helpers\Report\ReportHelperInterface;
|
||||
use FireflyIII\Http\Requests\ReportFormRequest;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
||||
use FireflyIII\Support\Http\Controllers\RenderPartialViews;
|
||||
@ -272,7 +272,7 @@ class ReportController extends Controller
|
||||
$months = $this->helper->listOfMonths($start);
|
||||
$customFiscalYear = app('preferences')->get('customFiscalYear', 0)->data;
|
||||
$accounts = $repository->getAccountsByType(
|
||||
[AccountTypeEnum::DEFAULT, AccountTypeEnum::ASSET, AccountTypeEnum::DEBT, AccountTypeEnum::LOAN, AccountTypeEnum::MORTGAGE]
|
||||
[AccountType::DEFAULT, AccountType::ASSET, AccountType::DEBT, AccountType::LOAN, AccountType::MORTGAGE]
|
||||
);
|
||||
|
||||
// group accounts by role:
|
||||
@ -282,7 +282,7 @@ class ReportController extends Controller
|
||||
$type = $account->accountType->type;
|
||||
$role = sprintf('opt_group_%s', $repository->getMetaValue($account, 'account_role'));
|
||||
|
||||
if (in_array($type, [AccountTypeEnum::MORTGAGE, AccountTypeEnum::DEBT, AccountTypeEnum::LOAN], true)) {
|
||||
if (in_array($type, [AccountType::MORTGAGE, AccountType::DEBT, AccountType::LOAN], true)) {
|
||||
$role = sprintf('opt_group_l_%s', $type);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user