From 7296796ed9a162936060da6ba0aeaf3a8b1c3d18 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sat, 1 Aug 2015 07:12:03 +0200 Subject: [PATCH] Fix chart. --- .../Chart/Account/ChartJsAccountChartGenerator.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/Generator/Chart/Account/ChartJsAccountChartGenerator.php b/app/Generator/Chart/Account/ChartJsAccountChartGenerator.php index 3b54a6dc16..a902219cec 100644 --- a/app/Generator/Chart/Account/ChartJsAccountChartGenerator.php +++ b/app/Generator/Chart/Account/ChartJsAccountChartGenerator.php @@ -59,15 +59,16 @@ class ChartJsAccountChartGenerator implements AccountChartGenerator foreach ($accounts as $account) { $ids[] = $account->id; } + $start->subDay(); $startBalances = Steam::balancesById($ids, $start); $endBalances = Steam::balancesById($ids, $end); foreach ($accounts as $account) { - $id = $account->id; - $start = isset($startBalances[$id]) ? $startBalances[$id] : 0; - $end = isset($endBalances[$id]) ? $endBalances[$id] : 0; - $diff = $end - $start; + $id = $account->id; + $startBalance = isset($startBalances[$id]) ? $startBalances[$id] : 0; + $endBalance = isset($endBalances[$id]) ? $endBalances[$id] : 0; + $diff = $endBalance - $startBalance; Log::debug($account->name . ' spent ' . $diff); if ($diff > 0) { $data['labels'][] = $account->name;