コード例 #1
0
        public void GetStockAdjustmentDetail_Test()
        {
            StockAdjustment sa = new StockAdjustment();

            sa.StockAdjustmentId = "test1";
            sa.CreatedBy         = new UserService(context).FindUserByEmail("*****@*****.**");
            sa.CreatedDateTime   = DateTime.Now;
            sa.Remarks           = "THIS IS A TEST";
            sa.Status            = statusRepository.FindById(4);

            StockAdjustmentDetail sad = new StockAdjustmentDetail();

            sad.StockAdjustmentId = "test1";
            sad.Reason            = "test1";
            sad.ItemCode          = "C001";

            List <StockAdjustmentDetail> detaillist = new List <StockAdjustmentDetail>();

            detaillist.Add(sad);

            sa.StockAdjustmentDetails = detaillist;
            saRepository.Save(sa);


            StockAdjustmentAPIController controller = new StockAdjustmentAPIController()
            {
                CurrentUserName = "******",
                Context         = this.context
            };

            StockAdjustmentDetailViewModel result = controller.GetStockAdjustmentDetail("test1").First();

            Assert.AreEqual(result.Reason, "test1");
            saRepository.Delete(saRepository.FindById("test1"));
        }
コード例 #2
0
        public IEnumerable <StockAdjustmentDetailViewModel> GetStockAdjustmentDetail(string StockAdjustmentId)
        {
            stockAdjustmentService = new StockAdjustmentService(Context);
            itemPriceService       = new ItemPriceService(Context);
            itemService            = new ItemService(Context);

            List <StockAdjustmentDetailViewModel> detailListViewModel = new List <StockAdjustmentDetailViewModel>();
            StockAdjustment sd = stockAdjustmentService.FindStockAdjustmentById(StockAdjustmentId);
            List <StockAdjustmentDetail> detaillist = sd.StockAdjustmentDetails;

            foreach (StockAdjustmentDetail sad in detaillist)
            {
                StockAdjustmentDetailViewModel sadv = new StockAdjustmentDetailViewModel();
                string itemcode = sad.ItemCode;
                sadv.ItemCode = itemcode;
                Item item = itemService.FindItemByItemCode(itemcode);
                sadv.Description = item.Description == null ? "" : item.Description;
                sadv.Reason      = sad.Reason == null ? "" : sad.Reason;

                sadv.UnitPrice = itemPriceService.GetDefaultPrice(item, 1);
                if (sadv.UnitPrice.CompareTo("250") == -1)
                {
                    sadv.PriceColor = "-1";
                }
                else
                {
                    sadv.PriceColor = "1";
                }

                sadv.Adjustment = sad.AfterQuantity - sad.OriginalQuantity;
                detailListViewModel.Add(sadv);
            }
            ;


            return(detailListViewModel);
        }