From 2c9eb3e7aa599e646f1d55859aa039096d1d1861 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Wed, 21 Jun 2017 14:02:03 +0300 Subject: [PATCH] Fix for negative line item taxes --- app/Ninja/Repositories/InvoiceRepository.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/app/Ninja/Repositories/InvoiceRepository.php b/app/Ninja/Repositories/InvoiceRepository.php index 80b02eab72f2..7fa81e8621f1 100644 --- a/app/Ninja/Repositories/InvoiceRepository.php +++ b/app/Ninja/Repositories/InvoiceRepository.php @@ -508,13 +508,17 @@ class InvoiceRepository extends BaseRepository } } - $taxRate1 = Utils::parseFloat($item['tax_rate1']); - if ($taxRate1 != 0) { - $itemTax += round($lineTotal * $taxRate1 / 100, 2); + if (isset($item['tax_rate1'])) { + $taxRate1 = Utils::parseFloat($item['tax_rate1']); + if ($taxRate1 != 0) { + $itemTax += round($lineTotal * $taxRate1 / 100, 2); + } } - $taxRate2 = Utils::parseFloat($item['tax_rate2']); - if ($taxRate2 != 0) { - $itemTax += round($lineTotal * $taxRate2 / 100, 2); + if (isset($item['tax_rate2'])) { + $taxRate2 = Utils::parseFloat($item['tax_rate2']); + if ($taxRate2 != 0) { + $itemTax += round($lineTotal * $taxRate2 / 100, 2); + } } }