예제 #1
0
        public ActionResult AddShipment(int orderId)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageOrders))
                return AccessDeniedView();

            var order = _orderService.GetOrderById(orderId);
            if (order == null)
                //No order found with the specified id
                return RedirectToAction("List");

            var model = new ShipmentModel()
            {
                OrderId = order.Id,
            };

            //measures
            var baseWeight = _measureService.GetMeasureWeightById(_measureSettings.BaseWeightId);
            var baseWeightIn = baseWeight != null ? baseWeight.Name : "";
            var baseDimension = _measureService.GetMeasureDimensionById(_measureSettings.BaseDimensionId);
            var baseDimensionIn = baseDimension != null ? baseDimension.Name : "";

            foreach (var opv in order.OrderProductVariants)
            {
                //we can ship only shippable products
                if (!opv.ProductVariant.IsShipEnabled)
                    continue;

                //quantities
                var qtyInThisShipment = 0;
                var maxQtyToAdd = opv.GetTotalNumberOfItemsCanBeAddedToShipment();
                var qtyOrdered = opv.Quantity;
                var qtyInAllShipments = opv.GetTotalNumberOfItemsInAllShipment();

                //ensure that this product variant can be added to a shipment
                if (maxQtyToAdd <= 0)
                    continue;

                var sopvModel = new ShipmentModel.ShipmentOrderProductVariantModel()
                {
                    OrderProductVariantId = opv.Id,
                    ProductVariantId = opv.ProductVariantId,
                    Sku = opv.ProductVariant.Sku,
                    AttributeInfo = opv.AttributeDescription,
                    ItemWeight = opv.ItemWeight.HasValue ? string.Format("{0:F2} [{1}]", opv.ItemWeight, baseWeightIn) : "",
                    ItemDimensions = string.Format("{0:F2} x {1:F2} x {2:F2} [{3}]", opv.ProductVariant.Length, opv.ProductVariant.Width, opv.ProductVariant.Height, baseDimensionIn),
                    QuantityOrdered = qtyOrdered,
                    QuantityInThisShipment = qtyInThisShipment,
                    QuantityInAllShipments = qtyInAllShipments,
                    QuantityToAdd = maxQtyToAdd,
                };

                //product name
                if (!String.IsNullOrEmpty(opv.ProductVariant.Name))
                    sopvModel.FullProductName = string.Format("{0} ({1})", opv.ProductVariant.Product.Name, opv.ProductVariant.Name);
                else
                    sopvModel.FullProductName = opv.ProductVariant.Product.Name;
                model.Products.Add(sopvModel);
            }

            return View(model);
        }
예제 #2
0
        public ActionResult AddShipment(int orderId)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageOrders))
                return AccessDeniedView();

            var order = _orderService.GetOrderById(orderId);
            if (order == null)
                //No order found with the specified id
                return RedirectToAction("List");

            var model = new ShipmentModel()
            {
                OrderId = order.Id,
            };

            foreach (var opv in order.OrderProductVariants)
            {
                //we can ship only shippable products
                if (!opv.ProductVariant.IsShipEnabled)
                    continue;

                //quantities
                var qtyShippedTotal = opv.GetTotalNumberOfShippedItems();
                var qtyOrdered = opv.Quantity;
                var maxQtyToShip = qtyOrdered - qtyShippedTotal;
                if (maxQtyToShip < 0)
                    maxQtyToShip = 0;

                //ensure that this product variant can be shipped (have at least one item to ship)
                if (maxQtyToShip <= 0)
                    continue;

                var sopvModel = new ShipmentModel.ShipmentOrderProductVariantModel()
                {
                    OrderProductVariantId = opv.Id,
                    ProductVariantId = opv.ProductVariantId,
                    AttributeInfo = opv.AttributeDescription,
                    QuantityOrdered = qtyOrdered,
                    QuantityShippedTotal = qtyShippedTotal,
                    QuantityToShip = maxQtyToShip,
                };

                //product name
                if (!String.IsNullOrEmpty(opv.ProductVariant.Name))
                    sopvModel.FullProductName = string.Format("{0} ({1})", opv.ProductVariant.Product.Name, opv.ProductVariant.Name);
                else
                    sopvModel.FullProductName = opv.ProductVariant.Product.Name;
                model.Products.Add(sopvModel);
            }

            return View(model);
        }
