private void RequestApproval(double amount) { string pendingApprover = approverChain.Approve(amount); OrderItems.Add(string.IsNullOrEmpty(pendingApprover) ? $"Expense of {amount} € was not approved by anyone" : $"Expense of {amount} € is pending at {pendingApprover}"); }
public void AddItem(OrderItem item) { if (item.Register()) { OrderItems.Add(item); } }
public void AddOrderItem(OrderItem orderItem) { DomainValidator.New().When(orderItem == null, "OrderItem cannot be null"); OrderItems.Add(orderItem); CalculateTotalItems(); }
public Order(long number, Guid orderTypeId, DateTime date, DateTime dueDate, Guid customerId, Guid?branchId, IEnumerable <OrderItem> items, IEnumerable <Guid> marketersIds) { Initilize(); Number = number; OrderTypeId = orderTypeId; Date = date; DueDate = dueDate; CustomerId = customerId; BranchId = branchId; foreach (var item in items) { OrderItems.Add(new OrderItem() { ItemUnitId = item.ItemUnitId, Quantity = item.Quantity }); } //foreach (var marketerId in marketersIds) //{ // OrderMarketers.Add(new OrderMarketer() // { // EmployeeId = marketerId // }); //} }
private void PrintStates() { OrderItems.Add($"I approved: {myself.TotalApproval}"); OrderItems.Add($"Local Manager approved: {localManager.TotalApproval}"); OrderItems.Add($"Level 2 Manager approved: {level2Manager.TotalApproval}"); OrderItems.Add($"Level 1 Manager approved: {level1Manager.TotalApproval}"); }
public void AddOrderItem(Guid productId, string productName, decimal unitPrice, decimal discount, string pictureUrl, int units = 1) { var existingOrderForProduct = OrderItems .SingleOrDefault(o => o.ProductId == productId); if (existingOrderForProduct != null) { //if previous line exist modify it with higher discount and units.. if (discount > existingOrderForProduct.Discount) { existingOrderForProduct.SetNewDiscount(discount); } existingOrderForProduct.AddUnits(units); } else { //add validated new order item var orderItem = new OrderItem(productId, productName, unitPrice, discount, pictureUrl, units); OrderItems.Add(orderItem); } }
private void Button_Click_2(object sender, RoutedEventArgs e) { string index = (sender as Button).Tag.ToString(); MenuItems food = foodMenu.Find(x => x.Id.ToString() == index); //int currentFoodinOrderIndex = orders.orders.FindIndex(x => x.Id == food.Id); //if (currentFoodinOrderIndex != -1) //{ // orders.ChangeQuantity(currentFoodinOrderIndex, food.Quantity); //} //else //{ orders.Add(new MenuItems() { Id = food.Id, Description = food.Description, Name = food.Name, Photo = food.Photo, Price = food.Price, Quantity = food.Quantity, }); // } Console.WriteLine(index); }
private void RequestApproval(double amount) { string approver = approverChain.Approve(amount); OrderItems.Add(string.IsNullOrEmpty(approver) ? $"Expense of {amount} € was not approved" : $"Expense of {amount} € was approved by {approver}"); }
private void AddGiftWrappingOnAll() { foreach (IOrderedItem item in OrderItems.ToList()) { OrderItems.Remove(item); OrderItems.Add(factory.AddGiftWrapping(item)); } }
private void RequestApproval(double amount) { string approver = null; OrderItems.Add(approverChain.Approve(amount, ref approver) ? $"Expense of {amount} € was approved by {approver}" : $"Expense of {amount} € was not approved"); }
private void OnApprovedRejected(double amount, string approver, bool accepted) { dispatcher.BeginInvoke(new Action(() => OrderItems.Add(string.IsNullOrEmpty(approver) ? $"Expense of {amount} € was not approved by anyone" : accepted ? $"Expense of {amount} € was approved by {approver}" : $"Expense of {amount} € was rejected by {approver}")) ); }
//When a new OrderItem is added, subtotal, tax, and total are //automatically updated. public void AddItemToOrder(OrderItem newOrderItem) { bool addItemToOrder = true; if (newOrderItem != null) { if (newOrderItem is Drink) { Drink drinkToAdd = (Drink)newOrderItem; if (UpdateDrinkIfAlreadyOnOrder(drinkToAdd)) { addItemToOrder = false; } } else if (newOrderItem is Dessert) { Dessert dessertToAdd = (Dessert)newOrderItem; if (UpdateDessertIfAlreadyOnOrder(dessertToAdd)) { addItemToOrder = false; } } else if (newOrderItem is Pizza) { Pizza pizzaToAdd = (Pizza)newOrderItem; if (UpdatePizzaIfAlreadyOnOrder(pizzaToAdd)) { addItemToOrder = false; } } else if (newOrderItem is Calzone) { Calzone calzoneToAdd = (Calzone)newOrderItem; if (UpdateCalzoneIfAlreadyOnOrder(calzoneToAdd)) { addItemToOrder = false; } } else if (newOrderItem is Salad) { Salad saladToAdd = (Salad)newOrderItem; if (UpdateSaladIfAlreadyOnOrder(saladToAdd)) { addItemToOrder = false; } } if (addItemToOrder) { newOrderItem.OrderItemNumber = OrderItems.Count + 1; OrderItems.Add(newOrderItem); } UpdateOrderTotals(); MenuHeaderModel.Instance.OrderTotal = Total; } }
//When a new OrderItem is added, subtotal, tax, and total are //automatically updated. public void AddItemToOrder(OrderItem item) { if (item != null) { SubTotal += item.Total; Total = SubTotal + HelperMethods.GetTaxAmount(SubTotal); OrderItems.Add(item); } }
public void AddOrderItem(System.Guid productId, string productName, decimal unitPrice, decimal discount, string pictureUrl) { var orderItem = new OrderItem() { ProductId = productId }; OrderItems.Add(orderItem); }
private void CalculateTaxAmount(InvoiceModel invoice, string memberId, string countryCode, Address address, string warehouseCode, string shippingMethodId, string locale) { 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 taxRates = GetTaxRatesFromTableStorage(locale); var productTax = 0M; var freightTax = 0M; var customerOrderItems = new OrderItems(); var totalPrice = customerOrder.OrderItems.Cast <CustomerOrderItem_V01>().Sum(item => item.RetailPrice); foreach (CustomerOrderItem_V01 item in customerOrder.OrderItems) { var taxRate = taxRates.Find(x => x.SKU.Equals(item.SKU)); // If we have the tax rate for the SKU in table storage, calculate the taxes for this item. // If not, then we need to pass this item to Vertex to calculate the taxes for this item. The orderCpy object gets passed to Vertex. if (taxRate != null) { var ratio = taxRate.GermanyPrice / totalPrice; productTax += decimal.Round((taxRate.GermanyPrice * (taxRate.VAT / 100)) * item.Quantity, 2); freightTax += decimal.Round((invoice.InvoicePrice.CalcShippingAmount * (taxRate.VAT / 100)) * ratio, 2); } else { customerOrderItems.Add(item); } } invoice.InvoicePrice.CalcTaxAmount = productTax + freightTax; invoice.InvoicePrice.TaxAmount = invoice.InvoicePrice.CalcTaxAmount; invoice.InvoicePrice.DisplayCalculatedTax = invoice.InvoicePrice.CalcTaxAmount.FormatPrice(); } }
public void AddOrderItem(OrderLine objOrdLine) { if (!HasPackingExceptionItems) { HasPackingExceptionItems = objOrdLine.Item.PackingException; } OrderItems.Add(objOrdLine.ProductId + "_" + objOrdLine.OrderItemID, new OrderItem(new OrderInfo(objOrdLine), objOrdLine.Item, objOrdLine.Quantity)); }
public PaymentOrderUpdateRequestDetailsDto(PaymentOrderUpdateRequestDetails paymentOrder) { Amount = paymentOrder.Amount.InLowestMonetaryUnit; Operation = paymentOrder.Operation.Value; VatAmount = paymentOrder.VatAmount?.InLowestMonetaryUnit; foreach (var item in paymentOrder.OrderItems) { OrderItems.Add(new OrderItemDto(item)); } }
public void When(OrderItemAdded @event) { OrderItems.Add(new OrderItem() { Name = @event.Name, Quantity = @event.Quantity, UnitPrice = @event.UnitPrice, ProductId = @event.ProductId }); }
//Creates and adds a new order item with the provided //product and quantity public void AddProduct(Product product, double quantity) { //add the product with quantity to orderitem list OrderItem newOrderItem = new OrderItem(); newOrderItem.Product = product; newOrderItem.Quantity = quantity; OrderItems.Add(newOrderItem); }
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; }
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)); } }
public void AddOrUpdateItem(OrderItem orderItem, Product product) { if (orderItem == null) { OrderItems.Add(new OrderItem(product)); } else { OrderItems.Where(x => x.Product.Id == orderItem.Product.Id).Select(x => x.Qtd++).ToList(); } }
public void AddProduct(string prodName, decimal latestPrice, int qty) { foreach (OrderItem item in OrderItems) { if (item.ProductName == prodName) { item.AddItems(latestPrice, qty); return; } } OrderItems.Add(new OrderItem(prodName, latestPrice, qty)); }
public void AddOrderItem(OrderItem orderItem) { OrderItemCount = 0; Subtotal = 0.0; OrderItems.Add(orderItem); foreach (var item in OrderItems) { OrderItemCount += item.Quantity; Subtotal += item.LineTotal; } }
public Order AddItem(int itemId, string name, int quantity, decimal unitPrice) { if (OrderItems.IsNullOrZero()) { OrderItems = new List <OrderItem>(); } var obj = new OrderItem(itemId, name, quantity, unitPrice); OrderItems.Add(obj); TotalPrice += obj.TotalPrice; RemainingPayment = TotalPrice - (Payments ?? new List <Payment>()).Sum(p => p.Amount); return(this); }
private Order ToDomainEntity(CreateInput input) { var orderItems = new OrderItems(); foreach (var item in input.ProductIdQuantityDictionary) { orderItems.Add(item.Key, item.Value); } var order = new Order(input.CustomerId, orderItems); return(order); }
public void UpdateOrderItem(OrderItem orderItem) { if (!IsOrderItemInOrder(orderItem)) { return; } RemoveOrderItemFromOrder(orderItem); if (orderItem.Quantity > 0) { OrderItems.Add(orderItem); } UpdateModifiedDate(); }
private void InitializeOrderItems(ICollection <OrderItem> orderItems) { foreach (var wrapper in OrderItems) { wrapper.PropertyChanged -= OrderItemWrapper_PropertyChanged; } OrderItems.Clear(); foreach (var orderItem in orderItems) { var wrapper = new OrderItemWrapper(orderItem); OrderItems.Add(wrapper); wrapper.PropertyChanged += OrderItemWrapper_PropertyChanged; } }
public void AddOrderItem(OrderItem newItem) { if (OrderItems == null) { OrderItems = new List <OrderItem>(); } foreach (OrderItem item in OrderItems) { if (item.Equals(newItem)) { throw new Exception("已有相同的订单明细项。"); } } OrderItems.Add(new OrderItem(newItem)); }
public void UpdateItems(OrderItem orderItem) { int index = OrderItems.FindIndex(item => item.Commodity.Equals(orderItem.Commodity)); if (index == -1) { OrderItems.Add(orderItem.DeepClone()); } else { OrderItems[index].Quantity += orderItem.Quantity; if (OrderItems[index].Quantity <= 0) { Delete(OrderItems[index]); } } }