From ee0e6a16bb276c1323da304ab5b7d188c64a2a90 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Tue, 18 Jul 2017 12:26:05 +0300 Subject: [PATCH] Prevent divide by zero with discounts --- app/Ninja/Repositories/InvoiceRepository.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/Ninja/Repositories/InvoiceRepository.php b/app/Ninja/Repositories/InvoiceRepository.php index 14d7ff75e368..1200261f887e 100644 --- a/app/Ninja/Repositories/InvoiceRepository.php +++ b/app/Ninja/Repositories/InvoiceRepository.php @@ -510,7 +510,9 @@ class InvoiceRepository extends BaseRepository if ($invoice->discount > 0) { if ($invoice->is_amount_discount) { - $lineTotal -= round(($lineTotal / $total) * $invoice->discount, 2); + if ($total != 0) { + $lineTotal -= round(($lineTotal / $total) * $invoice->discount, 2); + } } else { $lineTotal -= round($lineTotal * ($invoice->discount / 100), 2); }