$totalEarning += $completedOrder->total - ($completedOrder->delivery_charge + $completedOrder->tip_amount + $completedOrder->tax_amount);
This can just preview the tax excluded earning, but the database still remains same.
$balanceBeforeCommission = $balance->amount - (2.16*$balance->amount)/100;
and with this I'm able to somehow deduct around 2%. But it is not accurate. because percentage of total amount can't be equal to percentage of subtotal amount