mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2026-01-07 06:31:22 +00:00
Refactor findNull to find
This commit is contained in:
@@ -117,7 +117,7 @@ trait DepositValidation
|
||||
// if the user submits an ID only but that ID is not of the correct type,
|
||||
// return false.
|
||||
if (null !== $accountId && null === $accountName) {
|
||||
$search = $this->accountRepository->findNull($accountId);
|
||||
$search = $this->accountRepository->find($accountId);
|
||||
if (null !== $search && !in_array($search->accountType->type, $validTypes, true)) {
|
||||
Log::debug(sprintf('User submitted only an ID (#%d), which is a "%s", so this is not a valid source.', $accountId, $search->accountType->type));
|
||||
$result = false;
|
||||
|
||||
@@ -75,7 +75,7 @@ trait LiabilityValidation
|
||||
}
|
||||
|
||||
Log::debug('Destination ID is not null.');
|
||||
$search = $this->accountRepository->findNull($accountId);
|
||||
$search = $this->accountRepository->find($accountId);
|
||||
|
||||
// the source resulted in an account, but it's not of a valid type.
|
||||
if (null !== $search && !in_array($search->accountType->type, $validTypes, true)) {
|
||||
|
||||
@@ -115,7 +115,7 @@ trait OBValidation
|
||||
// return false.
|
||||
if (null !== $accountId && null === $accountName) {
|
||||
Log::debug('Source ID is not null, but name is null.');
|
||||
$search = $this->accountRepository->findNull($accountId);
|
||||
$search = $this->accountRepository->find($accountId);
|
||||
|
||||
// the source resulted in an account, but it's not of a valid type.
|
||||
if (null !== $search && !in_array($search->accountType->type, $validTypes, true)) {
|
||||
|
||||
@@ -46,7 +46,7 @@ trait ReconciliationValidation
|
||||
|
||||
return false;
|
||||
}
|
||||
$result = $this->accountRepository->findNull($accountId);
|
||||
$result = $this->accountRepository->find($accountId);
|
||||
if (null === $result) {
|
||||
$this->destError = (string)trans('validation.deposit_dest_bad_data', ['id' => $accountId, 'name' => '']);
|
||||
Log::debug('Return FALSE');
|
||||
@@ -92,7 +92,7 @@ trait ReconciliationValidation
|
||||
|
||||
return false;
|
||||
}
|
||||
$result = $this->accountRepository->findNull($accountId);
|
||||
$result = $this->accountRepository->find($accountId);
|
||||
$types = [AccountType::ASSET, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE, AccountType::RECONCILIATION];
|
||||
if (null === $result) {
|
||||
Log::debug('Return FALSE');
|
||||
|
||||
@@ -87,7 +87,7 @@ trait WithdrawalValidation
|
||||
|
||||
// if there's an ID it must be of the "validTypes".
|
||||
if (null !== $accountId && 0 !== $accountId) {
|
||||
$found = $this->accountRepository->findNull($accountId);
|
||||
$found = $this->accountRepository->find($accountId);
|
||||
if (null !== $found) {
|
||||
$type = $found->accountType->type;
|
||||
if (in_array($type, $validTypes, true)) {
|
||||
|
||||
@@ -228,7 +228,7 @@ class AccountValidator
|
||||
{
|
||||
// find by ID
|
||||
if ($accountId > 0) {
|
||||
$first = $this->accountRepository->findNull($accountId);
|
||||
$first = $this->accountRepository->find($accountId);
|
||||
if ((null !== $first) && in_array($first->accountType->type, $validTypes, true)) {
|
||||
return $first;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user