Ejemplo n.º 1
0
        public async Task StartAsync()
        {
            var orderId = Guid.NewGuid();
            var order   = await OrderSteps.CreateOrder(_orderServiceApi, orderId, _context.StoreId);


            var menuItems = _menuAvailabilityHelper.GetAvailableMenuItems()
                            .Where(
                a => a.ModifierGroups.Any(b => b.CommonModifiers.Any())
                );
            var menuItemsCount = menuItems.Count();

            Assert.IsTrue(menuItemsCount > 0, "Menuitems with common modifiers not found");

            var i = new Random().Next(menuItemsCount);

            var menuitem        = menuItems.Skip(i).First();
            var commonModifiers = menuitem.ModifierGroups.First(a => a.CommonModifiers.Any()).CommonModifiers;

            var orderItemId = Guid.NewGuid();

            var orderitem = new RestaurantOrderItemDto()
            {
                OrderItemId        = orderItemId,
                MenuItemId         = menuitem.MenuItemId,
                MenuItemVersionIds = new VersionIdsDto()
                {
                    ItemVersionId          = menuitem.MenuItemVersionId,
                    PriceListItemVersionId = menuitem.PriceListItemVersionId,
                },
                OrderId         = order.OrderId,
                CommonModifiers = commonModifiers.Select(a => new OrderItemCommonModifierDto
                {
                    OrderItemId = orderItemId,
                    OrderId     = orderId,
                    ModifierId  = a.Id,
                    CommonModifierVersionIds = new VersionIdsDto()
                    {
                        ItemVersionId          = a.VersionId,
                        PriceListItemVersionId = a.PriceListItemVersionId,
                    },
                    Quantity = 1
                }).ToList(),
                RelatedModifiers = new List <OrderItemRelatedModifierDto>(),
                Quantity         = 1,
                CalculatedPrice  = menuitem.Price + commonModifiers.Sum(a => a.Price)
            };

            var response2 = await _orderServiceApi.AddOrderItem(orderitem);

            var response3 = await _orderServiceApi.GetOrderInfo(order.OrderId);

            Assert.AreEqual(1, response3.Value.OrderItemsCosts.Count);

            var cost = response3.Value.OrderItemsCosts.Sum(p => p.Value);

            Assert.IsTrue(cost > 0);

            await OrderSteps.PayAndClose(_orderServiceApi, order.OrderId, cost);
        }
        public async Task StartAsync()
        {
            var orderId = Guid.NewGuid();
            var order   = await OrderSteps.CreateOrder(_orderServiceApi, orderId, _context.StoreId);


            var menuItems = _menuAvailabilityHelper.GetAvailableMenuItems();

            var menuItemsCount = menuItems.Count;

            var i         = new Random().Next(menuItemsCount);
            var menuitem1 = menuItems.Skip(i).First();

            var orderitem1 = new RestaurantOrderItemDto()
            {
                OrderItemId        = Guid.NewGuid(),
                MenuItemId         = menuitem1.MenuItemId,
                MenuItemVersionIds = new VersionIdsDto()
                {
                    ItemVersionId          = menuitem1.MenuItemVersionId,
                    PriceListItemVersionId = menuitem1.PriceListItemVersionId,
                },
                OrderId          = order.OrderId,
                CommonModifiers  = new List <OrderItemCommonModifierDto>(),
                RelatedModifiers = new List <OrderItemRelatedModifierDto>(),
                Quantity         = 1,
                CalculatedPrice  = menuitem1.Price
            };

            var response2 = await _orderServiceApi.AddOrderItem(orderitem1);

            var response3 = await _orderServiceApi.GetOrderInfo(order.OrderId);

            Assert.AreEqual(1, response3.Value.OrderItemsCosts.Count);
            var cost = response3.Value.OrderItemsCosts.Sum(p => p.Value);

            var customersResponse = await _terminalApi.GetFilteredCustomers(new FilteredRequestDto
            {
                Skip    = 0,
                Take    = 20,
                Filters = null
            });

            var customers = customersResponse.Value;

            Assert.IsTrue(customers.Results.Any());

            var customer = customers.Results.First();

            var updateOrderCustomerResponce = await _orderServiceApi.UpdateOrderCustomer(orderId, customer.CustomerId.Value);

            Assert.IsNull(updateOrderCustomerResponce.PostprocessingType);
            await OrderSteps.PayAndClose(_orderServiceApi, order.OrderId, cost);
        }
        public async Task StartAsync()
        {
            var orderId = Guid.NewGuid();
            var order   = await OrderSteps.CreateOrder(_orderServiceApi, orderId, _context.StoreId);

            var menuItems = _menuAvailabilityHelper.GetAvailableMenuItems();

            var menuItemsCount = menuItems.Count;

            var i         = new Random().Next(menuItemsCount);
            var menuitem1 = menuItems.Skip(i).First();

            var orderitem1 = new RestaurantOrderItemDto()
            {
                OrderItemId        = Guid.NewGuid(),
                MenuItemId         = menuitem1.MenuItemId,
                MenuItemVersionIds = new VersionIdsDto()
                {
                    ItemVersionId          = menuitem1.MenuItemVersionId,
                    PriceListItemVersionId = menuitem1.PriceListItemVersionId,
                },
                OrderId          = order.OrderId,
                CommonModifiers  = new List <OrderItemCommonModifierDto>(),
                RelatedModifiers = new List <OrderItemRelatedModifierDto>(),
                Quantity         = 1,
                CalculatedPrice  = menuitem1.Price
            };

            var response2 = await _orderServiceApi.AddOrderItem(orderitem1);

            var response3 = await _orderServiceApi.GetOrderInfo(order.OrderId);

            Assert.AreEqual(1, response3.Value.OrderItemsCosts.Count);
            var cost = response3.Value.OrderItemsCosts.Sum(p => p.Value);

            var discounts = await _terminalApi.GetAllDiscounts(_context.StoreId);

            Assert.IsTrue(discounts.Value.Any(a => a.IsActive && a.Value > 0));

            var discount = discounts.Value.First(a => a.IsActive && a.Value > 0);

            var addDiscountResponse = await _orderServiceApi.AddDiscount(
                new AddDiscountDto()
            {
                DiscountVersionId = discount.DiscountVersionId,
                IsAggregate       = discount.BitSettings.HasFlag(DiscountSettings.IsAggregatable),
                Type = DiscountType.ManualDiscount
            });

            Assert.IsNull(addDiscountResponse.PostprocessingType);

            await OrderSteps.PayAndClose(_orderServiceApi, order.OrderId, cost);
        }
