mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-25 13:10:35 +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.
|
||||
|
||||
Reference in New Issue
Block a user