mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-11-18 15:39:50 +00:00
Code cleanup. Moving closer to new release.
This commit is contained in:
@@ -31,10 +31,6 @@ use stdClass;
|
||||
*/
|
||||
class CategoryController extends Controller
|
||||
{
|
||||
const MAKE_POSITIVE = -1;
|
||||
const KEEP_POSITIVE = 1;
|
||||
|
||||
|
||||
/** @var CategoryChartGeneratorInterface */
|
||||
protected $generator;
|
||||
|
||||
@@ -192,20 +188,20 @@ class CategoryController extends Controller
|
||||
|
||||
// get data:
|
||||
if (is_null($category->id)) {
|
||||
$name = trans('firefly.noCategory');
|
||||
$spent = $repository->spentInPeriodWithoutCategory($accounts, $currentStart, $currentEnd);
|
||||
$earned = $repository->earnedInPeriodWithoutCategory($accounts, $currentStart, $currentEnd);
|
||||
} else {
|
||||
$entry['name'] = trans('firefly.noCategory');
|
||||
$entry['spent'][$year] = ($repository->spentInPeriodWithoutCategory($accounts, $currentStart, $currentEnd) * -1);
|
||||
$entry['earned'][$year] = $repository->earnedInPeriodWithoutCategory($accounts, $currentStart, $currentEnd);
|
||||
|
||||
// jump to next year.
|
||||
$currentStart = clone $currentEnd;
|
||||
$currentStart->addDay();
|
||||
continue;
|
||||
|
||||
$name = $category->name;
|
||||
$spent = $repository->spentInPeriod(new Collection([$category]), $accounts, $currentStart, $currentEnd);
|
||||
$earned = $repository->earnedInPeriod(new Collection([$category]), $accounts, $currentStart, $currentEnd);
|
||||
}
|
||||
|
||||
// save to array:
|
||||
$entry['name'] = $name;
|
||||
$entry['spent'][$year] = ($spent * -1);
|
||||
$entry['earned'][$year] = $earned;
|
||||
// alternative is a normal category:
|
||||
$entry['name'] = $category->name;
|
||||
$entry['spent'][$year] = ($repository->spentInPeriod(new Collection([$category]), $accounts, $currentStart, $currentEnd) * -1);
|
||||
$entry['earned'][$year] = $repository->earnedInPeriod(new Collection([$category]), $accounts, $currentStart, $currentEnd);
|
||||
|
||||
// jump to next year.
|
||||
$currentStart = clone $currentEnd;
|
||||
@@ -213,8 +209,8 @@ class CategoryController extends Controller
|
||||
}
|
||||
$entries->push($entry);
|
||||
}
|
||||
// generate chart with data:
|
||||
|
||||
// generate chart with data:
|
||||
$data = $this->generator->multiYear($entries);
|
||||
$cache->store($data);
|
||||
|
||||
|
||||
@@ -128,15 +128,18 @@ class ReportController extends Controller
|
||||
if ($start->diffInMonths($end) > 12) {
|
||||
// data = method X
|
||||
$data = $this->multiYearInOut($earnedArray, $spentArray, $start, $end);
|
||||
} else {
|
||||
// data = method Y
|
||||
$data = $this->singleYearInOut($earnedArray, $spentArray, $start, $end);
|
||||
$cache->store($data);
|
||||
|
||||
return Response::json($data);
|
||||
}
|
||||
|
||||
// data = method Y
|
||||
$data = $this->singleYearInOut($earnedArray, $spentArray, $start, $end);
|
||||
$cache->store($data);
|
||||
|
||||
return Response::json($data);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -179,13 +182,16 @@ class ReportController extends Controller
|
||||
if ($start->diffInMonths($end) > 12) {
|
||||
// per year
|
||||
$data = $this->multiYearInOutSummarized($earnedArray, $spentArray, $start, $end);
|
||||
} else {
|
||||
// per month!
|
||||
$data = $this->singleYearInOutSummarized($earnedArray, $spentArray, $start, $end);
|
||||
$cache->store($data);
|
||||
|
||||
return Response::json($data);
|
||||
}
|
||||
// per month!
|
||||
$data = $this->singleYearInOutSummarized($earnedArray, $spentArray, $start, $end);
|
||||
$cache->store($data);
|
||||
|
||||
return Response::json($data);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user