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 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)); }
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)); }
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 ActionResult SaveKeyProperties(int pohtId, int locationId, int supplierId, int brandcatgeoryId, string lgst) { var error = new Error(); var poht = PurchasingService.FindPurchaseOrderHeaderTempModel(pohtId, CurrentCompany, false); if (poht != null) { poht.LocationId = locationId; poht.SupplierId = supplierId; poht.BrandCategoryId = brandcatgeoryId; error = PurchasingService.InsertOrUpdatePurchaseOrderHeaderTemp(poht, CurrentUser, lgst); if (!error.IsError) { error.Data = PurchasingService.LockPurchaseOrderHeaderTemp(poht); } } return(Json(error, JsonRequestBehavior.AllowGet)); }
public ActionResult EditDetails(int id) { // Called when a user is on one of the order screens and clicks the order details option var model = new EditPurchaseOrderHeaderTempViewModel(); // Use the data in the temp tables var purchaseTemp = PurchasingService.FindPurchaseOrderHeaderTempModel(id, CurrentCompany, true); purchaseTemp.UserId = CurrentUser.Id; model.PurchaseTemp = purchaseTemp; prepareEditModel(model, id); var purchase = PurchasingService.FindPurchaseOrderHeaderModel(purchaseTemp.OriginalRowId, CurrentCompany, true); model.LGS = PurchasingService.LockPurchaseOrderHeader(purchase); model.LGST = PurchasingService.LockPurchaseOrderHeaderTemp(model.PurchaseTemp); return(View("Edit", model)); }
void prepareEditModel(EditNoteViewModel model, int id, int purchaseId) { var poht = PurchasingService.FindPurchaseOrderHeaderTempModel(purchaseId, CurrentCompany); string title = EvolutionResources.bnrAddEditPurchaseNote + (poht == null ? "" : " - Order Number: " + poht.OrderNumber); if (id <= 0) { title += " - " + EvolutionResources.lblNewNote; } PrepareViewModel(model, title, purchaseId, MakeMenuOptionFlags(0, poht.OriginalRowId)); model.ParentId = purchaseId; model.MaxUploadFileSize = GetMaxFileUploadSize(); model.ValidFileTypes = MediaServices.GetValidMediaTypes(); }
public ActionResult Save(EditNoteViewModel model, string command) { if (command.ToLower() == "save") { var poht = PurchasingService.FindPurchaseOrderHeaderTempModel(model.ParentId, CurrentCompany); int tempParentId = model.Note.ParentId; model.Note.ParentId = poht.OriginalRowId; var modelError = NoteService.InsertOrUpdateNote(model.Note, CurrentUser, model.LGS); if (modelError.IsError) { model.Note.ParentId = tempParentId; prepareEditModel(model, model.CurrentCompany.Id, model.Note.ParentId); model.SetErrorOnField(ErrorIcon.Error, modelError.Message, "Note_" + modelError.FieldName); return(View("EditNote", model)); } } return(RedirectToAction("PurchaseNotes", new { id = model.ParentId })); }
public ActionResult SendToSupplier(int id) // PurchaseOrderTempId { var model = new PurchaseOrderHeaderListModel(); // Activate the process of sending the purchase to the supplier try { var poht = PurchasingService.FindPurchaseOrderHeaderTempModel(id, CurrentCompany); var error = PurchasingService.SendPurchaseOrderToSupplier(poht, CurrentUser, CurrentCompany); if (error.IsError) { model.Error.SetError(error.Message); } else { model.Error.SetInfo(EvolutionResources.infPurchaseOrderSentToSupplier); } } catch (Exception e1) { model.Error.Icon = ErrorIcon.Error; model.Error.Message = "Error: " + e1.Message; } return(Json(model, JsonRequestBehavior.AllowGet)); }
public void CompleteOrderTest() { var testUser = GetTestUser(); var testCompany = GetTestCompany(testUser, true); var poh = GetTestPurchaseOrderHeader(testCompany, testUser, 10); Assert.IsTrue(poh.POStatusValue != PurchaseOrderStatus.Closed, $"Error: Purchase order status {PurchaseOrderStatus.Closed} was found when any other value was expected"); var podList = PurchasingService.FindPurchaseOrderDetailListModel(poh); var testProd1 = ProductService.FindProductModel(podList.Items[0].ProductId.Value, null, null, false); var testProd2 = ProductService.FindProductModel(podList.Items[1].ProductId.Value, null, null, false); // Clear the records for the first product db.DeleteAllocationsForProduct(testCompany.Id, testProd1.Id); testProd1.QuantityOnHand = 0; string lgs = ProductService.LockProduct(testProd1); ProductService.InsertOrUpdateProduct(testProd1, testUser, lgs); db.DeleteProductLocationsForProduct(testCompany.Id, testProd1.Id); // Copy the order to temp var poht = PurchasingService.CopyPurchaseOrderToTemp(testCompany, poh, testUser); // Complete the order var error = PurchasingService.CompleteOrder(testCompany, testUser, poht.Id); Assert.IsTrue(!error.IsError, error.Message); poht = PurchasingService.FindPurchaseOrderHeaderTempModel(poht.Id, testCompany, false); Assert.IsTrue(poht.POStatusValue == PurchaseOrderStatus.Closed, $"Error: Purchase order status {poht.POStatusValue} was returned when {PurchaseOrderStatus.Closed} was expected"); // Now try to complete the order again error = PurchasingService.CompleteOrder(testCompany, testUser, poht.Id); Assert.IsTrue(error.IsError, "Error: No error was returned when one was expected - an order cannot be completed twice"); poht = PurchasingService.FindPurchaseOrderHeaderTempModel(poht.Id, testCompany, false); Assert.IsTrue(poht.POStatusValue == PurchaseOrderStatus.Closed, $"Error: Purchase order status {poht.POStatusValue} was returned when {PurchaseOrderStatus.Closed} was expected"); // Check the results of the completion // Force a reload of all objects //ReloadDbContext(); // Check the Allocations table for the first product // The Allocations table records quantity reservations against order lines. var allocs1 = AllocationService.FindAllocationListModel(testCompany, testProd1); int expected = 0, // Because it was deleted above actual = allocs1.Items.Count(); Assert.IsTrue(actual == expected, $"Error: {actual} records were returned when {expected} were expected"); // Check the Allocations table for the second product var allocs2 = AllocationService.FindAllocationListModel(testCompany, testProd2); expected = 1; actual = allocs2.Items.Count(); Assert.IsTrue(actual >= expected, $"Error: {actual} records were returned when >={expected} were expected"); expected = (int)podList.Items[1].OrderQty; actual = (int)allocs2.Items[0].Quantity; Assert.IsTrue(actual >= expected, $"Error: Allocation quantity {actual} was returned when {expected} was expected"); // Check that the product table has been updated // Product.QuantityOnHand is for all locations whereas Allocation and ProductLocation // are for individual locations so the quantity in Product will always be higher than // the latter two. testProd1 = ProductService.FindProductModel(podList.Items[0].ProductId.Value, null, null, false); expected = (int)podList.Items[0].OrderQty; actual = (int)testProd1.QuantityOnHand.Value; Assert.IsTrue(actual >= expected, $"Error: Product quantity {actual} was returned when {expected} was expected"); testProd2 = ProductService.FindProductModel(podList.Items[1].ProductId.Value, null, null, false); expected = (int)podList.Items[1].OrderQty; actual = (int)testProd2.QuantityOnHand.Value; Assert.IsTrue(actual >= expected, $"Error: Product quantity {actual} was returned when {expected} was expected"); // Check that the ProductLocation table has been updated var prodLoc = ProductService.FindProductLocationModel(testCompany, testProd1, poh.LocationId.Value); expected = (int)podList.Items[0].OrderQty; actual = (int)prodLoc.QuantityOnHand; Assert.IsTrue(actual == expected, $"Error: ProductLocation quantity {actual} was returned when {expected} was expected"); prodLoc = ProductService.FindProductLocationModel(testCompany, testProd2, poh.LocationId.Value); expected = (int)podList.Items[1].OrderQty; actual = (int)prodLoc.QuantityOnHand; Assert.IsTrue(actual == expected, $"Error: ProductLocation quantity {actual} was returned when {expected} was expected"); }