First attempt at multi-year budget chart.

This commit is contained in:
James Cole
2015-12-16 10:17:15 +01:00
parent 69553b138b
commit 838330b909
4 changed files with 71 additions and 2 deletions

View File

@@ -46,6 +46,19 @@ class BudgetController extends Controller
*/
public function multiYear(BudgetRepositoryInterface $repository, $report_type, Carbon $start, Carbon $end, Collection $accounts, Collection $budgets)
{
// chart properties for cache:
$cache = new CacheProperties();
$cache->addProperty($report_type);
$cache->addProperty($start);
$cache->addProperty($end);
$cache->addProperty($accounts);
$cache->addProperty($budgets);
$cache->addProperty('multiYearBudget');
if ($cache->has()) {
return Response::json($cache->get()); // @codeCoverageIgnore
}
$currentStart = clone $start;
$collection = new Collection;
@@ -53,7 +66,7 @@ class BudgetController extends Controller
$currentEnd = clone $currentStart;
$currentEnd->endOfYear();
echo 'now for ' . $currentStart->format('Ymd') . ' to ' . $currentEnd->format('Ymd') . '<br>';
//echo 'now for ' . $currentStart->format('Ymd') . ' to ' . $currentEnd->format('Ymd') . '<br>';
/** @var Budget $budget */
foreach ($budgets as $budget) {
@@ -64,7 +77,8 @@ class BudgetController extends Controller
$name = $budget->name;
$sum = $repository->balanceInPeriodForList($budget, $currentStart, $currentEnd, $accounts);
}
echo $name.': '.$sum.'<br>';
$collection->push(['budget' => $name, 'sum' => $sum,'date' => $currentStart]);
//echo $name . ': ' . $sum . '<br>';
}
// do something for all budgets.
@@ -74,6 +88,12 @@ class BudgetController extends Controller
}
$data = $this->generator->multiYear($collection);
//$cache->store($data);
return Response::json($data);
}
/**