public static float CalculateTax(OrderItem orderItem, TaxElement tax, float discountPercent) { switch (tax.Type) { case RateType.LumpSum: return tax.RegionalRates.Count > 0 ? tax.RegionalRates.First().Rate : tax.FederalRate; case RateType.Proportional: { float returnTax = tax.RegionalRates.Count > 0 ? tax.RegionalRates.First().Rate : tax.FederalRate; if (tax.ShowInPrice) { returnTax = returnTax * (orderItem.Price - orderItem.Price * discountPercent/100) * orderItem.Amount / (100.0F + returnTax); } else { returnTax = returnTax * (orderItem.Price - orderItem.Price * discountPercent / 100) * orderItem.Amount / 100.0F; } return returnTax; } default: throw new NotImplementedException("This tax type does not exist"); } }
public void Initialize() { //New instance of Order Item _orderItem = new OrderItem() { Id = 123456L, LastUpdatedUtc = new DateTime(1969, 7, 21), BasePricePerItem = 3.14159265D, Discount = 3.14159265D, OrderId = "test", ProductId = "test", ItemType = ProductItemType.Apparel, VariantId = "test", ProductName = "test", ProductSku = "test", Quantity = 123, ProductShortDescription = "test", ShipFromAddress = new Address(), ShippingSchedule = new DateTime(1969, 7, 21), ProductShippingHeight = 3.14159265D, ProductShippingLength = 3.14159265D, ProductShippingWeight = 3.14159265D, ProductShippingWidth = 3.14159265D, ShipFromNotificationId = "test" }; }
/// <summary> /// 创建订单 /// </summary> private Order CreateOrder( Guid? orderId = null, Guid? itemId = null , Guid? itemId2 = null) { Order order; if ( orderId == null ) order = new Order(); else order = new Order( orderId.SafeValue() ); order.Name = "order"; //添加订单项1 OrderItem orderItem; if( itemId == null ) orderItem = new OrderItem(); else orderItem = new OrderItem( order.Id, itemId.SafeValue() ); orderItem.Name = "a"; order.Add( orderItem ); //添加订单项2 OrderItem orderItem2; if ( itemId == null ) orderItem2 = new OrderItem(); else orderItem2 = new OrderItem( order.Id, itemId2.SafeValue() ); orderItem2.Name = "b"; order.Add( orderItem2 ); return order; }
public OrderDetailPage(int orderID) { InitializeComponent(); order = OrderProvider.GetOrder(orderID); if (order.Status != OrderStatus.Ordered) { btnSendOrder.Visibility = System.Windows.Visibility.Hidden; btnPrint.Content = "补打订单"; } //转换成页面模型进行处理 detailModel = new OrderDetailViewModel(); detailModel.OrderID = order.OrderID; detailModel.Receiver = order.Receiver; detailModel.ReceiverPhone = order.Phone; detailModel.UserName = order.UserName; detailModel.TotalPrice = order.TotalPrice; detailModel.Address = order.Address; detailModel.OrderTime = order.OrderTime; detailModel.Remark = order.Remark; detailModel.DetailItems = new List<OrderDetailItemViewModel>(); totalPageCount = (order.OrderDetails.Count + eachPagedItemNumber - 1) / eachPagedItemNumber; ShowPagedOrderDetail(); btnPrePage.DataContext = this; btnNextPage.DataContext = this; }
public void ProcessRequest(HttpContext context) { var responseText = string.Empty; if (!string.IsNullOrEmpty(context.Request.QueryString["OrderItem"])) { try { var oi = new OrderItem(); var jsonSerializer = new JavaScriptSerializer(); responseText = jsonSerializer.Serialize(oi); } catch (Exception ex) { responseText = $"{{ \"result\": \"error\", \"error_msg\": \"{ex.Message}\" }}"; } } //responseText = "{ \"result\": \"success\", \"ProductGuid\": \"cyrano\" }"; context.Response.Clear(); context.Response.ContentType = "text/plain"; context.Response.Write(responseText); context.Response.End(); }
public OrderItem(OrderItem item) { Name = item.Name; Quantity = item.Quantity; Price = item.Price; Remarks = item.Remarks; }
public AddOrderItem( Guid orderId, OrderItem item) { OrderId = orderId; Item = item; }
protected void btnSubmit_Click(object sender, EventArgs e) { try { var oi = new OrderItem(); if (OrderItemID > 0) { oi = repo.Single<OrderItem>(OrderItemID); } if (!string.IsNullOrEmpty(tbMemberID.Text.Trim())) oi.MemberID = Convert.ToInt32(tbMemberID.Text.Trim()); else throw new Exception("Member ID can't be empty"); oi.MemberName = tbMemberName.Text.Trim(); oi.CreateTime = DateTime.Parse(tbCreateTime.Text.Trim()); oi.OrderID = Convert.ToInt32(tbOrderID.Text.Trim()); oi.IsActive = cbIsActive.Checked; if (!string.IsNullOrEmpty(tbCode.Text.Trim())) oi.Code = tbCode.Text.Trim(); else throw new Exception("OrderItem Code can't be empty"); oi.ProductGuid = new Guid(tbProductGuid.Text.Trim()); oi.ProductName = tbProductName.Text.Trim(); oi.Size = tbSize.Text.Trim(); oi.UnitPrice = Convert.ToSingle(tbUnitPrice.Text.Trim()); oi.Quantity = Convert.ToInt32(tbQuantity.Text.Trim()); if (!string.IsNullOrEmpty(tbSale.Text.Trim())) oi.Sale = Convert.ToSingle(tbSale.Text.Trim()); else oi.Sale = null; oi.Remark = tbRemark.Text.Trim(); if (OrderItemID > 0) { repo.Update(oi); ClientScript.RegisterClientScriptBlock(typeof (string), "succeed", "alert('更新成功');window.location.href=window.location.href", true); } else { repo.Insert(oi); ClientScript.RegisterClientScriptBlock(typeof (string), "succeed", "alert('添加成功');window.location.href = 'AdminOrderItem.aspx'", true); } } catch (Exception ex) { ClientScript.RegisterClientScriptBlock(typeof (string), "failed", $"alert('{ex.Message}')", true); } }
public void AddOrderItem(OrderItem orderItem) { var order = _entities.Orders.FirstOrDefault(o => o.OrderId == orderItem.OrderId); order.OrderTotal += orderItem.OrderItemTotal; _entities.OrderItems.Add(orderItem); _entities.Entry<Order>(order).State = EntityState.Modified; _entities.SaveChanges(); }
public OrderItem Build() { var orderItem = new OrderItem(_product, _unitPrice, _quantity); if (_discountPercentage.HasValue) orderItem.DiscountPercentage = _discountPercentage.Value; return orderItem; }
public decimal CalculatePrice(OrderItem item) { decimal total = 0m; total += item.Quantity * 1m; int setsOfFive = item.Quantity / 5; total -= setsOfFive * 1m; return total; }
public IOrderItem AddToBill(IProduct product) { var orderItem = new OrderItem(product); _orderItems.Add(orderItem); return orderItem; }
public decimal CalculateDiscount(OrderItem orderItem) { decimal discount = 0; if (orderItem.CalculatePartialTotal() >= 100) { discount = orderItem.CalculatePartialTotal() * 10 / 100; } return discount; }
public decimal CalculatePrice(OrderItem item) { decimal total = 0m; // $0.40 each; 3 for a $1.00 total += item.Quantity*.4m; int setsOfThree = item.Quantity/3; total -= setsOfThree*.2m; return total; }
public decimal CalculateDiscount(OrderItem orderItem) { decimal discount = 0; if (orderItem.ItemAmount() >= 100) { discount = orderItem.ItemAmount() * 10 / 100; } return discount; }
public decimal CalculateDiscount(OrderItem orderItem) { decimal discount = 0; if (orderItem.UnitPricePerQuantity() >= 100) { discount = orderItem.UnitPricePerQuantity() * 10 / 100; } return discount; }
public decimal CalculateDiscount(OrderItem orderItem) { decimal discount = 0; if (orderItem.Quantity > 2) { discount = orderItem.Product.UnitPrice; } return discount; }
public OrderBeingPrepared( Guid orderId, DiningLocation diningLocation, OrderItem[] orderItems) { OrderId = orderId; DiningLocation = diningLocation; OrderItems = orderItems; }
public OrderDelivered( Guid orderId, DiningLocation diningLocation, OrderItem[] orderItems) { OrderId = orderId; DiningLocation = diningLocation; OrderItems = orderItems; }
public void CompleteCheckout(string CreditCard) { try { if (Context.User.IsInRole("User")) { User myLoggedUser = new UsersLogic().RetrieveUserByUsername(Context.User.Identity.Name); List<ShoppingCart> myShoppingCartItems = new ShoppingCartLogic().RetrieveAllShoppingCartItems(myLoggedUser.Id).ToList(); List<OrderItem> myOrderItems = new List<OrderItem>(); foreach (ShoppingCart myShoppingCartItem in myShoppingCartItems) { UserTypeProduct myPriceType = new PriceTypesLogic().RetrievePriceTypeByID(myLoggedUser.UserTypeFK, myShoppingCartItem.ProductFK); OrderItem myOrderItem = new OrderItem(); myOrderItem.Id = myShoppingCartItem.ProductFK; double myPrice = 0; if (myPriceType != null) { myPrice = myPriceType.Price; double? NewPrice = 0; if ((myPriceType.DiscountDateFrom != null) && (myPriceType.DiscountDateTo != null) && (myPriceType.DiscountPercentage != null)) { if ((DateTime.Now >= myPriceType.DiscountDateFrom) && (DateTime.Now <= myPriceType.DiscountDateTo)) { NewPrice = myPriceType.Price - ((myPriceType.DiscountPercentage / 100) * myPriceType.Price); myPrice = Convert.ToDouble(NewPrice); } } } myOrderItem.Price = myPrice; myOrderItem.Quantity = myShoppingCartItem.Quantity; myOrderItems.Add(myOrderItem); } //if ( new OrdersLogic().AddOrder(null, myLoggedUser.Id, CreditCard.Trim(), myOrderItems); //{ //new UsersLogic().InsertCreditCardNumber(CreditCard.Trim(), myLoggedUser.Id); //new ShoppingCartLogic().EmptyCart(myLoggedUser.Id); //} } } catch (Exception Exception) { throw Exception; } }
public override OrderItem ToOrderItem(string option, int quantity) { OrderItem item = new OrderItem(); item.Quantity = quantity; item.Price = 19.95m; item.ProductDescription = Rentler.Configuration.Ribbons.Current.AvailableRibbons[option] + " ribbon"; item.ProductOption = option; item.ProductId = this.Name; return item; }
protected override OrderItem CreateAdjustmentItem(OrderItem item) { return new OrderItem { Product = item.Product + " " + PercentOff + "% off", PricePerUnit = -item.PricePerUnit*PercentOff/100, Quantity = item.Quantity, }; }
//IClonable Override public virtual object Clone() { OrderItem instance = new OrderItem() ; instance.IsBackOrder = IsBackOrder ; instance.title = title ; instance.note = note ; instance.quantity = quantity ; instance.price = price ; return instance; }
private bool TryAddOrderItem(Order order, OrderItemRepresentation requestedItem) { var product = TryFindProduct(requestedItem); if (product == null) return false; var orderItem = new OrderItem(product, requestedItem.Quantity, product.Price, requestedItem.Preferences); order.AddItem(orderItem); return true; }
public ActionResult AddOrderItems(OrderItem item) { List<Order> myOrderList = new List<Order>(); // await order = myHandler.GetOrdersList().Single(ord => ord.DataModified == DateTime.Now); TryUpdateModel(item); myHandler = new BusinessLogicHandler(); myHandler.AddOrderItem(item); return Json(new { success = true }); }
protected override OrderItem CreateAdjustmentItem(OrderItem item) { return new OrderItem { Product = item.Product + " $" + AmountOff + " off", PricePerUnit = -AmountOff, Quantity = item.Quantity, }; }
public QueueOrder( Guid baristaOrderId, Guid cashierOrderId, DiningLocation diningLocation, OrderItem[] orderItems) { BaristaOrderId = baristaOrderId; CashierOrderId = cashierOrderId; DiningLocation = diningLocation; OrderItems = orderItems; }
public void CanAddItem() { // arrange var orderItem = new OrderItem(); // act _order.AddItem(orderItem); // assert Assert.Equal(1, _order.Items.Count); }
public void IncrementCableQuantityByOne() { //Arrange OrderItem item = new OrderItem("cable", 1); //Act item.AddToTotal(3); //Assert Assert.AreEqual(item.Quantity, 4); }
//public OrderItemBalance(OrderItem orderItem, long invoiceItemId, long fuelReportDetailId, decimal amount, string unitCode) //{ // OrderItemId = orderItem.Id; // OrderId = orderItem.OrderId; // InvoiceItemId = invoiceItemId; // FuelReportDetailId = fuelReportDetailId; // this.setQuantity(amount, unitCode); //} public OrderItemBalance(OrderItem orderItem, InvoiceItem invoiceItem, FuelReportDetail fuelReportDetail, decimal amount, string unitCode) { OrderItem = orderItem; OrderId = orderItem.OrderId; InvoiceItem = invoiceItem; FuelReportDetail = fuelReportDetail; InvoiceItemId = invoiceItem.Id; FuelReportDetailId = fuelReportDetail.Id; this.setQuantity(amount, unitCode); }
public void UpdateOrderItems(OrderItem item) { _itemRepository.Update(item); }
public async Task <OrderItem> AddOrderItemAsync(OrderItem orderItem) { return(await _orderItemRepository.AddAsync(orderItem)); }
public void AddOrderItem(OrderItem o) { bestelling_db.AddOrderItem(o); }