Ejemplo n.º 1
0
 public ComplemarOrderHelper(Order order, MasterOrder masterOrder, ShipAddress shipAddress)
 {
     _order = order;
     _masterOrder = masterOrder;
     _orderItems = order.OrderLineItems.ToList();
     _shipAddress = shipAddress;
 }
Ejemplo n.º 2
0
        /* ******************************* Order Request *********************************
         * Required Fields:
         *
         * Items        -	List of items to order      -	ArrayOfOrderRequestItems   -    N/A
         * JobNumber    -	Customer contract number    -  	int
         * OrderedBy    -	Person placing order        -	OrderedByRequest
         * ShipTo	    -   Person receiving order      -	ShipToRequest
         *
         * *******************************************************************************/
        public OrderRequest EmitOrderRequest(Order order, MasterOrder masterOrder, List<OrderLineItem> orderItems, ShipAddress shipAddress, string uniqueId = null)
        {
            var orderRequest = new OrderRequest();
            var itemArray = new OrderRequestItem[orderItems.Count];
            // add item request for each item
            for (var i = 0; i < orderItems.Count; i++)
            {
                itemArray[i] = EmitOrderRequestItem(orderItems[i]);
            }
            orderRequest.Items = itemArray;

            orderRequest.OrderName = masterOrder.MasterOrderId.ToString(CultureInfo.InvariantCulture);
            orderRequest.JobNumber = 52000;
            orderRequest.OrderedBy = EmitOrderedByRequest(shipAddress);
            orderRequest.ShipTo = new[] { EmitShipToRequest(shipAddress) };
            orderRequest.Comment = "TEST ORDER: DO NOT SHIP";
            orderRequest.Transaction = 0; //*int.Parse(*/masterOrder.MasterOrderId;//.ToString() + masterOrder.CreateDateTime.Hour.ToString() + masterOrder.CreateDateTime.Minute.ToString()
            orderRequest.OrderPrefix = "FI";

            orderRequest.CreatedBy = uniqueId;

            orderRequest.TType = TransactionTypes.StandardOrder;

            #region Additional Fields

            orderRequest.REC_NUM = 0;
            //+ masterOrder.CreateDateTime.Second.ToString());
            orderRequest.Sequence = 0;
            //orderRequest.METHOD = 0;
            //orderRequest.WarehouseID = 0;
            orderRequest.OrderOrigination = OrderSources.Web;
            //orderRequest.Status = OrderStatuses.Open;
            //orderRequest.OrderApprovalStatus = ApprovalStatus.Approved;
            //orderRequest.CreatedDate = DateTime.Now;
            //orderRequest.CustReference = string.Empty;
            //orderRequest.CustomerNumber = string.Empty;
            // orderRequest.CustomerOrderType = string.Empty;
            //orderRequest.LastModDate = DateTime.Now;
            // orderRequest.LastUpdatedBy = string.Empty;
            //orderRequest.DiscountCode = 'a';
            // orderRequest.UsageCode = 'a';
            orderRequest.CustomerID = shipAddress.SubscriberId;
            #endregion

            System.Diagnostics.Debug.WriteLine(orderRequest.ToString());
            return orderRequest;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// if any special "ground ship only" (gso) items exist on an order, move them to a new order under the same master order.
        /// the shipping method isn't explicitly defined. It is handled by the shipping vendor.
        /// </summary>
        /// <param name="masterOrder"></param>
        /// <param name="fulfillmentLocation"></param>
        private void HandleGroundShipOnlyItems(MasterOrder masterOrder, int fulfillmentLocation)
        {
            if (masterOrder == null) return;

            var groundShipOnlyItems = ConfigurationManager.AppSettings["groundShipOnlyItems"];

            if (groundShipOnlyItems == null)
            {
                throw new Exception("Missing configuration value for the groundship only items");
            }

            var groundShipOnlyItemSKUs = groundShipOnlyItems.Split(',').ToList();
            var groundShipOnlyEquipTypes =
                DBCache.EquipmentTypes.Where(e => groundShipOnlyItemSKUs.Contains(e.FrontierSKU)).ToList();
            var newOrders = new List<Order>();

            foreach (var order in masterOrder.Orders)
            {
                if (order == null) continue;

                // get all gso items on the order
                var groundOnlyOrderLineItems =
                    order.OrderLineItems.Where(
                        o => groundShipOnlyEquipTypes.Select(e => e.EquipmentTypeId).Contains(o.EquipTypeId)).ToList();

                // if no gso's exist or ONLY gso's exist, do nothing
                if (!groundOnlyOrderLineItems.Any() || groundOnlyOrderLineItems.Count() == order.OrderLineItems.Count)
                    continue;

                // otherwise, remove them from the current order and place on a new one
                var newOrderLineItems = groundOnlyOrderLineItems.ToList();
                var orderLineItems = order.OrderLineItems.Except(groundOnlyOrderLineItems).ToList();

                newOrders.Add(GenerateOrder(OrderTypeEnum.Dropship, order.ShipAddress1, newOrderLineItems,
                    fulfillmentLocation));

                while (order.OrderLineItems.Any())
                {
                    order.OrderLineItems.Remove(order.OrderLineItems.First());
                }

                foreach (var orderLineItem in orderLineItems)
                {
                    order.OrderLineItems.Add(orderLineItem);
                }
            }

            masterOrder.Orders.AddRange(newOrders);
        }
Ejemplo n.º 4
0
        private MasterOrder GenerateMasterOrder(OrderTypeEnum orderType, string commentText, int entityId, int receivingId = 0)
        {
            if (receivingId == 0)
            {
                receivingId = entityId;
            }
            // Assign order and master order properties
            var masterOrder = new MasterOrder
                {
                    CreatingEntityId = entityId,
                    CreateDateTime = DateTime.Now,
                    ReceivingEntityId = orderType == OrderTypeEnum.Dropship ? 8 : receivingId
                };

            // find a master order number that doesn't exist
            var masterOrderNumber = 0;
            using (var context = DBContextFactory.CreateContext())
            {
                while (masterOrderNumber == 0 || context.MasterOrders.FirstOrDefault(o => o.MasterOrderId == masterOrderNumber) != null)
                {
                    masterOrderNumber = _random.Next(100000000, 999999999);
                }
            }

            masterOrder.MasterOrderId = masterOrderNumber;

            if (!String.IsNullOrEmpty(commentText))
            {
                var comment = new Comment
                    {
                        CommentEntityId = entityId,
                        CommentOrderId = masterOrder.MasterOrderId,
                        CommentText = commentText,
                        CommentTime = masterOrder.CreateDateTime
                    };

                masterOrder.Comments.Add(comment);
            }
            return masterOrder;
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Some items require their own order due to certain limitations. This method splits those items out into
 /// their own orders.
 /// </summary>
 /// <param name="masterOrder"></param>
 /// <param name="fulfillmentLocation"></param>
 private void ApplyBusinessRulesToOrder(MasterOrder masterOrder, int fulfillmentLocation)
 {
     HandleGroundShipOnlyItems(masterOrder, fulfillmentLocation);
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Create a new MasterOrder object.
 /// </summary>
 /// <param name="masterOrderId">Initial value of the MasterOrderId property.</param>
 /// <param name="receivingEntityId">Initial value of the ReceivingEntityId property.</param>
 /// <param name="creatingEntityId">Initial value of the CreatingEntityId property.</param>
 /// <param name="createDateTime">Initial value of the CreateDateTime property.</param>
 public static MasterOrder CreateMasterOrder(global::System.Int32 masterOrderId, global::System.Int32 receivingEntityId, global::System.Int32 creatingEntityId, global::System.DateTime createDateTime)
 {
     MasterOrder masterOrder = new MasterOrder();
     masterOrder.MasterOrderId = masterOrderId;
     masterOrder.ReceivingEntityId = receivingEntityId;
     masterOrder.CreatingEntityId = creatingEntityId;
     masterOrder.CreateDateTime = createDateTime;
     return masterOrder;
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Deprecated Method for adding a new object to the MasterOrders EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToMasterOrders(MasterOrder masterOrder)
 {
     base.AddObject("MasterOrders", masterOrder);
 }