public void GetItems_NoItemsStored_ReturnEmptyList()
        {
            var service = new InventoryService();

            var result = service.GetProducts();

            result.Should().BeEmpty();
        }
Beispiel #2
0
        private static OrderDetailEntity TranslateOrderDetailEntity(OrderDetailInfo info)
        {
            OrderDetailEntity entity = new OrderDetailEntity();

            if (info != null)
            {
                entity.ID          = info.ID;
                entity.OrderID     = info.OrderID;
                entity.GoodsID     = info.GoodsID;
                entity.InventoryID = info.InventoryID;
                entity.GoodsNo     = info.GoodsNo;
                entity.GoodsName   = info.GoodsName;
                entity.GoodsModel  = info.GoodsModel;
                entity.Quantity    = info.Quantity;
                entity.Units       = info.Units;
                entity.Weight      = info.Weight;
                entity.TotalWeight = string.IsNullOrEmpty(info.Weight) ? "0" : (info.Weight.ToInt(0) * info.Quantity).ToString();
                entity.BatchNumber = info.BatchNumber;
                entity.ProductDate = info.ProductDate;
                entity.ExceedDate  = info.ExceedDate;
                entity.CreateDate  = info.CreateDate;
                entity.ChangeDate  = info.ChangeDate;
                entity.CreateDate  = info.CreateDate;
                entity.ChangeDate  = info.ChangeDate;

                entity.goods = new GoodsEntity();
                if (entity.GoodsID > 0)
                {
                    entity.goods = GoodsService.GetGoodsEntityById(entity.GoodsID);
                }

                entity.inventory = new InventoryEntity();
                if (entity.InventoryID > 0)
                {
                    entity.inventory = InventoryService.GetInventoryById(entity.InventoryID);
                }
                entity.WaitQuantity   = entity.inventory != null ? entity.inventory.Quantity : 0;
                entity.CanUseQuantity = entity.Quantity - entity.WaitQuantity;
            }

            return(entity);
        }
Beispiel #3
0
        /// <summary>
        /// 出库操作
        /// </summary>
        /// <param name="GoodsID"></param>
        /// <param name="InventoryID"></param>
        /// <param name="BatchNumber"></param>
        /// <param name="OutQuantity"></param>
        /// <param name="UserID"></param>
        public static void InventoryOut(int GoodsID, int InventoryID, string BatchNumber, int OutQuantity, long UserID)
        {
            // 当前库存信息
            InventoryEntity entity = InventoryService.GetInventoryEntityById(InventoryID);
            // 商品信息
            GoodsEntity goodsEntity = GoodsService.GetGoodsEntityById(GoodsID);

            if (entity != null && goodsEntity != null)
            {
                // 库存可用数量=库存数量-待出库数量
                int canQuantity = entity.Quantity - entity.WaitQuantity;
                if (canQuantity >= OutQuantity)
                {
                    entity.Quantity = canQuantity - OutQuantity;
                    // 商品库存扣减
                    OrderInventoryService.ModifyQuantity(entity);

                    //记录库存明细
                    createInventoryDetail(entity, goodsEntity, UserID);
                }
            }
        }
Beispiel #4
0
        /// <summary>
        /// 库存处理
        /// </summary>
        /// <param name="orderInfo"></param>
        private static void OutInventoryProcess(OrderEntity orderInfo)
        {
            List <OrderDetailEntity> orderDetailList = orderInfo.orderDetailList;

            if (orderDetailList != null && orderDetailList.Count > 0)
            {
                foreach (OrderDetailEntity entity in orderDetailList)
                {
                    List <InventoryEntity> inventoryList = new List <InventoryEntity>();
                    if (entity.InventoryID > 0)
                    {
                        inventoryList.Add(InventoryService.GetInventoryEntityById(entity.InventoryID));
                    }
                    //同商品+批次号+客户
                    else
                    {
                        inventoryList = InventoryService.GetInventoryByRule(entity.GoodsID, -1, entity.BatchNumber.Trim(), orderInfo.CustomerID, true);
                    }

                    inventoryInfoProcess(entity, inventoryList, orderInfo);
                }
            }
        }