private static ICollection <coreTax.TaxLine> GetContextTaxLines()
        {
            var item1 = new coreTax.TaxLine
            {
                Id     = Guid.NewGuid().ToString(),
                Price  = 20,
                Name   = "shoes",
                Code   = "SKU1",
                Amount = 1
            };
            var item2 = new coreTax.TaxLine
            {
                Id     = Guid.NewGuid().ToString(),
                Price  = 100,
                Name   = "t-shirt",
                Code   = "SKU2",
                Amount = 1
            };

            return(new[] { item1, item2 });
        }
 public static taxCoreModel.TaxRequest ToTaxRequest(this coreModel.QuoteRequest quoteRequest)
 {
     var retVal = new taxCoreModel.TaxRequest();
     retVal.Id = quoteRequest.Id;
     retVal.Code = quoteRequest.Number;
     retVal.Currency = quoteRequest.Currency;
     retVal.Address = quoteRequest.Addresses != null ? quoteRequest.Addresses.FirstOrDefault() : null;
     retVal.Type = quoteRequest.GetType().Name;
     foreach(var quoteItem in quoteRequest.Items)
     {
         var line = new taxCoreModel.TaxLine
         {
             Id = quoteItem.Id,
             Code = quoteItem.Sku,
             Name = quoteItem.Name,
             TaxType = quoteItem.TaxType,
             Amount = quoteItem.SelectedTierPrice.Price * quoteItem.SelectedTierPrice.Quantity
         };
         retVal.Lines.Add(line);
     }
     return retVal;
 }
 public static taxCoreModel.TaxRequest ToTaxRequest(this ShoppingCart cart)
 {
     var retVal = new taxCoreModel.TaxRequest();
     retVal.Id = cart.Id;
     retVal.Code = cart.Name;
     retVal.Currency = cart.Currency;
     retVal.Address = cart.Addresses != null ? cart.Addresses.FirstOrDefault() : null;
     retVal.Type = cart.GetType().Name;
     foreach (var cartItem in cart.Items)
     {
         var line = new taxCoreModel.TaxLine
         {
             Id = cartItem.Id,
             Code = cartItem.Sku,
             Name = cartItem.Name,
             TaxType = cartItem.TaxType,
             Amount = cartItem.SalePrice * cartItem.Quantity
         };
         retVal.Lines.Add(line);
     }
     return retVal;
 }
Exemplo n.º 4
0
        public static taxCoreModel.TaxEvaluationContext ToTaxEvalContext(this coreModel.QuoteRequest quoteRequest)
        {
            var retVal = new taxCoreModel.TaxEvaluationContext();

            retVal.Id       = quoteRequest.Id;
            retVal.Code     = quoteRequest.Number;
            retVal.Currency = quoteRequest.Currency;
            retVal.Address  = quoteRequest.Addresses != null?quoteRequest.Addresses.FirstOrDefault() : null;

            retVal.Type = quoteRequest.GetType().Name;
            foreach (var quoteItem in quoteRequest.Items)
            {
                var line = new taxCoreModel.TaxLine
                {
                    Id      = quoteItem.Id,
                    Code    = quoteItem.Sku,
                    Name    = quoteItem.Name,
                    TaxType = quoteItem.TaxType,
                    Amount  = quoteItem.SelectedTierPrice.Price * quoteItem.SelectedTierPrice.Quantity
                };
                retVal.Lines.Add(line);
            }
            return(retVal);
        }
Exemplo n.º 5
0
        public static taxCoreModel.TaxRequest ToTaxRequest(this ShoppingCart cart)
        {
            var retVal = new taxCoreModel.TaxRequest();

            retVal.Id       = cart.Id;
            retVal.Code     = cart.Name;
            retVal.Currency = cart.Currency;
            retVal.Address  = cart.Addresses != null?cart.Addresses.FirstOrDefault() : null;

            retVal.Type = cart.GetType().Name;
            foreach (var cartItem in cart.Items)
            {
                var line = new taxCoreModel.TaxLine
                {
                    Id      = cartItem.Id,
                    Code    = cartItem.Sku,
                    Name    = cartItem.Name,
                    TaxType = cartItem.TaxType,
                    Amount  = cartItem.SalePrice * cartItem.Quantity
                };
                retVal.Lines.Add(line);
            }
            return(retVal);
        }