Exemple #1
0
        public ActionResult CreateStockCard(StockCardDTO stock, string decision)
        {
            if (decision == "Cancel")
            {
                return(RedirectToAction("ViewAllStocks"));
            }
            //check that item code and description does not exist
            if (stockService.FindStockByItemCode(stock.ItemCode) != null)
            {
                ModelState.AddModelError("ItemCode", "Item Code already exists");
                if (stockService.FindStockByDescription(stock.Description) != null)
                {
                    ModelState.AddModelError("Description", "Description already exists");
                }
                return(View(stock));
            }
            //save the stock
            StockEF s = new StockEF()
            {
                ItemCode       = stock.ItemCode,
                Category       = stock.Category,
                Description    = stock.Description,
                Uom            = stock.Uom,
                Bin            = stock.Bin,
                QuantityOnHand = 0
            };

            stockService.CreateStock(s);

            return(RedirectToAction("ViewStockCard", new { itemCode = stock.ItemCode }));
        }
Exemple #2
0
        public ActionResult UpdateStockCard(StockCardDTO stock, string decision)
        {
            if (decision == "Cancel")
            {
                return(RedirectToAction("ViewStockCard", new { itemCode = stock.ItemCode }));
            }
            //check that item description does not exist
            StockEF existingStock = stockService.FindStockByDescription(stock.Description);

            if (existingStock != null && existingStock.ItemCode != stock.ItemCode)
            {
                ModelState.AddModelError("Description", "Description already exists");
                return(View(stock));
            }
            //save the stock
            StockEF s = new StockEF()
            {
                ItemCode       = stock.ItemCode,
                Category       = stock.Category,
                Description    = stock.Description,
                Uom            = stock.Uom,
                Bin            = stock.Bin,
                QuantityOnHand = stock.QuantityOnHand
            };

            stockService.UpdateStock(s);

            return(RedirectToAction("ViewStockCard", new { itemCode = stock.ItemCode }));
        }
Exemple #3
0
        public void Update(StockManagementModel item)
        {
            StockEF stock = new StockEF(item.Id, item.Name);

            _db.Entry(stock).State = EntityState.Modified;
            _db.SaveChanges();
        }
Exemple #4
0
        public void Create(StockManagementModel item)
        {
            StockEF stock = new StockEF(item.Id, item.Name);

            _db.Stocks.Add(stock);
            _db.SaveChanges();
        }
Exemple #5
0
        public void SaveStock(StockEF stock)
        {
            var existingStock = context.Stocks.Find(stock.ItemCode);

            if (existingStock != null)
            {
                context.Entry(existingStock).CurrentValues.SetValues(stock);
                context.SaveChanges();
            }
        }
Exemple #6
0
        public ActionResult UpdateStockCard(string itemCode)
        {
            StockEF      s     = stockService.FindStockByItemCode(itemCode);
            StockCardDTO stock = new StockCardDTO()
            {
                ItemCode       = s.ItemCode,
                Category       = s.Category,
                Description    = s.Description,
                Uom            = s.Uom,
                Bin            = s.Bin,
                QuantityOnHand = s.QuantityOnHand
            };

            return(View(stock));
        }
Exemple #7
0
        public PredictReorderQtyDTO GetPredictModel(CatalogueItemDTO item)
        {
            using (var client = new HttpClient())
            {
                StockEF predictItem = stockEFF.FindStockByItemCode(item.ItemCode);

                //label encoding for the three features
                //contain the label encoding for category and also the average quantity based on category and uom
                int[] categoryAvgQty = LabelEncodeByCategory(predictItem.Category, predictItem.Uom);
                int   uom            = LabelEncodeByUOM(predictItem.Uom);
                int   popularity     = LabelEncodeByPopularity(predictItem.ItemCode, categoryAvgQty[1], uom);

                PredictReorderQtyDTO predModel = new PredictReorderQtyDTO(categoryAvgQty[0], popularity, uom);

                return(predModel);
            }
        }
