From 70da38193f13203f50998b0bcce0ed4015e53639 Mon Sep 17 00:00:00 2001 From: James Cole Date: Wed, 17 Jan 2018 10:17:49 +0100 Subject: [PATCH] Fix issue with budget chart. --- app/Http/Controllers/Chart/BudgetController.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/Chart/BudgetController.php b/app/Http/Controllers/Chart/BudgetController.php index 7852fe15d9..0e2c1fdb1f 100644 --- a/app/Http/Controllers/Chart/BudgetController.php +++ b/app/Http/Controllers/Chart/BudgetController.php @@ -106,11 +106,15 @@ class BudgetController extends Controller $current = app('navigation')->startOfPeriod($current, $step); while ($end >= $current) { - $currentEnd = app('navigation')->endOfPeriod($current, $step); + $currentEnd = app('navigation')->endOfPeriod($current, $step); + if ($step === '1Y') { + $currentEnd->subDay(); + } $spent = $this->repository->spentInPeriod($budgetCollection, new Collection, $current, $currentEnd); $label = app('navigation')->periodShow($current, $step); - $chartData[$label] = floatval(bcmul($spent,'-1')); - $current = app('navigation')->addPeriod($current, $step, 1); + $chartData[$label] = floatval(bcmul($spent, '-1')); + $current = clone $currentEnd; + $current->addDay(); } $data = $this->generator->singleSet(strval(trans('firefly.spent')), $chartData);