Move some stuff around.

This commit is contained in:
James Cole
2016-05-20 09:45:24 +02:00
parent 65b8882ed4
commit 724f423692
14 changed files with 58 additions and 80 deletions

View File

@@ -84,18 +84,17 @@ class AccountController extends Controller
}
/**
* @param ARI $repository
* @param AccountCrudInterface $crud
* @param Account $account
*
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*/
public function destroy(ARI $repository, AccountCrudInterface $crud, Account $account)
public function destroy(AccountCrudInterface $crud, Account $account)
{
$type = $account->accountType->type;
$typeName = config('firefly.shortNamesByFullName.' . $type);
$name = $account->name;
$moveTo = $repository->find(intval(Input::get('move_account_before_delete')));
$moveTo = $crud->find(intval(Input::get('move_account_before_delete')));
$crud->destroy($account, $moveTo);

View File

@@ -88,10 +88,8 @@ class ReportController extends Controller
/** @var BudgetRepositoryInterface $budgetRepository */
$budgetRepository = app(BudgetRepositoryInterface::class);
$budget = $budgetRepository->find(intval($attributes['budgetId']));
/** @var AccountRepositoryInterface $accountRepository */
$accountRepository = app(AccountRepositoryInterface::class);
$account = $accountRepository->find(intval($attributes['accountId']));
$crud = app('FireflyIII\Crud\Account\AccountCrudInterface');
$account = $crud->find(intval($attributes['accountId']));
switch (true) {
case ($role === BalanceLine::ROLE_DEFAULTROLE && !is_null($budget->id)):
@@ -183,7 +181,8 @@ class ReportController extends Controller
{
/** @var AccountRepositoryInterface $repository */
$repository = app(AccountRepositoryInterface::class);
$account = $repository->find(intval($attributes['accountId']));
$crud = app('FireflyIII\Crud\Account\AccountCrudInterface');
$account = $crud->find(intval($attributes['accountId']));
$types = [TransactionType::WITHDRAWAL, TransactionType::TRANSFER];
$journals = $repository->journalsInPeriod($attributes['accounts'], $types, $attributes['startDate'], $attributes['endDate']);
@@ -213,7 +212,8 @@ class ReportController extends Controller
{
/** @var AccountRepositoryInterface $repository */
$repository = app(AccountRepositoryInterface::class);
$account = $repository->find(intval($attributes['accountId']));
$crud = app('FireflyIII\Crud\Account\AccountCrudInterface');
$account = $crud->find(intval($attributes['accountId']));
$types = [TransactionType::DEPOSIT, TransactionType::TRANSFER];
$journals = $repository->journalsInPeriod(new Collection([$account]), $types, $attributes['startDate'], $attributes['endDate']);
$destinations = $attributes['accounts']->pluck('id')->toArray();
@@ -221,8 +221,8 @@ class ReportController extends Controller
$journals = $journals->filter(
function (TransactionJournal $journal) use ($account, $destinations) {
if (
$journal->source_account_id === $account->id &&
in_array($journal->destination_account_id, $destinations)
$journal->source_account_id === $account->id
&& in_array($journal->destination_account_id, $destinations)
) {
return $journal;
}