Fix 'spent per day' budget box

This commit is contained in:
Florian Dupret
2021-01-02 14:09:02 +01:00
parent 321bb33255
commit 1884746233

View File

@@ -97,7 +97,8 @@ class BoxController extends Controller
// also calculate spent per day.
$spent = $opsRepository->sumExpenses($start, $end, null, null, $currency);
$spentAmount = $spent[(int) $currency->id]['sum'] ?? '0';
$spentPerDay = '-1';
$days = $today->diffInDays($start) + 1;
$spentPerDay = bcdiv($spentAmount, (string) $days);
if ($availableBudgets->count() > 0) {
$display = 0; // assume user overspent
$boxTitle = (string) trans('firefly.overspent');