Prevent divide by zero with discounts

This commit is contained in:
Hillel Coren 2017-07-18 12:26:05 +03:00
parent 9846b3f42b
commit ee0e6a16bb

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);
} }