From 58fed668b95cbeab295f3b3643f10361d484a650 Mon Sep 17 00:00:00 2001
From: satish <satish.dvnk@vtiger.com>
Date: Thu, 8 Sep 2016 14:58:25 +0530
Subject: [PATCH] Fixes #282 - Product & Sercice Taxes and Shipping & Handling
 Taxes dilemma

---
 include/utils/EditViewUtils.php     | 3 ++-
 modules/Inventory/models/Record.php | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/include/utils/EditViewUtils.php b/include/utils/EditViewUtils.php
index 8317f75db..3637b37c1 100755
--- a/include/utils/EditViewUtils.php
+++ b/include/utils/EditViewUtils.php
@@ -312,8 +312,9 @@ function getAssociatedProducts($module,$focus,$seid='')
 		}
 		$product_Detail[$i]['netPrice'.$i] = $netPrice;
 
+		$taxMode = ($focus->id) ? 'available_associated' : 'all';
 		//First we will get all associated taxes as array
-		$tax_details = getTaxDetailsForProduct($hdnProductId,'all');
+		$tax_details = getTaxDetailsForProduct($hdnProductId, $taxMode);
 		//Now retrieve the tax values from the current query with the name
 		for($tax_count=0;$tax_count<count($tax_details);$tax_count++)
 		{
diff --git a/modules/Inventory/models/Record.php b/modules/Inventory/models/Record.php
index 4a911f428..f3cb379c3 100644
--- a/modules/Inventory/models/Record.php
+++ b/modules/Inventory/models/Record.php
@@ -62,6 +62,7 @@ class Inventory_Record_Model extends Vtiger_Record_Model {
 
 		//Updating Tax details
 		$taxtype = $relatedProducts[1]['final_details']['taxtype'];
+		$taxMode = ($this->getId()) ? 'available_associated' : 'all';
 
 		$subTotal = 0;
 		for ($i=1;$i<=$productsCount; $i++) {
@@ -70,7 +71,7 @@ class Inventory_Record_Model extends Vtiger_Record_Model {
 			$totalAfterDiscount = $product['totalAfterDiscount'.$i];
 
 			if ($taxtype == 'individual') {
-				$taxDetails = getTaxDetailsForProduct($productId, 'all');
+				$taxDetails = getTaxDetailsForProduct($productId, $taxMode);
 				$taxCount = count($taxDetails);
 				$taxTotal = '0';
 
-- 
GitLab