Ejemplo n.º 1
0
        protected virtual OrderLine GetOrderLine(ActiveCommerce.Orders.Legacy.OrderLine cartLine, string currencyCode, string discountCode)
        {
            Assert.ArgumentNotNull(cartLine, "cartLine");
            Assert.ArgumentNotNullOrEmpty(currencyCode, "currencyCode");

            var orderLine = OrderFactory.CreateOrderLine();
            var lineItem  = OrderFactory.CreateLineItem();
            var item      = OrderFactory.CreateItem();

            item.Code = cartLine.Product.Code;
            item.Sku  = cartLine.Product.SKU;
            item.Name = cartLine.Product.Title;
            item.AdditionalInformation = cartLine.Details;
            item.Type = cartLine.Type;

            lineItem.Item                = item;
            lineItem.Price               = OrderFactory.CreatePrice(OrderFactory.CreateAmount(cartLine.Totals.PriceExVat, currencyCode), cartLine.Quantity);
            lineItem.TotalTaxAmount      = OrderFactory.CreateAmount(cartLine.Totals.TotalVat, currencyCode);
            lineItem.LineExtensionAmount = OrderFactory.CreateAmount(cartLine.Totals.TotalPriceExVat, currencyCode);
            lineItem.Quantity            = cartLine.Quantity;
            orderLine.LineItem           = lineItem;

            if (cartLine.Totals.DiscountIncVat > 0)
            {
                orderLine.AllowanceCharge.Add(GetAllowanceCharge(cartLine.Totals.DiscountExVat, discountCode, currencyCode));
            }

            return(orderLine);
        }