First part of a large code cleanup commit.

This commit is contained in:
James Cole
2019-02-12 21:49:28 +01:00
parent b273af341c
commit e0d87aa11e
70 changed files with 336 additions and 354 deletions

View File

@@ -222,7 +222,7 @@ trait AccountServiceTrait
/** @var AccountFactory $factory */
$factory = app(AccountFactory::class);
$factory->setUser($user);
return $factory->findOrCreate($opposingAccountName, AccountType::INITIAL_BALANCE);
}

View File

@@ -23,10 +23,12 @@ declare(strict_types=1);
namespace FireflyIII\Services\Internal\Support;
use Exception;
use FireflyIII\Models\Bill;
use FireflyIII\Models\Note;
use FireflyIII\Models\RuleAction;
use Illuminate\Support\Collection;
use Log;
/**
* Trait BillServiceTrait
@@ -70,7 +72,11 @@ trait BillServiceTrait
if ('' === $note) {
$dbNote = $bill->notes()->first();
if (null !== $dbNote) {
$dbNote->delete(); // @codeCoverageIgnore
try {
$dbNote->delete();
} catch (Exception $e) {
Log::debug(sprintf('Error deleting note: %s', $e->getMessage()));
}
}
return true;

View File

@@ -55,7 +55,7 @@ trait JournalServiceTrait
return; // @codeCoverageIgnore
}
foreach ($data['tags'] as $string) {
if (\strlen($string) > 0) {
if ('' != $string) {
$tag = $factory->findOrCreate($string);
if (null !== $tag) {
$set[] = $tag->id;
@@ -116,7 +116,7 @@ trait JournalServiceTrait
protected function storeNote(TransactionJournal $journal, ?string $notes): void
{
$notes = (string)$notes;
if (\strlen($notes) > 0) {
if ('' !== $notes) {
$note = $journal->notes()->first();
if (null === $note) {
$note = new Note;

View File

@@ -107,7 +107,7 @@ trait TransactionServiceTrait
return $repository->findByName($accountName, [AccountType::ASSET]);
}
// for revenue and expense:
if (\strlen($accountName) > 0) {
if ('' !== $accountName) {
/** @var AccountFactory $factory */
$factory = app(AccountFactory::class);
$factory->setUser($this->user);
@@ -218,7 +218,7 @@ trait TransactionServiceTrait
return;
}
// enable currency if not enabled:
if(false === $currency->enabled) {
if (false === $currency->enabled) {
$currency->enabled = true;
$currency->save();
}