Ejemplo n.º 4
0
        public async Task StartAsync()
        {
            var orderId = Guid.NewGuid();
            var order   = await OrderSteps.CreateOrder(_orderServiceApi, orderId, _context.StoreId);

            var menuItems = _menuAvailabilityHelper.GetAvailableMenuItems();

            var menuItemsCount = menuItems.Count;

            var i         = new Random().Next(menuItemsCount);
            var menuitem1 = menuItems.Skip(i).First();

            var orderitem1 = new RestaurantOrderItemDto()
            {
                OrderItemId        = Guid.NewGuid(),
                MenuItemId         = menuitem1.MenuItemId,
                MenuItemVersionIds = new VersionIdsDto()
                {
                    ItemVersionId          = menuitem1.MenuItemVersionId,
                    PriceListItemVersionId = menuitem1.PriceListItemVersionId,
                },
                OrderId          = order.OrderId,
                CommonModifiers  = new List <OrderItemCommonModifierDto>(),
                RelatedModifiers = new List <OrderItemRelatedModifierDto>(),
                Quantity         = 1,
                CalculatedPrice  = menuitem1.Price
            };

            var response2 = await _orderServiceApi.AddOrderItem(orderitem1);

            var response3 = await _orderServiceApi.GetOrderInfo(order.OrderId);

            Assert.AreEqual(1, response3.Value.OrderItemsCosts.Count);
            var cost = response3.Value.OrderItemsCosts.Sum(p => p.Value);

            var addTaxExemptResponse = await _orderServiceApi.UpdateTaxExempt(orderId, true);

            Assert.AreEqual(null, addTaxExemptResponse.PostprocessingType);

            await OrderSteps.PayAndClose(_orderServiceApi, order.OrderId, cost);
        }
