mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Code cleanup
This commit is contained in:
@@ -33,13 +33,6 @@ use Log;
|
||||
*/
|
||||
trait OBValidation
|
||||
{
|
||||
/**
|
||||
* @param array $accountTypes
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
abstract protected function canCreateTypes(array $accountTypes): bool;
|
||||
|
||||
/**
|
||||
* @param int|null $accountId
|
||||
* @param $accountName
|
||||
@@ -56,7 +49,7 @@ trait OBValidation
|
||||
if (null === $accountId && null === $accountName && false === $this->canCreateTypes($validTypes)) {
|
||||
// if both values are NULL we return false,
|
||||
// because the destination of a deposit can't be created.
|
||||
$this->destError = (string) trans('validation.ob_dest_need_data');
|
||||
$this->destError = (string)trans('validation.ob_dest_need_data');
|
||||
Log::error('Both values are NULL, cant create OB destination.');
|
||||
$result = false;
|
||||
}
|
||||
@@ -68,10 +61,10 @@ trait OBValidation
|
||||
|
||||
if (null === $result) {
|
||||
// otherwise try to find the account:
|
||||
$search = $this->findExistingAccount($validTypes, (int) $accountId, (string) $accountName);
|
||||
$search = $this->findExistingAccount($validTypes, (int)$accountId, (string)$accountName);
|
||||
if (null === $search) {
|
||||
Log::debug('findExistingAccount() returned NULL, so the result is false.', $validTypes);
|
||||
$this->destError = (string) trans('validation.ob_dest_bad_data', ['id' => $accountId, 'name' => $accountName]);
|
||||
$this->destError = (string)trans('validation.ob_dest_bad_data', ['id' => $accountId, 'name' => $accountName]);
|
||||
$result = false;
|
||||
}
|
||||
if (null !== $search) {
|
||||
@@ -86,6 +79,13 @@ trait OBValidation
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $accountTypes
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
abstract protected function canCreateTypes(array $accountTypes): bool;
|
||||
|
||||
/**
|
||||
* Source of an opening balance can either be an asset account
|
||||
* or an "initial balance account". The latter can be created.
|
||||
@@ -107,7 +107,7 @@ trait OBValidation
|
||||
// if both values are NULL return false,
|
||||
// because the source of a deposit can't be created.
|
||||
// (this never happens).
|
||||
$this->sourceError = (string) trans('validation.ob_source_need_data');
|
||||
$this->sourceError = (string)trans('validation.ob_source_need_data');
|
||||
$result = false;
|
||||
}
|
||||
|
||||
@@ -143,6 +143,7 @@ trait OBValidation
|
||||
$account->accountType = $accountType;
|
||||
$this->source = $account;
|
||||
}
|
||||
|
||||
return $result ?? false;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user