From 7c3a6766c021c44c67316dd95d123ed0c2b4c7d8 Mon Sep 17 00:00:00 2001 From: = Date: Sat, 6 Feb 2021 11:18:42 +1100 Subject: [PATCH] FIxes for Zero taxes --- app/Helpers/Invoice/InvoiceItemSum.php | 5 +++-- app/Helpers/Invoice/InvoiceItemSumInclusive.php | 7 ++++--- tests/Unit/InvoiceInclusiveTest.php | 1 + 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/app/Helpers/Invoice/InvoiceItemSum.php b/app/Helpers/Invoice/InvoiceItemSum.php index 49b299d4434e..6cb00c4b6b2e 100644 --- a/app/Helpers/Invoice/InvoiceItemSum.php +++ b/app/Helpers/Invoice/InvoiceItemSum.php @@ -122,20 +122,21 @@ class InvoiceItemSum $item_tax += $item_tax_rate1_total; + if($item_tax_rate1_total != 0) $this->groupTax($this->item->tax_name1, $this->item->tax_rate1, $item_tax_rate1_total); - $item_tax_rate2_total = $this->calcAmountLineTax($this->item->tax_rate2, $amount); $item_tax += $item_tax_rate2_total; + if($item_tax_rate2_total != 0) $this->groupTax($this->item->tax_name2, $this->item->tax_rate2, $item_tax_rate2_total); - $item_tax_rate3_total = $this->calcAmountLineTax($this->item->tax_rate3, $amount); $item_tax += $item_tax_rate3_total; + if($item_tax_rate3_total != 0) $this->groupTax($this->item->tax_name3, $this->item->tax_rate3, $item_tax_rate3_total); diff --git a/app/Helpers/Invoice/InvoiceItemSumInclusive.php b/app/Helpers/Invoice/InvoiceItemSumInclusive.php index 3646ce2605e0..a04d4f229e7e 100644 --- a/app/Helpers/Invoice/InvoiceItemSumInclusive.php +++ b/app/Helpers/Invoice/InvoiceItemSumInclusive.php @@ -119,20 +119,21 @@ class InvoiceItemSumInclusive $item_tax += $this->formatValue($item_tax_rate1_total, $this->currency->precision); - $this->groupTax($this->item->tax_name1, $this->item->tax_rate1, $item_tax_rate1_total); - + if($item_tax_rate1_total != 0) + $this->groupTax($this->item->tax_name1, $this->item->tax_rate1, $item_tax_rate1_total); $item_tax_rate2_total = $this->calcInclusiveLineTax($this->item->tax_rate2, $amount); $item_tax += $this->formatValue($item_tax_rate2_total, $this->currency->precision); + if($item_tax_rate2_total != 0) $this->groupTax($this->item->tax_name2, $this->item->tax_rate2, $item_tax_rate2_total); - $item_tax_rate3_total = $this->calcInclusiveLineTax($this->item->tax_rate3, $amount); $item_tax += $this->formatValue($item_tax_rate3_total, $this->currency->precision); + if($item_tax_rate3_total != 0) $this->groupTax($this->item->tax_name3, $this->item->tax_rate3, $item_tax_rate3_total); diff --git a/tests/Unit/InvoiceInclusiveTest.php b/tests/Unit/InvoiceInclusiveTest.php index 5716649a2ad7..08f5a24e0c04 100644 --- a/tests/Unit/InvoiceInclusiveTest.php +++ b/tests/Unit/InvoiceInclusiveTest.php @@ -275,6 +275,7 @@ class InvoiceInclusiveTest extends TestCase $this->assertEquals($this->invoice_calc->getSubTotal(), 19); $this->assertEquals($this->invoice_calc->getTotalDiscount(), 0.95); $this->assertEquals($this->invoice_calc->getTotalTaxes(), 4.92); + nlog($this->invoice_calc->getTaxMap()); $this->assertEquals(count($this->invoice_calc->getTaxMap()), 1); $this->assertEquals($this->invoice_calc->getTotal(), 18.05); $this->assertEquals($this->invoice_calc->getBalance(), 18.05);