private void OnDecreaseQuantity()
 {
     if (SelectedOrderItem == null)
     {
         MessageBox.Show("Select item to decrease quantity");
         return;
     }
     //Check if the product was already selected
     if (OrderItems.Any(p => p.UPCCode == SelectedOrderItem.UPCCode))
     {
         if (OrderItems.First(p => p.UPCCode == SelectedOrderItem.UPCCode).Quantity <= 1)
         {
             if (SelectedOrderItem != null)
             {
                 MessageBoxResult result = MessageBox.Show("You are about to delete an item. Do you want to continue?", "Delete Item", MessageBoxButton.YesNo, MessageBoxImage.Question);
                 if (result == MessageBoxResult.Yes)
                 {
                     OrderItems.Remove(SelectedOrderItem);
                 }
                 ;
             }
         }
         else
         {
             OrderItems.First(p => p.UPCCode == SelectedOrderItem.UPCCode).Quantity -= 1;
             RaisePropertyChanged("OrderSubTotal");
             RaisePropertyChanged("OrderTax");
             RaisePropertyChanged("BalanceDue");
         }
     }
 }
Esempio n. 2
0
 public IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
 {
     if (!OrderItems.Any())
     {
         yield return(new ValidationResult("The order must have at least one item!", new [] { nameof(OrderItems) }));
     }
 }
Esempio n. 3
0
 public override void Validate()
 {
     if (!OrderItems.Any())
     {
         AddNewValidationMessage("Order must have OrderItem");
     }
 }
