mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-19 19:01:58 +00:00
Fix category report.
This commit is contained in:
@@ -124,10 +124,21 @@ class CategoryController extends Controller
|
|||||||
$report = [];
|
$report = [];
|
||||||
/** @var Category $category */
|
/** @var Category $category */
|
||||||
foreach ($categories as $category) {
|
foreach ($categories as $category) {
|
||||||
$spent = $repository->spentInPeriod(new Collection([$category]), $accounts, $start, $end);
|
$spent = $repository->spentInPeriod(new Collection([$category]), $accounts, $start, $end);
|
||||||
$report[$category->id] = ['name' => $category->name, 'spent' => $spent];
|
if (bccomp($spent, '0') !== 0) {
|
||||||
|
$report[$category->id] = ['name' => $category->name, 'spent' => $spent];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// sort the result
|
||||||
|
// Obtain a list of columns
|
||||||
|
$sum = [];
|
||||||
|
foreach ($report as $categoryId => $row) {
|
||||||
|
$sum[$categoryId] = floatval($row['spent']);
|
||||||
|
}
|
||||||
|
|
||||||
|
array_multisort($sum, SORT_DESC, $report);
|
||||||
|
|
||||||
$result = view('reports.partials.categories', compact('report'))->render();
|
$result = view('reports.partials.categories', compact('report'))->render();
|
||||||
$cache->store($result);
|
$cache->store($result);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user