Skip to content

Firefly III: a personal finances manager

Fix for #312

James Cole7d5bb72b0c56
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 CRI $repository
+ * @param AccountCrudInterface $crud
*
- * @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);