Esempio n. 4
0
        private void btnRemoveItem_Click(object sender, RoutedEventArgs e)
        {
            if (dgBeverages.SelectedItem != null)
            {
                ProductViewModel selected = dgBeverages.SelectedItem as ProductViewModel;

                if (selected != null)
                {
                    if (OrderItems.Any(i => i.Id == selected.AddedTo))
                    {
                        ProductViewModel       itemProductWasAddedTo = OrderItems.Where(i => i.Id == selected.AddedTo).Single();
                        ProductOptionViewModel addon = itemProductWasAddedTo.AddOnList.Where(a => a.Id == selected.Id).Single();
                        itemProductWasAddedTo.AddOnList.Remove(addon);
                    }

                    if (OrderItems.Any(i => i.AddedTo == selected.Id))
                    {
                        var addOnsToRemovedProuduct      = OrderItems.Where(i => i.AddedTo == selected.Id);
                        List <ProductViewModel> toRemove = new List <ProductViewModel>();
                        foreach (var addon in addOnsToRemovedProuduct)
                        {
                            toRemove.Add(addon);
                        }

                        foreach (var item in toRemove)
                        {
                            OrderItems.Remove(item);
                        }
                    }

                    OrderItems.Remove(selected);
                    dgBeverages.ItemsSource = OrderItems;
                }
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Subtotal
        /// </summary>
        /// <returns></returns>
        public int GetSubTotal()
        {
            var value = 0;

            if (OrderItems != null && OrderItems.Any())
            {
                OrderItems.ForEach(i => value += (i.GetExtendedPrice()));
            }
            return(value);
        }
Esempio n. 6
0
 public void Add(Product product, int count = 1)
 {
     if (OrderItems.Any(x => x.Product == product))
     {
         OrderItems.Where(x => x.Product == product).First().Add(count);
     }
     else
     {
         OrderItems.Add(new OrderItem(product, count));
     }
 }
        private async void AddProduct(Product product)
        {
            this.decimalTextBox.Text    = "1";
            this.quantityDialog.Content = this.decimalTextBox;
            this.quantityDialog.Title   = "Enter quantity";
            ContentDialogResult result = await this.ShowQuantityDialog();

            if (result == ContentDialogResult.Primary)
            {
                TextBox input = (TextBox)quantityDialog.Content;
                decimal.TryParse(input.Text, out decimal quantity);
                if (quantity == 0)
                {
                    quantity = 1;
                }
                if (quantity <= product.Quantity)
                {
                    if (OrderItems.Any(p => p.OrderItem.ProductId == product.ProductId))
                    {
                        OrderItemListView existingItem = OrderItems.FirstOrDefault(p => p.OrderItem.ProductId == product.ProductId);
                        int index = OrderItems.IndexOf(existingItem);
                        existingItem.OrderItem.Quantity += quantity;
                        OrderItemListView orderItemListView = this.GetDuplicatedItem(existingItem);
                        OrderItems.RemoveAt(index);
                        OrderItems.Insert(index, orderItemListView);
                    }
                    else
                    {
                        OrderItemListView orderItem = new OrderItemListView
                        {
                            OrderItem = new OrderItem
                            {
                                Product      = product,
                                ProductId    = product.ProductId,
                                Quantity     = quantity,
                                LineDiscount = 0,
                                SubTotal     = this.GetSubTotal(product.SellingPrice, quantity, 0)
                            }
                        };
                        orderItem.ItemDeleteClicked += this.HandleItemDeleted;
                        OrderItems.Add(orderItem);
                    }
                    RaisePropertyChanged("OrderItems");
                    RaisePropertyChanged("IsProceedEnabled");
                }
                else
                {
                    this.messageDialog.Content = "Insufficient quantity !";
                    await this.messageDialog.ShowAsync();
                }
                this.SearchText = product.Name;
            }
            this.SearchText = string.Empty;
        }
Esempio n. 8
0
 public void Remove(Product product, int count = 1)
 {
     if (OrderItems.Any(x => x.Product == product))
     {
         OrderItem item = OrderItems.Where(x => x.Product == product).First();
         item.Remove(count);
         if (0 == item.Quontity)
         {
             OrderItems.Remove(item);
         }
     }
 }
Esempio n. 9
0
        public void AddOrderItem(Book book, int quantity, decimal price)
        {
            if (!OrderItems.Any(oi => oi.BookOrdered.BookId == book.Id))
            {
                _orderItems.Add(new OrderItem(
                                    quantity,
                                    price,
                                    new BookItemSnapshot(book.Id, book.Title, book.ImageUrl))
                                );
                return;
            }
            var existingItem = OrderItems.First(oi => oi.BookOrdered.BookId == book.Id);

            existingItem.Quantity += quantity;
        }
 private void ReceiveMessage(Product product)
 {
     //Check if the product was already selected
     if (OrderItems.Any(p => p.UPCCode == product.UPCCode))
     {
         OrderItems.First(p => p.UPCCode == product.UPCCode).Quantity += 1;
         RaisePropertyChanged("OrderSubTotal");
         RaisePropertyChanged("OrderTax");
         RaisePropertyChanged("BalanceDue");
     }
     else
     {
         OrderItems.Add(new POS_DataLibrary.OrderItems
         {
             UPCCode      = product.UPCCode,
             CategoryName = product.CategoryName.ToString(),
             CategoryId   = product.CategoryId,
             Quantity     = 1,
             Price        = product.Price,
             Name         = product.Name
         });
     }
 }
Esempio n. 11
0
 // Check if the order contains the given produce and it's value is not 0
 public bool OrderContains(string name)
 {
     return(OrderItems.Any(ele => ele.Name.Equals(name) && ele.Amount > 0));
 }
Esempio n. 12
0
 // Check if the order is complete
 // True if complete, false otherwise
 public bool CheckOrder()
 {
     return(OrderItems.Any(ele => ele.Amount > 0));
 }
        private void CalculateTaxAmount(InvoiceModel invoice, string memberId, string countryCode, Address address,
                                        string warehouseCode, string shippingMethodId)
        {
            if (invoice.InvoicePrice.TaxPercentage > 0)
            {
                invoice.InvoicePrice.CalcTaxAmount =
                    decimal.Round(
                        ((invoice.InvoicePrice.SubTotal - invoice.InvoicePrice.CalcDiscountAmount) *
                         (invoice.InvoicePrice.TaxPercentage / 100)), 2);
                invoice.InvoicePrice.DisplayCalculatedTax = invoice.InvoicePrice.CalcTaxAmount.FormatPrice();
            }
            else if (invoice.InvoicePrice.TaxAmount > 0)
            {
                invoice.InvoicePrice.CalcTaxAmount        = invoice.InvoicePrice.TaxAmount;
                invoice.InvoicePrice.DisplayCalculatedTax = invoice.InvoicePrice.CalcTaxAmount.FormatPrice();
            }
            else if (invoice.InvoicePrice.TaxAmount == 0 && invoice.InvoicePrice.TaxPercentage == 0 && (invoice.IsCustomerTaxEdited && !invoice.ResetCustomerTaxValue))
            {
                invoice.InvoicePrice.CalcTaxAmount        = invoice.InvoicePrice.TaxAmount;
                invoice.InvoicePrice.DisplayCalculatedTax = invoice.InvoicePrice.CalcTaxAmount.FormatPrice();
            }
            else
            {
                var customerOrder = ConvertToCustomerOrder(invoice, memberId, countryCode, address, warehouseCode,
                                                           shippingMethodId);


                var productTax = 0M;
                var freightTax = 0M;

                var customerOrderItems = new OrderItems();

                foreach (CustomerOrderItem_V01 item in customerOrder.OrderItems)
                {
                    customerOrderItems.Add(item);
                }


                if (customerOrderItems.Any())
                {
                    customerOrder.OrderItems = null;
                    customerOrder.OrderItems = customerOrderItems;

                    var response = CallDwsPricing(customerOrder);
                    if (null != response && response.Status == ServiceProvider.OrderSvc.ServiceResponseStatusType.Success)
                    {
                        var responseV01 = response as GetTaxDataForDwsFromVertexResponse_V01;
                        if (responseV01 == null)
                        {
                            LoggerHelper.Error(
                                string.Format(
                                    "CalculateDistributorPrice - InvoicePriceProvider: An error occured while invoking CalculateDistributorPrice"
                                    ));
                        }
                        else
                        {
                            productTax += responseV01.ProductTaxData.AsParallel().Sum(x => x.Value);
                            freightTax += responseV01.FreightTaxData.AsParallel().Sum(x => x.Value);
                        }
                    }
                    else
                    {
                        LoggerHelper.Error(
                            string.Format(
                                "CalculateDistributorPrice - InvoicePriceProvider: An error occured while invoking CalculateDistributorPrice {0}",
                                memberId));
                    }
                }

                invoice.InvoicePrice.CalcTaxAmount        = productTax + freightTax;
                invoice.InvoicePrice.TaxAmount            = invoice.InvoicePrice.CalcTaxAmount;
                invoice.InvoicePrice.DisplayCalculatedTax = invoice.InvoicePrice.CalcTaxAmount.FormatPrice();
            }
        }
Esempio n. 14
0
        //Checks if Basket is empty.
        public bool EmptyBasket()
        {
            bool isEmpty = !OrderItems.Any();

            return(isEmpty);
        }
Esempio n. 15
0
 public bool IsOrderItemSkuInOrder(string sku)
 {
     return(OrderItems.Any(oi => string.Equals(oi.ProductOption.Sku.ToUpper(), sku.ToUpper())));
 }
Esempio n. 16
0
 public bool IsOrderItemInOrder(OrderItem orderItem)
 {
     return(OrderItems.Any(oi => oi.ProductOption.Sku == orderItem.ProductOption.Sku));
 }