コード例 #1
0
ファイル: TaxSplitter.cs プロジェクト: appliedi/MerchantTribe
 private static decimal SumUpDiscounts(LineItemDTO li)
 {
     if (li.DiscountDetails != null)
     {
         return (li.DiscountDetails).Sum(y => y.Amount);
     }
     return 0;
 }
コード例 #2
0
ファイル: Migrator.cs プロジェクト: appliedi/MerchantTribe
        private List<LineItemDTO> TranslateItems(data.bvc_Order o)
        {
            List<LineItemDTO> result = new List<LineItemDTO>();

            foreach (data.bvc_OrderItem item in o.bvc_OrderItem)
            {
                LineItemDTO li = new LineItemDTO();

                li.BasePricePerItem = ((decimal)item.LineTotal / (decimal)item.Qty);
                li.CustomProperties = TranslateOldProperties(item.ExtraInformation);
                li.DiscountDetails = new List<DiscountDetailDTO>();
                li.ExtraShipCharge = 0;
                li.Id = -1;
                li.LastUpdatedUtc = DateTime.UtcNow;
                li.OrderBvin = o.ID.ToString();
                li.ProductId = item.ProductID;
                li.ProductName = item.DisplayDescription;
                li.ProductShortDescription = item.DisplayDescription;

                li.ProductSku = item.ProductID;
                var displaySku = li.CustomProperties.Where(y => y.Key == "BVDISPLAYSKU").FirstOrDefault();
                if (displaySku != null)
                {
                    li.ProductSku = displaySku.Value;
                }
                li.ProductShippingHeight = (decimal)item.Height;
                li.ProductShippingLength = (decimal)item.Length;
                li.ProductShippingWeight = (decimal)item.Weight;
                li.ProductShippingWidth = (decimal)item.Width;
                li.Quantity = (int)item.Qty;
                li.QuantityReturned = (int)item.QtyReturned;
                li.QuantityShipped = (int)item.QtyShipped;
                li.SelectionData = new List<OptionSelectionDTO>();
                li.ShipFromAddress = new AddressDTO();
                li.ShipFromMode = ShippingModeDTO.ShipFromSite;
                li.ShipFromNotificationId = string.Empty;
                li.ShippingPortion = 0;
                li.ShippingSchedule = 0;
                li.ShipSeparately = false;
                li.StatusCode = string.Empty;
                li.StatusName = string.Empty;
                li.TaxPortion = 0m;
                li.TaxSchedule = 0;
                li.VariantId = string.Empty;

                // Calculate Adjustments and Discounts
                decimal lineTotal = (decimal)item.LineTotal;
                decimal prediscountTotal = (li.BasePricePerItem * (decimal)li.Quantity);
                decimal allDiscounts = prediscountTotal - lineTotal;
                if (allDiscounts != 0)
                {
                    li.DiscountDetails.Add(new DiscountDetailDTO() { Amount = -1 * allDiscounts, Description = "BVC2004 Discounts", Id = new Guid() });
                }

                result.Add(li);
            }

            return result;
        }
コード例 #3
0
ファイル: Migrator.cs プロジェクト: thepaleone/MerchantTribe
        private List<LineItemDTO> TranslateItems(string orderBvin)
        {
            List<LineItemDTO> result = new List<LineItemDTO>();

            data.BV53Entities db = new data.BV53Entities(EFConnString(settings.SourceConnectionString()));

            var old = db.bvc_LineItem.Where(y => y.OrderBvin == orderBvin);
            if (old == null) return result;

            foreach (data.bvc_LineItem item in old)
            {
                LineItemDTO li = new LineItemDTO();

                li.BasePricePerItem = item.BasePrice;
                li.CustomProperties = TranslateOldProperties(item.CustomProperties);
                li.DiscountDetails = new List<DiscountDetailDTO>();
                li.ExtraShipCharge = 0;
                li.Id = -1;
                li.LastUpdatedUtc = item.LastUpdated;
                li.OrderBvin = orderBvin;
                li.ProductId = item.ProductId;
                li.ProductName = item.ProductName;
                li.ProductShortDescription = item.ProductShortDescription;
                li.ProductSku = item.ProductSku;
                li.ProductShippingHeight = 0;
                li.ProductShippingLength = 0;
                li.ProductShippingWeight = 0;
                li.ProductShippingWidth = 0;
                li.Quantity = (int)item.Quantity;
                li.QuantityReturned = (int)item.QuantityReturned;
                li.QuantityShipped = (int)item.QuantityShipped;
                li.SelectionData = new List<OptionSelectionDTO>();
                li.ShipFromAddress = new AddressDTO();
                li.ShipFromMode = ShippingModeDTO.ShipFromSite;
                li.ShipFromNotificationId = string.Empty;
                li.ShippingPortion = 0;
                li.ShippingSchedule = 0;
                li.ShipSeparately = false;
                li.StatusCode = item.StatusCode;
                li.StatusName = item.StatusName;
                li.TaxPortion = 0m;
                li.TaxSchedule = 0;
                li.VariantId = string.Empty;

                // Calculate Adjustments and Discounts
                decimal lineTotal = item.LineTotal;
                decimal prediscountTotal = (li.BasePricePerItem * (decimal)li.Quantity);
                decimal allDiscounts = prediscountTotal - lineTotal;
                if (allDiscounts != 0)
                {
                    li.DiscountDetails.Add(new DiscountDetailDTO() { Amount = -1 * allDiscounts, Description = "BV5 Discounts", Id = new Guid() });
                }

                result.Add(li);
            }

            return result;
        }
コード例 #4
0
ファイル: TaxSplitter.cs プロジェクト: appliedi/MerchantTribe
 public static decimal LineTotalForItem(LineItemDTO li)
 {                        
     decimal result = li.BasePricePerItem * li.Quantity;
     result += SumUpDiscounts(li);
     return result;            
 }