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

            // Create a random number of purchases
            List <PurchaseOrderHeaderModel> pohList = new List <PurchaseOrderHeaderModel>();
            int numPohs = RandomInt(5, 15);

            for (int i = 0; i < numPohs; i++)
            {
                pohList.Add(GetTestPurchaseOrderHeader(testCompany, testUser, 10));
            }

            // Check that they are found
            var result   = PurchasingService.FindPurchaseOrderHeadersString(testCompany);
            int actual   = result.CountOf("|") + 1;
            int expected = numPohs;

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

            // Now delete them
            foreach (var poh in pohList)
            {
                PurchasingService.DeletePurchaseOrderHeader(poh);
            }

            // Now check that they have disappeared
            result = PurchasingService.FindPurchaseOrderHeadersString(testCompany);
            Assert.IsTrue(result == "", $"Error: '{result}' was returned when and empty string was expected");
        }
        PurchaseOrderSplitViewModel createModel(int id, bool bLock = false)
        {
            var model = new PurchaseOrderSplitViewModel();

            PrepareViewModel(model, EvolutionResources.bnrSplitPurchase, id);
            model.ParentId = id;

            model.OrderDetails.PurchaseOrderHeaderId = id;
            var poh = PurchasingService.FindPurchaseOrderHeaderModel(id, CurrentCompany);

            if (poh != null)
            {
                model.OrderDetails.SupplierName = poh.SupplierName;
                model.OrderDetails.OrderNumber  = poh.OrderNumber.Value;
                if (poh.RequiredDate != null)
                {
                    model.OrderDetails.AdvertisedETA = poh.RequiredDate.Value.ToString(model.DisplayDateFormat);
                }

                if (bLock)
                {
                    model.LGS = PurchasingService.LockPurchaseOrderHeader(poh);
                }
            }

            model.OrderDetails.NewOrderAdvertisedETA = DateTimeOffset.Now;
            model.LocationList      = LookupService.FindLocationListItemModel(CurrentCompany, true);
            model.PurchaseOrderList = PurchasingService.FindPurchaseOrderHeadersString(CurrentCompany, true);

            return(model);
        }