/// <summary> /// Populates a item totals list with the items provided by an /// order request. /// </summary> public void InitializeTotals(OrderItems items) { foreach (OrderItem_V01 item in items) { item.ReferenceID = Guid.NewGuid(); // Clean up SKUs. item.SKU = item.SKU.Trim(); // Add a new Item total which corresponds to the OrderItem to the list. ItemTotal_V01 itemTotal = new ItemTotal_V01(item.SKU, item.Quantity, 0, 0, 0, 0, 0, new ChargeList()); // Associate item total to order item for later lookups. itemTotal.ReferenceID = item.ReferenceID; this.Add(itemTotal); } }
public static decimal getDistributorPrice(ItemTotal_V01 lineItem, decimal discount, string locale) { var prodType = ProductType.Product; var catalogItem = CatalogProvider.GetCatalogItem(lineItem.SKU, locale.Substring(3)); if (catalogItem != null) { prodType = catalogItem.ProductType; } int marketingFundPercent = discount == 31 ? 10 : 5; var roundMode = MidpointRounding.AwayFromZero; decimal PH = prodType == ProductType.Literature ? 0 : Math.Round(lineItem.LinePrice * 7 / 100.0M, roundMode); decimal marketingFund = (lineItem.SKU == "4115" || lineItem.SKU == "4116") ? 0 : Math.Round(lineItem.LinePrice * marketingFundPercent / 1000.0M, roundMode); decimal discountAmt = prodType == ProductType.Product ? Math.Round(lineItem.LinePrice * discount / 100.0M, roundMode) : 0; decimal discountedPrice = lineItem.LinePrice - discountAmt; decimal tax = Math.Round(((discountedPrice + PH + marketingFund) * 10) / 100.0M, roundMode); return(discountedPrice + tax + marketingFund + PH); }