diff --git a/include/utils/EditViewUtils.php b/include/utils/EditViewUtils.php index 0bc464190e7d27e0e7c82f126358e5010b2b575a..2694b1360d93cb85dc279346c908f890b0b3822f 100755 --- a/include/utils/EditViewUtils.php +++ b/include/utils/EditViewUtils.php @@ -539,7 +539,7 @@ function getAssociatedProducts($module, $focus, $seid = '', $refModuleName = fal $shtax_percent = 0; //if condition is added to call this function when we create PO/SO/Quotes/Invoice from Product module if (in_array($module, $inventoryModules)) { - $shtax_percent = getInventorySHTaxPercent($focus->id,$shtax_name); + $shtax_percent = getInventorySHTaxPercent($focus->id,$shtax_name,$shtax_count); } $shtaxamount = $shCharge*$shtax_percent/100; $shtaxtotal = $shtaxtotal + $shtaxamount; diff --git a/include/utils/InventoryUtils.php b/include/utils/InventoryUtils.php index baa17172be770ec75f7ffec23b407984dd121372..2f0ce6152c99f69b44bca207db4fde5fd2c694e1 100644 --- a/include/utils/InventoryUtils.php +++ b/include/utils/InventoryUtils.php @@ -969,7 +969,7 @@ function getInventoryProductTaxValue($id, $productId, $taxName, $lineItemId = 0) * @param string $taxname - shipping and handling taxname * @return float $taxpercentage - shipping and handling taxpercentage which is associated with the given entity */ -function getInventorySHTaxPercent($id, $taxname) +function getInventorySHTaxPercent($id, $taxname, $taxnum=null) { global $log, $adb; $log->debug("Entering into function getInventorySHTaxPercent($id, $taxname)"); @@ -978,6 +978,15 @@ function getInventorySHTaxPercent($id, $taxname) $res = $adb->pquery("select $taxname from vtiger_inventoryshippingrel where id= ?", array($id)); $taxpercentage = $adb->query_result($res,0,$taxname); + //To get the values from the vtiger_inventorychargesrel where the actual shiiping and handling tax info of particular record stored. + if($adb->num_rows($res) < 1){ + $j=$taxnum+1; + $charges_result = $adb->pquery("SELECT JSON_EXTRACT(charges, '$.1.taxes.$j') as charges FROM vtiger_inventorychargesrel WHERE recordid=?", array($id)); + $rowData = $adb->fetch_array($charges_result); + $charges = Zend_Json::decode(html_entity_decode($rowData['charges'])); + $taxpercentage = $charges; + } + if($taxpercentage == '') $taxpercentage = 0;