mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-15 16:57:09 +00:00
Improve test coverage.
This commit is contained in:
@@ -69,13 +69,6 @@ class SetSourceAccount implements ActionInterface
|
||||
$this->journal = $journal;
|
||||
$this->repository = app(AccountRepositoryInterface::class);
|
||||
$this->repository->setUser($journal->user);
|
||||
$count = $journal->transactions()->count();
|
||||
if ($count > 2) {
|
||||
Log::error(sprintf('Cannot change source account of journal #%d because it is a split journal.', $journal->id));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// journal type:
|
||||
$type = $journal->transactionType->type;
|
||||
// if this is a transfer or a withdrawal, the new source account must be an asset account or a default account, and it MUST exist:
|
||||
@@ -102,9 +95,11 @@ class SetSourceAccount implements ActionInterface
|
||||
// get source transaction:
|
||||
$transaction = $journal->transactions()->where('amount', '<', 0)->first();
|
||||
if (null === $transaction) {
|
||||
// @codeCoverageIgnoreStart
|
||||
Log::error(sprintf('Cannot change source account of journal #%d because no source transaction exists.', $journal->id));
|
||||
|
||||
return false;
|
||||
// @codeCoverageIgnoreEnd
|
||||
}
|
||||
$transaction->account_id = $this->newSourceAccount->id;
|
||||
$transaction->save();
|
||||
|
Reference in New Issue
Block a user