Prevent divide by zero with discounts

This commit is contained in:
Hillel Coren 2017-07-18 12:26:19 +03:00
parent ac850dff35
commit 4204cbb06f

View File

@ -510,7 +510,9 @@ class InvoiceRepository extends BaseRepository
if ($invoice->discount > 0) { if ($invoice->discount > 0) {
if ($invoice->is_amount_discount) { if ($invoice->is_amount_discount) {
$lineTotal -= round(($lineTotal / $total) * $invoice->discount, 2); if ($total != 0) {
$lineTotal -= round(($lineTotal / $total) * $invoice->discount, 2);
}
} else { } else {
$lineTotal -= round($lineTotal * ($invoice->discount / 100), 2); $lineTotal -= round($lineTotal * ($invoice->discount / 100), 2);
} }