mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-12-18 20:38:57 +00:00
Fix code quality with rector [skip ci]
This commit is contained in:
@@ -24,6 +24,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Validation\Account;
|
||||
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use FireflyIII\Models\Account;
|
||||
|
||||
/**
|
||||
@@ -36,8 +37,8 @@ trait ReconciliationValidation
|
||||
|
||||
protected function validateReconciliationDestination(array $array): bool
|
||||
{
|
||||
$accountId = array_key_exists('id', $array) ? $array['id'] : null;
|
||||
$accountName = array_key_exists('name', $array) ? $array['name'] : null;
|
||||
$accountId = $array['id'] ?? null;
|
||||
$accountName = $array['name'] ?? null;
|
||||
// if both are NULL, the destination is valid because the reconciliation
|
||||
// is expected to be "negative", i.e. the money flows towards the
|
||||
// destination to the asset account which is the source.
|
||||
@@ -47,19 +48,19 @@ trait ReconciliationValidation
|
||||
}
|
||||
|
||||
// after that, search for it expecting an asset account or a liability.
|
||||
app('log')->debug('Now in validateReconciliationDestination', $array);
|
||||
Log::debug('Now in validateReconciliationDestination', $array);
|
||||
|
||||
// source can be any of the following types.
|
||||
$validTypes = array_keys($this->combinations[$this->transactionType]);
|
||||
$search = $this->findExistingAccount($validTypes, $array);
|
||||
if (null === $search) {
|
||||
$this->sourceError = (string) trans('validation.reconciliation_source_bad_data', ['id' => $accountId, 'name' => $accountName]);
|
||||
app('log')->warning('Not a valid source. Cant find it.', $validTypes);
|
||||
Log::warning('Not a valid source. Cant find it.', $validTypes);
|
||||
|
||||
return false;
|
||||
}
|
||||
$this->setSource($search);
|
||||
app('log')->debug('Valid source account!');
|
||||
Log::debug('Valid source account!');
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -69,32 +70,32 @@ trait ReconciliationValidation
|
||||
*/
|
||||
protected function validateReconciliationSource(array $array): bool
|
||||
{
|
||||
$accountId = array_key_exists('id', $array) ? $array['id'] : null;
|
||||
$accountName = array_key_exists('name', $array) ? $array['name'] : null;
|
||||
$accountId = $array['id'] ?? null;
|
||||
$accountName = $array['name'] ?? null;
|
||||
// if both are NULL, the source is valid because the reconciliation
|
||||
// is expected to be "positive", i.e. the money flows from the
|
||||
// source to the asset account that is the destination.
|
||||
if (null === $accountId && null === $accountName) {
|
||||
app('log')->debug('The source is valid because ID and name are NULL.');
|
||||
Log::debug('The source is valid because ID and name are NULL.');
|
||||
$this->setSource(new Account());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// after that, search for it expecting an asset account or a liability.
|
||||
app('log')->debug('Now in validateReconciliationSource', $array);
|
||||
Log::debug('Now in validateReconciliationSource', $array);
|
||||
|
||||
// source can be any of the following types.
|
||||
$validTypes = array_keys($this->combinations[$this->transactionType]);
|
||||
$search = $this->findExistingAccount($validTypes, $array);
|
||||
if (null === $search) {
|
||||
$this->sourceError = (string) trans('validation.reconciliation_source_bad_data', ['id' => $accountId, 'name' => $accountName]);
|
||||
app('log')->warning('Not a valid source. Cant find it.', $validTypes);
|
||||
Log::warning('Not a valid source. Cant find it.', $validTypes);
|
||||
|
||||
return false;
|
||||
}
|
||||
$this->setSource($search);
|
||||
app('log')->debug('Valid source account!');
|
||||
Log::debug('Valid source account!');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user