Skip to content

Firefly III: a personal finances manager

Remove old chart.

James Coleedde18aeef52
diff --git a/app/Generator/Chart/Category/CategoryChartGenerator.php b/app/Generator/Chart/Category/CategoryChartGenerator.php
index f249b320bb..f595fcf541 100644
--- a/app/Generator/Chart/Category/CategoryChartGenerator.php
+++ b/app/Generator/Chart/Category/CategoryChartGenerator.php
@@ -19,14 +19,6 @@ interface CategoryChartGenerator
*/
public function all(Collection $entries);
- /**
- * @param Collection $categories
- * @param Collection $entries
- *
- * @return array
- */
- public function earnedInYear(Collection $categories, Collection $entries);
-
/**
* @param Collection $categories
* @param Collection $entries
diff --git a/app/Generator/Chart/Category/ChartJsCategoryChartGenerator.php b/app/Generator/Chart/Category/ChartJsCategoryChartGenerator.php
index 88df36fd69..cf3a8a1dd9 100644
--- a/app/Generator/Chart/Category/ChartJsCategoryChartGenerator.php
+++ b/app/Generator/Chart/Category/ChartJsCategoryChartGenerator.php
@@ -2,9 +2,7 @@
namespace FireflyIII\Generator\Chart\Category;
-use Config;
use Illuminate\Support\Collection;
-use Preferences;
/**
@@ -101,40 +99,7 @@ class ChartJsCategoryChartGenerator implements CategoryChartGenerator
{
// language:
- $format = trans('config.month');
-
- $data = [
- 'count' => 0,
- 'labels' => [],
- 'datasets' => [],
- ];
-
- foreach ($categories as $category) {
- $data['labels'][] = $category->name;
- }
-
- foreach ($entries as $entry) {
- $date = $entry[0]->formatLocalized($format);
- array_shift($entry);
- $data['count']++;
- $data['datasets'][] = ['label' => $date, 'data' => $entry];
- }
-
- return $data;
-
- }
-
- /**
- * @param Collection $categories
- * @param Collection $entries
- *
- * @return array
- */
- public function earnedInYear(Collection $categories, Collection $entries)
- {
-
- // language:
- $format = trans('config.month');
+ $format = trans('config.month');
$data = [
'count' => 0,
@@ -167,7 +132,7 @@ class ChartJsCategoryChartGenerator implements CategoryChartGenerator
{
// language:
- $format = trans('config.month');
+ $format = trans('config.month');
$data = [
'count' => 0,
diff --git a/app/Http/Controllers/Chart/CategoryController.php b/app/Http/Controllers/Chart/CategoryController.php
index e36a93b975..5aa8db7ae0 100644
--- a/app/Http/Controllers/Chart/CategoryController.php
+++ b/app/Http/Controllers/Chart/CategoryController.php
@@ -446,62 +446,4 @@ class CategoryController extends Controller
}
- /**
- * This chart will only show income.
- *
- * @param CategoryRepositoryInterface $repository
- * @param $report_type
- * @param Carbon $start
- * @param Carbon $end
- * @param Collection $accounts
- *
- * @return \Illuminate\Http\JsonResponse
- */
- public function earnedInYear(CategoryRepositoryInterface $repository, $report_type, Carbon $start, Carbon $end, Collection $accounts)
- {
- $cache = new CacheProperties; // chart properties for cache:
- $cache->addProperty($start);
- $cache->addProperty($end);
- $cache->addProperty($report_type);
- $cache->addProperty($accounts);
- $cache->addProperty('category');
- $cache->addProperty('earned-in-year');
- if ($cache->has()) {
- return Response::json($cache->get()); // @codeCoverageIgnore
- }
-
- $allCategories = $repository->getCategories();
- $allEntries = new Collection;
- $categories = $allCategories->filter(
- function (Category $category) use ($repository, $start, $end, $accounts) {
- $spent = $repository->balanceInPeriod($category, $start, $end, $accounts);
- if ($spent > 0) {
- return $category;
- }
-
- return null;
- }
- );
-
- while ($start < $end) {
- $month = clone $start; // month is the current end of the period
- $month->endOfMonth();
- $row = [clone $start]; // make a row:
-
- foreach ($categories as $category) { // each budget, fill the row
- $spent = $repository->balanceInPeriod($category, $start, $month, $accounts);
- if ($spent > 0) {
- $row[] = $spent;
- } else {
- $row[] = 0;
- }
- }
- $allEntries->push($row);
- $start->addMonth();
- }
- $data = $this->generator->earnedInYear($categories, $allEntries);
- $cache->store($data);
-
- return Response::json($data);
- }
}