public List <AdjustmentVoucherDTO> getTotalAmountDTO() { List <AdjustmentVoucherDTO> voucherDTO = new List <AdjustmentVoucherDTO>(); IEnumerable <AdjustmentVoucher> adjs = adjustmentVoucherRepo.FindAll(); foreach (var adj in adjs) { AdjustmentVoucherDTO newVoucher = new AdjustmentVoucherDTO(); newVoucher.adjustmentVoucher = adj; if (adj.AdjustmentVoucherDetails.Count > 0) { var total = adjustmentVoucherRepo.GetTotalAmount(adj.Id); if (total < 0) { total = total * -1; } newVoucher.TotalAmount = total; } else { newVoucher.TotalAmount = 0; } voucherDTO.Add(newVoucher); } return(voucherDTO); }
public ActionResult CreateAdjustments() { var adjVoucherColView = new AdjVoucherColView(); var adjustmentVoucherDtos = new List <AdjustmentVoucherDTO>(); var adjustmentVoucherDto = new AdjustmentVoucherDTO(); adjustmentVoucherDtos.Add(adjustmentVoucherDto); adjVoucherColView.MyList = adjustmentVoucherDtos; return(View("CreateAdjustments", adjVoucherColView)); }
private AdjustmentVoucherDetail generateVoucherDetail(AdjustmentVoucherDTO adjdDTO) { AdjustmentVoucherDetail newVoucherDetail = new AdjustmentVoucherDetail(); newVoucherDetail.AdjustmentVoucherId = adjdDTO.adjustmentVoucher.Id; newVoucherDetail.StationeryId = adjdDTO.StationeryId; newVoucherDetail.Quantity = adjdDTO.Quantity; newVoucherDetail.Reason = adjdDTO.Reason; newVoucherDetail.DateTime = DateTime.Now; return(newVoucherDetail); }
private AdjustmentVoucher generateVoucher(AdjustmentVoucherDTO adjDTO) { LoginDTO currentUser = (LoginDTO)Session["existinguser"]; int clerkId = currentUser.EmployeeId; AdjustmentVoucher newVoucher = new AdjustmentVoucher(); newVoucher.Date = DateTime.Now; newVoucher.Status = Enum.GetName(typeof(Enums.AdjustmentVoucherStatus), Enums.AdjustmentVoucherStatus.Open); newVoucher.EmployeeId = clerkId; return(newVoucher); }
public ActionResult CreateAdjustment(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var adj = new AdjustmentVoucherDTO { ItemNum = id, Stationery = _stationeryRepo.GetById(id) }; return(View(adj)); }
public ActionResult Create() { if (Session["existinguser"] != null) { LoginDTO currentUser = (LoginDTO)Session["existinguser"]; if (currentUser.RoleId != (int)Enums.Roles.StoreClerk) { return(RedirectToAction("RedirectToClerkOrDepartmentView", "Login")); } AdjustmentVoucherDTO adj = new AdjustmentVoucherDTO(); adj.Stationeries = StationeryService.Instance.GetAllStationeries(); return(View(adj)); } return(RedirectToAction("Index", "Login")); }
public ActionResult CreateAdjustment([Bind(Include = "Quantity,Reason,ItemNum,Sign")] AdjustmentVoucherDTO adjVoucherDto) { if (ModelState.IsValid) { var empNum = Convert.ToInt32(Request.Cookies["Employee"]?["EmpNum"]); var self = _employeeRepo.GetById(empNum); if (adjVoucherDto.Sign == false) { adjVoucherDto.Quantity = adjVoucherDto.Quantity * -1; } var stationery = _stationeryRepo.GetById(adjVoucherDto.ItemNum); stationery.AvailableQty = stationery.AvailableQty + adjVoucherDto.Quantity; stationery.CurrentQty = stationery.CurrentQty + adjVoucherDto.Quantity; _stationeryRepo.Update(stationery); var adjustment = new AdjVoucher { ItemNum = adjVoucherDto.ItemNum, Quantity = adjVoucherDto.Quantity, Reason = adjVoucherDto.Reason, Status = Pending, RequestEmpNum = empNum, CreateDate = DateTime.Today }; adjustment.Stationery = _stockAdjustmentRepo.AddStockAdjustment(adjustment); var managerEmail = _employeeRepo.GetStoreManager().EmailAddress; var supervisorEmail = _employeeRepo.GetStoreSupervisor().EmailAddress; var email1 = new LUSSISEmail.Builder().From(self.EmailAddress) .To(managerEmail).ForNewStockAdjustment(self.FullName, adjustment).Build(); var email2 = new LUSSISEmail.Builder().From(self.EmailAddress) .To(supervisorEmail).ForNewStockAdjustment(self.FullName, adjustment).Build(); new System.Threading.Thread(delegate() { EmailHelper.SendEmail(email1); }).Start(); new System.Threading.Thread(delegate() { EmailHelper.SendEmail(email2); }).Start(); return(RedirectToAction("History")); } adjVoucherDto.Stationery = _stationeryRepo.GetById(adjVoucherDto.ItemNum); return(View(adjVoucherDto)); }
public ActionResult Detail(int adjId) { if (Session["existinguser"] != null) { LoginDTO currentUser = (LoginDTO)Session["existinguser"]; if (currentUser.RoleId != (int)Enums.Roles.StoreClerk && currentUser.RoleId != (int)Enums.Roles.StoreSupervisor && currentUser.RoleId != (int)Enums.Roles.StoreManager) { return(RedirectToAction("RedirectToClerkOrDepartmentView", "Login")); } AdjustmentVoucherDTO adjDTO = new AdjustmentVoucherDTO(); adjDTO.adjustmentVoucher = AdjustmentVoucherService.Instance.getAdjustmentVoucherById(adjId); return(View(adjDTO)); } return(RedirectToAction("Index", "Login")); }
public ActionResult SubmitVoucher(AdjustmentVoucherDTO adjDTO) { if (Session["existinguser"] != null) { LoginDTO currentUser = (LoginDTO)Session["existinguser"]; if (currentUser.RoleId != (int)Enums.Roles.StoreClerk) { return(RedirectToAction("RedirectToClerkOrDepartmentView", "Login")); } if (ModelState.IsValid) { AdjustmentVoucher updatedVoucher = AdjustmentVoucherService.Instance.getAdjustmentVoucherById(adjDTO.adjustmentVoucher.Id); if (TempData["AdjustQty"] != null) { AdjustmentVoucher AdjustQtyDTO = (AdjustmentVoucher)TempData["AdjustQty"]; TempData.Keep("AdjustQty"); //update POdetails deliveredQty foreach (var detail in AdjustQtyDTO.AdjustmentVoucherDetails) { AdjustmentVoucherDetail oldVoucherDetail = updatedVoucher.AdjustmentVoucherDetails.Single(x => x.Id == detail.Id); oldVoucherDetail.Quantity = detail.Quantity; oldVoucherDetail.Reason = detail.Reason; //AdjustmentVoucherService.Instance.UpdateAdjustmentVoucherDetail(oldVoucherDetail); } } updatedVoucher.Status = Enum.GetName(typeof(Enums.AdjustmentVoucherStatus), Enums.AdjustmentVoucherStatus.Submitted); updatedVoucher.Date = DateTime.Now; AdjustmentVoucherService.Instance.UpdateAdjustmentVoucher(updatedVoucher); TempData["AdjustQty"] = null; return(RedirectToAction("Index")); } return(View(adjDTO)); } return(RedirectToAction("Index", "Login")); }
public ActionResult Create(AdjustmentVoucherDTO adjDTO) { if (Session["existinguser"] != null) { LoginDTO currentUser = (LoginDTO)Session["existinguser"]; if (currentUser.RoleId != (int)Enums.Roles.StoreClerk) { return(RedirectToAction("RedirectToClerkOrDepartmentView", "Login")); } if (ModelState.IsValid) { int clerkId = currentUser.EmployeeId; adjDTO.adjustmentVoucher = new AdjustmentVoucher(); AdjustmentVoucher existVoucher = AdjustmentVoucherService.Instance.getOpenAdjustmentVoucherByClerk(clerkId); if (existVoucher != null) { adjDTO.adjustmentVoucher.Id = existVoucher.Id; } else { AdjustmentVoucher newVoucher = this.generateVoucher(adjDTO); AdjustmentVoucherService.Instance.CreateAdjustmentVoucher(newVoucher); adjDTO.adjustmentVoucher.Id = newVoucher.Id; } AdjustmentVoucherDetail newVoucherDetail = this.generateVoucherDetail(adjDTO); AdjustmentVoucherService.Instance.CreateAdjustmentVoucherDetail(newVoucherDetail); adjDTO.adjustmentVoucher = AdjustmentVoucherService.Instance.getAdjustmentVoucherById(adjDTO.adjustmentVoucher.Id); //return RedirectToAction("Index"); } adjDTO.Stationeries = StationeryService.Instance.GetAllStationeries(); return(RedirectToAction("Detail", "AdjustmentVoucher", new { @adjId = adjDTO.adjustmentVoucher.Id })); } return(RedirectToAction("Index", "Login")); }