Skip to content

Firefly III: a personal finances manager

Prevent empty box.

James Coleabf218fc2133
diff --git a/app/Http/Controllers/Json/BoxController.php b/app/Http/Controllers/Json/BoxController.php
index 27c857d97b..e61c522daf 100644
--- a/app/Http/Controllers/Json/BoxController.php
+++ b/app/Http/Controllers/Json/BoxController.php
@@ -153,6 +153,12 @@ class BoxController extends Controller
$incomes[$currencyId] = Amount::formatAnything($currency, $incomes[$currencyId] ?? '0', false);
$expenses[$currencyId] = Amount::formatAnything($currency, $expenses[$currencyId] ?? '0', false);
}
+ if (\count($sums) === 0) {
+ $currency = app('amount')->getDefaultCurrency();
+ $sums[$currency->id] = Amount::formatAnything($currency, '0', false);
+ $incomes[$currency->id] = Amount::formatAnything($currency, '0', false);
+ $expenses[$currency->id] = Amount::formatAnything($currency, '0', false);
+ }
$response = [
'incomes' => $incomes,
@@ -161,6 +167,7 @@ class BoxController extends Controller
'size' => \count($sums),
];
+
$cache->store($response);
return response()->json($response);