mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-11-18 07:38:29 +00:00
Clean up code after changing routes.
This commit is contained in:
@@ -245,7 +245,7 @@ class CategoryController extends Controller
|
||||
*
|
||||
* @return View
|
||||
*/
|
||||
public function showWithDate(Category $category, string $date)
|
||||
public function showByDate(Category $category, string $date)
|
||||
{
|
||||
$carbon = new Carbon($date);
|
||||
$range = Preferences::get('viewRange', '1M')->data;
|
||||
@@ -263,7 +263,7 @@ class CategoryController extends Controller
|
||||
$journals->setPath('categories/show/' . $category->id . '/' . $date);
|
||||
|
||||
|
||||
return view('categories.show_with_date', compact('category', 'journals', 'hideCategory', 'subTitle', 'carbon'));
|
||||
return view('categories.show-by-date', compact('category', 'journals', 'hideCategory', 'subTitle', 'carbon'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -155,11 +155,13 @@ class CategoryController extends Controller
|
||||
/**
|
||||
* @param CRI $repository
|
||||
* @param Category $category
|
||||
* @param Collection $accounts
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Collection $accounts
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse|mixed
|
||||
*/
|
||||
public function reportPeriod(CRI $repository, Category $category, Carbon $start, Carbon $end, Collection $accounts)
|
||||
public function reportPeriod(CRI $repository, Category $category, Collection $accounts, Carbon $start, Carbon $end)
|
||||
{
|
||||
$cache = new CacheProperties;
|
||||
$cache->addProperty($start);
|
||||
@@ -171,8 +173,9 @@ class CategoryController extends Controller
|
||||
|
||||
return $cache->get();
|
||||
}
|
||||
$report = $repository->getCategoryPeriodReport(new Collection([$category]), $accounts, $start, $end, true);
|
||||
$periods = Navigation::listOfPeriods($start, $end);
|
||||
$expenses = $repository->periodExpenses(new Collection([$category]), $accounts, $start, $end);
|
||||
$income = $repository->periodIncome(new Collection([$category]), $accounts, $start, $end);
|
||||
$periods = Navigation::listOfPeriods($start, $end);
|
||||
|
||||
|
||||
// join them:
|
||||
@@ -180,8 +183,46 @@ class CategoryController extends Controller
|
||||
foreach (array_keys($periods) as $period) {
|
||||
$nice = $periods[$period];
|
||||
$result[$nice] = [
|
||||
'earned' => $report['income'][$category->id]['entries'][$period] ?? '0',
|
||||
'spent' => $report['expense'][$category->id]['entries'][$period] ?? '0',
|
||||
'earned' => $income[$category->id]['entries'][$period] ?? '0',
|
||||
'spent' => $expenses[$category->id]['entries'][$period] ?? '0',
|
||||
];
|
||||
}
|
||||
$data = $this->generator->reportPeriod($result);
|
||||
|
||||
return Response::json($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CRI $repository
|
||||
* @param Category $category
|
||||
* @param Collection $accounts
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse|mixed
|
||||
*/
|
||||
public function reportPeriodNoCategory(CRI $repository, Collection $accounts, Carbon $start, Carbon $end)
|
||||
{
|
||||
$cache = new CacheProperties;
|
||||
$cache->addProperty($start);
|
||||
$cache->addProperty($end);
|
||||
$cache->addProperty('no-category-period-chart');
|
||||
$cache->addProperty($accounts->pluck('id')->toArray());
|
||||
if ($cache->has()) {
|
||||
|
||||
return $cache->get();
|
||||
}
|
||||
$expenses = $repository->periodExpensesNoCategory($accounts, $start, $end);
|
||||
$income = $repository->periodIncomeNoCategory($accounts, $start, $end);
|
||||
$periods = Navigation::listOfPeriods($start, $end);
|
||||
|
||||
// join them:
|
||||
$result = [];
|
||||
foreach (array_keys($periods) as $period) {
|
||||
$nice = $periods[$period];
|
||||
$result[$nice] = [
|
||||
'earned' => $income['entries'][$period] ?? '0',
|
||||
'spent' => $expenses['entries'][$period] ?? '0',
|
||||
];
|
||||
}
|
||||
$data = $this->generator->reportPeriod($result);
|
||||
|
||||
@@ -60,14 +60,13 @@ class CategoryController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param Collection $accounts
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Collection $accounts
|
||||
*
|
||||
* @return string
|
||||
* @return mixed|string
|
||||
*/
|
||||
public function expenseReport(Carbon $start, Carbon $end, Collection $accounts)
|
||||
public function expenses(Collection $accounts, Carbon $start, Carbon $end)
|
||||
{
|
||||
$cache = new CacheProperties;
|
||||
$cache->addProperty($start);
|
||||
@@ -100,7 +99,7 @@ class CategoryController extends Controller
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function incomeReport(Carbon $start, Carbon $end, Collection $accounts)
|
||||
public function income(Collection $accounts, Carbon $start, Carbon $end)
|
||||
{
|
||||
$cache = new CacheProperties;
|
||||
$cache->addProperty($start);
|
||||
|
||||
Reference in New Issue
Block a user