Esempio n. 1
0
        public ZCRMInventoryLineItem GetZCRMInventoryLineItem(JObject lineItemJSON)
        {
            JObject productDetails         = (JObject)lineItemJSON["product"];
            long    lineItemId             = Convert.ToInt64(lineItemJSON["id"]);
            ZCRMInventoryLineItem lineItem = ZCRMInventoryLineItem.GetInstance(lineItemId);

            ZCRMRecord product = ZCRMRecord.GetInstance("Products", Convert.ToInt64(productDetails["id"]));

            product.LookupLabel         = (string)productDetails["name"];
            lineItem.Product            = product;
            lineItem.Description        = (string)lineItemJSON["product_description"];
            lineItem.Quantity           = Convert.ToDouble(lineItemJSON["quantity"]);
            lineItem.ListPrice          = Convert.ToDouble(lineItemJSON["list_price"]);
            lineItem.UnitPrice          = Convert.ToDouble(lineItemJSON["unit_price"]);
            lineItem.Total              = Convert.ToDouble(lineItemJSON["total"]);
            lineItem.Discount           = Convert.ToDouble(lineItemJSON["Discount"]);
            lineItem.TotalAfterDiscount = Convert.ToDouble(lineItemJSON["tota_after_discount"]);
            lineItem.TaxAmount          = Convert.ToDouble(lineItemJSON["Tax"]);
            JArray lineTaxes = (JArray)lineItemJSON["line_tax"];

            foreach (JObject lineTax in lineTaxes)
            {
                ZCRMTax tax = ZCRMTax.GetInstance((string)lineTax["name"]);
                tax.Percentage = Convert.ToDouble(lineTax["percentage"]);
                tax.Value      = Convert.ToDouble(lineTax["value"]);
                lineItem.AddLineTax(tax);
            }
            lineItem.NetTotal = Convert.ToDouble(lineItemJSON["net_total"]);
            return(lineItem);
        }
Esempio n. 2
0
        public ZCRMInventoryLineItem GetZCRMInventoryLineItem(JObject lineItemJSON)
        {
            JObject productDetails = (JObject)lineItemJSON["product"];

            long lineItemId = Convert.ToInt64(lineItemJSON["id"]);

            ZCRMInventoryLineItem lineItem = ZCRMInventoryLineItem.GetInstance(lineItemId);

            ZCRMRecord product = ZCRMRecord.GetInstance("Products", Convert.ToInt64(productDetails["id"]));

            product.LookupLabel = (string)productDetails["name"];

            if (productDetails.ContainsKey("Product_Code") && productDetails["Product_Code"].Type != JTokenType.Null)
            {
                product.SetFieldValue("Product_Code", (string)productDetails["name"]);
            }

            lineItem.Product = product;

            lineItem.Quantity = Convert.ToDouble(lineItemJSON["quantity"]);

            lineItem.Discount = Convert.ToDouble(lineItemJSON["Discount"]);

            lineItem.TotalAfterDiscount = Convert.ToDouble(lineItemJSON["total_after_discount"]);

            lineItem.NetTotal = Convert.ToDouble(lineItemJSON["net_total"]);

            lineItem.TaxAmount = Convert.ToDouble(lineItemJSON["Tax"]);

            lineItem.ListPrice = Convert.ToDouble(lineItemJSON["list_price"]);

            if (lineItemJSON.ContainsKey("unit_price") && lineItemJSON["unit_price"].Type != JTokenType.Null)
            {
                lineItem.UnitPrice = Convert.ToDouble(lineItemJSON["unit_price"]);
            }

            lineItem.QuantityInStock = Convert.ToInt32(lineItemJSON["quantity_in_stock"]);

            lineItem.Total = Convert.ToDouble(lineItemJSON["total"]);

            lineItem.Description = (string)lineItemJSON["product_description"];

            JArray lineTaxes = (JArray)lineItemJSON["line_tax"];

            foreach (JObject lineTax in lineTaxes)
            {
                ZCRMTax tax = ZCRMTax.GetInstance((string)lineTax["name"]);

                tax.Percentage = Convert.ToDouble(lineTax["percentage"]);

                tax.Value = Convert.ToDouble(lineTax["value"]);

                lineItem.AddLineTax(tax);
            }

            return(lineItem);
        }