Пример #1
0
        public virtual decimal GetTotal(IProductOrder item)
        {
            int     units     = item.GetUnits();
            decimal unitPrice = item.GetUnitPrice();

            return(units * unitPrice);
        }
Пример #2
0
        public override decimal GetTotal(IProductOrder item)
        {
            var     regularPrice   = base.GetTotal(item);
            decimal volumeDiscount = 0;
            int     units          = item.GetUnits();
            decimal unitPrice      = item.GetUnitPrice();

            if (units >= _volumeThreshold)
            {
                volumeDiscount = _volumeThreshold * unitPrice - _volumePrice;

                int multiplyDiscount = units / _volumeThreshold;

                //Handle if volumeThreshold is 3 and units are 6 then the discount should be applied twice
                if (multiplyDiscount > 1)
                {
                    volumeDiscount *= multiplyDiscount;
                }
            }

            return(regularPrice - volumeDiscount);
        }