//For store employee to view catalogue details and update & delete catalogue public ActionResult Details(long itemId, string sessionId) { ViewData["catalogue"] = CatalogueService.GetCatalogueById(itemId); ViewData["pricelist"] = PriceListService.GetPriceListByItemId(itemId); ViewData["sessionId"] = sessionId; return(View()); }
public ActionResult StockCard(long itemId, string sessionId) { ViewData["catalogue"] = CatalogueService.GetCatalogueById(itemId); ViewData["priceList"] = PriceListService.GetPriceListByItemId(itemId); ViewData["stockCards"] = StockCardService.GetStockCardById(itemId); ViewData["sessionId"] = sessionId; return(View()); }
public ActionResult Update(long itemId, string sessionId) { ViewData["catalogue"] = CatalogueService.GetCatalogueById(itemId); List <string> categories = CatalogueService.GetAllCategories(); ViewData["categories"] = categories; List <string> unitsOfMeasure = CatalogueService.GetAllUnits(); ViewData["unitsOfMeasure"] = unitsOfMeasure; ViewData["sessionId"] = sessionId; return(View()); }
public ActionResult PutReason(string sessionId) { List <AdjVoucher> adjVouchers = new List <AdjVoucher>(); //status = 0 means need to be submit for reason. adjVouchers = AdjVoucherService.GetAdjByStatus(0); if (adjVouchers.Count == 0) { return(RedirectToAction("AllAdjVouchers", new { sessionId })); } else { foreach (AdjVoucher adj in adjVouchers) { adj.Reason = null; adj.Item = CatalogueService.GetCatalogueById(adj.ItemId); adj.Item.ItemSuppliersDetails = PurchaseOrderService.GetItemSuppliersDetails(adj.ItemId); } ViewData["adjVouchers"] = adjVouchers; ViewData["sessionId"] = sessionId; return(View()); } }
public ActionResult UpdatePurchaseOrder(PurchaseOrder order, FormCollection formCollection, string sessionId) { PurchaseOrder selectedOrder = PurchaseOrderService.GetOrderDetails(order.OrderNumber); List <long> selectedItemsIds = new List <long>(); List <Inventory> selectedItems = new List <Inventory>(); foreach (var item in order.ItemDetails) { if (item.Item.IsChecked) { selectedItemsIds.Add(item.Item.ItemId); } } foreach (var id in selectedItemsIds) { selectedItems.Add(CatalogueService.GetCatalogueById(id)); } foreach (var item in selectedItems) { item.ItemSuppliersDetails = PurchaseOrderService.GetItemSuppliersDetails(item.ItemId); item.ItemSuppliersDetails.Supplier1Name = SupplierService.GetSupplierName(item.ItemSuppliersDetails.Supplier1Id); item.ItemSuppliersDetails.Supplier2Name = SupplierService.GetSupplierName(item.ItemSuppliersDetails.Supplier2Id); item.ItemSuppliersDetails.Supplier3Name = SupplierService.GetSupplierName(item.ItemSuppliersDetails.Supplier3Id); } ViewData["selectedItems"] = selectedItems; ViewData["order"] = selectedOrder; ViewData["deliverTo"] = formCollection["deliverTo"]; ViewData["deliverBy"] = formCollection["deliverBy"]; ViewData["sessionId"] = sessionId; return(View()); }
public ActionResult AdjDetails(long adjId, string sessionId) { List <AdjVoucher> adjVouchers = new List <AdjVoucher>(); adjVouchers = AdjVoucherService.GetAdjByAdjId(adjId); foreach (AdjVoucher adj in adjVouchers) { Inventory c = CatalogueService.GetCatalogueById(adj.ItemId); adj.ItemCode = c.ItemCode; adj.Description = c.Description; PriceList p = PriceListService.GetPriceListByItemId(adj.ItemId); if (p != null) { adj.UnitPrice = p.Supplier1UnitPrice; } else { adj.UnitPrice = 1; } double total = adj.AdjQty * adj.UnitPrice; adj.TotalPrice = Math.Abs(total); } string adjIdstring = adjId.ToString("000/000/00"); string authorisedBy = "Nil"; if (adjVouchers[0].AuthorisedBy != 0) { authorisedBy = EmployeeService.GetEmployeeById(adjVouchers[0].AuthorisedBy).EmpName; } ViewData["adjIdstring"] = adjIdstring; ViewData["adjVouchers"] = adjVouchers; ViewData["authorisedBy"] = authorisedBy; ViewData["sessionId"] = sessionId; return(View()); }
//public ActionResult AuthoriseByS(List<AdjVoucher> adjVouchers, string sessionId) //{ // Employee user = EmployeeService.GetUserBySessionId(sessionId); // double totalAmount = 0; // foreach (AdjVoucher adj in adjVouchers) // { // PriceList priceList = PriceListService.GetPriceListByItemId(adj.ItemId); // double price = 0; // if (priceList != null) // { // price = priceList.Supplier1UnitPrice; // } // double amount = price * adj.AdjQty; // totalAmount = totalAmount + amount; // AdjVoucherService.UpdateReason(adj); // } // if (totalAmount > -250) // { // //status = 1, auto approved by supervisor // AdjVoucherService.UpdateStatus(adjVouchers[0].AdjId, 1); // AdjVoucherService.AuthoriseBy(adjVouchers[0].AdjId, user.EmpId); // TempData["errorMsg"] = "<script>alert('Total discrepancy is less than $250, authorised already.');</script>"; // } // else // { // //status = 2, pending approve for manager // AdjVoucherService.UpdateStatus(adjVouchers[0].AdjId, 2); // TempData["errorMsg"] = "<script>alert('Total discrepancy is more than $250, pending for Store Manager to authorise.');</script>"; // } // ViewData["userName"] = user.EmpName; // ViewData["sessionId"] = sessionId; // return View("~/Views/StoreLandingPage/Home.cshtml"); //} public ActionResult PendingApprove(string sessionId) { Employee user = EmployeeService.GetUserBySessionId(sessionId); List <AdjVoucher> adjVouchers = new List <AdjVoucher>(); string authoriseBy = null; if (user.EmpRole == "STORE_SUPERVISOR") { adjVouchers = AdjVoucherService.GetAdjByStatus(2); foreach (var adj in adjVouchers) { //to get item details for view adj.Item = CatalogueService.GetCatalogueById(adj.ItemId); adj.Item.ItemSuppliersDetails = PurchaseOrderService.GetItemSuppliersDetails(adj.ItemId); } if (adjVouchers.Count == 0) { return(RedirectToAction("AllAdjVouchers", new { sessionId })); } authoriseBy = "Supervisor"; } else if (user.EmpRole == "STORE_MANAGER") { adjVouchers = AdjVoucherService.GetAdjByStatus(3); foreach (var adj in adjVouchers) { //to get item details for view adj.Item = CatalogueService.GetCatalogueById(adj.ItemId); adj.Item.ItemSuppliersDetails = PurchaseOrderService.GetItemSuppliersDetails(adj.ItemId); } if (adjVouchers.Count == 0) { return(RedirectToAction("AllAdjVouchers", new { sessionId })); } authoriseBy = "Manager"; } //To group by vouchers Dictionary <long, List <AdjVoucher> > byVouchers = new Dictionary <long, List <AdjVoucher> >(); foreach (var adj in adjVouchers) { if (byVouchers.ContainsKey(adj.AdjId)) { byVouchers[adj.AdjId].Add(adj); } else { List <AdjVoucher> adjs = new List <AdjVoucher>(); adjs.Add(adj); byVouchers[adj.AdjId] = adjs; } } ViewData["authoriseBy"] = authoriseBy; ViewData["adjVouchers"] = adjVouchers; ViewData["byVouchers"] = byVouchers; ViewData["sessionId"] = sessionId; return(View()); }