From 773e131afc0bcb97002d9353f1f4fad44ef760b6 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sat, 6 Feb 2021 10:39:40 +1100 Subject: [PATCH] Fixes for negative taxes --- app/Helpers/Invoice/InvoiceItemSum.php | 9 +++------ app/Helpers/Invoice/InvoiceItemSumInclusive.php | 9 +++------ 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/app/Helpers/Invoice/InvoiceItemSum.php b/app/Helpers/Invoice/InvoiceItemSum.php index 12b9878b4775..49b299d4434e 100644 --- a/app/Helpers/Invoice/InvoiceItemSum.php +++ b/app/Helpers/Invoice/InvoiceItemSum.php @@ -122,25 +122,22 @@ 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); - } + $this->setTotalTaxes($this->formatValue($item_tax, $this->currency->precision)); diff --git a/app/Helpers/Invoice/InvoiceItemSumInclusive.php b/app/Helpers/Invoice/InvoiceItemSumInclusive.php index 9a0d890cb3ab..3646ce2605e0 100644 --- a/app/Helpers/Invoice/InvoiceItemSumInclusive.php +++ b/app/Helpers/Invoice/InvoiceItemSumInclusive.php @@ -119,25 +119,22 @@ class InvoiceItemSumInclusive $item_tax += $this->formatValue($item_tax_rate1_total, $this->currency->precision); - 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); - } + $this->setTotalTaxes($this->formatValue($item_tax, $this->currency->precision));