public void CompleteShipment(int purchaseOrderId) { PurchaseOrder order = OrderContext.Current.GetPurchaseOrderById(purchaseOrderId); if (order == null || order.OrderForms.Count == 0) { throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.NotFound)); } if (order.OrderForms.Count > 1) { throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.NotImplemented) { ReasonPhrase = "Orderform contains more than one form, this is not supported by the API." }); } ShipmentCollection shipments = order.OrderForms[0].Shipments; if (shipments.Count > 1) { throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.NotImplemented) { ReasonPhrase = "Orderform contains more than one shipment, this is not supported by the API." }); } // Set status and run workflows OrderStatusManager.CompleteOrderShipment(shipments[0]); // Workflows could have changed the order order.AcceptChanges(); }
/// <summary> /// Loads the shipment LineItems. /// </summary> /// <param name="iStartIndex">Start index of the i.</param> /// <param name="iNumItems">The i num items.</param> /// <param name="sFilter">The s filter.</param> private void LoadShipmentLineItems() { string indexColumnName = "LineItemIndex"; string idColumnName = "LineItemId"; string checkedColumnName = "Checked"; string nameColumnName = "Name"; DataTable lineItemsDT = new DataTable(); lineItemsDT.Columns.AddRange(new DataColumn[4] { new DataColumn(indexColumnName, typeof(int)), new DataColumn(idColumnName, typeof(int)), new DataColumn(checkedColumnName, typeof(bool)), new DataColumn(nameColumnName, typeof(string)) }); // get items that are not associated with any shipment yet ShipmentCollection allShipments = _order.OrderForms[0].Shipments; LineItemCollection orderLineItems = _order.OrderForms[0].LineItems; int index = -1; foreach (LineItem li in orderLineItems) { index++; bool isInShipment = false; bool isInCurrentShipment = false; if (SelectedShipment != null && SelectedShipment.LineItemIndexes.Contains(index.ToString())) { // if it is current shipment, add lineItem to the grid isInCurrentShipment = true; } else { foreach (Shipment shipment in allShipments) { if (shipment != SelectedShipment && shipment.LineItemIndexes.Contains(index.ToString())) { isInShipment = true; break; } } } if (!isInShipment || isInCurrentShipment) { // if it is current shipment, add lineItem to the grid DataRow row = lineItemsDT.NewRow(); row[indexColumnName] = index; row[idColumnName] = li.LineItemId; row[checkedColumnName] = isInCurrentShipment; row[nameColumnName] = li.DisplayName; lineItemsDT.Rows.Add(row); } } ShipmentItemsList.DataSource = lineItemsDT.DefaultView; ShipmentItemsList.DataBind(); }
/// <summary> /// Calculates the shipping discounts and sets the discount message for the sample store user controls. /// </summary> /// <param name="shipmentCollection"></param> /// <param name="currency"></param> /// <param name="shippingDiscountMessage"></param> /// <returns></returns> internal Money CalculateShippingDiscounts(ShipmentCollection shipmentCollection, Currency currency, out string shippingDiscountMessage) { return CalculateShippingDiscounts(shipmentCollection.Cast<Shipment>(), currency, out shippingDiscountMessage); }
/// <summary> /// Sums the shipping COSTS of a Cart without the discounts applied. /// </summary> /// <param name="shipments"></param> /// <returns></returns> internal Money CalculateShippingCostSubTotal(ShipmentCollection shipments, CartHelper cartHelper) { return CalculateShippingCostSubTotal(shipments.Cast<Shipment>(), cartHelper); }
/// <summary> /// Sums the shipping COSTS of a Cart without the discounts applied. /// </summary> /// <param name="shipments"></param> /// <returns></returns> internal Money CalculateShippingCostSubTotal(ShipmentCollection shipments, CartHelper cartHelper) { return(CalculateShippingCostSubTotal(shipments.Cast <Shipment>(), cartHelper)); }
/// <summary> /// Calculates the shipping discounts and sets the discount message for the sample store user controls. /// </summary> /// <param name="shipmentCollection"></param> /// <param name="currency"></param> /// <param name="shippingDiscountMessage"></param> /// <returns></returns> internal Money CalculateShippingDiscounts(ShipmentCollection shipmentCollection, Currency currency, out string shippingDiscountMessage) { return(CalculateShippingDiscounts(shipmentCollection.Cast <Shipment>(), currency, out shippingDiscountMessage)); }