From 9b420c461f8ab84d4b5555b2d582fc44b05fbab6 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sun, 19 Jan 2020 18:07:54 +0100 Subject: [PATCH] Fix for https://github.com/firefly-iii/firefly-iii/issues/3016 --- app/Http/Controllers/Chart/BillController.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/Chart/BillController.php b/app/Http/Controllers/Chart/BillController.php index c6fedb3419..f81d021279 100644 --- a/app/Http/Controllers/Chart/BillController.php +++ b/app/Http/Controllers/Chart/BillController.php @@ -108,17 +108,22 @@ class BillController extends Controller $cache->addProperty('chart.bill.single'); $cache->addProperty($bill->id); if ($cache->has()) { - return response()->json($cache->get()); // @codeCoverageIgnore + //return response()->json($cache->get()); // @codeCoverageIgnore } /** @var GroupCollectorInterface $collector */ $collector = app(GroupCollectorInterface::class); $journals = $collector->setBill($bill)->getExtractedJournals(); + // sort the other way around: + usort($journals, static function (array $left, array $right) { + return $left['date']->gte($right['date'])? 1 : 0; + }); + $chartData = [ - ['type' => 'bar', 'label' => (string)trans('firefly.min-amount'), 'currency_symbol' => $bill->transactionCurrency->symbol, 'entries' => []], - ['type' => 'bar', 'label' => (string)trans('firefly.max-amount'), 'currency_symbol' => $bill->transactionCurrency->symbol, 'entries' => []], - ['type' => 'line', 'label' => (string)trans('firefly.journal-amount'), 'currency_symbol' => $bill->transactionCurrency->symbol, 'entries' => []], + ['type' => 'line', 'label' => (string)trans('firefly.max-amount'), 'currency_symbol' => $bill->transactionCurrency->symbol, 'entries' => []], + ['type' => 'line', 'label' => (string)trans('firefly.min-amount'), 'currency_symbol' => $bill->transactionCurrency->symbol, 'entries' => []], + ['type' => 'bar', 'label' => (string)trans('firefly.journal-amount'), 'currency_symbol' => $bill->transactionCurrency->symbol, 'entries' => []], ]; foreach ($journals as $journal) {