Include "no budget" thing for issue #152

This commit is contained in:
James Cole
2016-03-20 20:06:05 +01:00
parent 201790ff8d
commit 189d969ee6
2 changed files with 11 additions and 3 deletions

View File

@@ -310,7 +310,7 @@ class BudgetController extends Controller
$cache->addProperty('budget');
$cache->addProperty('year');
if ($cache->has()) {
return Response::json($cache->get()); // @codeCoverageIgnore
//return Response::json($cache->get()); // @codeCoverageIgnore
}
$budgetInformation = $repository->getBudgetsAndExpensesPerMonth($accounts, $start, $end);
@@ -321,7 +321,6 @@ class BudgetController extends Controller
foreach ($budgetInformation as $row) {
$budgets->push($row['budget']);
}
while ($start < $end) {
// month is the current end of the period:
$month = clone $start;
@@ -329,6 +328,9 @@ class BudgetController extends Controller
$row = [clone $start];
$dateFormatted = $start->format('Y-m');
//echo $start,' '.$month.'<br>';
// each budget, check if there is an entry for this month:
/** @var array $row */
foreach ($budgetInformation as $budgetRow) {
@@ -338,10 +340,13 @@ class BudgetController extends Controller
}
$row[] = $spent;
}
// add "no budget" thing.
$row[] = round(bcmul($repository->getWithoutBudgetSum($accounts, $start, $month), '-1'), 4);
$entries->push($row);
$start->endOfMonth()->addDay();
}
$data = $this->generator->year($budgets, $entries);
$cache->store($data);