Пример #1
0
        private SalesOrderLinePayload GetLineItem(DataSets.Order.CalculatedOrderDetailsRow row, NorthwindConfig config)
        {
            #region Declarations
            SalesOrderLinePayload payload;
            string id;
            decimal discountPercentage;
            #endregion

            id = row.OrderID.ToString() + "-" + row.ProductID.ToString();

            payload = new SalesOrderLinePayload();
            payload.LocalID = id;
            //payload.SyncUuid = GetUuid(id, "", SupportedResourceKinds.salesOrderLines);
            payload.SalesOrderLinetype.applicationID = id;

            payload.ForeignIds.Add("commodity", row.ProductID.ToString());
            payload.ForeignIds.Add("salesOrder", row.OrderID.ToString());
            payload.ForeignIds.Add("unitOfMeasure", row.ProductID.ToString());

            payload.SalesOrderLinetype.quantitySpecified = true;
            payload.SalesOrderLinetype.quantity = row.IsQuantityNull() ? Convert.ToInt16(0) : row.Quantity;

            payload.SalesOrderLinetype.initialPriceSpecified = true;
            payload.SalesOrderLinetype.initialPrice = row.IsUnitPriceNull() ? new decimal(0) : row.UnitPrice;

            payload.SalesOrderLinetype.orderLineDiscountPercentSpecified = true;
            payload.SalesOrderLinetype.orderLineDiscountPercent = row.IsDiscountNull() ? (decimal)0 : Convert.ToDecimal(row.Discount);

            payload.SalesOrderLinetype.discountTotalSpecified = true;
            payload.SalesOrderLinetype.discountTotal = payload.SalesOrderLinetype.initialPrice * (decimal)payload.SalesOrderLinetype.orderLineDiscountPercent;

            payload.SalesOrderLinetype.costTotalSpecified = true;
            payload.SalesOrderLinetype.costTotal = (decimal)payload.SalesOrderLinetype.initialPrice * (1 - payload.SalesOrderLinetype.orderLineDiscountPercent);

            payload.SalesOrderLinetype.netTotalSpecified = true;
            payload.SalesOrderLinetype.netTotal = Convert.ToDecimal(payload.SalesOrderLinetype.quantity) * Convert.ToDecimal(payload.SalesOrderLinetype.costTotal);

            return payload;
        }
Пример #2
0
        private Document GetDocumentLineItem(DataSets.Order.CalculatedOrderDetailsRow row, Token lastToken, NorthwindConfig config)
        {
            #region Declarations
            LineItemDocument doc;
            string id;
            decimal discountPercentage;
            #endregion

            id = row.OrderID.ToString() + "-" + row.ProductID.ToString();

            doc = new LineItemDocument();
            doc.Id = id;

            if (lastToken.InitRequest)
                doc.LogState = LogState.Created;
            else if ((row.CreateID >= lastToken.SequenceNumber) && (row.CreateUser != config.CrmUser))
                doc.LogState = LogState.Created;
            else if ((row.ModifyID >= lastToken.SequenceNumber) && (row.ModifyUser != config.CrmUser))
                doc.LogState = LogState.Updated;

            doc.productid.Value = row.ProductID;
            //doc.orderquouteid.Value = row.OrderID;
            doc.uomid.Value = row.ProductID;
            doc.quantity.Value = row.IsQuantityNull() ? Convert.ToInt16(0) : row.Quantity;
            doc.listprice.Value = row.IsUnitPriceNull() ? new decimal(0) : row.UnitPrice;
            discountPercentage = row.IsDiscountNull() ? (decimal)0 : Convert.ToDecimal(row.Discount);

            //doc.discountsum.Value = (decimal)(short)doc.Quantity.Value * (decimal)doc.ListPrice.Value * discountPercentage;
            doc.discountsum.Value = (decimal)doc.listprice.Value * discountPercentage;
            doc.quotedprice.Value = (decimal)doc.listprice.Value * (1 - discountPercentage);

            //doc.quotedprice.Value = row.IsQuotePriceNull() ? new decimal(0) : Convert.ToDecimal(row.QuotePrice);

            doc.taxrate.Value = "0";
            doc.tax.Value = new decimal(0);
            doc.quotedpricetotal.Value = Convert.ToDecimal(doc.quantity.Value) * Convert.ToDecimal(doc.quotedprice.Value);
            return doc;
        }
Пример #3
0
        private PriceDocument GetDocument(DataSets.Product.ProductsRow productRow, Token lastToken, NorthwindConfig config)
        {
            #region Declarations
            PriceDocument priceDoc;
            string identity;
            #endregion

            identity = productRow.ProductID.ToString();

            // create Account Doc
            priceDoc = new PriceDocument();
            priceDoc.Id = identity;

            if (lastToken.InitRequest)
                priceDoc.LogState = LogState.Created;

            else if (productRow.IsCreateIDNull() || productRow.IsModifyIDNull()
                || productRow.IsCreateUserNull() || productRow.IsModifyUserNull())
                priceDoc.LogState = LogState.Created;

            else if ((productRow.CreateID > lastToken.SequenceNumber)
                 && (productRow.CreateUser != config.CrmUser))
                priceDoc.LogState = LogState.Created;

            else if ((productRow.CreateID == lastToken.SequenceNumber)
                && (productRow.CreateUser != config.CrmUser)
                && (identity.CompareTo(lastToken.Id.Id) > 0))
                priceDoc.LogState = LogState.Created;
            else if ((productRow.ModifyID >= lastToken.SequenceNumber) && (productRow.ModifyUser != config.CrmUser))
                priceDoc.LogState = LogState.Updated;

            priceDoc.active.Value = true;

            priceDoc.price_cid.Value = config.CurrencyCode;

            priceDoc.pricinglistid.Value = Constants.DefaultValues.PriceList.ID;

            priceDoc.productid.Value = identity;

            priceDoc.uomid.Value = identity;

            priceDoc.price.Value = productRow.IsUnitPriceNull() ? new Decimal(0) : productRow.UnitPrice;

            return priceDoc;
        }