diff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.php index 547fa6b043..20430d4e80 100644 --- a/app/Http/Controllers/AccountController.php +++ b/app/Http/Controllers/AccountController.php @@ -127,7 +127,7 @@ class AccountController extends Controller $what = config('firefly.shortNamesByFullName')[$account->accountType->type]; $subTitle = trans('firefly.edit_' . $what . '_account', ['name' => $account->name]); $subTitleIcon = config('firefly.subIconsByIdentifier.' . $what); - $openingBalance = $repository->openingBalanceTransaction($account); + $openingBalance = $account->openingBalanceTransaction($account); // put previous url in session if not redirect from store (not "return_to_edit"). if (session('accounts.edit.fromUpdate') !== true) { diff --git a/app/Repositories/Account/AccountRepository.php b/app/Repositories/Account/AccountRepository.php index beac239765..a9849afaad 100644 --- a/app/Repositories/Account/AccountRepository.php +++ b/app/Repositories/Account/AccountRepository.php @@ -158,23 +158,4 @@ class AccountRepository implements AccountRepositoryInterface return $first; } - /** - * @param Account $account - * - * @return TransactionJournal|null - */ - public function openingBalanceTransaction(Account $account): TransactionJournal - { - $journal = TransactionJournal - ::sortCorrectly() - ->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id') - ->where('transactions.account_id', $account->id) - ->transactionTypes([TransactionType::OPENING_BALANCE]) - ->first(['transaction_journals.*']); - if (is_null($journal)) { - return new TransactionJournal; - } - - return $journal; - } } diff --git a/app/Repositories/Account/AccountRepositoryInterface.php b/app/Repositories/Account/AccountRepositoryInterface.php index 8416620654..6743371d97 100644 --- a/app/Repositories/Account/AccountRepositoryInterface.php +++ b/app/Repositories/Account/AccountRepositoryInterface.php @@ -78,12 +78,4 @@ interface AccountRepositoryInterface */ public function oldestJournalDate(Account $account): Carbon; - /** - * - * @param Account $account - * - * @return TransactionJournal - */ - public function openingBalanceTransaction(Account $account) : TransactionJournal; - }