public static IEnumerable <Order> GetOrders(string sql, string connString) { DataTable table = GetDataTable(sql, connString); string currentId = string.Empty; Order order = null; foreach (DataRow row in table.Rows) { if ((string)row["id"] != currentId && currentId != string.Empty) { yield return(order); } if ((string)row["id"] != currentId) { currentId = (string)row["id"]; order = DataRowToObject <Order>(row); order.customer = DataRowToObject <OrderCustomer>(row); if ((string)row["store"] == "0501") { order.shipping_address = DataRowToObject <OrderAdress>(row); } } OrderLineItem lineItem = DataRowToObject <OrderLineItem>(row); AddAttriutesFromRow(lineItem.variant_options, row); order.lineitems.Add(lineItem); } yield return(order); }
public IHttpActionResult PutOrderLineItem(int id, OrderLineItem orderLineItem) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != orderLineItem.OrderLineItemId) { return(BadRequest()); } db.Entry(orderLineItem).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!OrderLineItemExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
protected override void ApplyImplementation(OrderLineItem lineItem, DateTime orderDate, IGroceryOrder groceryOrder) { int groups = 0; if (lineItem.Quantity >= Quantity) { lineItem.Promotion = this; OrderLineItem workingItem = null; groups = lineItem.Quantity / Quantity; if (groups > 0) { workingItem = groceryOrder.LineItems.AddNew() as OrderLineItem; //TODO: re-use the catalog instead of re-coding this. figure out a more elegant method. workingItem.Product = Product; workingItem.Quantity = groups * Quantity; workingItem.ListPrice = lineItem.ListPrice; workingItem.Promotion = this; lineItem.Quantity -= workingItem.Quantity; if (lineItem.Quantity == 0) { groceryOrder.LineItems.Remove(lineItem); } } else { workingItem = lineItem; } workingItem.OrderPrice = Price; workingItem.OverridePrice(true, Convert.ToDecimal(groups) * Price); } }
public async Task <bool> DecrementOnLineCreate(int locationId, OrderLineItem lineItem) { bool success = true; // var detail = await _context.LineItems.Where(o => o.OrderId == order.OrderId).ToListAsync(); var products = await _context.Products.Where(p => p.LocationId == locationId).Select(c => c).ToListAsync(); // for every line item decrement the corresponding product quantity /*foreach(var item in lineItem.) * { * var update = products.Where(p => p.ProductId == item.ProductId).FirstOrDefault(); * update.Qty -= item.Qty; * }*/ foreach (var item in products) { if (item.ProductId == lineItem.ProductId) { item.Qty -= lineItem.Qty; } } await _context.SaveChangesAsync(); return(success); }
private OrdersShipLineItemsRequest ShipAllLineItem(ulong merchantId, string orderId, OrderLineItem item) { Console.WriteLine("================================================================="); Console.WriteLine("Shipping {0} of item {1}", item.QuantityPending, item.Id); Console.WriteLine("================================================================="); var itemShip = new OrderShipmentLineItemShipment(); itemShip.LineItemId = item.Id; itemShip.Quantity = item.QuantityPending; var req = new OrdersShipLineItemsRequest(); req.Carrier = item.ShippingDetails.Method.Carrier; req.ShipmentId = prng.Next().ToString(); req.TrackingId = prng.Next().ToString(); req.LineItems = new List <OrderShipmentLineItemShipment>(); req.LineItems.Add(itemShip); req.OperationId = NewOperationId(); var resp = sandboxService.Orders.Shiplineitems(req, merchantId, orderId).Execute(); Console.WriteLine("Finished with status {0}.", resp.ExecutionStatus); Console.WriteLine(); // We return req here so that we have access to the randomly-generated IDs in the // main program. return(req); }
public ActionResult AddToCart(int id) { var customerId = User.Identity.GetUserId(); var order = db.Orders.FirstOrDefault(o => o.Cid == customerId && o.SubmittedDate == null); if (order == null) { order = new Order { Cid = customerId }; db.Orders.Add(order); } var orderLineItem = order.OrderLineItems.FirstOrDefault(item => item.Pid == id); var product = db.Products.Find(id); if (orderLineItem != null) { orderLineItem.Quantity++; db.Entry(orderLineItem).State = EntityState.Modified; } else { orderLineItem = new OrderLineItem { Pid = id, Quantity = 1, Price = product.Price }; order.OrderLineItems.Add(orderLineItem); } db.SaveChanges(); return(RedirectToAction("Index")); }
public void ToSvOrderLineItem() { const string quantity = "32"; long? amount = 21; var unitPrice = new Money(amount, "USD"); var orderLineItem = new OrderLineItem(null, null, Quantity: quantity) { BasePriceMoney = unitPrice }; const string sku = "testSku3"; const string catalogObjectId = "asdfsdf"; var item = new SquareItem { VariationId = catalogObjectId, Sku = sku }; Money totalTax = new Money(6, "SOS"); orderLineItem.Discounts = new List <OrderLineItemDiscount> { new OrderLineItemDiscount(), new OrderLineItemDiscount() }; orderLineItem.TotalTaxMoney = totalTax; var result = orderLineItem.ToSvOrderLineItem(item); result.Sku.Should().Be(sku); result.Quantity.Should().Be(quantity); result.UnitPrice.Should().Be(orderLineItem.BasePriceMoney.ToNMoney()); result.Discounts.Count().Should().Be(orderLineItem.Discounts.Count()); result.TotalTax.Should().Be(totalTax.ToNMoney()); }
public async Task <IActionResult> PutOrderLineItem([FromRoute] int id, [FromBody] OrderLineItem orderLineItem) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != orderLineItem.Id) { return(BadRequest()); } _context.Entry(orderLineItem).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!OrderLineItemExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
private static IEnumerable <OrderedItem> CreateOrderedItemsFromLineItem(OrderLineItem lineItem) { var menuItem = StaticData.Menu.Single(item => item.MenuNumber == lineItem.MenuNumber); return(Enumerable.Range(0, lineItem.NumberToOrder) .Select(i => CreateOrderedItem(lineItem.MenuNumber, menuItem))); }
/// <summary> /// Inserts the order and updates the inventory stock within a transaction. /// </summary> /// <param name="order">All information about the order</param> public void InsertOrder(Order order) { using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required)) { OrderAccessor accessor = Accessor; using (DbManager db = accessor.GetDbManager()) { order.Courier = "UPS"; order.Locale = "US_en"; order.ID = accessor.Query.InsertAndGetIdentity(db, order); accessor.InsertStatus(db, order.ID); for (int i = 0; i < order.Lines.Length; i++) { OrderLineItem line = order.Lines[i]; line.OrderID = order.ID; accessor.Query.Insert(line); } } InventoryAccessor inv = InventoryAccessor.CreateInstance(); using (DbManager db = inv.GetDbManager()) foreach (OrderLineItem line in order.Lines) { inv.TakeInventory(db, line.Quantity, line.ItemID); } ts.Complete(); } }
public void Apply(OrderLineItem lineItem, DateTime orderDate, Entity.IGroceryOrder groceryOrder) { if (IsApplicable(lineItem, orderDate, groceryOrder)) { ApplyImplementation(lineItem, orderDate, groceryOrder); } }
protected override void ApplyImplementation(OrderLineItem lineItem, DateTime orderDate, IGroceryOrder groceryOrder) { if (lineItem.Quantity >= PurchaseQuantity) { lineItem.Promotion = this; } }
public static TS_OR_DETAIL_STAGE ConvertOLItem2DetailStage(OrderLineItem item, string seq, string appUser) { TS_OR_DETAIL_STAGE dStage = new TS_OR_DETAIL_STAGE(); dStage.ORDER_REQ_NO = string.IsNullOrEmpty(seq) ? 0 : decimal.Parse(seq);; dStage.ORDER_LINE_NO = item.OrderLineNo; if (item.PriAVLCheck < item.Qty && item.AltAVLCheck >= item.Qty) { dStage.SHIPFROM_SEQ = 1; } else { dStage.SHIPFROM_SEQ = 0; } dStage.PART_NO = item.PartNo; dStage.CUSTOMER_PART_NO = item.CustomerPartNo; dStage.BUY_QTY = item.Qty; dStage.DESCRIPTION = item.Description; dStage.DESC_CN = item.DescCN; dStage.DESCRIPTION = null; dStage.CREATION_DATE = DateTime.Now; dStage.CREATED_BY = appUser; dStage.UPDATED_DATE = null; dStage.UPDATED_BY = null; return(dStage); }
public void RejectsHighOrderQuantities() { var options = TestUtil.GetMemDbOptions("RejectsHighOrderQuantities"); String productName; Guid customerId; Guid orderId; using (var db = new StoreContext(options)) { var(customer, location, product, inventory) = SimplePopulate(db); customerId = customer.CustomerId; productName = product.Name; inventory.Quantity = 300; var order = new Order(customer, location); orderId = order.OrderId; var orderLine = new OrderLineItem(order, product); orderLine.Quantity = 201; order.OrderLineItems.Add(orderLine); db.Add(order); db.SaveChanges(); } Assert.Equal(PlaceOrderResult.HighQuantityRejection, options.PlaceOrder(orderId, StoreDbUtil.Config.MAX_ORDER_QUANTITY)); using (var db = new StoreContext(options)) { var inventory = (from i in db.LocationInventories where i.Product.Name == productName select i).First(); Assert.Equal(300, inventory.Quantity); } }
public void UpdatesSubmittedTimeWhenOrderPlaced() { var options = TestUtil.GetMemDbOptions("UpdatesSubmittedTimeWhenOrderPlaced"); String productName; Guid customerId; Guid orderId; using (var db = new StoreContext(options)) { var(customer, location, product, inventory) = SimplePopulate(db); customerId = customer.CustomerId; productName = product.Name; var order = new Order(customer, location); orderId = order.OrderId; var orderLine = new OrderLineItem(order, product); orderLine.Quantity = 1; order.OrderLineItems.Add(orderLine); db.Add(order); db.SaveChanges(); } Assert.Equal(PlaceOrderResult.Ok, options.PlaceOrder(orderId, StoreDbUtil.Config.MAX_ORDER_QUANTITY)); using (var db = new StoreContext(options)) { var order = db.GetOrderById(orderId); Assert.NotNull(order.TimeSubmitted); } }
public ActionResult DeleteConfirmed(int id) { OrderLineItem orderLineItem = db.OrderLineItems.Find(id); db.OrderLineItems.Remove(orderLineItem); db.SaveChanges(); return(RedirectToAction("Index", "Orders")); }
public void WhenDecrementOrderLineItem_ExpectedQuantityIsShown(int startingQuantity, int quantityToIncrement, int expectedQuantity) { var sut = new OrderLineItem(new Book(BookTitles.GobletOfFire), startingQuantity); sut.Decrement(quantityToIncrement); sut.Quantity.Should().Be(expectedQuantity); }
public void Apply(Entity.IGroceryOrder groceryOrder) { //foreach (OrderLineItem lineItem in groceryOrder.LineItems) for (int idx = 0; idx < groceryOrder.LineItems.Count; idx++) { OrderLineItem lineItem = groceryOrder.LineItems[idx] as OrderLineItem; Apply(lineItem, groceryOrder.OrderDate, groceryOrder); } }
public IActionResult AddToCart(OrderLineItem itemToBuy) { var cookie = new CheckoutCookie(HttpContext.Request.Cookies, HttpContext.Response.Cookies); var service = new CheckoutCookieService(cookie.GetValue()); service.AddLineItem(itemToBuy); cookie.AddOrUpdateCookie(service.EncodeForCookie()); return(RedirectToAction("Index")); }
public void UpdateLineItem(int itemIndex, OrderLineItem replacement) { if (itemIndex < 0 || itemIndex > lineItems.Count) { throw new InvalidOperationException($"System error. Attempt to remove line item index {itemIndex}. _lineItems.Count = {lineItems.Count}"); } lineItems[itemIndex] = replacement; }
public void OnGet(int?id) { orderLineItem = new OrderLineItem(); ViewData["ProductId"] = new SelectList(_context.Set <Product>(), "ID", "Name"); if (id != null) { orderLineItem.OrderId = id.Value; } }
protected bool IsApplicable(OrderLineItem lineItem, DateTime orderDate, Entity.IGroceryOrder groceryOrder) { bool result = false; result = (Product == lineItem.Product && orderDate >= Period.From && (Period.To == null || orderDate <= Period.To)); return(result); }
public IActionResult Buy(OrderLineItem itemToBuy) { var cookie = new CheckoutCookie(HttpContext.Request.Cookies, HttpContext.Response.Cookies); var service = new CheckoutCookieService(cookie.GetValue()); service.AddLineItem(itemToBuy); cookie.AddOrUpdateCookie(service.EncodeForCookie()); SetupTraceInfo(); return(RedirectToAction(nameof(Index))); }
public void RejectsOrderWithNonExistentInventory() { var options = TestUtil.GetMemDbOptions("RejectsOrderWithNonExistentInventory"); String productName; Guid customerId; Guid orderId; using (var db = new StoreContext(options)) { var(customer, location, product1, inventory) = SimplePopulate(db); customerId = customer.CustomerId; var product2 = new Product(Guid.NewGuid().ToString(), 2.0); db.Add(product2); productName = product1.Name; // Intentionally not adding product 2 to inventory // var inventory2 = new LocationInventory(product2, location, 20); // db.Add(inventory2); var order = new Order(customer, location); orderId = order.OrderId; var orderLine1 = new OrderLineItem(order, product1); orderLine1.Quantity = 9; order.OrderLineItems.Add(orderLine1); var orderLine2 = new OrderLineItem(order, product2); orderLine2.Quantity = 21; order.OrderLineItems.Add(orderLine2); db.Add(order); db.SaveChanges(); } using (var db = new StoreContext(options)) { var customer = (from c in db.Customers where c.CustomerId == customerId select c).First(); var order = (from o in db.Orders where o.Customer.CustomerId == customer.CustomerId select o).First(); Assert.Equal(customer.CustomerId, order.Customer.CustomerId); } Assert.Equal(PlaceOrderResult.OutOfStock, options.PlaceOrder(orderId, StoreDbUtil.Config.MAX_ORDER_QUANTITY)); using (var db = new StoreContext(options)) { var inventoryP1 = (from i in db.LocationInventories where i.Product.Name == productName select i).First(); Assert.Equal(10, inventoryP1.Quantity); } }
public IHttpActionResult GetOrderLineItem(int id) { OrderLineItem orderLineItem = db.OrderLineItems.Find(id); if (orderLineItem == null) { return(NotFound()); } return(Ok(orderLineItem)); }
/// <summary> /// Additional operations to be performed when cloning an instance of <see cref="OrderLineItem" /> to an instance of <see cref="PSOrderLineItem" />. /// </summary> /// <param name="lineItem">An instance of the <see cref="OrderLineItem" /> class that will serve as base for this instance.</param> private void CloneAdditionalOperations(OrderLineItem lineItem) { if (lineItem.ProvisioningContext == null) { return; } foreach (KeyValuePair <string, string> item in lineItem.ProvisioningContext) { ProvisioningContext.Add(item.Key, item.Value); } }
public async Task <IActionResult> PostOrderLineItem([FromBody] OrderLineItem orderLineItem) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.OrderLineItems.Add(orderLineItem); await _context.SaveChangesAsync(); return(CreatedAtAction("GetOrderLineItem", new { id = orderLineItem.Id }, orderLineItem)); }
public ActionResult Edit([Bind(Include = "Id,Oid,Pid,Quantity,Price")] OrderLineItem orderLineItem) { if (ModelState.IsValid) { db.Entry(orderLineItem).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index", "Orders")); } ViewBag.Oid = new SelectList(db.Orders, "Id", "Cid", orderLineItem.Oid); ViewBag.Pid = new SelectList(db.Products, "Id", "Name", orderLineItem.Pid); return(RedirectToAction("Index", "Orders")); }
public IActionResult Index(DateTime date, int customerId, List <OrderLineItem> lineItems) { try { // Manual Validation. View Models To be implemented ... if (customerId == 0) { throw new Exception("Please Select a customer"); } if (lineItems.Count < 1) { throw new Exception("Please add line items"); } if (date.ToShortDateString() == "1/1/0001") { throw new Exception("Please Enter Date"); } foreach (var item in lineItems) { item.Product = mapper.Map <Product>(productService.GetProductById(item.Product.Id)); item.Total = item.Product.UnitPrice * item.Quantity; } date.AddHours(DateTime.Now.Hour); var results = mapper.Map <List <OrderLineItem> >(orderService.AddOrder(customerId, date, mapper.Map <List <OrderLineItemBO> >(lineItems))); var last = new OrderLineItem(); if (results.Count == 0) { throw new Exception($"There are inadequate products"); } else { last = results[results.Count - 1]; } results.Remove(last); if (results.Count > 0) { var model = new IndexViewModel(); model.LineItems = results; model.Customers = mapper.Map <List <Customer> >(customerService.GetCustomers()); model.Date = date; model.Products = mapper.Map <List <Product> >(productService.GetProducts()); return(View(model)); } return(RedirectToAction("ViewOrder", new { orderId = last.OrderId })); } catch (Exception e) { return(View("ErrorDisplay", new ErrorModel { Message = e.Message })); } }
public IHttpActionResult PostOrderLineItem(OrderLineItem orderLineItem) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.OrderLineItems.Add(orderLineItem); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = orderLineItem.OrderLineItemId }, orderLineItem)); }
private ApproveOrderViewModel.ApproveOrderLineItemViewModel Map(OrderLineItem lineItem, Guid documentId) { return new ApproveOrderViewModel.ApproveOrderLineItemViewModel { DocumentId = documentId.ToString(), LineItemId = lineItem.Id.ToString(), ProductId = lineItem.Product.Id, ProductDesc = lineItem.Product.Description, Qty = lineItem.Qty, Value = lineItem.Value, TotalNet = (lineItem.Qty * lineItem.Value), VatValue = lineItem.LineItemVatValue, LineTotal = lineItem.LineItemTotal, ProductType = lineItem.Product.GetType().ToString().Split('.').Last(), }; }
private void InsertLineItems(int orderId, OrderLineItem lineItem) { using (var cmd = new SqlCommand("usp_InsertOrderItem", cn, trans)) { var parameters = new[] { new SqlParameter("@OrderID", SqlDbType.Int) {Value = orderId}, new SqlParameter("@OrderLineItemId", SqlDbType.NVarChar, 50) {Value = lineItem.OrderLineItemId}, new SqlParameter("@ProductIdentifier", SqlDbType.NVarChar, 50) {Value = lineItem.ProductIdentifier}, new SqlParameter("@Quantity", SqlDbType.Int) {Value = lineItem.Quantity}, new SqlParameter("@ShipMethod", SqlDbType.NVarChar, 25) {Value = lineItem.ShippingMethod}, new SqlParameter("@GiftMessage", SqlDbType.NVarChar, 1000) {Value = lineItem.GiftMessage} }; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddRange(parameters); cmd.ExecuteNonQuery(); } }
public static OrderLineItem CreateOrderLineItem(int ID, global::System.DateTime fulfilmentDate, int units, double pricePerUnit, double amount, double adminFee, double pivotExchangeRate, double globalPivotExchangeRate, string currencyId, int itemId, int orderId) { OrderLineItem orderLineItem = new OrderLineItem(); orderLineItem.Id = ID; orderLineItem.FulfilmentDate = fulfilmentDate; orderLineItem.Units = units; orderLineItem.PricePerUnit = pricePerUnit; orderLineItem.Amount = amount; orderLineItem.AdminFee = adminFee; orderLineItem.PivotExchangeRate = pivotExchangeRate; orderLineItem.GlobalPivotExchangeRate = globalPivotExchangeRate; orderLineItem.CurrencyId = currencyId; orderLineItem.ItemId = itemId; orderLineItem.OrderId = orderId; return orderLineItem; }
public void AddToOrderLineItems(OrderLineItem orderLineItem) { base.AddObject("OrderLineItems", orderLineItem); }
public void DeleteLineItem(OrderLineItem oli) { tblLineItems lineItem = _ctx.tblLineItems.FirstOrDefault(n => n.id == oli.Id); if (lineItem != null) { _ctx.tblLineItems.DeleteObject(lineItem); _ctx.SaveChanges(); } }
public void SaveLineItem(OrderLineItem lineItem, Guid orderId) { tblLineItems ll = null; if (_ctx.tblLineItems.Any(p => p.id == lineItem.Id)) ll = _ctx.tblLineItems.First(p => p.id == lineItem.Id); else { ll = new tblLineItems(); ll.id = lineItem.Id; _ctx.tblLineItems.AddObject(ll); } ll.ProductID = lineItem.Product.Id; ll.DocumentID = orderId; ll.Description = lineItem.Description; ll.Quantity = lineItem.Qty; ll.LineItemSequenceNo = lineItem.LineItemSequenceNo; ll.Value = lineItem.Value; ll.Vat = lineItem.LineItemVatValue; ll.OrderLineItemType = (int)lineItem.LineItemType; ll.ProductDiscount = lineItem.ProductDiscount; ll.DiscountLineItemTypeId = (int)lineItem.DiscountType; ll.Description = lineItem.Description; _ctx.SaveChanges(); }
/// <summary> /// Method to convert all cart items to order line items /// </summary> /// <returns>A new array of order line items</returns> public OrderLineItem[] GetOrderLineItems() { OrderLineItem[] items = new OrderLineItem[_items.Count]; int lineNum = 0; foreach (CartItem item in _items.Values) { OrderLineItem line = new OrderLineItem(); items[lineNum] = line; line.ItemID = item.ItemID; line.Line = ++lineNum; line.Quantity = item.Quantity; line.Price = item.Price; } return items; }
private void AddLineItem(OrderLineItem oli) { using (var container = NestedContainer) { IOtherUtilities _otherUtilities = Using<IOtherUtilities>(container); ApproveSalesmanOrderItem li = null; int sequenceNo = 1; if (LineItems.Count > 0) { sequenceNo = LineItems.Max(n => n.SequenceNo) + 1; } if (LineItems.Any(n => n.ProductId == oli.Product.Id)) { li = LineItems.First(n => n.ProductId == oli.Product.Id); li.Qty += oli.Qty; li.TotalLineItemVatAmount += oli.LineItemVatTotal; li.LineItemVatValue = oli.LineItemVatValue; li.TotalPrice += oli.LineItemTotal; } else { li = new ApproveSalesmanOrderItem(_otherUtilities) { SequenceNo = sequenceNo, ProductId = oli.Product.Id, Product = oli.Product.Description, UnitPrice = oli.Value, LineItemVatValue = oli.LineItemVatValue, TotalLineItemVatAmount = oli.LineItemVatTotal, Qty = oli.Qty, TotalPrice = oli.LineItemTotal, IsEditable = false, LineItemId = oli.Id, CanEdit = false, CanRemove = false, ProductType = oli.Product.GetType().ToString().Split('.').Last(), HlnkDeleteContent = GetLocalText("sl.approveOrder.lineItemsGrid.deleteLineItem"), }; LineItems.Add(li); } CalcTotals(); } }
private void InsertIntoLineItem(OrderLineItem orderLineItem) { //get confirmed/discount line item OrderLineItem oli = _order.LineItems.FirstOrDefault( n => n.Description == orderLineItem.Description && n.LineItemType == OrderLineItemType.PostConfirmation); if (oli == null) oli = _order.LineItems.FirstOrDefault( n => n.Id.ToString() == orderLineItem.Description && n.LineItemType == OrderLineItemType.Discount); if (oli == null) { throw new Exception("Main line item " + orderLineItem.Product.Description + " whose Id is " + orderLineItem.Description + " is missing in list."); } var lineItemToUpdate = LineItems.FirstOrDefault(n => n.LineItemId == oli.Id); if (lineItemToUpdate == null) { throw new Exception("Line item " + orderLineItem.Product.Description + " whose Id is " + orderLineItem.Description + " is missing in list."); } switch (orderLineItem.LineItemType) { case OrderLineItemType.BackOrder: lineItemToUpdate.BackOrder += orderLineItem.Qty; lineItemToUpdate.ProcessedQty = (lineItemToUpdate.Qty - lineItemToUpdate.BackOrder); break; case OrderLineItemType.LostSale: lineItemToUpdate.LostSale = orderLineItem.Qty; break; case OrderLineItemType.ProcessedBackOrder: lineItemToUpdate.BackOrder -= orderLineItem.Qty; lineItemToUpdate.ProcessedQty = (lineItemToUpdate.Qty - lineItemToUpdate.BackOrder); break; } }
OrderLineItem CreateNewLineItem(Guid lineItemId, ApproveSalesmanOrderItem item, OrderLineItemType orderLineItemType = OrderLineItemType.PostConfirmation) { using (var container = NestedContainer) { IProductRepository _productService = Using<IProductRepository>(container); lineItemId = lineItemId == Guid.Empty ? Guid.NewGuid() : lineItemId; var oli = new OrderLineItem(lineItemId) { Description = item.Product, Product = _productService.GetById(item.ProductId), Qty = item.Qty, IsNew = true, LineItemSequenceNo = item.SequenceNo }; oli.Value = item.UnitPrice; oli.LineItemVatValue = item.LineItemVatValue; oli.LineItemType = orderLineItemType; oli.ProductDiscount = item.ProductDiscount; oli.LineItemType = orderLineItemType; oli.DiscountType = item.LineItemDiscountType; return oli; } }