Beispiel #1
0
        private LineItem GetLineItem(Domain.PrintItem printItem)
        {
            var strategy = GetItemStrategy(printItem);

            return(new LineItem()
            {
                Name = printItem.Name,
                Amount = strategy.CalculateTotal(printItem),
                TaxAmount = strategy.CalculateTax(printItem)
            });
        }
Beispiel #2
0
        /// <summary>
        /// Decides best calculation strategy for a line item
        /// </summary>
        /// <param name="printItem"></param>
        /// <returns></returns>
        private IPrintItemCalculationStrategy GetItemStrategy(Domain.PrintItem printItem)
        {
            if (printItem.Taxation == TaxationType.Standard)
            {
                return(new StandardTaxCalulcationStrategy());
            }
            if (printItem.Taxation == TaxationType.TaxFree)
            {
                return(new TaxFreeItemCalculationStrategy());
            }

            throw new Exception("Unknown taxation: " + printItem.Taxation);
        }
 public override decimal CalculateTax(Domain.PrintItem item)
 {
     return(Round(item.Cost * TaxAmount));
 }
 public override decimal CalculateTax(Domain.PrintItem item)
 {
     return(0.00m);
 }
 public virtual decimal CalculateTotal(Domain.PrintItem item)
 {
     return(Round(item.Cost));
 }
 public abstract decimal CalculateTax(Domain.PrintItem item);