mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Expand chart generation.
This commit is contained in:
parent
29dc122ad3
commit
006d68e279
@ -55,6 +55,30 @@ class ReportController extends Controller
|
|||||||
return Response::json($cache->get()); // @codeCoverageIgnore
|
return Response::json($cache->get()); // @codeCoverageIgnore
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// per year?
|
||||||
|
if ($start->diffInMonths($end) > 12) {
|
||||||
|
|
||||||
|
$entries = new Collection;
|
||||||
|
while ($start < $end) {
|
||||||
|
$startOfYear = clone $start;
|
||||||
|
$startOfYear->startOfYear();
|
||||||
|
$endOfYear = clone $startOfYear;
|
||||||
|
$endOfYear->endOfYear();
|
||||||
|
|
||||||
|
// total income and total expenses:
|
||||||
|
$incomeSum = $query->incomeInPeriod($startOfYear, $endOfYear, $accounts)->sum('amount_positive');
|
||||||
|
$expenseSum = $query->expenseInPeriod($startOfYear, $endOfYear, $accounts)->sum('amount_positive');
|
||||||
|
|
||||||
|
$entries->push([clone $start, $incomeSum, $expenseSum]);
|
||||||
|
$start->addYear();
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = $this->generator->multiYearInOut($entries);
|
||||||
|
$cache->store($data);
|
||||||
|
} else {
|
||||||
|
// per month:
|
||||||
|
|
||||||
$entries = new Collection;
|
$entries = new Collection;
|
||||||
while ($start < $end) {
|
while ($start < $end) {
|
||||||
$month = clone $start;
|
$month = clone $start;
|
||||||
@ -70,6 +94,8 @@ class ReportController extends Controller
|
|||||||
|
|
||||||
$data = $this->generator->yearInOut($entries);
|
$data = $this->generator->yearInOut($entries);
|
||||||
$cache->store($data);
|
$cache->store($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return Response::json($data);
|
return Response::json($data);
|
||||||
|
|
||||||
@ -105,6 +131,28 @@ class ReportController extends Controller
|
|||||||
|
|
||||||
bcscale(2);
|
bcscale(2);
|
||||||
|
|
||||||
|
if ($start->diffInMonths($end) > 12) {
|
||||||
|
// per year
|
||||||
|
while ($start < $end) {
|
||||||
|
$startOfYear = clone $start;
|
||||||
|
$startOfYear->startOfYear();
|
||||||
|
$endOfYear = clone $startOfYear;
|
||||||
|
$endOfYear->endOfYear();
|
||||||
|
|
||||||
|
// total income and total expenses:
|
||||||
|
$currentIncome = $query->incomeInPeriod($startOfYear, $endOfYear, $accounts)->sum('amount_positive');
|
||||||
|
$currentExpense = $query->expenseInPeriod($startOfYear, $endOfYear, $accounts)->sum('amount_positive');
|
||||||
|
$income = bcadd($income, $currentIncome);
|
||||||
|
$expense = bcadd($expense, $currentExpense);
|
||||||
|
|
||||||
|
$count++;
|
||||||
|
$start->addYear();
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = $this->generator->multiYearInOutSummarized($income, $expense, $count);
|
||||||
|
$cache->store($data);
|
||||||
|
} else {
|
||||||
|
// per month!
|
||||||
while ($start < $end) {
|
while ($start < $end) {
|
||||||
$month = clone $start;
|
$month = clone $start;
|
||||||
$month->endOfMonth();
|
$month->endOfMonth();
|
||||||
@ -120,6 +168,8 @@ class ReportController extends Controller
|
|||||||
|
|
||||||
$data = $this->generator->yearInOutSummarized($income, $expense, $count);
|
$data = $this->generator->yearInOutSummarized($income, $expense, $count);
|
||||||
$cache->store($data);
|
$cache->store($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return Response::json($data);
|
return Response::json($data);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user