Various code cleanup.

This commit is contained in:
James Cole
2021-04-06 18:36:37 +02:00
parent 9c1cee738d
commit fe06a1f7a0
10 changed files with 31 additions and 27 deletions

View File

@@ -66,6 +66,7 @@ trait AccountServiceTrait
return null;
}
return $iban;
}
@@ -132,7 +133,7 @@ trait AccountServiceTrait
foreach ($fields as $field) {
// if the field is set but NULL, skip it.
// if the field is set but "", update it.
if (isset($data[$field]) && null !== $data[$field]) {
if (array_key_exists($field, $data) && null !== $data[$field]) {
// convert boolean value:
if (is_bool($data[$field]) && false === $data[$field]) {
@@ -192,7 +193,7 @@ trait AccountServiceTrait
if ('' !== $data['opening_balance'] && 0 === bccomp($data['opening_balance'], '0')) {
$data['opening_balance'] = ''; // @codeCoverageIgnore
}
if ('' !== $data['opening_balance'] && isset($data['opening_balance'], $data['opening_balance_date'])) {
if ('' !== $data['opening_balance'] && array_key_exists('opening_balance_date', $data) && '' !== $data['opening_balance_date']) {
Log::debug('Array has valid opening balance data.');
return true;
@@ -244,7 +245,7 @@ trait AccountServiceTrait
// find currency, or use default currency instead.
/** @var TransactionCurrencyFactory $factory */
$factory = app(TransactionCurrencyFactory::class);
/** @var TransactionCurrency $currency */
/** @var TransactionCurrency|null $currency */
$currency = $factory->find($currencyId, $currencyCode);
if (null === $currency) {