Example #1
0
        public void FindSplitPurchaseDetailsListModelTest()
        {
            var testUser    = GetTestUser();
            var testCompany = GetTestCompany(testUser, true);

            int itemCount   = 6;
            var testOrder   = GetTestPurchaseOrderHeader(testCompany, testUser, itemCount);
            var testDetails = PurchasingService.FindPurchaseOrderDetailListModel(testOrder)
                              .Items
                              .OrderBy(td => td.Id)
                              .ToList();

            var splitModel = PurchasingService.FindSplitPurchaseDetailsListModel(testCompany, testOrder.Id, 0, 1, 1000)
                             .Items
                             .OrderBy(sd => sd.PurchaseOrderDetailId)
                             .ToList();
            int expected = itemCount,
                actual   = splitModel.Count();

            Assert.IsTrue(actual == expected, $"Error: {actual} items were returned when {expected} were expected");

            // Check that all the items match
            for (int i = 0; i < itemCount; i++)
            {
                expected = testDetails[i].Id;
                actual   = splitModel[i].PurchaseOrderDetailId;
                Assert.IsTrue(actual == expected, $"Error: Object Id {actual} was found when Id {expected} was expected");

                expected = testDetails[i].OrderQty.Value;
                actual   = splitModel[i].OrigOrderQty;
                Assert.IsTrue(actual == expected, $"Error: Order Qty {actual} was found when {expected} was expected");
            }
        }
        public ActionResult GetSplitPurchaseDetails(int index, int parentId, int pageNo, int pageSize)
        {
            var model = createModel(parentId);

            return(Json(PurchasingService.FindSplitPurchaseDetailsListModel(model.CurrentCompany, parentId, index, pageNo, pageSize), JsonRequestBehavior.AllowGet));
        }