コード例 #1
0
        public void CheckSave(DeliveryOrder deliveryOrder)
        {
            foreach (DeliveryOrderDetail dod in deliveryOrder.DeliveryOrderDetails)
            {
                PurchaseOrderDetail purchaseOrderDetail = purchaseOrderService.FindPurchaseOrderDetailbyIdItem(deliveryOrder.PurchaseOrder.PurchaseOrderNo, dod.ItemCode);

                if (dod.ActualQuantity == dod.PlanQuantity)
                {
                    purchaseOrderDetail.Status = statusRepository.FindById(13);
                }

                else if (purchaseOrderDetail.Quantity != dod.ActualQuantity)
                {
                    purchaseOrderDetail.Status = statusRepository.FindById(12);
                }

                purchaseOrderDetailsRepository.Save(purchaseOrderDetail);

                deliveryOrderDetailRepository.Save(dod);

                SaveInventory(itemRepository.FindById(dod.ItemCode), dod.ActualQuantity);

                SaveStockMovement(dod);
            }

            deliveryOrderRepository.Save(deliveryOrder);


            PurchaseOrder po   = deliveryOrder.PurchaseOrder;
            int           flag = 0;

            foreach (PurchaseOrderDetail pod in po.PurchaseOrderDetails)
            {
                if ((pod.Status.StatusId == 12) || (pod.Status.StatusId == 11))
                {
                    po.Status = statusRepository.FindById(12);

                    purchaseOrderRepository.Save(po);

                    flag = 1;

                    break;
                }
            }


            if (flag != 1)
            {
                po.Status = statusRepository.FindById(13);
                purchaseOrderRepository.Save(po);
            }
        }
コード例 #2
0
        public void FindByIdTestNotNull()
        {
            // Arrange
            var expected = new DeliveryOrderDetail()
            {
                DeliveryOrderNo = "DODREPOTEST",
                ItemCode        = "E030",
            };

            deliveryOrderRepository.Save(new DeliveryOrder()
            {
                DeliveryOrderNo = "DODREPOTEST",
                CreatedDateTime = DateTime.Now,
            });
            deliveryOrderDetailRepository.Save(expected);

            // Act
            var result = deliveryOrderDetailRepository.FindById("DODREPOTEST", "E030");

            // Assert
            Assert.IsInstanceOfType(result, typeof(DeliveryOrderDetail));
        }
コード例 #3
0
        public void FindReceivedQuantityByPurchaseOrderDetailTest()
        {
            Item i = new Item();

            i.ItemCode        = "IT3";
            i.ReorderLevel    = 100;
            i.ReorderQuantity = 500;
            i.CreatedDateTime = DateTime.Now;

            itemRepository.Save(i);

            Item i2 = new Item();

            i2.ItemCode        = "IT4";
            i2.ReorderLevel    = 100;
            i2.ReorderQuantity = 500;
            i2.CreatedDateTime = DateTime.Now;

            itemRepository.Save(i2);


            PurchaseOrder p1 = new PurchaseOrder();

            p1.PurchaseOrderNo = "PO3";
            p1.Status          = statusRepository.FindById(12);
            p1.Status.StatusId = 12;
            p1.Supplier        = supplierRepository.FindById("CHEP");
            p1.CreatedDateTime = DateTime.Now;

            PurchaseOrderDetail pd1 = new PurchaseOrderDetail();

            pd1.PurchaseOrder   = p1;
            pd1.PurchaseOrderNo = "PO3";
            pd1.Item            = itemRepository.FindById("IT3");
            pd1.ItemCode        = i.ItemCode;
            pd1.Quantity        = 15;
            pd1.Status          = statusRepository.FindById(12);

            PurchaseOrderDetail pd2 = new PurchaseOrderDetail();

            pd2.PurchaseOrder   = p1;
            pd2.PurchaseOrderNo = "PO3";
            pd2.Item            = itemRepository.FindById("IT4");
            pd2.ItemCode        = i2.ItemCode;
            pd2.Quantity        = 50;
            pd2.Status          = statusRepository.FindById(12);

            p1.PurchaseOrderDetails = new List <PurchaseOrderDetail>();

            p1.PurchaseOrderDetails.Add(pd1);
            p1.PurchaseOrderDetails.Add(pd2);


            purchaseOrderRepository.Save(p1);
            purchaseOrderDetailRepository.Save(pd1);
            purchaseOrderDetailRepository.Save(pd2);

            DeliveryOrder d1 = new DeliveryOrder();

            d1.DeliveryOrderNo = "DO1";
            d1.PurchaseOrder   = p1;
            d1.PurchaseOrder.PurchaseOrderNo = "PO3";
            d1.CreatedDateTime = DateTime.Now;

            DeliveryOrderDetail do1 = new DeliveryOrderDetail();

            do1.DeliveryOrderNo = "DO1";
            do1.Item            = itemRepository.FindById("IT3");
            do1.ItemCode        = i.ItemCode;
            do1.ActualQuantity  = 10;
            do1.PlanQuantity    = 15;

            DeliveryOrderDetail do2 = new DeliveryOrderDetail();

            do2.DeliveryOrderNo = "DO1";
            do2.Item            = itemRepository.FindById("IT4");
            do2.ItemCode        = i2.ItemCode;
            do2.ActualQuantity  = 10;
            do2.PlanQuantity    = 50;

            d1.DeliveryOrderDetails = new List <DeliveryOrderDetail>();

            d1.DeliveryOrderDetails.Add(do1);
            d1.DeliveryOrderDetails.Add(do2);

            deliveryOrderRepository.Save(d1);

            deliveryOrderDetailRepository.Save(do1);
            deliveryOrderDetailRepository.Save(do2);


            DeliveryOrder d2 = new DeliveryOrder();

            d2.DeliveryOrderNo = "DO2";
            d2.PurchaseOrder   = p1;
            d2.PurchaseOrder.PurchaseOrderNo = "PO3";
            d2.CreatedDateTime = DateTime.Now;

            DeliveryOrderDetail do3 = new DeliveryOrderDetail();

            do3.DeliveryOrderNo = "DO2";
            do3.Item            = itemRepository.FindById("IT3");
            do3.ItemCode        = i.ItemCode;
            do3.ActualQuantity  = 2;
            do3.PlanQuantity    = 15;

            DeliveryOrderDetail do4 = new DeliveryOrderDetail();

            do4.DeliveryOrderNo = "DO2";
            do4.Item            = itemRepository.FindById("IT4");
            do4.ItemCode        = i2.ItemCode;
            do4.ActualQuantity  = 15;
            do4.PlanQuantity    = 50;

            d2.DeliveryOrderDetails = new List <DeliveryOrderDetail>();

            d2.DeliveryOrderDetails.Add(do3);
            d2.DeliveryOrderDetails.Add(do4);

            deliveryOrderRepository.Save(d2);

            deliveryOrderDetailRepository.Save(do3);
            deliveryOrderDetailRepository.Save(do4);


            //Act
            var result  = purchaseOrderService.FindReceivedQuantityByPurchaseOrderDetail(pd1);
            var result2 = purchaseOrderService.FindReceivedQuantityByPurchaseOrderDetail(pd2);

            //Assert
            Assert.AreEqual(result, 12);
            Assert.AreEqual(result2, 25);
        }
