public List<ReceiptItemBO> CreateRecipeReceipt(RecipeBO recipe) { var receipt = new List<ReceiptItemBO>(); foreach (var ingr in recipe.Ingredients) { var beforeTax = BeforeTaxPrice(ingr); var product = new Repository<Product, long>().GetById(ingr.ProductId); var wellnessDiscountAmount = ((product.IsOrganic) ? Math.Round(beforeTax * (AppSettings.WellnessDiscountRate / 100), 2) : 0.00m); var itemTaxAmount = ((product.ProductType != Enums.ProductTypes.Produce) ? (Math.Round(beforeTax * (AppSettings.SalesTax / 100), 2)) : 0.00m); receipt.Add( new ReceiptItemBO() { Quantity = ingr.Quantity, ProductId = product.Id, ProductName = product.ProductName, UnitType = ingr.UnitType, ProductPrice = product.Price, ProductType = product.ProductType, WellnessDiscount = wellnessDiscountAmount, ItemTax = itemTaxAmount, BeforeTaxTotal = Math.Round(beforeTax, 2), ItemTotal = Math.Round((beforeTax - wellnessDiscountAmount) + itemTaxAmount, 2) } ); } return receipt; }
private RecipeBO CreateRecipeTwo() { var recipeTwo = new RecipeBO() { Id = 2, RecipeName = "RecipeTwo" }; var ingredients = new List<IngredientBO>(); ingredients.AddRange ( new IngredientBO[] { new IngredientBO() { Id = 6, ProductId = 1, Quantity = 1, RecipeId = 2, UnitType = Enums.UnitTypes.Clove }, new IngredientBO() { Id = 7, ProductId = 4, Quantity = 4, RecipeId = 2, UnitType = Enums.UnitTypes.None }, new IngredientBO() { Id = 8, ProductId = 7, Quantity = 0.5m, RecipeId = 2, UnitType = Enums.UnitTypes.Cup }, new IngredientBO() { Id = 9, ProductId = 8, Quantity = 0.5m, RecipeId = 2, UnitType = Enums.UnitTypes.Cup } } ); recipeTwo.Ingredients = ingredients; return recipeTwo; }
private RecipeBO CreateRecipeThree() { var recipeThree = new RecipeBO() { Id = 3, RecipeName = "RecipeThree" }; var ingredients = new List<IngredientBO>(); ingredients.AddRange ( new IngredientBO[] { new IngredientBO() { Id = 10, ProductId = 1, Quantity = 1, RecipeId = 3, UnitType = Enums.UnitTypes.Clove }, new IngredientBO() { Id = 11, ProductId = 3, Quantity = 4, RecipeId = 3, UnitType = Enums.UnitTypes.Cup }, new IngredientBO() { Id = 12, ProductId = 5, Quantity = 4, RecipeId = 3, UnitType = Enums.UnitTypes.Slice }, new IngredientBO() { Id = 13, ProductId = 6, Quantity = 8, RecipeId = 3, UnitType = Enums.UnitTypes.Ounce }, new IngredientBO() { Id = 14, ProductId = 7, Quantity = 0.33333333333m, RecipeId = 3, UnitType = Enums.UnitTypes.Cup }, new IngredientBO() { Id = 15, ProductId = 9, Quantity = 1.25m, RecipeId = 3, UnitType = Enums.UnitTypes.Teaspoon }, new IngredientBO() { Id = 16, ProductId = 10, Quantity = 0.75m, RecipeId = 3, UnitType = Enums.UnitTypes.Teaspoon } } ); recipeThree.Ingredients = ingredients; return recipeThree; }
//Helpers private RecipeBO CreateRecipeOne() { var recipeOne = new RecipeBO() { Id = 1, RecipeName = "RecipeOne" }; var ingredients = new List<IngredientBO>(); ingredients.AddRange ( new IngredientBO[] { new IngredientBO() { Id = 1, ProductId = 1, Quantity = 1, RecipeId = 1, UnitType = Enums.UnitTypes.Clove }, new IngredientBO() { Id = 2, ProductId = 2, Quantity = 1, RecipeId = 1, UnitType = Enums.UnitTypes.None }, new IngredientBO() { Id = 3, ProductId = 7, Quantity = 0.75m, RecipeId = 1, UnitType = Enums.UnitTypes.Cup }, new IngredientBO() { Id = 4, ProductId = 9, Quantity = 0.75m, RecipeId = 1, UnitType = Enums.UnitTypes.Teaspoon }, new IngredientBO() { Id = 5, ProductId = 10, Quantity = 0.5m, RecipeId = 1, UnitType = Enums.UnitTypes.Teaspoon } } ); recipeOne.Ingredients = ingredients; return recipeOne; }