mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-01-05 21:53:08 -06:00
Invert stuff so chart works again.
This commit is contained in:
parent
6f08482aaf
commit
98fd5b8858
@ -327,9 +327,9 @@ class CategoryController extends Controller
|
||||
return $category->name;
|
||||
}
|
||||
);
|
||||
|
||||
$entries = $this->filterCollection($start, $end, $set, $categories);
|
||||
$data = $this->generator->spentInPeriod($categories, $entries);
|
||||
$entries = $this->filterCollection($start, $end, $set, $categories);
|
||||
$entries = $this->invertSelection($entries);
|
||||
$data = $this->generator->spentInPeriod($categories, $entries);
|
||||
$cache->store($data);
|
||||
|
||||
return $data;
|
||||
@ -362,7 +362,7 @@ class CategoryController extends Controller
|
||||
}
|
||||
)->first();
|
||||
if (!is_null($entry)) {
|
||||
$row[] = round($entry->earned, 2);
|
||||
$row[] = $entry->earned ? round($entry->earned, 2) : round($entry->spent, 2);
|
||||
} else {
|
||||
$row[] = 0;
|
||||
}
|
||||
@ -374,6 +374,27 @@ class CategoryController extends Controller
|
||||
return $entries;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Collection $entries
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
private function invertSelection(Collection $entries): Collection
|
||||
{
|
||||
$result = new Collection;
|
||||
foreach ($entries as $entry) {
|
||||
$new = [$entry[0]];
|
||||
$count = count($entry);
|
||||
for ($i = 1; $i < $count; $i++) {
|
||||
$new[$i] = ($entry[$i] * -1);
|
||||
}
|
||||
$result->push($new);
|
||||
}
|
||||
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SCRI $repository
|
||||
* @param Category $category
|
||||
|
Loading…
Reference in New Issue
Block a user