From 4204cbb06f2086f70d4f44ece41ab22c5f01fc5d Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Tue, 18 Jul 2017 12:26:19 +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 fbf475bf9fbc..6b805ab5e5d7 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); }