Many more route fixes.

This commit is contained in:
James Cole
2016-12-06 08:59:08 +01:00
parent f4887bbbf7
commit 628c7cd055
25 changed files with 112 additions and 111 deletions

View File

@@ -29,13 +29,13 @@ class AccountController extends Controller
{
/**
* @param Collection $accounts
* @param Carbon $start
* @param Carbon $end
* @param Collection $accounts
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
* @return mixed|string
*/
public function accountReport(Carbon $start, Carbon $end, Collection $accounts)
public function general(Collection $accounts, Carbon $start, Carbon $end)
{
// chart properties for cache:
$cache = new CacheProperties;
@@ -47,9 +47,9 @@ class AccountController extends Controller
return $cache->get();
}
/** @var AccountTaskerInterface $accountTasker */
$accountTasker = app(AccountTaskerInterface::class);
$accountReport = $accountTasker->getAccountReport($start, $end, $accounts);
$accountReport = $accountTasker->getAccountReport($accounts, $start, $end);
$result = view('reports.partials.accounts', compact('accountReport'))->render();
$cache->store($result);

View File

@@ -30,13 +30,13 @@ class BalanceController extends Controller
/**
* @param BalanceReportHelperInterface $helper
* @param Collection $accounts
* @param Carbon $start
* @param Carbon $end
* @param Collection $accounts
*
* @return string
* @return mixed|string
*/
public function balanceReport(BalanceReportHelperInterface $helper, Carbon $start, Carbon $end, Collection $accounts)
public function general(BalanceReportHelperInterface $helper,Collection $accounts, Carbon $start, Carbon $end)
{
@@ -50,7 +50,7 @@ class BalanceController extends Controller
return $cache->get();
}
$balance = $helper->getBalanceReport($start, $end, $accounts);
$balance = $helper->getBalanceReport($accounts, $start, $end);
$result = view('reports.partials.balance', compact('balance'))->render();
$cache->store($result);

View File

@@ -31,34 +31,6 @@ use Navigation;
*/
class CategoryController extends Controller
{
/**
* @param ReportHelperInterface $helper
* @param Carbon $start
* @param Carbon $end
* @param Collection $accounts
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function categoryReport(ReportHelperInterface $helper, Carbon $start, Carbon $end, Collection $accounts)
{
// chart properties for cache:
$cache = new CacheProperties;
$cache->addProperty($start);
$cache->addProperty($end);
$cache->addProperty('category-report');
$cache->addProperty($accounts->pluck('id')->toArray());
if ($cache->has()) {
return $cache->get();
}
$categories = $helper->getCategoryReport($start, $end, $accounts);
$result = view('reports.partials.categories', compact('categories'))->render();
$cache->store($result);
return $result;
}
/**
* @param Collection $accounts
* @param Carbon $start
@@ -75,6 +47,7 @@ class CategoryController extends Controller
$cache->addProperty($accounts->pluck('id')->toArray());
if ($cache->has()) {
Log::debug('Return report from cache');
return $cache->get();
}
/** @var CategoryRepositoryInterface $repository */
@@ -84,7 +57,7 @@ class CategoryController extends Controller
$data[0] = $repository->periodExpensesNoCategory($accounts, $start, $end);
$report = $this->filterReport($data);
$periods = Navigation::listOfPeriods($start, $end);
$result = view('reports.partials.category-period', compact('report', 'periods'))->render();
$result = view('reports.partials.category-period', compact('report', 'periods'))->render();
$cache->store($result);
@@ -108,6 +81,7 @@ class CategoryController extends Controller
$cache->addProperty($accounts->pluck('id')->toArray());
if ($cache->has()) {
Log::debug('Return report from cache');
return $cache->get();
}
/** @var CategoryRepositoryInterface $repository */
@@ -117,13 +91,48 @@ class CategoryController extends Controller
$data[0] = $repository->periodIncomeNoCategory($accounts, $start, $end);
$report = $this->filterReport($data);
$periods = Navigation::listOfPeriods($start, $end);
$result = view('reports.partials.category-period', compact('report', 'periods'))->render();
$result = view('reports.partials.category-period', compact('report', 'periods'))->render();
$cache->store($result);
return $result;
}
/**
* @param ReportHelperInterface $helper
* @param Collection $accounts
* @param Carbon $start
* @param Carbon $end
*
* @return mixed|string
*/
public function operations(Collection $accounts, Carbon $start, Carbon $end)
{
// chart properties for cache:
$cache = new CacheProperties;
$cache->addProperty($start);
$cache->addProperty($end);
$cache->addProperty('category-report');
$cache->addProperty($accounts->pluck('id')->toArray());
if ($cache->has()) {
return $cache->get();
}
/** @var CategoryRepositoryInterface $repository */
$repository = app(CategoryRepositoryInterface::class);
$categories = $repository->getCategories();
$report = [];
/** @var Category $category */
foreach ($categories as $category) {
$spent = $repository->spentInPeriod(new Collection([$category]), $accounts, $start, $end);
$report[$category->id] = ['name' => $category->name, 'spent' => $spent];
}
$result = view('reports.partials.categories', compact('report'))->render();
$cache->store($result);
return $result;
}
/**
* Filters empty results from category period report

View File

@@ -1,6 +1,6 @@
<?php
/**
* InOutController.php
* OperationsController.php
* Copyright (C) 2016 thegrumpydictator@gmail.com
*
* This software may be modified and distributed under the terms of the
@@ -24,21 +24,21 @@ use FireflyIII\Support\CacheProperties;
use Illuminate\Support\Collection;
/**
* Class InOutController
* Class OperationsController
*
* @package FireflyIII\Http\Controllers\Report
*/
class InOutController extends Controller
class OperationsController extends Controller
{
/**
* @param Collection $accounts
* @param Carbon $start
* @param Carbon $end
* @param Collection $accounts
*
* @return \Illuminate\Http\JsonResponse
* @return mixed|string
*/
public function expenseReport(Carbon $start, Carbon $end, Collection $accounts)
public function expenses(Collection $accounts, Carbon $start, Carbon $end)
{
// chart properties for cache:
$cache = new CacheProperties;
@@ -58,14 +58,13 @@ class InOutController extends Controller
}
/**
* @param ReportHelperInterface $helper
* @param Carbon $start
* @param Carbon $end
* @param Collection $accounts
* @param Collection $accounts
* @param Carbon $start
* @param Carbon $end
*
* @return \Illuminate\Http\JsonResponse
* @return mixed|string
*/
public function incExpReport(ReportHelperInterface $helper, Carbon $start, Carbon $end, Collection $accounts)
public function operations(Collection $accounts, Carbon $start, Carbon $end)
{
// chart properties for cache:
$cache = new CacheProperties;
@@ -95,7 +94,7 @@ class InOutController extends Controller
)
);
$result = view('reports.partials.income-vs-expenses', compact('incomeSum', 'expensesSum'))->render();
$result = view('reports.partials.operations', compact('incomeSum', 'expensesSum'))->render();
$cache->store($result);
return $result;
@@ -103,14 +102,13 @@ class InOutController extends Controller
}
/**
* @param ReportHelperInterface $helper
* @param Carbon $start
* @param Carbon $end
* @param Collection $accounts
* @param Collection $accounts
* @param Carbon $start
* @param Carbon $end
*
* @return \Illuminate\Http\JsonResponse
* @return string
*/
public function incomeReport(ReportHelperInterface $helper, Carbon $start, Carbon $end, Collection $accounts)
public function income(Collection $accounts, Carbon $start, Carbon $end)
{
// chart properties for cache:
$cache = new CacheProperties;

View File

@@ -62,7 +62,7 @@ class ConvertController extends Controller
*
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|View
*/
public function convert(TransactionType $destinationType, TransactionJournal $journal)
public function index(TransactionType $destinationType, TransactionJournal $journal)
{
if ($this->isOpeningBalance($journal)) {
return $this->redirectToAccount($journal);
@@ -115,7 +115,7 @@ class ConvertController extends Controller
*
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*/
public function submit(Request $request, JournalRepositoryInterface $repository, TransactionType $destinationType, TransactionJournal $journal)
public function postIndex(Request $request, JournalRepositoryInterface $repository, TransactionType $destinationType, TransactionJournal $journal)
{
if ($this->isOpeningBalance($journal)) {
return $this->redirectToAccount($journal);

View File

@@ -179,7 +179,7 @@ class SingleController extends Controller
$count = $journal->transactions()->count();
if ($count > 2) {
return redirect(route('transactions.edit-split', [$journal->id]));
return redirect(route('transactions.split.edit', [$journal->id]));
}
$what = strtolower(TransactionJournal::transactionTypeStr($journal));
@@ -286,7 +286,7 @@ class SingleController extends Controller
if ($doSplit === true) {
// redirect to edit screen:
return redirect(route('transactions.edit-split', [$journal->id]));
return redirect(route('transactions.split.edit', [$journal->id]));
}

View File

@@ -157,7 +157,7 @@ class SplitController extends Controller
// set value so edit routine will not overwrite URL:
Session::put('transactions.edit-split.fromUpdate', true);
return redirect(route('transactions.edit-split', [$journal->id]))->withInput(['return_to_edit' => 1]);
return redirect(route('transactions.split.edit', [$journal->id]))->withInput(['return_to_edit' => 1]);
}
// redirect to previous URL.

View File

@@ -146,7 +146,7 @@ class TransactionController extends Controller
*
* @return View
*/
public function indexDate(Request $request, string $what, string $date)
public function indexByDate(Request $request, string $what, string $date)
{
$carbon = new Carbon($date);
$range = Preferences::get('viewRange', '1M')->data;