Exemplo n.º 1
0
 // TODO: dlong - refactor into extension methods?
 public static int CalculateIngredientDiscountAmount(RecipeIngredientBase input)
 {
     if (input.IsOrganic)
     {
         return input.Cost - (int)Math.Round(CalculateIngredientDiscountedPrice(input), MidpointRounding.AwayFromZero);
     }
     else
     {
         return 0;
     }
 }
Exemplo n.º 2
0
 public static float CalculateIngredientDiscountedPrice(RecipeIngredientBase input)
 {
     if (input.IsOrganic)
     {
         return input.Cost * DISCOUNT_PERCENTAGE;
     }
     else
     {
         return (float)input.Cost;
     }
 }
Exemplo n.º 3
0
        public static int CalculateIngredientTax(RecipeIngredientBase input, float extendedPrice)
        {
            if (input.IsProduce)
            {
                return 0;
            }
            else
            {
                // HACK: dlong - for review - Not sure why we'd take the ceiling here but based on the supplied data/unit tests
                // this is what needs to happen to make it work

                //int tax = (int)Math.Round(extendedPrice * TAX_RATE, MidpointRounding.AwayFromZero);
                int tax = (int)Math.Ceiling(extendedPrice * TAX_RATE);

                while (tax % 7 != 0)
                {
                    tax += 1;
                }

                return tax;
            }
        }
Exemplo n.º 4
0
 public RecipeLineItem(RecipeIngredientBase ingredient, float units)
 {
     this.Ingredient = ingredient;
     this.Units = units;
 }