use journal repository instead of direct calls.

This commit is contained in:
James Cole
2018-02-25 19:09:05 +01:00
parent 99983a5c8f
commit 1b304bf85e
18 changed files with 175 additions and 222 deletions

View File

@@ -43,6 +43,9 @@ class ConvertController extends Controller
/** @var AccountRepositoryInterface */
private $accounts;
/** @var JournalRepositoryInterface */
private $repository;
/**
* ConvertController constructor.
*/
@@ -53,7 +56,8 @@ class ConvertController extends Controller
// some useful repositories:
$this->middleware(
function ($request, $next) {
$this->accounts = app(AccountRepositoryInterface::class);
$this->accounts = app(AccountRepositoryInterface::class);
$this->repository = app(JournalRepositoryInterface::class);
app('view')->share('title', trans('firefly.transactions'));
app('view')->share('mainTitleIcon', 'fa-exchange');
@@ -76,8 +80,7 @@ class ConvertController extends Controller
return $this->redirectToAccount($journal);
}
// @codeCoverageIgnoreEnd
$positiveAmount = $journal->amountPositive();
$positiveAmount = $this->repository->getJournalTotal($journal);
$assetAccounts = ExpandedForm::makeSelectList($this->accounts->getActiveAccountsByType([AccountType::DEFAULT, AccountType::ASSET]));
$sourceType = $journal->transactionType;
$subTitle = trans('firefly.convert_to_' . $destinationType->type, ['description' => $journal->description]);
@@ -98,8 +101,8 @@ class ConvertController extends Controller
}
// get source and destination account:
$sourceAccount = $journal->sourceAccountList()->first();
$destinationAccount = $journal->destinationAccountList()->first();
$sourceAccount = $this->repository->getJournalSourceAccounts($journal)->first();
$destinationAccount = $this->repository->getJournalDestinationAccounts($journal)->first();
return view(
'transactions.convert',
@@ -183,8 +186,8 @@ class ConvertController extends Controller
{
/** @var AccountRepositoryInterface $accountRepository */
$accountRepository = app(AccountRepositoryInterface::class);
$sourceAccount = $journal->sourceAccountList()->first();
$destinationAccount = $journal->destinationAccountList()->first();
$sourceAccount = $this->repository->getJournalSourceAccounts($journal)->first();
$destinationAccount = $this->repository->getJournalDestinationAccounts($journal)->first();
$sourceType = $journal->transactionType;
$joined = $sourceType->type . '-' . $destinationType->type;
switch ($joined) {
@@ -239,8 +242,8 @@ class ConvertController extends Controller
{
/** @var AccountRepositoryInterface $accountRepository */
$accountRepository = app(AccountRepositoryInterface::class);
$sourceAccount = $journal->sourceAccountList()->first();
$destinationAccount = $journal->destinationAccountList()->first();
$sourceAccount = $this->repository->getJournalSourceAccounts($journal)->first();
$destinationAccount = $this->repository->getJournalDestinationAccounts($journal)->first();
$sourceType = $journal->transactionType;
$joined = $sourceType->type . '-' . $destinationType->type;
switch ($joined) {