Various code cleanup.

This commit is contained in:
James Cole
2021-04-07 07:28:43 +02:00
parent 4ddcb0c965
commit f12744ad8c
180 changed files with 714 additions and 721 deletions

View File

@@ -85,7 +85,7 @@ trait AccountServiceTrait
// not set, so false.
return false;
}
// if isset, but is empty:
// if is set, but is empty:
if (
(array_key_exists('opening_balance', $data) && '' === $data['opening_balance'])
|| (array_key_exists('opening_balance_date', $data) && '' === $data['opening_balance_date'])
@@ -126,7 +126,7 @@ trait AccountServiceTrait
}
if ($account->accountType->type === AccountType::ASSET && array_key_exists('account_role', $data) && 'ccAsset' === $data['account_role']) {
$fields = $this->validCCFields; // @codeCoverageIgnore
$fields = $this->validCCFields;
}
/** @var AccountMetaFactory $factory */
$factory = app(AccountMetaFactory::class);
@@ -137,10 +137,10 @@ trait AccountServiceTrait
// convert boolean value:
if (is_bool($data[$field]) && false === $data[$field]) {
$data[$field] = 0; // @codeCoverageIgnore
$data[$field] = 0;
}
if (is_bool($data[$field]) && true === $data[$field]) {
$data[$field] = 1; // @codeCoverageIgnore
$data[$field] = 1;
}
$factory->crud($account, $field, (string)$data[$field]);
@@ -191,7 +191,7 @@ trait AccountServiceTrait
{
$data['opening_balance'] = (string)($data['opening_balance'] ?? '');
if ('' !== $data['opening_balance'] && 0 === bccomp($data['opening_balance'], '0')) {
$data['opening_balance'] = ''; // @codeCoverageIgnore
$data['opening_balance'] = '';
}
if ('' !== $data['opening_balance'] && array_key_exists('opening_balance_date', $data) && '' !== $data['opening_balance_date']) {
Log::debug('Array has valid opening balance data.');
@@ -350,11 +350,11 @@ trait AccountServiceTrait
$sourceId = $account->id;
}
if (0 === bccomp($amount, '0')) {
// @codeCoverageIgnoreStart
Log::debug('Amount is zero, so will not make an OB group.');
return null;
// @codeCoverageIgnoreEnd
}
$amount = app('steam')->positive($amount);
if (!array_key_exists('currency_id', $data)) {
@@ -402,13 +402,13 @@ trait AccountServiceTrait
try {
$group = $factory->create($submission);
// @codeCoverageIgnoreStart
} catch (FireflyException $e) {
Log::error($e->getMessage());
Log::error($e->getTraceAsString());
}
// @codeCoverageIgnoreEnd
return $group;
}