Merge pull request #7438 from firefly-iii/division-by-zero

Fix division by zero
This commit is contained in:
James Cole
2023-04-28 08:39:54 +02:00
committed by GitHub

View File

@@ -82,8 +82,10 @@ class BudgetController extends Controller
$percentage = '0';
if (null !== $availableBudget) {
$available = $availableBudget->amount;
$percentage = bcmul(bcdiv($budgeted, $available), '100');
$available = $availableBudget->amount;
if (0 !== bccomp($available, '0')) {
$percentage = bcmul(bcdiv($budgeted, $available), '100');
}
}
// if available, get the AB for this period + currency, so the bar can be redrawn.