mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Refactor isSplitJournal()
This commit is contained in:
parent
136f983353
commit
0c2093753d
@ -445,18 +445,4 @@ class SingleController extends Controller
|
||||
// redirect to previous URL.
|
||||
return redirect($this->getPreviousUri('transactions.edit.uri'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if journal is split.
|
||||
*
|
||||
* @param TransactionJournal $journal
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function isSplitJournal(TransactionJournal $journal): bool // validate objects
|
||||
{
|
||||
$count = $this->repository->countTransactions($journal);
|
||||
|
||||
return $count > 2;
|
||||
}
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ namespace FireflyIII\Support\Http\Controllers;
|
||||
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Models\TransactionType;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
|
||||
/**
|
||||
* Trait ModelInformation
|
||||
@ -45,5 +46,21 @@ trait ModelInformation
|
||||
return TransactionType::OPENING_BALANCE === $journal->transactionType->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if journal is split.
|
||||
*
|
||||
* @param TransactionJournal $journal
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function isSplitJournal(TransactionJournal $journal): bool // validate objects
|
||||
{
|
||||
/** @var JournalRepositoryInterface $repository */
|
||||
$repository = app(JournalRepositoryInterface::class);
|
||||
$repository->setUser($journal->user);
|
||||
$count = $repository->countTransactions($journal);
|
||||
|
||||
return $count > 2;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user