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); } }
public decimal CalculateDiscount(IShoppingCartEntry cartEntry) { if (cartEntry.SKU != SKU) { return(0); } return(this.Discount * (cartEntry.Quantity / this.Quantity)); }
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); }