if (!$balance) {
$balanceBeforeCommission = 0;
$balanceAfterCommission = 0;
$balanceAfterCommissionandTax = 0;
} else {
$balanceBeforeCommission = $balance->amount - (2*$balance->amount)/100;
$balanceAfterCommissionandTax = ($balance->amount - (2*$balance->amount)/100 - ($restaurant->commission_rate / 100) * $balance->amount);
$balanceAfterCommission = ($balance->amount - (2*$balanceAfterCommissionandTax)/100 - ($restaurant->commission_rate / 100) * $balance->amount);
$balanceAfterCommission = number_format((float) $balanceAfterCommission, 2, '.', '');
}