mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
This fixes #422
This commit is contained in:
parent
7852b8a785
commit
b34e4cd31b
@ -26,7 +26,6 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
|
||||
use Illuminate\Support\Collection;
|
||||
use Log;
|
||||
use Navigation;
|
||||
use Response;
|
||||
|
||||
|
||||
@ -273,24 +272,33 @@ class CategoryReportController extends Controller
|
||||
public function mainChart(Collection $accounts, Collection $categories, Carbon $start, Carbon $end)
|
||||
{
|
||||
// determin optimal period:
|
||||
$period = '1D';
|
||||
$format = 'month_and_day';
|
||||
$period = '1D';
|
||||
$format = 'month_and_day';
|
||||
$function = 'endOfDay';
|
||||
if ($start->diffInMonths($end) > 1) {
|
||||
$period = '1M';
|
||||
$format = 'month';
|
||||
$period = '1M';
|
||||
$format = 'month';
|
||||
$function = 'endOfMonth';
|
||||
}
|
||||
if ($start->diffInMonths($end) > 13) {
|
||||
$period = '1Y';
|
||||
$format = 'year';
|
||||
$period = '1Y';
|
||||
$format = 'year';
|
||||
$function = 'endOfYear';
|
||||
}
|
||||
Log::debug(sprintf('Period is %s', $period));
|
||||
$data = [];
|
||||
$current = clone $start;
|
||||
while ($current < $end) {
|
||||
$currentEnd = Navigation::endOfPeriod($current, $period);
|
||||
$expenses = $this->groupByCategory($this->getExpenses($accounts, $categories, $current, $currentEnd));
|
||||
$income = $this->groupByCategory($this->getIncome($accounts, $categories, $current, $currentEnd));
|
||||
$label = $current->formatLocalized(strval(trans('config.' . $format)));
|
||||
$data = [];
|
||||
$currentStart = clone $start;
|
||||
while ($currentStart < $end) {
|
||||
$currentEnd = clone $currentStart;
|
||||
Log::debug(sprintf('Function is %s', $function));
|
||||
$currentEnd = $currentEnd->$function();
|
||||
//$currentEnd = Navigation::endOfPeriod($current, $period);
|
||||
$expenses = $this->groupByCategory($this->getExpenses($accounts, $categories, $currentStart, $currentEnd));
|
||||
$income = $this->groupByCategory($this->getIncome($accounts, $categories, $currentStart, $currentEnd));
|
||||
$label = $currentStart->formatLocalized(strval(trans('config.' . $format)));
|
||||
|
||||
Log::debug(sprintf('Now grabbing CMC expenses between %s and %s', $currentStart->format('Y-m-d'), $currentEnd->format('Y-m-d')));
|
||||
|
||||
$data[$label] = [
|
||||
'in' => [],
|
||||
'out' => [],
|
||||
@ -305,7 +313,8 @@ class CategoryReportController extends Controller
|
||||
$data[$label]['out'][$categoryId] = $expenses[$categoryId] ?? '0';
|
||||
}
|
||||
|
||||
$current = Navigation::addPeriod($current, $period, 0);
|
||||
$currentStart = clone $currentEnd;
|
||||
$currentStart->addDay();// = Navigation::addPeriod($current, $period, 0);
|
||||
}
|
||||
|
||||
$data = $this->generator->mainReportChart($data);
|
||||
|
Loading…
Reference in New Issue
Block a user