public decimal GetAllDiscounts(IList <string> scannedItems, IItemCatalogue itemCatalogue) { var discounts = 0m; foreach (var offer in _currentOffers) { var discountAndProportion = offer.DiscountItemAndProportion(); var timesApplicable = offer.TimesApplicable(scannedItems); var itemPrice = itemCatalogue.LookupPrice(discountAndProportion.Item); var priceProportion = discountAndProportion.Proportion; discounts += itemPrice * priceProportion * timesApplicable; } return(-discounts); }
public Checkout(IItemCatalogue itemCatalogue, IOffersService offersService) { _itemCatalogue = itemCatalogue; _offersService = offersService; }