private SalesOrderLineFeedEntry GetLineItem(Sage.Integration.Northwind.Adapter.Data.SalesOrders.DataSets.Order.CalculatedOrderDetailsRow row, NorthwindConfig config) { #region Declarations SalesOrderLineFeedEntry payload; string id; decimal discountPercentage; #endregion id = row.OrderID.ToString() + "-" + row.ProductID.ToString(); payload = new SalesOrderLineFeedEntry(); payload.UUID = GetUuid(id, "", SupportedResourceKinds.salesOrderLines); payload.commodity = (CommodityFeedEntry)_commoditiesFeedEntryWrapper.GetFeedEntry(row.ProductID.ToString()); /* payload.commodity = new CommodityFeedEntry(); payload.commodity.UUID = GetUuid(row.ProductID.ToString(), "", SupportedResourceKinds.commodities);*/ payload.salesOrder = new SalesOrderFeedEntry(); payload.salesOrder.UUID = GetUuid(row.OrderID.ToString(), "", SupportedResourceKinds.salesOrders); payload.unitOfMeasure = (UnitOfMeasureFeedEntry)_unitsOfMeasureFeedEntryWrapper.GetFeedEntry(row.ProductID.ToString()); /*payload.unitOfMeasure = new UnitOfMeasureFeedEntry(); payload.unitOfMeasure.UUID = GetUuid(row.ProductID.ToString(), "", SupportedResourceKinds.unitsOfMeasure);*/ payload.quantity = row.IsQuantityNull() ? Convert.ToInt16(0) : row.Quantity; payload.initialPrice = row.IsUnitPriceNull() ? new decimal(0) : row.UnitPrice; payload.orderLineDiscountPercent = row.IsDiscountNull() ? (decimal)0 : Convert.ToDecimal(row.Discount); payload.discountTotal = payload.initialPrice * (decimal)payload.orderLineDiscountPercent; payload.costTotal = (decimal)payload.initialPrice * (1 - payload.orderLineDiscountPercent); payload.netTotal = Convert.ToDecimal(payload.quantity) * Convert.ToDecimal(payload.costTotal); SetCommonProperties(id, payload, SupportedResourceKinds.salesOrderLines); return payload; }
private SalesInvoiceLineFeedEntry GetLineItem(Sage.Integration.Northwind.Adapter.Data.SalesOrders.DataSets.Order.CalculatedOrderDetailsRow row, NorthwindConfig config) { #region Declarations SalesInvoiceLineFeedEntry payload; string id; decimal discountPercentage; #endregion id = row.OrderID.ToString() + "-" + row.ProductID.ToString(); payload = new SalesInvoiceLineFeedEntry(); payload.Key = id; payload.Id = GetSDataId(payload.Key, SupportedResourceKinds.salesInvoiceLines); payload.UUID = GetUuid(id, "", SupportedResourceKinds.salesInvoiceLines); /*payload.commodity = (CommodityPayload)PayloadFactory.CreateResourcePayload( SupportedResourceKinds.commodities, row.ProductID.ToString(), _context.DatasetLink, true);*/ payload.commodity = new CommodityFeedEntry(); payload.commodity.Key = row.ProductID.ToString(); payload.commodity.Id = GetSDataId(payload.commodity.Key, SupportedResourceKinds.commodities); payload.commodity.UUID = GetUuid(row.ProductID.ToString(), "", SupportedResourceKinds.commodities); //payload.SalesInvoiceLinetype.salesInvoice = (SalesInvoicePayload)PayloadFactory.CreateResourcePayload( // SupportedResourceKinds.salesInvoices, row.OrderID.ToString(), _context.DatasetLink, true); //payload.SalesInvoiceLinetype.salesInvoice.Uuid = GetUuid(row.OrderID.ToString(), "", SupportedResourceKinds.salesInvoices); /*payload.unitOfMeasure = (UnitOfMeasurePayload)PayloadFactory.CreateResourcePayload( SupportedResourceKinds.unitsOfMeasure, row.ProductID.ToString(), _context.DatasetLink, true);*/ payload.unitOfMeasure = new UnitOfMeasureFeedEntry(); payload.unitOfMeasure.Key = row.ProductID.ToString(); payload.unitOfMeasure.Id = GetSDataId(payload.unitOfMeasure.Key, SupportedResourceKinds.unitsOfMeasure); payload.unitOfMeasure.UUID = GetUuid(row.ProductID.ToString(), "", SupportedResourceKinds.unitsOfMeasure); payload.quantity = row.IsQuantityNull() ? Convert.ToInt16(0) : row.Quantity; payload.initialPrice = row.IsUnitPriceNull() ? new decimal(0) : row.UnitPrice; payload.invoiceLineDiscountPercent = row.IsDiscountNull() ? (decimal)0 : Convert.ToDecimal(row.Discount); payload.discountTotal = (decimal)payload.initialPrice * (decimal)payload.invoiceLineDiscountPercent; payload.costTotal = (decimal)payload.initialPrice * (1 - payload.invoiceLineDiscountPercent); payload.netTotal = Convert.ToDecimal(payload.quantity) * Convert.ToDecimal(payload.costTotal); return payload; }