[Vtigercrm-commits] [vtiger-commits] r10052 - /vtigercrm/branches/5.0.3/include/utils/EditViewUtils.php

vtigercrm-commits at vtiger.fosslabs.com vtigercrm-commits at vtiger.fosslabs.com
Sat Jan 13 06:09:45 EST 2007


Author: richie
Date: Sat Jan 13 04:09:41 2007
New Revision: 10052

Log:
* Modified to fix the issue 2817, Fixes #2817

Modified:
    vtigercrm/branches/5.0.3/include/utils/EditViewUtils.php

Modified: vtigercrm/branches/5.0.3/include/utils/EditViewUtils.php
==============================================================================
--- vtigercrm/branches/5.0.3/include/utils/EditViewUtils.php (original)
+++ vtigercrm/branches/5.0.3/include/utils/EditViewUtils.php Sat Jan 13 04:09:41 2007
@@ -1496,6 +1496,23 @@
 		$product_Detail[$i]['discountTotal'.$i] = $discountTotal;
 		$product_Detail[$i]['totalAfterDiscount'.$i] = $totalAfterDiscount;
 
+		$taxTotal = '0.00';
+		$product_Detail[$i]['taxTotal'.$i] = $taxTotal;
+
+		//Calculate netprice
+		$netPrice = $totalAfterDiscount+$taxTotal;
+		//if condition is added to call this function when we create PO/SO/Quotes/Invoice from Product module
+		if($module == 'PurchaseOrder' || $module == 'SalesOrder' || $module == 'Quotes' || $module == 'Invoice')
+		{
+			$taxtype = getInventoryTaxType($module,$focus->id);
+			if($taxtype == 'individual')
+			{
+				//Add the tax with product total and assign to netprice
+				$netPrice = $netPrice+$taxTotal;
+			}
+		}
+		$product_Detail[$i]['netPrice'.$i] = $netPrice;
+
 		//First we will get all associated taxes as array
 		$tax_details = getTaxDetailsForProduct($hdnProductId,'all');
 		//Now retrieve the tax values from the current query with the name
@@ -1507,7 +1524,12 @@
 
 			//condition to avoid this function call when create new PO/SO/Quotes/Invoice from Product module
 			if($focus->id != '')
-				$tax_value = getInventoryProductTaxValue($focus->id, $hdnProductId, $tax_name);
+			{
+				if($taxtype == 'individual')//if individual then show the entered tax percentage
+					$tax_value = getInventoryProductTaxValue($focus->id, $hdnProductId, $tax_name);
+				else//if group tax then we have to show the default value when change to individual tax
+					$tax_value = $tax_details[$tax_count]['percentage'];
+			}
 			else//if the above function not called then assign the default associated value of the product
 				$tax_value = $tax_details[$tax_count]['percentage'];
 
@@ -1516,22 +1538,6 @@
 			$product_Detail[$i]['taxes'][$tax_count]['percentage'] = $tax_value;
 		}
 
-		$taxTotal = '0.00';
-		$product_Detail[$i]['taxTotal'.$i] = $taxTotal;
-
-		//Calculate netprice
-		$netPrice = $totalAfterDiscount+$taxTotal;
-		//if condition is added to call this function when we create PO/SO/Quotes/Invoice from Product module
-		if($module == 'PurchaseOrder' || $module == 'SalesOrder' || $module == 'Quotes' || $module == 'Invoice')
-		{
-			$taxtype = getInventoryTaxType($module,$focus->id);
-			if($taxtype == 'individual')
-			{
-				//Add the tax with product total and assign to netprice
-				$netPrice = $netPrice+$taxTotal;
-			}
-		}
-		$product_Detail[$i]['netPrice'.$i] = $netPrice;
 	}
 
 	//set the taxtype
@@ -1572,29 +1578,36 @@
 	$product_Detail[1]['final_details']['discountTotal_final'] = $finalDiscount;
 
 	//To set the Final Tax values
-	if($taxtype == 'group')
-	{
-		$taxtotal = '0.00';
-		//First we should get all available taxes and then retrieve the corresponding tax values
-		$tax_details = getAllTaxes('available');
-		//if taxtype is group then the tax will be same for all products in vtiger_inventoryproductrel table
-		for($tax_count=0;$tax_count<count($tax_details);$tax_count++)
-		{
-			$tax_name = $tax_details[$tax_count]['taxname'];
-			$tax_label = $tax_details[$tax_count]['taxlabel'];
+	//we will get all taxes. if individual then show the product related taxes only else show all taxes
+	//suppose user want to change individual to group or vice versa in edit time the we have to show all taxes. so that here we will store all the taxes and based on need we will show the corresponding taxes
+	
+	$taxtotal = '0.00';
+	//First we should get all available taxes and then retrieve the corresponding tax values
+	$tax_details = getAllTaxes('available');
+
+	for($tax_count=0;$tax_count<count($tax_details);$tax_count++)
+	{
+		$tax_name = $tax_details[$tax_count]['taxname'];
+		$tax_label = $tax_details[$tax_count]['taxlabel'];
+
+		//if taxtype is individual and want to change to group during edit time then we have to show the all available taxes and their default values 
+		//Also taxtype is group and want to change to individual during edit time then we have to provide the asspciated taxes and their default tax values for individual products
+		if($taxtype == 'group')
 			$tax_percent = $adb->query_result($result,0,$tax_name);
-			if($tax_percent == '' || $tax_percent == 'NULL')
-				$tax_percent = '0.00';
-			$taxamount = ($subTotal-$finalDiscount)*$tax_percent/100;
-			$taxtotal = $taxtotal + $taxamount;
-			$product_Detail[1]['final_details']['taxes'][$tax_count]['taxname'] = $tax_name;
-			$product_Detail[1]['final_details']['taxes'][$tax_count]['taxlabel'] = $tax_label;
-			$product_Detail[1]['final_details']['taxes'][$tax_count]['percentage'] = $tax_percent;
-			$product_Detail[1]['final_details']['taxes'][$tax_count]['amount'] = $taxamount;
-		}
-		$product_Detail[1]['final_details']['tax_totalamount'] = $taxtotal;
-	}
-
+		else
+			$tax_percent = $tax_details[$tax_count]['percentage'];//$adb->query_result($result,0,$tax_name);
+		
+		if($tax_percent == '' || $tax_percent == 'NULL')
+			$tax_percent = '0.00';
+		$taxamount = ($subTotal-$finalDiscount)*$tax_percent/100;
+		$taxtotal = $taxtotal + $taxamount;
+		$product_Detail[1]['final_details']['taxes'][$tax_count]['taxname'] = $tax_name;
+		$product_Detail[1]['final_details']['taxes'][$tax_count]['taxlabel'] = $tax_label;
+		$product_Detail[1]['final_details']['taxes'][$tax_count]['percentage'] = $tax_percent;
+		$product_Detail[1]['final_details']['taxes'][$tax_count]['amount'] = $taxamount;
+	}
+	$product_Detail[1]['final_details']['tax_totalamount'] = $taxtotal;
+	
 	//To set the Shipping & Handling charge
 	$shCharge = ($focus->column_fields['hdnS_H_Amount'] != '')?$focus->column_fields['hdnS_H_Amount']:'0.00';
 	$shCharge = getConvertedPriceFromDollar($shCharge);





More information about the vtigercrm-commits mailing list