diff --git a/app/Http/Controllers/Transaction/SingleController.php b/app/Http/Controllers/Transaction/SingleController.php index 820949f258..6b2f5f934e 100644 --- a/app/Http/Controllers/Transaction/SingleController.php +++ b/app/Http/Controllers/Transaction/SingleController.php @@ -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; - } } diff --git a/app/Support/Http/Controllers/ModelInformation.php b/app/Support/Http/Controllers/ModelInformation.php index dd0cd6b8d9..3bb8282d63 100644 --- a/app/Support/Http/Controllers/ModelInformation.php +++ b/app/Support/Http/Controllers/ModelInformation.php @@ -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; + } } \ No newline at end of file