public function create($elementType, $element) { $element = $this->sanitizeInventoryForInsert($element); $lineItems = $element['LineItems']; if (!empty($lineItems)) { $element = parent::create($elementType, $element); $handler = vtws_getModuleHandlerFromName('LineItem', $this->user); $handler->setLineItems('LineItem', $lineItems, $element); $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); } else { throw new WebServiceException(WebServiceErrorCode::$MANDFIELDSMISSING, "Mandatory Fields Missing.."); } return array_merge($element, $parent); }