mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Replace enum
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
@@ -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 LiabilityValidation
|
||||
app('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);
|
||||
}
|
||||
|
@@ -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);
|
||||
}
|
||||
|
@@ -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.
|
||||
|
@@ -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,
|
||||
]
|
||||
);
|
||||
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user