From 7d5bb72b0c5671716293c37cf9a0126e70d20950 Mon Sep 17 00:00:00 2001 From: James Cole Date: Thu, 15 Sep 2016 19:14:22 +0200 Subject: [PATCH] Fix for #312 Signed-off-by: James Cole --- app/Http/Controllers/Chart/CategoryController.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/Http/Controllers/Chart/CategoryController.php b/app/Http/Controllers/Chart/CategoryController.php index b585c0d1d2..2cccc3a026 100644 --- a/app/Http/Controllers/Chart/CategoryController.php +++ b/app/Http/Controllers/Chart/CategoryController.php @@ -108,13 +108,12 @@ class CategoryController extends Controller } /** - * Show this month's category overview. + * @param CRI $repository + * @param AccountCrudInterface $crud * - * @param CRI $repository - * - * @return \Symfony\Component\HttpFoundation\Response + * @return \Illuminate\Http\JsonResponse */ - public function frontpage(CRI $repository) + public function frontpage(CRI $repository, AccountCrudInterface $crud) { $start = session('start', Carbon::now()->startOfMonth()); $end = session('end', Carbon::now()->endOfMonth()); @@ -128,10 +127,11 @@ class CategoryController extends Controller return Response::json($cache->get()); } $categories = $repository->getCategories(); + $accounts = $crud->getAccountsByType([AccountType::ASSET, AccountType::DEFAULT]); $set = new Collection; /** @var Category $category */ foreach ($categories as $category) { - $spent = $repository->spentInPeriod(new Collection([$category]), new Collection, $start, $end); + $spent = $repository->spentInPeriod(new Collection([$category]), $accounts, $start, $end); if (bccomp($spent, '0') === -1) { $category->spent = $spent; $set->push($category);