Пример #1
0
 public void ApplyTaxes(IShoppingCartEntry shoppingCartEntry)
 {
     if (shoppingCartEntry.Product.Origin == Origin.Foreign)
     {
         decimal tax = TaxRounder.Round(shoppingCartEntry.Product.Price * shoppingCartEntry.Quantity * 0.05m);
         shoppingCartEntry.Taxes.Add(TaxType.ImportDuty, tax);
     }
 }
Пример #2
0
        public decimal CalculateDiscount(IShoppingCartEntry cartEntry)
        {
            if (cartEntry.SKU != SKU)
            {
                return(0);
            }

            return(this.Discount * (cartEntry.Quantity / this.Quantity));
        }
Пример #3
0
 public void ApplyTaxes(IShoppingCartEntry shoppingCartEntry)
 {
     if (!(typeof(IBook).IsAssignableFrom(shoppingCartEntry.Product.GetType()) ||
           typeof(IMedicine).IsAssignableFrom(shoppingCartEntry.Product.GetType()) ||
           typeof(IFood).IsAssignableFrom(shoppingCartEntry.Product.GetType())))  // Exemptions list could be configured
     {
         decimal tax = TaxRounder.Round(shoppingCartEntry.Product.Price * shoppingCartEntry.Quantity * 0.1m);
         shoppingCartEntry.Taxes.Add(TaxType.SalesTax, tax);
     }
 }
        public decimal CalculateDiscount(IShoppingCartEntry cartEntry)
        {
            decimal discount = 0;

            foreach (var rule in _rules)
            {
                discount += rule.CalculateDiscount(cartEntry);
            }

            return(discount);
        }