Ejemplo n.º 1
0
        public InventoryPickOrderItemParameter(InventoryPickOrderItem orderItem) : this(orderItem, orderItem, orderItem, orderItem.Quantity, orderItem.Customer, orderItem.CustomerProductCode, orderItem.CustomerLotCode)
        {
            var cast = ((ISchedulePickOrderItemParameter)this);

            cast.PickOrderKey = new InventoryPickOrderKey(orderItem);
            cast.ItemSequence = orderItem.ItemSequence;
        }
        private IResult ValidateModifyPickedInventoryItems(InventoryShipmentOrder order, IEnumerable <ModifyPickedInventoryItemParameters> items)
        {
            var validator  = PickedInventoryValidator.ForInterWarehouseOrder(order.SourceFacility);
            var orderItems = order.InventoryPickOrder.Items.ToDictionary(i => i.ToInventoryPickOrderItemKey());

            foreach (var item in items)
            {
                InventoryPickOrderItem orderItem = null;
                if (item.OrderItemKey != null && !orderItems.TryGetValue(item.OrderItemKey, out orderItem))
                {
                    return(new InvalidResult(string.Format(UserMessages.CannotPickForOrderItem_DoesNotExist, item.OrderItemKey)));
                }

                if (item.NewQuantity > item.OriginalQuantity)
                {
                    Dictionary <string, Inventory> inventory;
                    var validResult = validator.ValidateItems(_inventoryShipmentUnitOfWork.InventoryRepository, new[] { item.InventoryKey }, out inventory);

                    IChileProductKey chileProduct;
                    if (orderItem != null)
                    {
                        chileProduct = ChileProductKey.FromProductKey(orderItem.Product);
                    }
                    else
                    {
                        var lotKey = inventory.Single().Value.ToLotKey();
                        chileProduct = _inventoryShipmentUnitOfWork.ChileLotRepository.FindByKey(lotKey);
                        if (chileProduct == null)
                        {
                            return(new InvalidResult(string.Format(UserMessages.ChileLotNotFound, lotKey)));
                        }
                    }

                    IDictionary <AttributeNameKey, ChileProductAttributeRange>    productSpec;
                    IDictionary <AttributeNameKey, CustomerProductAttributeRange> customerSpec;
                    var specResult = new GetProductSpecCommand(_inventoryShipmentUnitOfWork).Execute(chileProduct, orderItem == null ? null : orderItem.Customer, out productSpec, out customerSpec);
                    if (!specResult.Success)
                    {
                        return(specResult);
                    }

                    var inventoryItem  = inventory.Values.Single();
                    var context        = new PickingValidatorContext(productSpec, customerSpec, null, null, orderItem == null ? null : orderItem.Customer);
                    var pickable       = new PickingValidator(inventoryItem.Lot);
                    var pickableResult = pickable.ValidForPicking(context);

                    if (!validResult.Success || !pickableResult.Success)
                    {
                        return(new InvalidResult(new[] { validResult, pickableResult }.CombineMessages()));
                    }
                }
            }

            return(new SuccessResult());
        }
        internal static InventoryPickOrderItem SetTreatment(this InventoryPickOrderItem item, IInventoryTreatmentKey treatment)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }

            item.InventoryTreatment = null;
            item.TreatmentId        = treatment.InventoryTreatmentKey_Id;

            return(item);
        }
        internal static InventoryPickOrderItem SetPackaging(this InventoryPickOrderItem item, IPackagingProductKey packaging)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }

            item.PackagingProduct   = null;
            item.PackagingProductId = packaging.PackagingProductKey_ProductId;

            return(item);
        }
        internal static InventoryPickOrderItem SetProduct(this InventoryPickOrderItem item, IProductKey productKey)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }

            if (productKey != null)
            {
                item.Product   = null;
                item.ProductId = productKey.ProductKey_ProductId;
            }

            return(item);
        }
        internal static InventoryPickOrderItem SetCustomer(this InventoryPickOrderItem item, ICustomerKey customer)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }

            if (customer != null)
            {
                item.Customer   = null;
                item.CustomerId = customer == null ? (int?)null : customer.CustomerKey_Id;
            }

            return(item);
        }
        internal static InventoryPickOrderItem SetOrder(this InventoryPickOrderItem item, IInventoryPickOrderKey pickOrderKey)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }

            if (pickOrderKey != null)
            {
                item.InventoryPickOrder = null;
                item.DateCreated        = pickOrderKey.InventoryPickOrderKey_DateCreated;
                item.OrderSequence      = pickOrderKey.InventoryPickOrderKey_Sequence;
            }

            return(item);
        }
        public IResult Execute(ISchedulePickOrderItemParameter item)
        {
            var newSequence = new EFUnitOfWorkHelper(_inventoryPickOrderUnitOfWork).GetNextSequence(InventoryPickOrderItemPredicates.FilterByInventoryPickOrderKey(item.PickOrderKey), i => i.ItemSequence);

            var newItem = new InventoryPickOrderItem
            {
                DateCreated         = item.PickOrderKey.InventoryPickOrderKey_DateCreated,
                OrderSequence       = item.PickOrderKey.InventoryPickOrderKey_Sequence,
                ItemSequence        = newSequence,
                ProductId           = item.ProductId,
                PackagingProductId  = item.PackagingProductId,
                TreatmentId         = item.TreatmentId ?? StaticInventoryTreatments.NoTreatment.Id,
                Quantity            = item.Quantity,
                CustomerLotCode     = item.CustomerLotCode,
                CustomerProductCode = item.CustomerProductCode,
                CustomerId          = item.CustomerKey != null ? item.CustomerKey.CustomerKey_Id : (int?)null
            };

            _inventoryPickOrderUnitOfWork.InventoryPickOrderItemRepository.Add(newItem);

            return(new SuccessResult());
        }
Ejemplo n.º 9
0
 private void ConstrainItemToOrder(InventoryPickOrderItem item, InventoryPickOrder order)
 {
     item.DateCreated   = order.DateCreated;
     item.OrderSequence = order.Sequence;
 }