Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Fix #3145
James Colea486d658935c
diff --git a/app/Http/Controllers/Chart/CategoryController.php b/app/Http/Controllers/Chart/CategoryController.phpindex 21ae827a07..ddc6062980 100644--- a/app/Http/Controllers/Chart/CategoryController.php+++ b/app/Http/Controllers/Chart/CategoryController.php@@ -114,7 +114,7 @@ class CategoryController extends Controller$cache->addProperty($end);$cache->addProperty('chart.category.frontpage');if ($cache->has()) {- return response()->json($cache->get()); // @codeCoverageIgnore+ // return response()->json($cache->get()); // @codeCoverageIgnore}// currency repos:@@ -163,22 +163,24 @@ class CategoryController extends Controller// no category per currency:$noCategory = $noCatRepository->sumExpenses($start, $end);+ if (0 !== bccomp($noCategory[0]['sum'] ?? '0', '0')) {- foreach ($noCategory as $currency) {- $currencyId = $currency['currency_id'];- $currencies[$currencyId] = $currencies[$currencyId] ?? [- 'currency_id' => $currency['currency_id'],- 'currency_name' => $currency['currency_name'],- 'currency_symbol' => $currency['currency_symbol'],- 'currency_code' => $currency['currency_code'],- 'currency_decimal_places' => $currency['currency_decimal_places'],+ foreach ($noCategory as $currency) {+ $currencyId = $currency['currency_id'];+ $currencies[$currencyId] = $currencies[$currencyId] ?? [+ 'currency_id' => $currency['currency_id'],+ 'currency_name' => $currency['currency_name'],+ 'currency_symbol' => $currency['currency_symbol'],+ 'currency_code' => $currency['currency_code'],+ 'currency_decimal_places' => $currency['currency_decimal_places'],+ ];+ $tempData[] = [+ 'name' => trans('firefly.no_category'),+ 'sum' => $currency['sum'],+ 'sum_float' => round($currency['sum'], $currency['currency_decimal_places'] ?? 2),+ 'currency_id' => $currency['currency_id'],];- $tempData[] = [- 'name' => trans('firefly.no_category'),- 'sum' => $currency['sum'],- 'sum_float' => round($currency['sum'], $currency['currency_decimal_places']),- 'currency_id' => $currency['currency_id'],- ];+ }}// sort temp array by amount.@@ -203,6 +205,7 @@ class CategoryController extends Controller$name = $entry['name'];$chartData[$currencyId]['entries'][$name] = bcmul($entry['sum'], '-1');}+$data = $this->generator->multiSet($chartData);$cache->store($data);diff --git a/app/Repositories/Category/NoCategoryRepository.php b/app/Repositories/Category/NoCategoryRepository.phpindex a8c5d7a958..9243e01f30 100644--- a/app/Repositories/Category/NoCategoryRepository.php+++ b/app/Repositories/Category/NoCategoryRepository.php@@ -198,7 +198,7 @@ class NoCategoryRepository implements NoCategoryRepositoryInterface'currency_code' => $journal['currency_code'],'currency_decimal_places' => $journal['currency_decimal_places'],];- $array[$currencyId]['sum'] = bcadd($array[$currencyId]['sum'], app('steam')->negative($journal['amount']));+ $array[$currencyId]['sum'] = bcadd($array[$currencyId]['sum'], app('steam')->negative($journal['amount'] ?? '0'));}return $array;diff --git a/app/Support/Http/Controllers/UserNavigation.php b/app/Support/Http/Controllers/UserNavigation.phpindex d8ee0a92e0..e63a550e78 100644--- a/app/Support/Http/Controllers/UserNavigation.php+++ b/app/Support/Http/Controllers/UserNavigation.php@@ -97,7 +97,7 @@ trait UserNavigation/** @var Transaction $transaction */foreach ($transactions as $transaction) {$type = $transaction->account->accountType->type;- if (!in_array($type, $ignore)) {+ if (!in_array($type, $ignore, true)) {return redirect(route('accounts.edit', [$transaction->account_id]));}}diff --git a/public/v1/js/ff/charts.js b/public/v1/js/ff/charts.jsindex 737bcadfe6..4dbfa70e54 100644--- a/public/v1/js/ff/charts.js+++ b/public/v1/js/ff/charts.js@@ -374,7 +374,9 @@ function drawAChart(URI, container, chartType, options, colorData) {$.getJSON(URI).done(function (data) {containerObj.removeClass('general-chart-error');- if (data.labels.length === 0) {+ console.log(data);+ if (!(Array.isArray(data) && data.length) ||+ (typeof data.labels != 'undefined' && data.labels.length === 0)) {// remove the chart container + parentvar holder = $('#' + container).parent().parent();if (holder.hasClass('box') || holder.hasClass('box-body')) {