diff --git a/app/Repositories/Account/AccountRepository.php b/app/Repositories/Account/AccountRepository.php index ea19ac2dc2..38bf2f0caa 100644 --- a/app/Repositories/Account/AccountRepository.php +++ b/app/Repositories/Account/AccountRepository.php @@ -72,6 +72,18 @@ class AccountRepository implements AccountRepositoryInterface return Auth::user()->accounts()->findOrNew($accountId); } + /** + * Gets all the accounts by ID, for a given set. + * + * @param array $ids + * + * @return Collection + */ + public function get(array $ids) + { + return Auth::user()->accounts()->whereIn('id', $ids)->get(['accounts.*']); + } + /** * @param array $types * @@ -464,9 +476,7 @@ class AccountRepository implements AccountRepositoryInterface if (!$existingAccount) { Log::error('Account create error: ' . $newAccount->getErrors()->toJson()); abort(500); - // @codeCoverageIgnoreStart } - // @codeCoverageIgnoreEnd $newAccount = $existingAccount; } @@ -554,7 +564,7 @@ class AccountRepository implements AccountRepositoryInterface { $journal->date = $data['openingBalanceDate']; $journal->save(); - + /** @var Transaction $transaction */ foreach ($journal->transactions()->get() as $transaction) { if ($account->id == $transaction->account_id) { diff --git a/app/Repositories/Account/AccountRepositoryInterface.php b/app/Repositories/Account/AccountRepositoryInterface.php index 628aca2d15..9b10c383c7 100644 --- a/app/Repositories/Account/AccountRepositoryInterface.php +++ b/app/Repositories/Account/AccountRepositoryInterface.php @@ -17,6 +17,7 @@ use Illuminate\Support\Collection; */ interface AccountRepositoryInterface { + /** * @param array $types * @@ -41,6 +42,15 @@ interface AccountRepositoryInterface */ public function find($accountId); + /** + * Gets all the accounts by ID, for a given set. + * + * @param array $ids + * + * @return Collection + */ + public function get(array $ids); + /** * @param array $types *