Prevent empty box.

This commit is contained in:
James Cole 2018-06-17 07:45:10 +02:00
parent dcf90b6159
commit abf218fc21
No known key found for this signature in database
GPG Key ID: C16961E655E74B5E

View File

@ -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);