From b48de98865cf288a508b8292c26d680d1a2d0696 Mon Sep 17 00:00:00 2001 From: James Cole Date: Thu, 8 Jun 2017 10:35:02 +0200 Subject: [PATCH] Fix a bug where the balance routine forgot to account for accounts without a currency preference. --- app/Http/Controllers/Chart/AccountController.php | 1 + app/Support/Steam.php | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/app/Http/Controllers/Chart/AccountController.php b/app/Http/Controllers/Chart/AccountController.php index c0af003e81..3771f913a8 100644 --- a/app/Http/Controllers/Chart/AccountController.php +++ b/app/Http/Controllers/Chart/AccountController.php @@ -127,6 +127,7 @@ class AccountController extends Controller $chartData[$account->name] = $diff; } } + arsort($chartData); $data = $this->generator->singleSet(strval(trans('firefly.spent')), $chartData); $cache->store($data); diff --git a/app/Support/Steam.php b/app/Support/Steam.php index 398400e05b..7294b07bde 100644 --- a/app/Support/Steam.php +++ b/app/Support/Steam.php @@ -13,6 +13,7 @@ declare(strict_types=1); namespace FireflyIII\Support; +use Amount; use Carbon\Carbon; use Crypt; use DB; @@ -47,6 +48,11 @@ class Steam return $cache->get(); // @codeCoverageIgnore } $currencyId = intval($account->getMeta('currency_id')); + // if null, use system default currency: + if ($currencyId === 0) { + $currency = Amount::getDefaultCurrency(); + $currencyId = $currency->id; + } // first part: get all balances in own currency: $nativeBalance = strval( $account->transactions()