From 37376cd0b24a9d1dbe9de98a6148f6b41552d837 Mon Sep 17 00:00:00 2001 From: cuneytsenturk Date: Tue, 4 Dec 2018 12:02:15 +0300 Subject: [PATCH] close #660 Fixed: Inclusive tax calculation seems incorrect --- app/Http/Controllers/Common/Items.php | 4 ++-- app/Jobs/Expense/CreateBillItem.php | 2 +- app/Jobs/Income/CreateInvoiceItem.php | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/Common/Items.php b/app/Http/Controllers/Common/Items.php index 3c3db8559..6e7f8a4e3 100644 --- a/app/Http/Controllers/Common/Items.php +++ b/app/Http/Controllers/Common/Items.php @@ -372,7 +372,7 @@ class Items extends Controller foreach ($inclusives as $inclusive) { $item_sub_and_tax_total = $item_sub_total + $item_tax_total; - $item_tax_total = $item_sub_and_tax_total - (($item_sub_and_tax_total * (100 - $inclusive->rate)) / 100); + $item_tax_total = $item_sub_and_tax_total - ($item_sub_and_tax_total / (1 + ($inclusive->rate / 100))); $item_sub_total = $item_sub_and_tax_total - $item_tax_total; @@ -382,7 +382,7 @@ class Items extends Controller foreach ($inclusives as $inclusive) { $item_sub_and_tax_total = $item_discount_total + $item_tax_total; - $item_tax_total = $item_sub_and_tax_total - (($item_sub_and_tax_total * (100 - $inclusive->rate)) / 100); + $item_tax_total = $item_sub_and_tax_total - ($item_sub_and_tax_total / (1 + ($inclusive->rate / 100))); $item_sub_total = $item_sub_and_tax_total - $item_tax_total; diff --git a/app/Jobs/Expense/CreateBillItem.php b/app/Jobs/Expense/CreateBillItem.php index 1826fa2cc..cc83823b3 100644 --- a/app/Jobs/Expense/CreateBillItem.php +++ b/app/Jobs/Expense/CreateBillItem.php @@ -117,7 +117,7 @@ class CreateBillItem foreach ($inclusives as $inclusive) { $item_sub_and_tax_total = $item_amount + $item_tax_total; - $item_tax_total = $item_sub_and_tax_total - (($item_sub_and_tax_total * (100 - $inclusive->rate)) / 100); + $item_tax_total = $item_sub_and_tax_total - ($item_sub_and_tax_total / (1 + ($inclusive->rate / 100))); $item_sub_total = $item_sub_and_tax_total - $item_tax_total; diff --git a/app/Jobs/Income/CreateInvoiceItem.php b/app/Jobs/Income/CreateInvoiceItem.php index 6e6575dff..3478baff1 100644 --- a/app/Jobs/Income/CreateInvoiceItem.php +++ b/app/Jobs/Income/CreateInvoiceItem.php @@ -144,7 +144,7 @@ class CreateInvoiceItem foreach ($inclusives as $inclusive) { $item_sub_and_tax_total = $item_amount + $item_tax_total; - $item_tax_total = $item_sub_and_tax_total - (($item_sub_and_tax_total * (100 - $inclusive->rate)) / 100); + $item_tax_total = $item_sub_and_tax_total - ($item_sub_and_tax_total / (1 + ($inclusive->rate / 100))); $item_sub_total = $item_sub_and_tax_total - $item_tax_total;