Ejemplo n.º 5
0
        public async Task StartAsync()
        {
            var orderId = Guid.NewGuid();
            var order   = await OrderSteps.CreateOrder(_orderServiceApi, orderId, _context.StoreId);

            decimal cost           = 0;
            int     menuItemsCount = _context.FullMenu.MenuItems.Count;

            while (cost == 0)
            {
                var i          = new Random().Next(menuItemsCount);
                var menuitem1  = _context.FullMenu.MenuItems.Skip(i).First().Value;
                var orderitem1 = new RestaurantOrderItemDto()
                {
                    OrderItemId        = Guid.NewGuid(),
                    MenuItemId         = menuitem1.MenuItemId,
                    MenuItemVersionIds = new VersionIdsDto()
                    {
                        ItemVersionId          = menuitem1.MenuItemVersionId,
                        PriceListItemVersionId = menuitem1.PriceListItemVersionId,
                    },
                    OrderId          = order.OrderId,
                    CommonModifiers  = new List <OrderItemCommonModifierDto>(),
                    RelatedModifiers = new List <OrderItemRelatedModifierDto>(),
                    Quantity         = 1,
                    CalculatedPrice  = menuitem1.Price
                };
                var response2 = await _orderServiceApi.AddOrderItem(orderitem1);

                var response3 = await _orderServiceApi.GetOrderInfo(order.OrderId);

                cost = response3.Value.OrderItemsCosts.Sum(p => p.Value);
            }
            var reciept = (await _orderServiceApi.GetOrderReceiptsByOrderId(order.OrderId)).Value.Single();

            await OrderSteps.PayAndClose(_orderServiceApi, order.OrderId, reciept.TotalAmount);
        }
        public async Task StartAsync()
        {
            var orderId = Guid.NewGuid();
            var order   = await OrderSteps.CreateOrder(_orderServiceApi, orderId, _context.StoreId);

            var menuItems = _menuAvailabilityHelper.GetAvailableMenuItems()
                            .Where(
                a => a.RelatedModifiers.Count > 1 &&
                a.ModifierGroups.Any(b => b.CommonModifiers.Any())
                );
            var menuItemsCount = menuItems.Count();

            Assert.IsTrue(menuItemsCount > 0);

            var i = new Random().Next(menuItemsCount);

            var menuitem         = menuItems.Skip(i).First();
            var relatedModifiers = menuitem.RelatedModifiers.Take(menuitem.RelatedModifiers.Count / 2);
            var commonModifiers  = menuitem.ModifierGroups.First(a => a.CommonModifiers.Any()).CommonModifiers;

            var orderItemId = Guid.NewGuid();

            var orderitem = new RestaurantOrderItemDto()
            {
                OrderItemId        = orderItemId,
                MenuItemId         = menuitem.MenuItemId,
                MenuItemVersionIds = new VersionIdsDto()
                {
                    ItemVersionId          = menuitem.MenuItemVersionId,
                    PriceListItemVersionId = menuitem.PriceListItemVersionId,
                },
                OrderId         = order.OrderId,
                CommonModifiers = commonModifiers.Select(a => new OrderItemCommonModifierDto
                {
                    OrderItemId = orderItemId,
                    OrderId     = orderId,
                    ModifierId  = a.Id,
                    CommonModifierVersionIds = new VersionIdsDto()
                    {
                        ItemVersionId          = a.VersionId,
                        PriceListItemVersionId = a.PriceListItemVersionId,
                    },
                    Quantity = 1
                }).ToList(),
                RelatedModifiers = relatedModifiers.Select(a => new OrderItemRelatedModifierDto
                {
                    OrderId                   = orderId,
                    OrderItemId               = orderItemId,
                    Quantity                  = 1,
                    RelatedModifierId         = a.Id,
                    RelatedModifierVersionIds = new VersionIdsDto()
                    {
                        ItemVersionId          = a.VersionId,
                        PriceListItemVersionId = a.PriceListItemVersionId,
                    },
                }).ToList(),
                Quantity        = 1,
                CalculatedPrice = menuitem.Price + relatedModifiers.Sum(a => a.Price) + commonModifiers.Sum(a => a.Price)
            };

            var response2 = await _orderServiceApi.AddOrderItem(orderitem);

            var response3 = await _orderServiceApi.GetOrderInfo(order.OrderId);

            Assert.AreEqual(1, response3.Value.OrderItemsCosts.Count);

            var cost = response3.Value.OrderItemsCosts.Sum(p => p.Value);

            Assert.IsTrue(cost > 0);

            var commonModifier  = commonModifiers.First();
            var relatedModifier = relatedModifiers.First();

            #region Remove modifiers


            var response4 = await _orderServiceApi.UpdateOrderItem(new RestaurantOrderItemDto()
            {
                OrderItemId     = orderItemId,
                OrderId         = order.OrderId,
                CommonModifiers = commonModifiers.Where(a => a.Id != commonModifier.Id).Select(a => new OrderItemCommonModifierDto
                {
                    OrderItemId = orderItemId,
                    OrderId     = orderId,
                    ModifierId  = a.Id,
                    CommonModifierVersionIds = new VersionIdsDto()
                    {
                        ItemVersionId          = a.VersionId,
                        PriceListItemVersionId = a.PriceListItemVersionId,
                    },
                    Quantity = 1
                }).ToList(),
                RelatedModifiers = relatedModifiers.Where(a => a.Id != relatedModifier.Id).Select(a => new OrderItemRelatedModifierDto
                {
                    OrderId                   = orderId,
                    OrderItemId               = orderItemId,
                    Quantity                  = 1,
                    RelatedModifierId         = a.Id,
                    RelatedModifierVersionIds = new VersionIdsDto()
                    {
                        ItemVersionId          = a.VersionId,
                        PriceListItemVersionId = a.PriceListItemVersionId,
                    },
                }).ToList(),
                Quantity = 1,
            });

            #endregion

            var costs = await _orderServiceApi.GetOrderInfo(order.OrderId);

            var newCost = costs.Value.OrderItemsCosts.Sum(a => a.Value);
            Assert.IsTrue(newCost <= cost);
            cost = newCost;

            #region Add modifiers

            var response5 = await _orderServiceApi.UpdateOrderItem(new RestaurantOrderItemDto()
            {
                OrderItemId     = orderItemId,
                OrderId         = order.OrderId,
                CommonModifiers = commonModifiers.Select(a => new OrderItemCommonModifierDto
                {
                    OrderItemId = orderItemId,
                    OrderId     = orderId,
                    ModifierId  = a.Id,
                    CommonModifierVersionIds = new VersionIdsDto()
                    {
                        ItemVersionId          = a.VersionId,
                        PriceListItemVersionId = a.PriceListItemVersionId,
                    },
                    Quantity = 1
                }).ToList(),
                RelatedModifiers = relatedModifiers.Select(a => new OrderItemRelatedModifierDto
                {
                    OrderId                   = orderId,
                    OrderItemId               = orderItemId,
                    Quantity                  = 1,
                    RelatedModifierId         = a.Id,
                    RelatedModifierVersionIds = new VersionIdsDto()
                    {
                        ItemVersionId          = a.VersionId,
                        PriceListItemVersionId = a.PriceListItemVersionId,
                    },
                }).ToList(),
                Quantity = 1,
            });

            #endregion

            costs = await _orderServiceApi.GetOrderInfo(order.OrderId);

            newCost = costs.Value.OrderItemsCosts.Sum(a => a.Value);
            Assert.IsTrue(newCost >= cost);
            cost = newCost;

            #region Update quantity

            var response6 = await _orderServiceApi.UpdateOrderItem(new RestaurantOrderItemDto()
            {
                OrderItemId     = orderItemId,
                OrderId         = order.OrderId,
                CommonModifiers = commonModifiers.Select(a => new OrderItemCommonModifierDto
                {
                    OrderItemId = orderItemId,
                    OrderId     = orderId,
                    ModifierId  = a.Id,
                    CommonModifierVersionIds = new VersionIdsDto()
                    {
                        ItemVersionId          = a.VersionId,
                        PriceListItemVersionId = a.PriceListItemVersionId,
                    },
                    Quantity = 5
                }).ToList(),
                RelatedModifiers = relatedModifiers.Select(a => new OrderItemRelatedModifierDto
                {
                    OrderId                   = orderId,
                    OrderItemId               = orderItemId,
                    Quantity                  = 5,
                    RelatedModifierId         = a.Id,
                    RelatedModifierVersionIds = new VersionIdsDto()
                    {
                        ItemVersionId          = a.VersionId,
                        PriceListItemVersionId = a.PriceListItemVersionId,
                    },
                }).ToList(),
                Quantity = 1,
            });

            #endregion

            costs = await _orderServiceApi.GetOrderInfo(order.OrderId);

            newCost = costs.Value.OrderItemsCosts.Sum(a => a.Value);
            Assert.IsTrue(newCost >= cost);
            cost = newCost;
            await OrderSteps.PayAndClose(_orderServiceApi, order.OrderId, cost);
        }