mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
parent
46e5aae8bb
commit
7d5bb72b0c
@ -108,13 +108,12 @@ class CategoryController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show this month's category overview.
|
* @param CRI $repository
|
||||||
|
* @param AccountCrudInterface $crud
|
||||||
*
|
*
|
||||||
* @param CRI $repository
|
* @return \Illuminate\Http\JsonResponse
|
||||||
*
|
|
||||||
* @return \Symfony\Component\HttpFoundation\Response
|
|
||||||
*/
|
*/
|
||||||
public function frontpage(CRI $repository)
|
public function frontpage(CRI $repository, AccountCrudInterface $crud)
|
||||||
{
|
{
|
||||||
$start = session('start', Carbon::now()->startOfMonth());
|
$start = session('start', Carbon::now()->startOfMonth());
|
||||||
$end = session('end', Carbon::now()->endOfMonth());
|
$end = session('end', Carbon::now()->endOfMonth());
|
||||||
@ -128,10 +127,11 @@ class CategoryController extends Controller
|
|||||||
return Response::json($cache->get());
|
return Response::json($cache->get());
|
||||||
}
|
}
|
||||||
$categories = $repository->getCategories();
|
$categories = $repository->getCategories();
|
||||||
|
$accounts = $crud->getAccountsByType([AccountType::ASSET, AccountType::DEFAULT]);
|
||||||
$set = new Collection;
|
$set = new Collection;
|
||||||
/** @var Category $category */
|
/** @var Category $category */
|
||||||
foreach ($categories as $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) {
|
if (bccomp($spent, '0') === -1) {
|
||||||
$category->spent = $spent;
|
$category->spent = $spent;
|
||||||
$set->push($category);
|
$set->push($category);
|
||||||
|
Loading…
Reference in New Issue
Block a user