public ActionResult GetAdjustmentById(int adjustmentId) { Adjustment adj = AdjustmentDao.GetAdjustmentDetailById(adjustmentId); ViewData["Adjustment"] = adj; return(View("AdjustmentDetail")); }
public ActionResult GetPendingAdjustments() { int userId = Convert.ToInt32(RouteData.Values["userId"]); List <Adjustment> adjustments = AdjustmentDao.GetAllPendingAdjustments(userId); ViewData["Adjustments"] = adjustments; return(View("PendingAdjustments")); }
public ActionResult GetAllAdjustments() { int rank = Convert.ToInt32(RouteData.Values["rank"]); List <Adjustment> adjustments = AdjustmentDao.GetAllAdjustments(rank); ViewData["Adjustments"] = adjustments; return(View("Adjustments")); }
public ActionResult GetMyAdjustmentDetailById(int adjustmentId) { Adjustment adjustment = AdjustmentDao.GetAdjustmentDetailById(adjustmentId); ViewData["Adjustment"] = adjustment; //reuse the view for storemanager and storesupervisor ViewData["MyAdjustment"] = 1; return(View("AdjustmentDetail")); }
public AdjustmentVoucherManagerController() { LogicUniStoreModel db = new LogicUniStoreModel(); adj = new AdjustmentItemDao(); adao = new AdjustmentDao(db); idao = new ItemDao(); sdao = new StockCardDao(); }
public ActionResult UpdateAdjustmentStatus(int adjustmentId) { int userId = Convert.ToInt32(RouteData.Values["userId"]); User u = new User() { UserId = userId }; AdjustmentDao.UpdateAdjustmentStatus(adjustmentId, u); return(RedirectToAction("GetPendingAdjustments")); }
public ActionResult Disbursements(List <RetrievalItem> items) { List <AdjustmentDetail> adjustmentDetails = new List <AdjustmentDetail>(); bool valid = true; foreach (var i in items) { if (i.AllocatedQuantity > i.ActualQuantity) { AdjustmentDetail detail = new AdjustmentDetail() { Count = (i.StockQuantity - i.ActualQuantity), Item = new Item() { ItemId = i.ItemId } }; adjustmentDetails.Add(detail); } else if (i.AllocatedQuantity == i.ActualQuantity) { } else { valid = false; break; } } if (valid != false) { if (adjustmentDetails.Count > 0) { int userId = Convert.ToInt32(RouteData.Values["userId"]); User u = new User() { UserId = userId }; Adjustment ad = AdjustmentDao.InsertAdjustment(adjustmentDetails, u); AdjustmentDao.CalculateAdjustmentCost(ad); ItemDao.UpdateStockForAdjustment(adjustmentDetails); } DisbursementDao.GenerateDisbursements(items); Task.Run(() => EmailUtility.SendEmailForItemsPickUp()); return(RedirectToAction("Retrieval", "Stationery")); } else { return(RedirectToAction("Retrieval", "Stationery")); } }
public bool CreateSpotAdjustment(Adjustment adjustment) { bool isSuccessful = false; LogicUniStoreModel dbContext; try { StockAdjustment objAdjustment = new StockAdjustment() { CreatedBy = adjustment.CreatedBy, CreatedDate = DateTime.Now, SockAdjustmentNumber = adjustment.Number, Status = AdjustmentStatus.Created.ToString(), Type = StockCheckType.OnSpot.ToString() }; objAdjustment.StockAdjustmentItems = new List <StockAdjustmentItem>(); foreach (AdjustmentItem item in adjustment.Items) { StockAdjustmentItem objAdjItem = new StockAdjustmentItem() { CountDate = DateTime.Now, CountPerson = adjustment.CreatedBy.ToString(), //TODO: Change to Id CountQuantity = item.Quantity, ItemID = item.ItemId, Remark = item.Remarks, Status = AdjustmentStatus.Created.ToString(), AdjustQuantity = item.Quantity, StockAdjustment = objAdjustment }; objAdjustment.StockAdjustmentItems.Add(objAdjItem); } dbContext = new LogicUniStoreModel(); dbContext.Database.Connection.Open(); using (var txn = dbContext.Database.BeginTransaction()) { //Create Adjustment and Items AdjustmentDao dao = new AdjustmentDao(dbContext); dao.CreateAdjustment(objAdjustment); //Update stock card //dao.updateStockCard(objAdjustment.StockAdjustmentItems.ToList()); txn.Commit(); isSuccessful = true; } dbContext.Database.Connection.Close(); } catch (Exception) { // throw; } return(isSuccessful); }
public ActionResult GetAdjustmentsByClerk() { int rank = (int)UserRank.Clerk; int userId = Convert.ToInt32(RouteData.Values["userId"]); int departmentId = Convert.ToInt32(RouteData.Values["departmentId"]); List <Adjustment> adjustments = AdjustmentDao.GetAllAdjustmentsByClerk(userId, departmentId); ViewData["Adjustments"] = adjustments; //reuse the view for storemanager and storesupervisor ViewData["MyAdjustment"] = 1; return(View("Adjustments")); }
public ActionResult ReceiveItemsByDepartment(List <DisbursementDetail> details, int id) { Dictionary <int, DisbursementDetail> dDict = DisbursementDao.GetDisbursementDetailDictByDisbursementId(id); //generate adjustment if items are missing List <AdjustmentDetail> adjustmentDetails = new List <AdjustmentDetail>(); foreach (var d in details) { DisbursementDetail disDetail = dDict[d.DisbursementDetailId]; if (disDetail.Quantity != d.Quantity && d.Quantity < disDetail.Quantity) { AdjustmentDetail adDetail = new AdjustmentDetail() { Item = new Item() { ItemId = d.Item.ItemId }, Count = disDetail.Quantity - d.Quantity }; adjustmentDetails.Add(adDetail); } } if (adjustmentDetails.Count > 0) { int userId = Convert.ToInt32(RouteData.Values["userId"]); User u = new User() { UserId = userId }; Adjustment ad = AdjustmentDao.InsertAdjustment(adjustmentDetails, u); AdjustmentDao.CalculateAdjustmentCost(ad); } Disbursement dis = DisbursementDao.DeliverDisbursement(id, details); //need to update the request such as status, delivered Qty RequestDao.UpdateRequestById(dis.Request.RequestId); return(RedirectToAction("Deliveries")); }
public ActionResult Adjustments(List <Item> items) { int userId = Convert.ToInt32(RouteData.Values["userId"]); User u = new User() { UserId = userId }; List <AdjustmentDetail> details = new List <AdjustmentDetail>(); foreach (var i in items) { if (i.Quantity > 0) { AdjustmentDetail adjDetail = new AdjustmentDetail() { Item = new Item() { ItemId = i.ItemId }, Count = i.Quantity }; details.Add(adjDetail); } } if (details.Count > 0) { foreach (var d in details) { Debug.WriteLine("Item Id {0} Amount is {1} Requestor is {2}", d.Item.ItemId, d.Count, u.UserId); } Adjustment ad = AdjustmentDao.InsertAdjustment(details, u); AdjustmentDao.CalculateAdjustmentCost(ad); ItemDao.UpdateStockForAdjustment(details); } return(new HttpStatusCodeResult(200)); }
public ActionResult ReceiveItemsByDepartment(List <DisbursementDetail> details, int id) { Dictionary <int, DisbursementDetail> dDict = DisbursementDao.GetDisbursementDetailDictByDisbursementId(id); //generate adjustment if items are missing List <AdjustmentDetail> adjustmentDetails = new List <AdjustmentDetail>(); //if detail drop to 0 , it should be removed List <DisbursementDetail> disDetails = new List <DisbursementDetail>(); foreach (var d in details) { DisbursementDetail disDetail = dDict[d.DisbursementDetailId]; if (disDetail.Quantity != d.Quantity && d.Quantity < disDetail.Quantity) { AdjustmentDetail adDetail = new AdjustmentDetail() { Item = new Item() { ItemId = d.Item.ItemId }, Count = disDetail.Quantity - d.Quantity }; if (d.Quantity == 0) { disDetails.Add(disDetail); } adjustmentDetails.Add(adDetail); } } if (adjustmentDetails.Count > 0) { int userId = Convert.ToInt32(RouteData.Values["userId"]); User u = new User() { UserId = userId }; Adjustment ad = AdjustmentDao.InsertAdjustment(adjustmentDetails, u); AdjustmentDao.CalculateAdjustmentCost(ad); } Disbursement dis = DisbursementDao.GetDisbursement(id); int requestId = dis.Request.RequestId; dis = DisbursementDao.DeliverDisbursement(id, details); //remove disbursement detail with quantity of zero if (disDetails.Count > 0) { DisbursementDao.RemoveDisbursementDetails(disDetails); //details have been removed, need to remove disbursement if disbursement got no details //removedDisbursement = DisbursementDao.RemoveDisbursementWithoutDetails(id); } dis = DisbursementDao.GetDeliveredDisbursement(id); if (dis != null) { //need to update the request such as status, delivered Qty RequestDao.UpdateRequestById(requestId); } else { //if disbursement is removed, change disbursement status of request back to not prepared RequestDao.UpdateRequestDisbursementStatus(requestId); } return(RedirectToAction("Deliveries")); }
public AdjustmentController() { LogicUniStoreModel db = new LogicUniStoreModel(); dao = new AdjustmentDao(db); }