mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-26 05:26:17 +00:00
Various code cleanup.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -136,11 +136,11 @@ trait RecurringTransactionTrait
|
||||
$validator->setUser($recurrence->user);
|
||||
$validator->setTransactionType($recurrence->transactionType->type);
|
||||
if (!$validator->validateSource($source->id, null, null)) {
|
||||
throw new FireflyException(sprintf('Source invalid: %s', $validator->sourceError)); // @codeCoverageIgnore
|
||||
throw new FireflyException(sprintf('Source invalid: %s', $validator->sourceError));
|
||||
}
|
||||
|
||||
if (!$validator->validateDestination($destination->id, null, null)) {
|
||||
throw new FireflyException(sprintf('Destination invalid: %s', $validator->destError)); // @codeCoverageIgnore
|
||||
throw new FireflyException(sprintf('Destination invalid: %s', $validator->destError));
|
||||
}
|
||||
if (array_key_exists('foreign_amount', $array) && '' === (string)$array['foreign_amount']) {
|
||||
unset($array['foreign_amount']);
|
||||
@@ -220,11 +220,11 @@ trait RecurringTransactionTrait
|
||||
if (!in_array($expectedType, $cannotCreate, true)) {
|
||||
try {
|
||||
$result = $factory->findOrCreate($accountName, $expectedType);
|
||||
// @codeCoverageIgnoreStart
|
||||
|
||||
} catch (FireflyException $e) {
|
||||
Log::error($e->getMessage());
|
||||
}
|
||||
// @codeCoverageIgnoreEnd
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -48,8 +48,8 @@ trait TransactionTypeTrait
|
||||
$factory = app(TransactionTypeFactory::class);
|
||||
$transactionType = $factory->find($type);
|
||||
if (null === $transactionType) {
|
||||
Log::error(sprintf('Could not find transaction type for "%s"', $type)); // @codeCoverageIgnore
|
||||
throw new FireflyException(sprintf('Could not find transaction type for "%s"', $type)); // @codeCoverageIgnore
|
||||
Log::error(sprintf('Could not find transaction type for "%s"', $type));
|
||||
throw new FireflyException(sprintf('Could not find transaction type for "%s"', $type));
|
||||
}
|
||||
|
||||
return $transactionType;
|
||||
|
||||
Reference in New Issue
Block a user