Various code cleanup.

This commit is contained in:
James Cole
2018-03-02 16:31:02 +01:00
parent 91909a70d7
commit 139c2284b8
11 changed files with 42 additions and 51 deletions

View File

@@ -24,8 +24,10 @@ declare(strict_types=1);
namespace FireflyIII\Services\Internal\Destroy;
use DB;
use Exception;
use FireflyIII\Models\Account;
use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionJournal;
use Log;
/**
@@ -49,17 +51,19 @@ class AccountDestroyService
/** @var Transaction $transaction */
foreach ($account->transactions()->get() as $transaction) {
Log::debug('Now at transaction #' . $transaction->id);
/** @var TransactionJournal $journal */
$journal = $transaction->transactionJournal()->first();
if (null !== $journal) {
Log::debug('Call for deletion of journal #' . $journal->id);
$journal->delete();
/** @var JournalDestroyService $service */
$service = app(JournalDestroyService::class);
$service->destroy($journal);
}
}
try {
$account->delete();
} catch (\Exception $e) {
// don't care
Log::error($e->getMessage());
} catch (Exception $e) { // @codeCoverageIgnore
Log::error(sprintf('Could not delete account: %s',$e->getMessage())); // @codeCoverageIgnore
}
return true;

View File

@@ -25,8 +25,9 @@ namespace FireflyIII\Services\Internal\Destroy;
use Exception;
use FireflyIII\Models\Bill;
use Log;
/**
* @codeCoverageIgnore
* Class BillDestroyService
*/
class BillDestroyService
@@ -38,8 +39,8 @@ class BillDestroyService
{
try {
$bill->delete();
} catch (Exception $e) {
// don't care.
} catch (Exception $e) { // @codeCoverageIgnore
Log::error(sprintf('Could not delete bill: %s',$e->getMessage())); // @codeCoverageIgnore
}
}

View File

@@ -30,6 +30,7 @@ use FireflyIII\Models\TransactionJournalMeta;
use Log;
/**
* @codeCoverageIgnore
* Class JournalDestroyService
*/
class JournalDestroyService
@@ -55,7 +56,7 @@ class JournalDestroyService
}
$journal->delete();
} catch (Exception $e) {
// don't care
Log::error(sprintf('Could not delete bill: %s',$e->getMessage())); // @codeCoverageIgnore
}
return;