Exemple #8
0
        public ActionResult ViewStockCard(string itemCode)
        {
            StockEF stock = stockService.FindStockByItemCode(itemCode);

            ViewData["stock"] = stock;

            List <SupplierEF> suppliers = purchaseService.FindSupplierByItemCodeOrderByRank(itemCode);

            ViewData["suppliers"] = suppliers;

            List <StockTransactionDetailsEF> transactions = stockService.FindTransactionsByItemCode(itemCode);

            ViewData["transactions"] = transactions;

            StaffEF staff = staffService.GetStaff();

            ViewData["staff"] = staff;
            return(View());
        }
        public void LogTransactionsForDeliveryOrder(int purchaseOrderId)
        {
            List <PurchaseOrderDetailsEF> poDetails = purchaseEFF.FindPurchaseOrderDetailsByOrderId(purchaseOrderId);

            foreach (PurchaseOrderDetailsEF d in poDetails)
            {
                StockTransactionDetailsEF transaction = new StockTransactionDetailsEF()
                {
                    ItemCode = d.ItemCode,
                    Date     = Timestamp.unixTimestamp(),
                    Quantity = d.QuantityOrdered,
                    Type     = "Supplier " + d.PurchaseOrder.SupplierCode,
                    Balance  = stockEFF.FindStockByItemCode(d.ItemCode).QuantityOnHand + d.QuantityOrdered,
                };
                stockEFF.AddToStockTransaction(transaction);

                StockEF stock = stockEFF.FindStockByItemCode(d.ItemCode);
                stock.QuantityOnHand = stock.QuantityOnHand + d.QuantityOrdered;
                stockEFF.SaveStock(stock);
            }
        }
        public void LogTransactionsForRetrieval(int retrievalId)
        {
            List <StationeryDisbursementDetailsEF> details = rndEFF.FindDisbursementDetailsByRetrievalId(retrievalId);

            foreach (StationeryDisbursementDetailsEF d in details)
            {
                StockTransactionDetailsEF transaction = new StockTransactionDetailsEF()
                {
                    ItemCode = d.ItemCode,
                    Date     = Timestamp.unixTimestamp(),
                    Quantity = -d.RetrievedQuantity,
                    Type     = d.StationeryDisbursement.Department.DepartmentName,
                    Balance  = stockEFF.FindStockByItemCode(d.ItemCode).QuantityOnHand - d.RetrievedQuantity
                };
                stockEFF.AddToStockTransaction(transaction);

                StockEF stock = stockEFF.FindStockByItemCode(d.ItemCode);
                stock.QuantityOnHand = transaction.Balance;
                stockEFF.SaveStock(stock);
            }
        }
        public void LogTransactionsForAdjustmentVoucher(string adjustmentVoucherId)
        {
            List <AdjustmentVoucherDetailsEF> adjVoucherDetails = stockEFF.FindAdjustmentVoucherDetailsById(adjustmentVoucherId);

            foreach (AdjustmentVoucherDetailsEF d in adjVoucherDetails)
            {
                StockTransactionDetailsEF transaction = new StockTransactionDetailsEF()
                {
                    ItemCode = d.ItemCode,
                    Date     = Timestamp.unixTimestamp(),
                    Quantity = d.Quantity,
                    Type     = "Stock Adjustment " + d.VoucherId,
                    Balance  = stockEFF.FindStockByItemCode(d.ItemCode).QuantityOnHand + d.Quantity,
                };
                stockEFF.AddToStockTransaction(transaction);

                StockEF stock = stockEFF.FindStockByItemCode(d.ItemCode);
                stock.QuantityOnHand = stock.QuantityOnHand + d.Quantity;
                stockEFF.SaveStock(stock);
            }
        }
Exemple #12
0
        public ActionResult CreateAdjustmentVoucher(string itemToAdd, string removalItem, string choice, string voucherId, List <AdjustmentVoucherDetailsDTO> detailsList)
        {
            List <StockEF> itemList = stockService.FindAllStocks().OrderBy(x => x.ItemCode).ToList();

            ViewData["itemList"] = itemList;

            AdjustmentVoucherEF voucher = new AdjustmentVoucherEF();

            if (voucherId == null)
            {
                voucher = new AdjustmentVoucherEF();
            }
            else
            {
                voucher = stockService.FindAdjustmentVoucherById(voucherId);
            }
            ViewData["voucher"] = voucher;

            if (detailsList == null)
            {
                detailsList = new List <AdjustmentVoucherDetailsDTO>();
            }
            if (choice == "Add Item")
            {
                StockEF item        = new StockEF();
                bool    isValid     = false;
                string  description = "";
                //check if in the existing stock
                foreach (var v in itemList)
                {
                    if (v.ItemCode == itemToAdd)
                    {
                        description = v.Description;
                        isValid     = true;
                    }
                }
                if (isValid)
                {
                    AdjustmentVoucherDetailsDTO newVoucherDetails = new AdjustmentVoucherDetailsDTO();
                    newVoucherDetails.ItemCode    = itemToAdd;
                    newVoucherDetails.Description = description;
                    newVoucherDetails.Quantity    = 1;
                    newVoucherDetails.Remove      = false;
                    detailsList.Add(newVoucherDetails);
                }
            }
            if (choice == "Remove" && detailsList.Count > 0)
            {
                for (int i = 0; i < detailsList.Count; i++)
                {
                    if (detailsList[i].Remove == true)
                    {
                        detailsList.RemoveAt(i);
                        i--;
                    }
                }
            }
            if (choice == "Submit")
            {
                StaffEF requester = staffService.GetStaff();
                string  newId     = "";
                List <AdjustmentVoucherDetailsDTO> QOHValid = stockService.checkQuantityOnHand(detailsList);

                if (QOHValid.Count == 0)
                {
                    if (stockService.VoucherExceedsSetValue(detailsList))
                    {
                        newId = stockService.SaveAdjustmentVoucherAndDetails(requester, voucher, detailsList, "Manager");
                        Debug.Print("Pending appr sent to manager email");
                        SendEmailToAuthorityOnRequest(voucher.VoucherId, "Manager");
                    }
                    else if (!stockService.VoucherExceedsSetValue(detailsList))
                    {
                        newId = stockService.SaveAdjustmentVoucherAndDetails(requester, voucher, detailsList, "Supervisor");
                        Debug.Print("Pending appr sent to supervisor email");
                        SendEmailToAuthorityOnRequest(voucher.VoucherId, "Supervisor");
                    }
                    return(RedirectToAction("ViewAdjustmentDetails", "ManageAdjustmentVoucher", new { voucherId = newId }));
                }
                else
                {
                    ViewData["invalidItems"] = QOHValid;
                }
            }
            if (choice == "Cancel")
            {
                return(RedirectToAction("Index", "ManageAdjustmentVoucher", new { page = 1 }));
            }

            //get prices for each item
            detailsList = stockService.GetPricesForVoucherDetails(detailsList);

            ModelState.Clear();
            return(View(detailsList));
        }
 public void UpdateStock(StockEF stock)
 {
     stockEFF.SaveStock(stock);
 }
 public void CreateStock(StockEF stock)
 {
     stockEFF.AddToStock(stock);
 }
Exemple #15
0
 public void AddToStock(StockEF stock)
 {
     context.Stocks.Add(stock);
     context.SaveChanges();
 }