예제 #3
0
        protected ShipmentModel PrepareShipmentModel(Shipment shipment, bool prepareProducts)
        {
            //measures
            var baseWeight = _measureService.GetMeasureWeightById(_measureSettings.BaseWeightId);
            var baseWeightIn = baseWeight != null ? baseWeight.Name : "";
            var baseDimension = _measureService.GetMeasureDimensionById(_measureSettings.BaseDimensionId);
            var baseDimensionIn = baseDimension != null ? baseDimension.Name : "";

            var model = new ShipmentModel()
            {
                Id = shipment.Id,
                OrderId = shipment.OrderId,
                TrackingNumber = shipment.TrackingNumber,
                TotalWeight = shipment.TotalWeight.HasValue ? string.Format("{0:F2} [{1}]", shipment.TotalWeight, baseWeightIn) : "",
                ShippedDate = shipment.ShippedDateUtc.HasValue ? _dateTimeHelper.ConvertToUserTime(shipment.ShippedDateUtc.Value, DateTimeKind.Utc).ToString() : _localizationService.GetResource("Admin.Orders.Shipments.ShippedDate.NotYet"),
                CanShip = !shipment.ShippedDateUtc.HasValue,
                DeliveryDate = shipment.DeliveryDateUtc.HasValue ? _dateTimeHelper.ConvertToUserTime(shipment.DeliveryDateUtc.Value, DateTimeKind.Utc).ToString() : _localizationService.GetResource("Admin.Orders.Shipments.DeliveryDate.NotYet"),
                CanDeliver = shipment.ShippedDateUtc.HasValue && !shipment.DeliveryDateUtc.HasValue,
                DisplayPdfPackagingSlip = _pdfSettings.Enabled,
            };

            if (prepareProducts)
            {
                foreach (var sopv in shipment.ShipmentOrderProductVariants)
                {
                    var opv = _orderService.GetOrderProductVariantById(sopv.OrderProductVariantId);
                    if (opv == null)
                        continue;

                    //quantities
                    var qtyInThisShipment = sopv.Quantity;
                    var maxQtyToAdd = opv.GetTotalNumberOfItemsCanBeAddedToShipment();
                    var qtyOrdered = opv.Quantity;
                    var qtyInAllShipments = opv.GetTotalNumberOfItemsInAllShipment();

                    var sopvModel = new ShipmentModel.ShipmentOrderProductVariantModel()
                    {
                        Id = sopv.Id,
                        OrderProductVariantId = opv.Id,
                        ProductVariantId = opv.ProductVariantId,
                        Sku = opv.ProductVariant.Sku,
                        AttributeInfo = opv.AttributeDescription,
                        ItemWeight = opv.ItemWeight.HasValue ? string.Format("{0:F2} [{1}]", opv.ItemWeight, baseWeightIn) : "",
                        ItemDimensions = string.Format("{0:F2} x {1:F2} x {2:F2} [{3}]", opv.ProductVariant.Length, opv.ProductVariant.Width, opv.ProductVariant.Height, baseDimensionIn),
                        QuantityOrdered = qtyOrdered,
                        QuantityInThisShipment = qtyInThisShipment,
                        QuantityInAllShipments = qtyInAllShipments,
                        QuantityToAdd = maxQtyToAdd,
                    };

                    //product name
                    if (!String.IsNullOrEmpty(opv.ProductVariant.Name))
                        sopvModel.FullProductName = string.Format("{0} ({1})", opv.ProductVariant.Product.Name,
                                                                  opv.ProductVariant.Name);
                    else
                        sopvModel.FullProductName = opv.ProductVariant.Product.Name;
                    model.Products.Add(sopvModel);
                }
            }
            return model;
        }
예제 #4
0
        public ActionResult ShipmentDetails(int id)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageOrders))
                return AccessDeniedView();

            var shipment = _shipmentService.GetShipmentById(id);
            if (shipment == null)
                //No shipment found with the specified id
                return RedirectToAction("List");

            var model = new ShipmentModel()
            {
                Id = shipment.Id,
                OrderId = shipment.OrderId,
                TrackingNumber = shipment.TrackingNumber,
                ShippedDate = _dateTimeHelper.ConvertToUserTime(shipment.ShippedDateUtc, DateTimeKind.Utc).ToString(),
                DeliveryDate = shipment.DeliveryDateUtc.HasValue ? _dateTimeHelper.ConvertToUserTime(shipment.DeliveryDateUtc.Value, DateTimeKind.Utc).ToString() : _localizationService.GetResource("Admin.Orders.Shipments.DeliveryDate.NotYet"),
                CanDeliver = !shipment.DeliveryDateUtc.HasValue,
                DisplayPdfPackagingSlip = _pdfSettings.Enabled,
            };

            foreach (var sopv in shipment.ShipmentOrderProductVariants)
            {
                var opv = _orderService.GetOrderProductVariantById(sopv.OrderProductVariantId);
                if (opv == null)
                    continue;

                //quantities
                var qtyShipped = sopv.Quantity;
                var qtyShippedTotal = opv.GetTotalNumberOfShippedItems();
                var qtyOrdered = opv.Quantity;
                var maxQtyToShip = qtyOrdered - qtyShippedTotal;
                if (maxQtyToShip < 0)
                    maxQtyToShip = 0;

                var sopvModel = new ShipmentModel.ShipmentOrderProductVariantModel()
                {
                    Id = sopv.Id,
                    OrderProductVariantId = opv.Id,
                    ProductVariantId = opv.ProductVariantId,
                    AttributeInfo = opv.AttributeDescription,
                    QuantityOrdered = qtyOrdered,
                    QuantityShipped = qtyShipped,
                    QuantityShippedTotal = qtyShippedTotal,
                    QuantityToShip = maxQtyToShip,
                };

                //product name
                if (!String.IsNullOrEmpty(opv.ProductVariant.Name))
                    sopvModel.FullProductName = string.Format("{0} ({1})", opv.ProductVariant.Product.Name, opv.ProductVariant.Name);
                else
                    sopvModel.FullProductName = opv.ProductVariant.Product.Name;
                model.Products.Add(sopvModel);
            }

            return View(model);
        }