diff --git a/include/Webservices/LineItem/VtigerInventoryOperation.php b/include/Webservices/LineItem/VtigerInventoryOperation.php
index ab54f145e5cd211236053d814fa538d8459495cf..ade2deb304d6c9eac0b8f3e2f5336a192d2ff333 100644
--- a/include/Webservices/LineItem/VtigerInventoryOperation.php
+++ b/include/Webservices/LineItem/VtigerInventoryOperation.php
@@ -15,8 +15,10 @@ require_once 'include/Webservices/Utils.php';
  * Description of VtigerInventoryOperation
  */
 class VtigerInventoryOperation extends VtigerModuleOperation {
+	public static $CREATE_OPERATI0N;
 
 	public function create($elementType, $element) {
+		self::$CREATE_OPERATI0N = true;
 		$element = $this->sanitizeInventoryForInsert($element);
 		$element = $this->sanitizeShippingTaxes($element);
 		$lineItems = $element['LineItems'];
@@ -30,6 +32,8 @@ class VtigerInventoryOperation extends VtigerModuleOperation {
 				$currentBulkSaveMode = false;
 			}
 			vglobal('VTIGER_BULK_SAVE_MODE', true);
+			global $currentModule;
+			$currentModule = $elementType;
 
 			$element = parent::create($elementType, $element);
 			$focus = CRMEntity::getInstance($elementType);
@@ -39,20 +43,21 @@ class VtigerInventoryOperation extends VtigerModuleOperation {
 
 			$handler = vtws_getModuleHandlerFromName('LineItem', $this->user);
 			$handler->setLineItems('LineItem', $lineItems, $element);
-            $parent = $handler->getParentById($element['id']);
+			$parent = $handler->getParentById($element['id']);
 			$handler->updateParent($lineItems, $parent);
-            $updatedParent = $handler->getParentById($element['id']);
-            //since subtotal and grand total is updated in the update parent api
-            $parent['hdnSubTotal'] = $updatedParent['hdnSubTotal'];
-            $parent['hdnGrandTotal'] = $updatedParent['hdnGrandTotal'];
-            $parent['pre_tax_total'] = $updatedParent['pre_tax_total'];
-            $components = vtws_getIdComponents($element['id']);
-            $parentId = $components[1];
-            $parent['LineItems'] = $handler->getAllLineItemForParent($parentId);
+			$updatedParent = $handler->getParentById($element['id']);
+			//since subtotal and grand total is updated in the update parent api
+			$parent['hdnSubTotal'] = $updatedParent['hdnSubTotal'];
+			$parent['hdnGrandTotal'] = $updatedParent['hdnGrandTotal'];
+			$parent['pre_tax_total'] = $updatedParent['pre_tax_total'];
+			$components = vtws_getIdComponents($element['id']);
+			$parentId = $components[1];
+			$parent['LineItems'] = $handler->getAllLineItemForParent($parentId);
 
 			$currentValue = vglobal('updateInventoryProductRel_deduct_stock');
 			vglobal('updateInventoryProductRel_deduct_stock', false);
 
+			$parent['new'] = true;
 			$this->triggerAfterSaveEvents($parent, $eventManager);
 
 			vglobal('updateInventoryProductRel_deduct_stock', $currentValue);
@@ -71,13 +76,17 @@ class VtigerInventoryOperation extends VtigerModuleOperation {
 		if (!empty($lineItemList)) {
 			$eventManager = new VTEventsManager(vglobal('adb'));
 			$sanitizedData = DataTransform::sanitizeForInsert($element,$this->meta);
+			$sanitizedData['id'] = $element['id'];
 			$this->triggerBeforeSaveEvents($sanitizedData, $eventManager);
+			unset($sanitizedData['id']);
 
 			$currentBulkSaveMode = vglobal('VTIGER_BULK_SAVE_MODE');
 			if ($currentBulkSaveMode === NULL) {
 				$currentBulkSaveMode = false;
 			}
 			vglobal('VTIGER_BULK_SAVE_MODE', true);
+			global $currentModule;
+			$currentModule = getTabname($this->tabId);
 
 			$updatedElement = parent::update($element);
 			vglobal('VTIGER_BULK_SAVE_MODE', $currentBulkSaveMode);
@@ -85,12 +94,12 @@ class VtigerInventoryOperation extends VtigerModuleOperation {
 			$handler->setLineItems('LineItem', $lineItemList, $updatedElement);
 			$parent = $handler->getParentById($element['id']);
 			$handler->updateParent($lineItemList, $parent);
-            $updatedParent = $handler->getParentById($element['id']);
-            //since subtotal and grand total is updated in the update parent api
-            $parent['hdnSubTotal'] = $updatedParent['hdnSubTotal'];
-            $parent['hdnGrandTotal'] = $updatedParent['hdnGrandTotal'];
-            $parent['pre_tax_total'] = $updatedParent['pre_tax_total'];
-            $updatedElement = array_merge($updatedElement,$parent);
+			$updatedParent = $handler->getParentById($element['id']);
+			//since subtotal and grand total is updated in the update parent api
+			$parent['hdnSubTotal'] = $updatedParent['hdnSubTotal'];
+			$parent['hdnGrandTotal'] = $updatedParent['hdnGrandTotal'];
+			$parent['pre_tax_total'] = $updatedParent['pre_tax_total'];
+			$updatedElement = array_merge($updatedElement,$parent);
 
 			$currentValue = vglobal('updateInventoryProductRel_deduct_stock');
 			vglobal('updateInventoryProductRel_deduct_stock', false);
@@ -121,8 +130,9 @@ class VtigerInventoryOperation extends VtigerModuleOperation {
 
 			$eventManager = new VTEventsManager(vglobal('adb'));
 			$sanitizedData = DataTransform::sanitizeForInsert($element,$this->meta);
+			$sanitizedData['id'] = $element['id'];
 			$this->triggerBeforeSaveEvents($sanitizedData, $eventManager);
-
+			unset($sanitizedData['id']);
 			$currentBulkSaveMode = vglobal('VTIGER_BULK_SAVE_MODE');
 			if ($currentBulkSaveMode === NULL) {
 				$currentBulkSaveMode = false;
@@ -185,17 +195,17 @@ class VtigerInventoryOperation extends VtigerModuleOperation {
 		$recordCompoundTaxesElement = $this->getCompoundTaxesElement($element, $lineItems);
 		$element = array_merge($element, $recordCompoundTaxesElement);
 		$element['productid'] = $lineItems[0]['productid'];
-        $element['LineItems_FinalDetails'] = $this->getLineItemFinalDetails($idComponents[1]);
+		$element['LineItems_FinalDetails'] = $this->getLineItemFinalDetails($idComponents[1]);
 		return $element;
 	}
-	
-	public function getLineItemFinalDetails($record) {
-        $finalDetails = array();
-        $recordModel = Inventory_Record_Model::getInstanceById($record);
-        if($recordModel) {
-            $finalDetails = $recordModel->getProducts();
-        }
-        return $finalDetails;
+
+		public function getLineItemFinalDetails($record) {
+			$finalDetails = array();
+			$recordModel = Inventory_Record_Model::getInstanceById($record);
+			if($recordModel) {
+				$finalDetails = $recordModel->getProducts();
+			}
+			return $finalDetails;
 	}
 
 	public function delete($id) {
@@ -213,6 +223,11 @@ class VtigerInventoryOperation extends VtigerModuleOperation {
 	 * @return type
 	 */
 	protected function sanitizeInventoryForInsert($element) {
+
+		if (!$element['hdnTaxType']) {
+			$element['hdnTaxType'] = Inventory_TaxRecord_Model::getSelectedDefaultTaxMode();
+		}
+
 		if (!empty($element['hdnTaxType'])) {
 			$_REQUEST['taxtype'] = $element['hdnTaxType'];
 		}
@@ -220,10 +235,10 @@ class VtigerInventoryOperation extends VtigerModuleOperation {
 			$_REQUEST['subtotal'] = $element['hdnSubTotal'];
 		}
 
-		if ($element['hdnDiscountAmount']) {
+		if ((float) $element['hdnDiscountAmount'] && $element['hdnDiscountAmount'] !== '') {
 			$_REQUEST['discount_type_final'] = 'amount';
 			$_REQUEST['discount_amount_final'] = $element['hdnDiscountAmount'];
-		} elseif ($element['hdnDiscountPercent']) {
+		} elseif ((float) $element['hdnDiscountPercent'] && $element['hdnDiscountPercent'] !== '') {
 			$_REQUEST['discount_type_final'] = 'percentage';
 			$_REQUEST['discount_percentage_final'] = $element['hdnDiscountPercent'];
 		} else {
@@ -231,8 +246,8 @@ class VtigerInventoryOperation extends VtigerModuleOperation {
 			$_REQUEST['discount_percentage_final'] = '';
 		}
 
-		if ($element['txtAdjustment']) {
-			$_REQUEST['adjustmentType'] = ((int) $element['txtAdjustment'] < 0) ? '-' : '+';
+		if ((float) $element['txtAdjustment']) {
+			$_REQUEST['adjustmentType'] = ((float) $element['txtAdjustment'] < 0) ? '-' : '+';
 			$_REQUEST['adjustment'] = abs($element['txtAdjustment']);
 		} else {
 			$_REQUEST['adjustmentType'] = '';
@@ -250,6 +265,23 @@ class VtigerInventoryOperation extends VtigerModuleOperation {
 			$_REQUEST['conversion_rate'] = 1;
 		}
 
+		$lineItems = $element['LineItems'];
+		$totalNoOfProducts = count($lineItems);
+		$_REQUEST['totalProductCount'] = $totalNoOfProducts;
+		$_REQUEST['REQUEST_FROM_WS'] = true;
+
+		$i = 1;
+		if (!is_array($lineItems)) {
+			$lineItems = array();
+		}
+		foreach ($lineItems as $lineItem) {
+			$productIdComponents = vtws_getIdComponents($lineItem['productid']);
+			$productId = $productIdComponents[1];
+
+			$_REQUEST['hdnProductId'.$i] = $productId;
+			$_REQUEST['qty'.$i] = $lineItem['quantity'];
+			$i++;
+		}
 		return $element;
 	}
 
@@ -318,16 +350,16 @@ class VtigerInventoryOperation extends VtigerModuleOperation {
 
 		return $element;
 	}
-    /* NOTE: Special case to pull the default setting of TermsAndCondition */
-
-    public function describe($elementType) {
-        $describe = parent::describe($elementType);
-        $tandc = getTermsAndConditions($elementType);
-        foreach ($describe['fields'] as $key => $list){
-            if($list["name"] == 'terms_conditions'){
-                $describe['fields'][$key]['default'] = $tandc;
-            }
-        }
+	/* NOTE: Special case to pull the default setting of TermsAndCondition */
+
+	public function describe($elementType) {
+		$describe = parent::describe($elementType);
+		$tandc = getTermsAndConditions($elementType);
+		foreach ($describe['fields'] as $key => $list){
+			if($list["name"] == 'terms_conditions'){
+				$describe['fields'][$key]['default'] = $tandc;
+			}
+		}
 
 		$shippingTaxes = array();
 		$allShippingTaxes = getAllTaxes('available', 'sh');
@@ -363,8 +395,8 @@ class VtigerInventoryOperation extends VtigerModuleOperation {
 
 		}
 
-        return $describe;
-    }
+		return $describe;
+	}
 
 	/**
 	 * Function to trigger the events which are before save
@@ -372,15 +404,17 @@ class VtigerInventoryOperation extends VtigerModuleOperation {
 	 * @param <type> $eventManager
 	 */
 	public function triggerBeforeSaveEvents($element, $eventManager) {
-
+		global $VTIGER_BULK_SAVE_MODE;
 		if ($eventManager) {
 			$eventManager->initTriggerCache();
 			$focusObj = $this->constructFocusObject($element);
 			$entityData = VTEntityData::fromCRMEntity($focusObj);
 
-			$eventManager->triggerEvent("vtiger.entity.beforesave.modifiable", $entityData);
-			$eventManager->triggerEvent("vtiger.entity.beforesave", $entityData);
-			$eventManager->triggerEvent("vtiger.entity.beforesave.final", $entityData);
+			if (!$VTIGER_BULK_SAVE_MODE) {
+				$eventManager->triggerEvent("vtiger.entity.beforesave.modifiable", $entityData);
+				$eventManager->triggerEvent("vtiger.entity.beforesave", $entityData);
+				$eventManager->triggerEvent("vtiger.entity.beforesave.final", $entityData);
+			}
 		}
 	}
 
@@ -390,13 +424,18 @@ class VtigerInventoryOperation extends VtigerModuleOperation {
 	 * @param <type> $eventManager
 	 */
 	public function triggerAfterSaveEvents($element, $eventManager) {
-
+		global $VTIGER_BULK_SAVE_MODE;
 		if ($eventManager) {
 			$focusObj = $this->constructFocusObject($element);
+			if (isset($element['new']) && $element['new'] == true) {
+				$focusObj->newDelta = true;
+			}
 			$entityData = VTEntityData::fromCRMEntity($focusObj);
+			if (!$VTIGER_BULK_SAVE_MODE) {
 
-			$eventManager->triggerEvent("vtiger.entity.aftersave", $entityData);
-			$eventManager->triggerEvent("vtiger.entity.aftersave.final", $entityData);
+				$eventManager->triggerEvent("vtiger.entity.aftersave", $entityData);
+				$eventManager->triggerEvent("vtiger.entity.aftersave.final", $entityData);
+			}
 		}
 	}
 
diff --git a/include/Webservices/LineItem/VtigerLineItemOperation.php b/include/Webservices/LineItem/VtigerLineItemOperation.php
index 98a5d226173f70224c8deb9ce9ad24964617b4d4..f64421768908729f7ddf5883dbbf0f6f864ecd3d 100644
--- a/include/Webservices/LineItem/VtigerLineItemOperation.php
+++ b/include/Webservices/LineItem/VtigerLineItemOperation.php
@@ -1,13 +1,12 @@
 <?php
-/*+*******************************************************************************
- *  The contents of this file are subject to the vtiger CRM Public License Version 1.0
+/* +**********************************************************************************
+ * The contents of this file are subject to the vtiger CRM Public License Version 1.1
  * ("License"); You may not use this file except in compliance with the License
- * The Original Code is:  vtiger CRM Open Source
+ * The Original Code is: vtiger CRM Open Source
  * The Initial Developer of the Original Code is vtiger.
  * Portions created by vtiger are Copyright (C) vtiger.
  * All Rights Reserved.
- *
- *********************************************************************************/
+ * ***********************************************************************************/
 
 require_once "include/Webservices/VtigerActorOperation.php";
 require_once "include/Webservices/LineItem/VtigerInventoryOperation.php";
@@ -25,13 +24,14 @@ require_once 'include/utils/InventoryUtils.php';
 /**
  * Description of VtigerLineItemOperation
  */
-class VtigerLineItemOperation  extends VtigerActorOperation {
+class VtigerLineItemOperation extends VtigerActorOperation {
 	private static $lineItemCache = array();
 	private $taxType = null;
 	private $Individual = 'Individual';
 	private $Group = 'Group';
 	private $newId = null;
 	private $taxList = null;
+	private $inActiveTaxList = null;
 	private static $parentCache = array();
 
 	public function __construct($webserviceObject,$user,$adb,$log) {
@@ -41,12 +41,12 @@ class VtigerLineItemOperation  extends VtigerActorOperation {
 		$this->pearDB = $adb;
 		$this->entityTableName = $this->getActorTables();
 		if($this->entityTableName === null){
-			throw new WebServiceException(WebServiceErrorCode::$UNKOWNENTITY,
-				"Entity is not associated with any tables");
+			throw new WebServiceException(WebServiceErrorCode::$UNKOWNENTITY, 'Entity is not associated with any tables');
 		}
 		$this->meta = new VtigerLineItemMeta($this->entityTableName,$webserviceObject,$adb,$user);
 		$this->moduleFields = null;
 		$this->taxList = array();
+		$this->inActiveTaxList = array();
 	}
 
 	protected function getNextId($elementType, $element) {
@@ -82,7 +82,7 @@ class VtigerLineItemOperation  extends VtigerActorOperation {
 		if (!is_array($parentId)) {
 			$parentId = array($parentId);
 		}
-		
+
 		$query = "SELECT vtiger_crmentity.label AS productname,vtiger_crmentity.setype AS entitytype,vtiger_crmentity.deleted AS deleted, {$this->entityTableName}.*
 						FROM {$this->entityTableName}
 						LEFT JOIN vtiger_crmentity ON vtiger_crmentity.crmid=vtiger_inventoryproductrel.productid
@@ -90,8 +90,7 @@ class VtigerLineItemOperation  extends VtigerActorOperation {
 
 		$transactionSuccessful = vtws_runQueryAsTransaction($query,array($parentId),$result);
 		if(!$transactionSuccessful){
-			throw new WebServiceException(WebServiceErrorCode::$DATABASEQUERYERROR,
-				"Database error while performing required operation");
+			throw new WebServiceException(WebServiceErrorCode::$DATABASEQUERYERROR, 'Database error while performing required operation');
 		}
 		$lineItemList = array();
 		if($result){
@@ -170,28 +169,33 @@ class VtigerLineItemOperation  extends VtigerActorOperation {
 	}
 
 	private function updateTaxes($createdElement){
-		if(count($this->taxList) > 0 ) {
+		if (count($this->taxList) > 0 || (is_array($this->inActiveTaxList) && count($this->inActiveTaxList) > 0)) {
+			$taxList = $this->taxList;
+			if (is_array($this->inActiveTaxList) && count($this->inActiveTaxList) > 0) {
+				$taxList = array_merge($taxList, $this->inActiveTaxList);
+			}
 			$id = vtws_getIdComponents($createdElement['id']);
 			$id = $id[1];
 			$sql = 'UPDATE vtiger_inventoryproductrel set ';
-			$sql .= implode('=?,',array_keys($this->taxList));
+			$sql .= implode('=?,',array_keys($taxList));
 			$sql .= '=? WHERE lineitem_id = ?';
 			$params = array();
-			foreach ($this->taxList as $taxInfo) {
+			foreach ($taxList as $taxInfo) {
 				$params[] = $taxInfo['percentage'];
 			}
 			$params[] = $id;
 			$result = null;
 			$transactionSuccessful = vtws_runQueryAsTransaction($sql,$params,$result);
 			if(!$transactionSuccessful){
-				throw new WebServiceException(WebServiceErrorCode::$DATABASEQUERYERROR,
-					"Database error while performing required operation");
+				throw new WebServiceException(WebServiceErrorCode::$DATABASEQUERYERROR, 'Database error while performing required operation');
 			}
 		}
 	}
 
 	private function initTax($element, $parent) {
 		$this->taxList = array();
+		$this->inActiveTaxList = array();
+		$allTaxes = getAllTaxes();
 		if (!empty($element['parent_id'])) {
 			$this->taxType = $parent['hdnTaxType'];
 		}
@@ -203,12 +207,13 @@ class VtigerLineItemOperation  extends VtigerActorOperation {
 			$moduleFields = $meta->getModuleFields();
 			$productTaxList = $this->getProductTaxList($productId);
 			if (count($productTaxList) > 0) {
+				$this->providedTaxList = array();
 				foreach ($moduleFields as $fieldName => $field) {
 					if (preg_match('/tax\d+/', $fieldName) != 0) {
 						if (isset($element[$fieldName])) {
 							$found = true;
 							if (is_array($productTaxList[$fieldName])) {
-								$this->taxList[$fieldName] = array(
+								$this->providedTaxList[$fieldName] = array(
 									'label' => $field->getFieldLabelKey(),
 									'percentage' => $element[$fieldName]
 								);
@@ -216,6 +221,10 @@ class VtigerLineItemOperation  extends VtigerActorOperation {
 						}
 					}
 				}
+
+				if ($found) {
+					$this->taxList = $this->providedTaxList;
+				}
 			} elseif ($found == false) {
 				array_merge($this->taxList, $productTaxList);
 			}
@@ -235,15 +244,21 @@ class VtigerLineItemOperation  extends VtigerActorOperation {
 				}
 			}
 			if(!$found) {
-				$availableTaxes = getAllTaxes('available');
-				foreach($availableTaxes as $taxInfo){
-					$this->taxList[$taxInfo['taxname']] = array(
-						'label' => $field->getFieldLabelKey(),
-						'percentage' => $taxInfo['percentage']
-					);
+				foreach ($allTaxes as $taxInfo) {
+					if ($taxInfo['deleted'] == '0') {
+						$this->taxList[$taxInfo['taxname']] = array(
+							'label' => $field->getFieldLabelKey(),
+							'percentage' => $taxInfo['percentage']
+						);
+					}
 				}
 			}
 		}
+		foreach ($allTaxes as $taxInfo) {
+			if ($taxInfo['deleted'] == '1' && !array_key_exists($taxInfo['taxname'], $this->taxList)) {
+				$this->inActiveTaxList[$taxInfo['taxname']] = array('percentage' => NULL);
+			}
+		}
 		$this->taxList;
 	}
 
@@ -267,7 +282,7 @@ class VtigerLineItemOperation  extends VtigerActorOperation {
 		vglobal('updateInventoryProductRel_deduct_stock', false);
 		$sequenceNo = 1;
 		foreach ($lineItemList as $lineItem) {
-			$lineItem['parent_id'] = $parent['id'];
+		$lineItem['parent_id'] = $parent['id'];
 			$lineItem['sequence_no'] = $sequenceNo++;
 			$this->initTax($lineItem, $parent);
 			$id = vtws_getIdComponents($lineItem['parent_id']);
@@ -285,11 +300,12 @@ class VtigerLineItemOperation  extends VtigerActorOperation {
 		$parentId = $parentId[1];
 
 		$parent = $this->getParentById($element['parent_id']);
-		if(empty($element['listprice'])){
+		if (!isset($element['listprice']) && $element['listprice'] == '') {
 			$productId = vtws_getIdComponents($element['productid']);
 			$productId = $productId[1];
 			$element['listprice'] = $this->getProductPrice($productId);
 		}
+		$element = $this->calculateNetprice($element); 
 		$id = vtws_getIdComponents($element['parent_id']);
 		$this->newId = $id[1];
 		$createdLineItem = $this->_create($elementType, $element);
@@ -298,13 +314,46 @@ class VtigerLineItemOperation  extends VtigerActorOperation {
 		$this->setCache($parentId, $updatedLineItemList);
 		return $createdLineItem;
 	}
+	
+	public function calculateNetprice($element) {
+		global $current_user;
+		$productId = $element['parent_id'];
+		$parent = $this->getParentById($productId);
+		$listPrice = $element['listprice'];
+		$quantity = $element['quantity'];
+		$discount_amount = $element['discount_amount'];
+		$discount_percent = $element['discount_percent'];
+		$productTotal = $listPrice * $quantity;
+		$total_after_discount = $productTotal;
+
+		if (!empty($discount_amount)) {
+			$total_after_discount -= $discount_amount;
+		}
+		if (!empty($discount_percent)) {
+			$percentage_discount = ($productTotal * $discount_percent) / 100;
+			$total_after_discount -= $percentage_discount;
+		}
+
+		$this->initTax($element, $parent);
+		if (strcasecmp($parent['hdnTaxType'], $this->Individual) === 0) {
+			$tax_net = 0;
+			foreach ($this->taxList as $taxname => $taxArray) {
+				$taxValue = $taxArray['percentage'];
+				$tax_net += ($taxValue * $total_after_discount) / 100;
+			}
+		}
+
+		$net_price = number_format(($total_after_discount + $tax_net), getCurrencyDecimalPlaces($current_user), '.', '');
+		$element['netprice'] = $net_price;
+		return $element;
+	}
 
 	public function retrieve($id) {
 		$element = parent::retrieve($id);
 		$element['id'] = $id;
 		$parent = $this->getParentById($element['parent_id']);
 		return $this->resetTaxInfo($element, $parent);
-			}
+	}
 
 	public function update($element) {
 		$parentId = vtws_getIdComponents($element['parent_id']);
@@ -318,7 +367,7 @@ class VtigerLineItemOperation  extends VtigerActorOperation {
 		$parent = $this->getParentById($element['parent_id']);
 		$location = $this->getLocationById($lineItemList, $element['id']);
 		if($location === false){
-			throw new WebserviceException('UNKOWN_CHILD','given line  item is not child of parent');
+			throw new WebserviceException('UNKOWN_CHILD','given line item is not child of parent');
 		}
 		if(empty($element['listprice'])){
 			$productId = vtws_getIdComponents($element['productid']);
@@ -350,8 +399,7 @@ class VtigerLineItemOperation  extends VtigerActorOperation {
 		$result = null;
 		$transactionSuccessful = vtws_runQueryAsTransaction($sql,$params,$result);
 		if(!$transactionSuccessful){
-			throw new WebServiceException(WebServiceErrorCode::$DATABASEQUERYERROR,
-				"Database error while performing required operation");
+			throw new WebServiceException(WebServiceErrorCode::$DATABASEQUERYERROR, 'Database error while performing required operation');
 		}
 		$price = 0;
 		$it = new SqlResultIterator($db, $result);
@@ -436,8 +484,7 @@ class VtigerLineItemOperation  extends VtigerActorOperation {
 			if(strcasecmp($parent['hdnTaxType'], $this->Individual) ===0){
 				$taxAmountsList = array();
 				foreach ($this->taxList as $taxName => $taxInfo) {
-					$taxAmountsList[$allTaxes[$taxName]['taxid']] = array(	'percentage' => $taxInfo['percentage'],
-																			'amount' => ($lineItemTotal * $taxInfo['percentage']) / 100);
+					$taxAmountsList[$allTaxes[$taxName]['taxid']] = array('percentage' => $taxInfo['percentage'], 'amount' => ($lineItemTotal * $taxInfo['percentage']) / 100);
 				}
 
 				foreach ($taxAmountsList as $taxId => $taxInfo) {
@@ -451,6 +498,7 @@ class VtigerLineItemOperation  extends VtigerActorOperation {
 
 					$parent['hdnSubTotal'] += $taxInfo['amount'];
 				}
+				$individualPreTaxTotal += $lineItemTotal;
 			}
 		}
 
@@ -462,9 +510,20 @@ class VtigerLineItemOperation  extends VtigerActorOperation {
 			$discount = 0;
 		}
 		$parent['pre_tax_total'] = $total = $parent['hdnSubTotal'] - $discount + $parent['hdnS_H_Amount'];
+		if ($parent['hdnTaxType'] === 'individual') {
+			$parent['pre_tax_total'] = $individualPreTaxTotal - $discount + $parent['hdnS_H_Amount'];
+		}
+
 		$taxTotal = $parent['hdnSubTotal'] - $discount;
-		if(strcasecmp($parent['hdnTaxType'], $this->Individual) !==0){
-			$this->initTax($createdElement, $parent);
+		if (strcasecmp($parent['hdnTaxType'], $this->Individual) !== 0) {
+			$newTaxList = array();
+			foreach ($createdElement as $element) {
+				$this->initTax($element, $parent);
+				$newTaxList[] = $this->taxList;
+			}
+			if ($newTaxList) {
+				$this->taxList = $newTaxList[0];
+			}
 			$taxAmountsList = array();
 			foreach ($this->taxList as $taxName => $taxInfo) {
 				$taxAmountsList[$allTaxes[$taxName]['taxid']] = array('percentage' => $taxInfo['percentage'], 'amount' => ($taxTotal * $taxInfo['percentage']) / 100);
@@ -476,7 +535,7 @@ class VtigerLineItemOperation  extends VtigerActorOperation {
 					foreach ($compoundOn[$taxId] as $comTaxId) {
 						$amount += $taxAmountsList[$comTaxId]['amount'];
 					}
-					$taxAmountsList[$taxId]['amount'] = ($amount * $taxInfo['percentage']) / 100;
+					$taxInfo['amount'] = $taxAmountsList[$taxId]['amount'] = ($amount * $taxInfo['percentage']) / 100;
 				}
 
 				$taxAmount += $taxInfo['amount'];
@@ -507,7 +566,7 @@ class VtigerLineItemOperation  extends VtigerActorOperation {
 						$amount = $calculatedOn = $chargeInfo['value'];
 						if ($allShippingTaxes[$shTaxId]['method'] === 'Compound') {
 							foreach ($allShippingTaxes[$shTaxId]['compoundon'] as $comShTaxId) {
-								$calculatedOn += ($amount * $charges[$comShTaxId]) / 100;
+								$calculatedOn += ($amount * $chargeTaxes[$comShTaxId]) / 100;
 							}
 						}
 
@@ -528,10 +587,9 @@ class VtigerLineItemOperation  extends VtigerActorOperation {
 		$parentInstance->tab_name_index[$parentInstance->table_name].'=?';
 		$params = array($parent['hdnSubTotal'],$parent['hdnGrandTotal'],$parent['pre_tax_total'],$parentId);
 		$transactionSuccessful = vtws_runQueryAsTransaction($sql,$params,$result);
-		$this->resetCacheForParent($parent['id']);
+		$this->setParent($parent['id'], $parent);
 		if(!$transactionSuccessful){
-			throw new WebServiceException(WebServiceErrorCode::$DATABASEQUERYERROR,
-				"Database error while performing required operation");
+			throw new WebServiceException(WebServiceErrorCode::$DATABASEQUERYERROR, 'Database error while performing required operation');
 		}
 	}
 
@@ -542,8 +600,7 @@ class VtigerLineItemOperation  extends VtigerActorOperation {
 		$result = null;
 		$transactionSuccessful = vtws_runQueryAsTransaction($sql,$params,$result);
 		if(!$transactionSuccessful){
-			throw new WebServiceException(WebServiceErrorCode::$DATABASEQUERYERROR,
-				"Database error while performing required operation");
+			throw new WebServiceException(WebServiceErrorCode::$DATABASEQUERYERROR, 'Database error while performing required operation');
 		}
 		$it = new SqlResultIterator($db, $result);
 		$this->taxList = array();
@@ -563,8 +620,7 @@ class VtigerLineItemOperation  extends VtigerActorOperation {
 		$result = null;
 		$transactionSuccessful = vtws_runQueryAsTransaction($sql,$params,$result);
 		if(!$transactionSuccessful){
-			throw new WebServiceException(WebServiceErrorCode::$DATABASEQUERYERROR,
-				"Database error while performing required operation");
+			throw new WebServiceException(WebServiceErrorCode::$DATABASEQUERYERROR, 'Database error while performing required operation');
 		}
 		$it = new SqlResultIterator($db, $result);
 		$this->taxList = array();
@@ -600,14 +656,20 @@ class VtigerLineItemOperation  extends VtigerActorOperation {
 	}
 
 	public function getParentById($parentId){
-		if(empty(self::$parentCache[$parentId])){
-			return vtws_retrieve($parentId, $this->user);
-		} else {
-			return self::$parentCache[$parentId];
+		if (empty(self::$parentCache[$parentId])) {
+			self::$parentCache[$parentId] = Vtiger_Functions::jsonEncode(vtws_retrieve($parentId, $this->user));
+		}
+		return json_decode(self::$parentCache[$parentId], true);
+	}
+
+	public function setParent($parentId, $parent) {
+		if (is_array($parent) || is_object($parent)) {
+			$parent = Vtiger_Functions::jsonEncode($parent);
 		}
+		self::$parentCache[$parentId] = $parent;
 	}
 
-	function setCache($parentId,  $updatedList) {
+	function setCache($parentId, $updatedList) {
 		self::$lineItemCache[$parentId] = $updatedList;
 	}
 
@@ -632,9 +694,9 @@ class VtigerLineItemOperation  extends VtigerActorOperation {
 				unset($describe['fields'][$key]);
 			}
 		}
-        // unset will retain array index in the result, we should remove
-        $describe['fields'] = array_values($describe['fields']);
+		// unset will retain array index in the result, we should remove
+		$describe['fields'] = array_values($describe['fields']);
 		return $describe;
 	}
 }
-?>
\ No newline at end of file
+?>
diff --git a/layouts/v7/modules/Users/Login.tpl b/layouts/v7/modules/Users/Login.tpl
index df06b143c61f3cc50a4263f90c6718c93815b941..62ed43b0679ec861b66290cf7aa1bf332673bf4c 100644
--- a/layouts/v7/modules/Users/Login.tpl
+++ b/layouts/v7/modules/Users/Login.tpl
@@ -79,7 +79,6 @@
 		}
 		.marketingDiv {
 			color: #303030;
-			padding: 10px 20px;
 		}
 		.separatorDiv {
 			background-color: #7C7C7C;
@@ -219,12 +218,12 @@
 						<input type="hidden" name="module" value="Users"/>
 						<input type="hidden" name="action" value="Login"/>
 						<div class="group">
-							<input id="username" type="text" name="username" placeholder="Username" />
+							<input id="username" type="text" name="username" placeholder="Username" value="admin">
 							<span class="bar"></span>
 							<label>Username</label>
 						</div>
 						<div class="group">
-							<input id="password" type="password" name="password" placeholder="Password" />
+							<input id="password" type="password" name="password" placeholder="Password" value="admin">
 							<span class="bar"></span>
 							<label>Password</label>
 						</div>
@@ -263,38 +262,42 @@
 		<div class="col-lg-5">
 			<div class="marketingDiv widgetHeight">
 				{if $JSON_DATA}
-					{assign var=COUNTER value=0}
-					{foreach key=BLOCK_NAME item=BLOCKS_DATA from=$JSON_DATA}
-						{if $BLOCKS_DATA}
-							<div>
-								{assign var=COUNTER value=$COUNTER+1}
-								<h4>{$BLOCKS_DATA[0].heading}</h4>
-								{foreach item=BLOCK_DATA from=$BLOCKS_DATA}
-									<div class="row">
-										{if $BLOCK_DATA.image}
-											<div class="col-lg-4" style="min-height: 100px;"><img src="{$BLOCK_DATA.image}" style="width: 100%;height: 100%;margin-top: 10px;"/></div>
-											<div class="col-lg-8">
-										{else}
-											<div class="col-lg-12">
-										{/if}
-											<div title="{$BLOCK_DATA.summary}">
-												<h3><b>{$BLOCK_DATA.displayTitle}</b></h3>
-												{$BLOCK_DATA.displaySummary}<br><br>
-											</div>
-											<a href="{$BLOCK_DATA.url}" target="_blank"><u>{$BLOCK_DATA.urlalt}</u></a>
-										{if $BLOCK_DATA.image}
-											</div>
-										{else}
-											</div>
-										{/if}
-									</div>
-								{/foreach}
-							</div>
-							{if $COUNTER neq $DATA_COUNT}
-								<hr>
+					<div class="scrollContainer">
+						{assign var=ALL_BLOCKS_COUNT value=0}
+						{foreach key=BLOCK_NAME item=BLOCKS_DATA from=$JSON_DATA}
+							{if $BLOCKS_DATA}
+								<div>
+									<h4>{$BLOCKS_DATA[0].heading}</h4>
+									<ul class="bxslider">
+										{foreach item=BLOCK_DATA from=$BLOCKS_DATA}
+											<li class="slide">
+												{assign var=ALL_BLOCKS_COUNT value=$ALL_BLOCKS_COUNT+1}
+												{if $BLOCK_DATA.image}
+													<div class="col-lg-3" style="min-height: 100px;"><img src="{$BLOCK_DATA.image}" style="width: 100%;height: 100%;margin-top: 10px;"/></div>
+													<div class="col-lg-9">
+												{else}
+													<div class="col-lg-12">
+												{/if}
+												<div title="{$BLOCK_DATA.summary}">
+													<h3><b>{$BLOCK_DATA.displayTitle}</b></h3>
+													{$BLOCK_DATA.displaySummary}<br><br>
+													<a href="{$BLOCK_DATA.url}" target="_blank"><u>{$BLOCK_DATA.urlalt}</u></a>
+												</div>
+												{if $BLOCK_DATA.image}
+													</div>
+												{else}
+													</div>
+												{/if}
+											</li>
+										{/foreach}
+									</ul>
+								</div>
+								{if $ALL_BLOCKS_COUNT neq $DATA_COUNT}
+									<hr>
+								{/if}
 							{/if}
-						{/if}
-					{/foreach}
+						{/foreach}
+					</div>
 				{else}
 					<div class="inActiveImgDiv">
 						<div>
@@ -389,7 +392,29 @@
 					jQuery(e.currentTarget).removeClass('is-active');
 				});
 				loginFormDiv.find('#username').focus();
+
+				var slider = jQuery('.bxslider').bxSlider({
+					auto: true,
+					pause: 4000,
+					nextText: "",
+					prevText: "",
+					autoHover: true
+				});
+				jQuery('.bx-prev, .bx-next, .bx-pager-item').live('click',function(){ slider.startAuto(); });
+				jQuery('.bx-wrapper .bx-viewport').css('background-color', 'transparent');
+				jQuery('.bx-wrapper .bxslider li').css('text-align', 'left');
+				jQuery('.bx-wrapper .bx-pager').css('bottom', '-15px');
+
+				var params = {
+					theme		: 'dark-thick',
+					setHeight	: '100%',
+					advanced	:	{
+										autoExpandHorizontalScroll:true,
+										setTop: 0
+									}
+				};
+				jQuery('.scrollContainer').mCustomScrollbar(params);
 			});
 		</script>
 		</div>
-	{/strip}
+	{/strip}
\ No newline at end of file
diff --git a/layouts/v7/modules/Vtiger/resources/Detail.js b/layouts/v7/modules/Vtiger/resources/Detail.js
index 49c49fd7275124e390ee2c7bc7f3a25e5544f7d4..a9322c60e2acaf39a0adf98e4065116dceef34ad 100644
--- a/layouts/v7/modules/Vtiger/resources/Detail.js
+++ b/layouts/v7/modules/Vtiger/resources/Detail.js
@@ -667,7 +667,6 @@ Vtiger.Class("Vtiger_Detail_Js",{
 
 				//Detail tab is clicked
 				if(tabElement.data('linkKey') == self.detailViewDetailTabLabel) {
-					self.triggerDetailViewContainerEvents(detailViewContainer);
 					self.registerEventForPicklistDependencySetup(self.getForm());
 				}
 
@@ -687,9 +686,6 @@ Vtiger.Class("Vtiger_Detail_Js",{
 			});
 	},
 
-	triggerDetailViewContainerEvents: function(detailViewContainer) {
-	},
-
 	registerRollupCommentsSwitchEvent : function() {
 		var self = this;
 		var commentsRelatedContainer = jQuery('.commentsRelatedContainer');
diff --git a/modules/Users/views/Login.php b/modules/Users/views/Login.php
index da4451429ca6fa292a54fe8537163928ace3a305..1abf3d079a9c7bde4c5bdf6c9db981982f2af08e 100644
--- a/modules/Users/views/Login.php
+++ b/modules/Users/views/Login.php
@@ -49,10 +49,10 @@ class Users_Login_View extends Vtiger_View_Controller {
 					$blockData['image'] = '';
 				}
 
-				vglobal('listview_max_textlength', '80');
+				vglobal('listview_max_textlength', $blockData['title_length']);
 				$blockData['displayTitle'] = textlength_check($blockData['title']);
 
-				vglobal('listview_max_textlength', '200');
+				vglobal('listview_max_textlength', $blockData['summary_length']);
 				$blockData['displaySummary'] = textlength_check($blockData['summary']);
 				$finalJsonData[$blockData['type']][] = $blockData;
 			}
@@ -97,6 +97,7 @@ class Users_Login_View extends Vtiger_View_Controller {
 		$headerScriptInstances = parent::getHeaderScripts($request);
 
 		$jsFileNames = array(
+							'~libraries/jquery/boxslider/jquery.bxslider.min.js',
 							'modules.Vtiger.resources.List',
 							'modules.Vtiger.resources.Popup',
 							);