public void CreateOrderSummaryTest() { var testUser = GetTestUser(); var testCompany = GetTestCompany(testUser, true); var testPurchase = GetTestPurchaseOrderHeader(testCompany, testUser, 10); var pohtModel = PurchasingService.CopyPurchaseOrderToTemp(testCompany, testPurchase, testUser); var pos = PurchasingService.CreateOrderSummary(pohtModel, testCompany.DateFormat); // 16/1/2018 TBD: Lines commented out below are because CreateOrderSummary does not // populate them yet as allocations have not been implemented Assert.IsTrue(pos.OrderNumber != 0, $"Error: OrderNumber '{pos.OrderNumber}' was returned when a non-zero value was expected"); Assert.IsTrue(pos.TotalCbms != 0, $"Error: TotalCbms '{pos.TotalCbms}' was returned when a non-zero value was expected"); //Assert.IsTrue(pos.AllocValueEx != 0, $"Error: AllocValueEx '{pos.AllocValueEx}' was returned when a non-zero value was expected"); Assert.IsTrue(pos.OrderValueEx != 0, $"Error: OrderValueEx '{pos.OrderValueEx}' was returned when a non-zero value was expected"); //Assert.IsTrue(pos.AllocatedPercent != 0, $"Error: AllocatedPercent '{pos.AllocatedPercent}' was returned when a non-zero value was expected"); // Can't check GST because it is permissible to be zero //Assert.IsTrue(pos.Tax != 0, $"Error: GST '{pos.Tax}' was returned when a non-zero value was expected"); Assert.IsTrue(pos.Total != 0, $"Error: Total '{pos.Total}' was returned when a non-zero value was expected"); Assert.IsTrue(!string.IsNullOrEmpty(pos.POStatusText), $"Error: POStatusText '{pos.POStatusText}' was returned when a non-empty value was expected"); // Can't test the LandingDate field as it is caluculated from multiple other tables which haven't been set up in this test //Assert.IsTrue(!string.IsNullOrEmpty(pos.LandingDate), $"Error: LandingDate '{pos.LandingDate}' was returned when a non-empty value was expected"); Assert.IsTrue(!string.IsNullOrEmpty(pos.RealisticRequiredDate), $"Error: RealisticRequiredDate '{pos.RealisticRequiredDate}' was returned when a non-empty value was expected"); Assert.IsTrue(!string.IsNullOrEmpty(pos.RequiredDate), $"Error: RequiredDate '{pos.RequiredDate}' was returned when a non-empty value was expected"); Assert.IsTrue(!string.IsNullOrEmpty(pos.CompletedDate), $"Error: CompletedDate '{pos.CompletedDate}' was returned when a non-empty value was expected"); }
public void FindShipmentContentByPONoModelTest() { var testUser = GetTestUser(); var testCompany = GetTestCompany(testUser, true); var testShipment = GetTestShipment(testCompany, testUser, 10); var newPoh = GetTestPurchaseOrderHeader(testCompany, testUser, RandomInt(10, 20)); var newItem = ShipmentService.AddPurchaseOrder(testCompany, testUser, testShipment, newPoh); var checkContent = ShipmentService.FindShipmentContentByPONoModel(testCompany, newPoh.OrderNumber.Value, false); Assert.IsTrue(checkContent != null, "Error: A NULL value was returned when an object was expected"); var checkPoh = PurchasingService.FindPurchaseOrderHeaderModel(checkContent.PurchaseOrderHeaderId.Value, testCompany, false); var excludes = new List <string>(); excludes.Add("OrderNumberUrl"); // Because it isn't known at test prep AreEqual(newPoh, checkPoh, excludes); db.DeletePurchaseOrderHeader(newPoh.Id); // Check that it has gone checkContent = ShipmentService.FindShipmentContentByPONoModel(testCompany, newPoh.OrderNumber.Value, false); Assert.IsTrue(checkContent == null, "Error: A non-NULL value was returned when a NULL value was expected"); checkPoh = PurchasingService.FindPurchaseOrderHeaderModel(newPoh.Id, testCompany, false); Assert.IsTrue(checkPoh == null, "Error: An object was returned when NULL was expected"); }
public void DeletePurchaseOrderDetailTempTest() { // Get a test user var testUser = GetTestUser(); var testCompany = GetTestCompany(testUser, true); var testPurchase = GetTestPurchaseOrderHeader(testCompany, testUser, 1); var pohtModel = PurchasingService.CopyPurchaseOrderToTemp(testCompany, testPurchase, testUser); var model = PurchasingService.FindPurchaseOrderDetailTempsListModel(testCompany.Id, pohtModel.Id, 0, 1, PageSize, ""); // Create a record var newItem = createPurchaseOrderDetailTemp(model); var error = PurchasingService.InsertOrUpdatePurchaseOrderDetailTemp(newItem, testUser, ""); Assert.IsTrue(!error.IsError, error.Message); // Check that it was written var result = db.FindPurchaseOrderDetailTemp(newItem.Id); var test = PurchasingService.MapToModel(result); AreEqual(model, test); // Now delete it PurchasingService.DeletePurchaseOrderDetailTemp(newItem.Id); // And check that is was deleted result = db.FindPurchaseOrderDetailTemp(newItem.Id); Assert.IsTrue(result == null, "Error: A non-NULL value was returned when a NULL value was expected - record delete failed"); }
ViewModelBase createModel() { var model = new SystemStatusViewModel(); PrepareViewModel(model, EvolutionResources.bnrSystemStatus); // Software version info Assembly assembly = Assembly.GetExecutingAssembly(); model.Attributes.Add(new ListItemModel("", EvolutionResources.lblSoftware)); model.Attributes.Add(new ListItemModel(LookupService.GetExecutableName(assembly), EvolutionResources.lblAssembly)); model.Attributes.Add(new ListItemModel(LookupService.GetSoftwareVersionInfo(assembly), EvolutionResources.lblSoftwareVersion)); model.Attributes.Add(new ListItemModel(LookupService.GetExecutableDate(assembly).ToString(CurrentUser.DateFormat), EvolutionResources.lblBuildDate)); model.Attributes.Add(new ListItemModel(LookupService.GetSoftwareCopyrightInfo(assembly), EvolutionResources.lblCopyright)); // Create a list of statistics model.Attributes.Add(new ListItemModel("", "<br/>")); model.Attributes.Add(new ListItemModel("", EvolutionResources.lblCompanies)); var companyList = CompanyService.FindCompaniesListModel(0, 1, 1000, "", true); foreach (var company in companyList.Items) { int purchaseCount = PurchasingService.GetPurchaseCount(company); int customerCount = CustomerService.GetCustomerCount(company); model.Attributes.Add(new ListItemModel($"{customerCount} Customer(s), {purchaseCount} Purchase(s)", company.FriendlyName)); } return(model); }
public void LockPurchaseOrderHeaderTempTest() { var testUser = GetTestUser(); var testCompany = GetTestCompany(testUser, true); var testPurchase = GetTestPurchaseOrderHeader(testCompany, testUser, 10); var model = PurchasingService.CopyPurchaseOrderToTemp(testCompany, testPurchase, testUser); Assert.IsTrue(model != null, "Error: A NULL value was returned when an object was expected"); // Get the current Lock string lockGuid = PurchasingService.LockPurchaseOrderHeaderTemp(model); Assert.IsTrue(!string.IsNullOrEmpty(lockGuid), "Error: Lock record was not found"); // Simulate another user updating the record var otherUser = GetTestUser(); var error = PurchasingService.InsertOrUpdatePurchaseOrderHeaderTemp(model, otherUser, lockGuid); Assert.IsTrue(!error.IsError, error.Message); // Now get the first user to update the record error = PurchasingService.InsertOrUpdatePurchaseOrderHeaderTemp(model, testUser, lockGuid); Assert.IsTrue(error.IsError, "Error: The lock should have caused an error as it has changed"); // Try to update with the new lock lockGuid = PurchasingService.LockPurchaseOrderHeaderTemp(model); error = PurchasingService.InsertOrUpdatePurchaseOrderHeaderTemp(model, testUser, lockGuid); Assert.IsTrue(!error.IsError, $"Error: {error.Message}"); }
public void LockPurchaseOrderDetailTest() { var testUser = GetTestUser(); var testCompany = GetTestCompany(testUser, true); // Create a record var poh = GetTestPurchaseOrderHeader(testCompany, testUser, 1); // Get the first detail record var detailList = PurchasingService.FindPurchaseOrderDetailListModel(poh); var detail = detailList.Items.First(); // Get the current Lock string lockGuid = PurchasingService.LockPurchaseOrderDetail(detail); Assert.IsTrue(!string.IsNullOrEmpty(lockGuid), "Error: Lock record was not found"); // Simulate another user updating the record var otherUser = GetTestUser(); var error = PurchasingService.InsertOrUpdatePurchaseOrderDetail(detail, otherUser, lockGuid); Assert.IsTrue(!error.IsError, error.Message); // Now get the first user to update the record error = PurchasingService.InsertOrUpdatePurchaseOrderDetail(detail, testUser, lockGuid); Assert.IsTrue(error.IsError, "Error: The lock should have caused an error as it has changed"); // Try to update with the new lock lockGuid = PurchasingService.LockPurchaseOrderDetail(detail); error = PurchasingService.InsertOrUpdatePurchaseOrderDetail(detail, testUser, lockGuid); Assert.IsTrue(!error.IsError, $"Error: {error.Message}"); }
void prepareEditModel(EditPurchaseOrderHeaderTempViewModel model, int id) { var poht = PurchasingService.FindPurchaseOrderHeaderTempModel(id, CurrentCompany, false); PrepareViewModel(model, EvolutionResources.bnrAddEditPurchase + " - " + EvolutionResources.lblOrderNumber + ": " + model.PurchaseTemp.OrderNumber.ToString(), id, MakeMenuOptionFlags(0, poht.OriginalRowId, 0) + MenuOptionFlag.RequiresNewPurchase); model.ParentId = id; // Get the landing date from the Shipment record if (model.PurchaseTemp.OrderNumber != null) { var shipmentContent = ShipmentService.FindShipmentContentByPONoModel(CurrentCompany, model.PurchaseTemp.OrderNumber.Value); if (shipmentContent != null && shipmentContent.ShipmentId != null) { var shipment = ShipmentService.FindShipmentModel(shipmentContent.ShipmentId.Value, CurrentCompany); } } model.LocationList = LookupService.FindLocationListItemModel(model.CurrentCompany); model.SupplierList = SupplierService.FindSupplierListItemModel(CurrentCompany); model.POStatusList = LookupService.FindPurchaseOrderHeaderStatusListItemModel(); model.UserList = MembershipManagementService.FindUserListItemModel(); model.PaymentTermsList = LookupService.FindPaymentTermsListItemModel(model.CurrentCompany); model.CommercialTermsList = LookupService.FindLOVItemsListItemModel(model.CurrentCompany, LOVName.CommercialTerms); model.PortList = LookupService.FindPortsListItemModel(); model.ShipMethodList = LookupService.FindLOVItemsListItemModel(model.CurrentCompany, LOVName.ShippingMethod); model.ContainerTypeList = LookupService.FindContainerTypeListItemModel(); model.FreightForwarderList = LookupService.FindFreightForwardersListItemModel(model.CurrentCompany); model.CurrencyList = LookupService.FindCurrenciesListItemModel(); model.BrandCategoryList = ProductService.FindBrandCategoryListItemModel(model.CurrentCompany); }
public ActionResult GetPurchaseOrderDetailTemps(int index, int parentId, int pageNo, int pageSize, string search, string sortColumn, int sortOrder) { return(Json(PurchasingService.FindPurchaseOrderDetailTempsListModel(CurrentCompany.Id, parentId, index, pageNo, pageSize, search, sortColumn, (SortOrder)sortOrder), JsonRequestBehavior.AllowGet)); }
public void FindPurchaseOrderTotalTest() { var testUser = GetTestUser(); var testCompany = GetTestCompany(testUser, true); var poh = GetTestPurchaseOrderHeader(testCompany, testUser, 1); var model = PurchasingService.FindPurchaseOrderDetailListModel(poh); var pod = model.Items.First(); decimal totalValue = pod.OrderQty.Value * pod.UnitPriceExTax.Value; for (int i = 0; i < 16; i++) { pod = model.Items.First(); pod.Id = 0; pod.OrderQty = RandomInt(); totalValue += pod.OrderQty.Value * pod.UnitPriceExTax.Value; var error = PurchasingService.InsertOrUpdatePurchaseOrderDetail(pod, testUser, ""); Assert.IsTrue(!error.IsError, error.Message); } var result = PurchasingService.FindPurchaseOrderTotal(poh); Assert.IsTrue(result == totalValue, $"Error: {result} was returned when {totalValue} 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); }
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"); }
public void DeletePurchaseOrderHeaderTest() { // Get a test user var testUser = GetTestUser(); var testCompany = GetTestCompany(testUser, true); // Create a purchase var model = GetTestPurchaseOrderHeader(testCompany, testUser, 10); // Check that it was written var result = db.FindPurchaseOrderHeader(model.Id); var test = PurchasingService.MapToModel(result); var excludes = new List <string>(); excludes.Add("OrderNumberUrl"); // Because it isn't known yet AreEqual(model, test, excludes); // Now delete it PurchasingService.DeletePurchaseOrderHeader(model.Id); // And check that is was deleted result = db.FindPurchaseOrderHeader(model.Id); Assert.IsTrue(result == null, "Error: A non-NULL value was returned when a NULL value was expected - record delete failed"); }
public void FindPurchaseOrderHeaderSummaryListModelTest() { var testUser = GetTestUser(); var testCompany = GetTestCompany(testUser, true); // Create a random number of purchases List <PurchaseOrderHeaderModel> pohList = new List <PurchaseOrderHeaderModel>(); int numPohs = RandomInt(5, 25); for (int i = 0; i < numPohs; i++) { pohList.Add(GetTestPurchaseOrderHeader(testCompany, testUser, 10)); } // Check that they are found var result = PurchasingService.FindPurchaseOrderHeaderSummaryListModel(testCompany, testUser, 0, 1, PageSize, ""); int actual = result.Items.Count; 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.FindPurchaseOrderHeadersListModel(testCompany.Id, 0, 1, PageSize, "", 0, 0, 0); actual = result.Items.Count; expected = 0; Assert.IsTrue(actual == expected, $"Error: {actual} items were returned when {expected} were expected"); }
public void FindPurchaseOrderHeaderByPONumberModelTest() { var testUser = GetTestUser(); var testCompany = GetTestCompany(testUser, true); // Create a record var poh1 = GetTestPurchaseOrderHeader(testCompany, testUser, 1); // Try to find it using the PONumber var poh2 = PurchasingService.FindPurchaseOrderHeaderByPONumberModel(poh1.OrderNumber.Value, testCompany); Assert.IsTrue(poh2 != null, "Error: A non-NULL value was expected"); // Check thiat it is the same record decimal expected = poh1.OrderNumber.Value, actual = poh2.OrderNumber.Value; Assert.IsTrue(expected == actual, $"Error: {actual} was returned when {expected} was expected"); expected = poh1.Id; actual = poh2.Id; Assert.IsTrue(expected == actual, $"Error: {actual} was returned when {expected} was expected"); PurchasingService.DeletePurchaseOrderHeader(poh1.Id); // Now try to find it again poh2 = PurchasingService.FindPurchaseOrderHeaderByPONumberModel(poh1.OrderNumber.Value, testCompany); Assert.IsTrue(poh2 == null, "Error: A NULL value was expected but an object was returned"); }
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 GetOrderSummary(int id) { var poht = PurchasingService.FindPurchaseOrderHeaderTempModel(id, CurrentCompany); var model = PurchasingService.CreateOrderSummary(poht, CurrentUser.DateFormat); model.CurrencySymbol = LookupService.FindCurrencySymbol(CurrentCompany.DefaultCurrencyID); return(View("OrderSummary", model)); }
private void Awake() { shopUiSpawner = FindObjectOfType <ShopUiSpawner>() ?? throw new NullReferenceException(nameof(ShopUiSpawner)); purchasingService = FindObjectOfType <PurchasingService>() ?? throw new NullReferenceException(nameof(PurchasingService)); lobbyEcsController = FindObjectOfType <LobbyEcsController>() ?? throw new NullReferenceException(nameof(PurchasingService)); }
public async Task CreatePurchaseOrder_GivenNewPurchaseOrder_ReturnsInt() { var context = this.BuildContext(); var service = new PurchasingService(context); IEnumerable <PurchaseOrderHeaderModel> result = await service.CreatePurchaseOrderHeaders(new PurchaseOrderHeaderModel()); Assert.NotNull(result); }
private void Awake() { purchasingService = FindObjectOfType <PurchasingService>() ?? throw new NullReferenceException(nameof(PurchasingService)); lobbyEcsController = FindObjectOfType <LobbyEcsController>() ?? throw new NullReferenceException(nameof(lobbyEcsController)); textTooltip = FindObjectOfType <TextTooltip>() ?? throw new NullReferenceException(nameof(TextTooltip)); }
public ActionResult Upload(FileUploadViewModel model, string command) { Server.ScriptTimeout = 600; // Allow 10 minutes for an upload/import if (command.ToLower() == "upload") { if (model.Files != null && model.Files.Count() > 0) { var targetFile = Path.GetTempPath(); var attachment = model.Files.FirstOrDefault(); string fileName = attachment.FileName; if (!MediaServices.IsValidOrderImportType(fileName)) { model.SetError(ErrorIcon.Error, EvolutionResources.errInvalidImportFile.Replace("%1", MediaServices.GetValidOrderImportTypes())); } else if (attachment != null && attachment.ContentLength > 0) { try { targetFile += fileName.FileName(); attachment.SaveAs(targetFile); var error = FileImportService.UploadFile(CurrentCompany, CurrentUser, targetFile, model.FirstLineContainsHeader); if (error.IsError) { model.SetError(ErrorIcon.Error, error.Message); } else { // Display the table var mappingsModel = new EditPurchaseImportDataMappingsViewModel(); prepareViewModel(mappingsModel); mappingsModel.LocationId = CurrentCompany.DefaultLocationID.Value; mappingsModel.Data = FileImportService.GetData(CurrentCompany, CurrentUser); PurchasingService.ValidateOrders(CurrentCompany, CurrentUser, mappingsModel.Data.Headings); mappingsModel.Data = FileImportService.GetData(CurrentCompany, CurrentUser); return(View("ImportMappings", mappingsModel)); } } catch (Exception e1) { model.SetError(ErrorIcon.Error, EvolutionResources.errFailedToUploadFile.Replace("%1", fileName).Replace("%2", e1.Message)); LogService.WriteLog(e1, Request.RawUrl); } } PrepareViewModel(model, EvolutionResources.bnrPurchaseImport, 0, 0); return(View("PurchaseImport", model)); } } return(RedirectToAction("Index")); }
public ActionResult GetPurchaserList() { var model = createModel(); var list = PurchasingService.FindPurchasersListItemModel(model.CurrentCompany); list.Insert(0, new ListItemModel { Id = "0", Text = EvolutionResources.lblNone }); return(Json(list, JsonRequestBehavior.AllowGet)); }
private PurchaseOrderDetailModel createPurchaseOrderDetail(PurchaseOrderDetailListModel model) { // Create a new item by duplicating a randomly selected item already in the list // This is an easy way, otherwise we have to go looking for suppliers, products, tax codes etc var pod = PurchasingService.MapToModel(model.Items[RandomInt(0, model.Items.Count() - 1)]); pod.Id = 0; pod.LineNumber = 0; pod.OrderQty = RandomInt(); return(pod); }
public ActionResult Allocations(int id = 0) { var model = new ViewModelBase(); // On entry, the Id is the Id of the PurchaseOrderHeaderTemp var poht = PurchasingService.FindPurchaseOrderHeaderTempModel(id, CurrentCompany, false); model.ParentId = id; PrepareViewModel(model, EvolutionResources.bnrAllocations + (poht == null ? "" : " - Order Number: " + poht.OrderNumber.ToString()), id, MakeMenuOptionFlags(0, poht.OriginalRowId)); return(View("Allocations", model)); }
public ActionResult Delete(int index, int id, int parentId) { var model = new PurchaseOrderDetailTempListModel(); model.GridIndex = index; try { PurchasingService.DeletePurchaseOrderDetailTemp(id); } catch (Exception e1) { model.Error.SetError(e1); } return(Json(model, JsonRequestBehavior.AllowGet)); }
public ActionResult AddEditItem(int parentId, int id) { var model = new EditPurchaseOrderDetailTempViewModel(); model.PurchaseOrderDetailTemp = PurchasingService.FindPurchaseOrderDetailTempModel(id, CurrentCompany, true); model.PurchaseOrderDetailTemp.PurchaseOrderHeaderTempId = parentId; prepareEditModel(model, parentId); model.LGS = PurchasingService.LockPurchaseOrderDetailTemp(model.PurchaseOrderDetailTemp); return(View("AddEditItem", model)); }
ViewModelBase createModel(int purchaseId) // Id of temp table POH { var model = new NoteListViewModel(); var poht = PurchasingService.FindPurchaseOrderHeaderTempModel(purchaseId, CurrentCompany); PrepareViewModel(model, EvolutionResources.bnrPurchaseNotes + (poht == null ? "" : " - Order Number: " + poht.OrderNumber), purchaseId, MakeMenuOptionFlags(0, poht.OriginalRowId)); model.ParentId = purchaseId; return(model); }
public ActionResult GetPurchaseNotes(int index, int purchaseId, int pageNo, int pageSize, string search) { var tempPoh = PurchasingService.FindPurchaseOrderHeaderTempModel(purchaseId, CurrentCompany, false); return(Json(NoteService.FindNotesListModel(NoteType.Purchase, (tempPoh == null ? 0 : tempPoh.OriginalRowId), index, pageNo, pageSize, search, MediaSize.Medium, 640, 480), JsonRequestBehavior.AllowGet)); }
public void FindPurchaseOrderHeaderModelTest() { var testUser = GetTestUser(); var testCompany = GetTestCompany(testUser, true); var model = GetTestPurchaseOrderHeader(testCompany, testUser); var test = PurchasingService.FindPurchaseOrderHeaderModel(model.Id, testCompany, false); var excludes = new List <string>(); excludes.Add("OrderNumberUrl"); // Because it isn't known in data prep AreEqual(model, test, excludes); }
public void CopyPurchaseOrderToTempTest() { var testUser = GetTestUser(); var testCompany = GetTestCompany(testUser, true); var testPurchase = GetTestPurchaseOrderHeader(testCompany, testUser, 10); var pohtModel = PurchasingService.CopyPurchaseOrderToTemp(testCompany, testPurchase, testUser); var excludes = new List <string>(); excludes.Add("Id"); excludes.Add("OriginalRowIdId"); AreEqual(testPurchase, pohtModel, excludes); }
public void GetNextSequenceNumberTest() { var user = GetTestUser(); var testCompany = GetTestCompany(user); decimal actual = 0; // At this stage, no sequences or orders exist for (int expected = 1; expected <= 10; expected++) { actual = LookupService.GetNextSequenceNumber(testCompany, SequenceNumberType.PurchaseOrderNumber); Assert.IsTrue(actual == expected, $"Error: {actual} was returned when {expected} was expected"); } // Find the "Warehouse" location var location = db.FindLocations() .Where(l => l.LocationName == "Warehouse") .FirstOrDefault(); // Find a supplier with lots of products var supplier = db.FindSuppliers(testCompany.Id) .Where(s => s.Products.Count() > 100) .FirstOrDefault(); // Now create a purchase order with a large purchase order number var poh = new PurchaseOrderHeaderModel { CompanyId = testCompany.Id, LocationId = location.Id, POStatus = Convert.ToInt32(LookupService.FindPurchaseOrderHeaderStatusListItemModel().First().Id), SupplierId = supplier.Id, SupplierInv = "INV" + RandomInt(1000, 9999).ToString(), RequiredDate = RandomDateTime(), OrderNumber = 1000 }; var error = PurchasingService.InsertOrUpdatePurchaseOrderHeader(poh, user, ""); Assert.IsTrue(!error.IsError, error.Message); // Check that the correct number is returned // On the first iteration, the next number should be one more than the largest purchase order number ie 1001 for (int expected = 1001; expected <= 1010; expected++) { actual = LookupService.GetNextSequenceNumber(testCompany, SequenceNumberType.PurchaseOrderNumber); Assert.IsTrue(actual == expected, $"Error: {actual} was returned when {expected} was expected"); } }