コード例 #4
0
        public void TestInitialize()
        {
            context = new ApplicationDbContext();

            stockmovementService = new StockMovementService(context);
            itemService          = new ItemService(context);

            stockmovementRepository = new StockMovementRepository(context);

            ddRepository           = new DisbursementDetailRepository(context);
            sadRepository          = new StockAdjustmentDetailRepository(context);
            dodRepository          = new DeliveryOrderDetailRepository(context);
            disbursementRepository = new DisbursementRepository(context);
            doRepository           = new DeliveryOrderRepository(context);
            saRepository           = new StockAdjustmentRepository(context);

            //create new test object and save into db
            StockMovement sm = new StockMovement()
            {
                StockMovementId   = IdService.GetNewStockMovementId(context),
                DisbursementId    = "TEST",
                StockAdjustmentId = "TEST",
                DeliveryOrderNo   = "TEST",
                Item             = context.Item.Where(x => x.ItemCode == "C003").First(),
                CreatedDateTime  = DateTime.Now,
                OriginalQuantity = 1,
                AfterQuantity    = 2
            };

            stockmovementRepository.Save(sm);

            //create new disbursement object and save into db
            Disbursement disbursement = new Disbursement();

            if (disbursementRepository.FindById("TEST") == null)
            {
                disbursement.DisbursementId  = "TEST";
                disbursement.CreatedDateTime = DateTime.Now;
            }
            else
            {
                disbursement = disbursementRepository.FindById("TEST");
            }
            disbursementRepository.Save(disbursement);

            //create new DisbursementDetail object and save into db
            DisbursementDetail detail = new DisbursementDetail()
            {
                DisbursementId = "TEST",
                Item           = context.Item.First(),
                PlanQuantity   = 3,
                ActualQuantity = 3
            };

            ddRepository.Save(detail);

            //create new DO object and save into db
            DeliveryOrder d = new DeliveryOrder();

            if (doRepository.FindById("TEST") == null)
            {
                d.DeliveryOrderNo = "TEST";
                d.CreatedDateTime = DateTime.Now;
            }
            else
            {
                d = doRepository.FindById("TEST");
            }
            doRepository.Save(d);

            //create new DO detail object and save into db
            DeliveryOrderDetail dod = new DeliveryOrderDetail()
            {
                DeliveryOrder  = d,
                Item           = context.Item.First(),
                PlanQuantity   = 4,
                ActualQuantity = 4
            };

            dodRepository.Save(dod);

            //create new SA object and save into db
            StockAdjustment SA = new StockAdjustment();

            if (saRepository.FindById("TEST") == null)
            {
                SA.StockAdjustmentId = "TEST";
                SA.CreatedDateTime   = DateTime.Now;
            }
            else
            {
                SA = saRepository.FindById("TEST");
            }
            saRepository.Save(SA);

            //create new SA detail object and save into db
            StockAdjustmentDetail SADetail = new StockAdjustmentDetail()
            {
                StockAdjustment  = SA,
                Item             = context.Item.First(),
                OriginalQuantity = 2,
                AfterQuantity    = 4
            };

            sadRepository.Save(SADetail);
        }