public ActionResult AdjustmentVoucherCreation() { avvm = adjBizLogic.InitiateAdjustmentVoucher(Session); tempList = new List <AdjustmentVoucherViewModelDetail>(); avvm.itemList = tempList; return(View(avvm)); }
public ActionResult Create(AdjustmentVoucherViewModel adjustmentVoucherViewModel) { if (ModelState.IsValidField("quantity") && adjustmentVoucherViewModel.quantity != 0 && adjustmentVoucherViewModel.remark != null) { if (Int32.TryParse(adjustmentVoucherViewModel.remark, out int result)) { MyReasonCode myCode = (MyReasonCode)result; // set the reasonable quantity if (myCode == MyReasonCode.InstoreDamaged || myCode == MyReasonCode.InstoreMissing) { adjustmentVoucherViewModel.quantity = -Math.Abs(adjustmentVoucherViewModel.quantity); } else if (myCode == MyReasonCode.FreeOfCharge) { adjustmentVoucherViewModel.quantity = Math.Abs(adjustmentVoucherViewModel.quantity); } // create the voucher AdjustmentVoucherDAO.CreateAdjustmentVoucher(adjustmentVoucherViewModel.itemNo, adjustmentVoucherViewModel.quantity, DateTime.Now.Date, myCode); return(RedirectToAction("ViewTotal")); } } return(RedirectToAction("Create")); }
public AdjustmentVoucherViewModel GetAdjustmentVoucher(string adjustmentID, HttpSessionStateBase session) { if (adjustmentID != null) { if (db.Adjustments.Find(adjustmentID) != null) { Adjustment adjustment = db.Adjustments.Find(adjustmentID); AdjustmentVoucherViewModel avvm = new AdjustmentVoucherViewModel(); Dictionary <string, string> storeEmpList = GetStoreEmployeeList("mstan", "mstan"); avvm.clerkIDName = storeEmpList["clerk"]; avvm.supervisorIDName = storeEmpList["supervisor"]; avvm.managerIDName = storeEmpList["manager"]; avvm.status = adjustment.status; avvm.needAuthority = adjustment.needAuthority == null ? false : true; avvm.voucherDate = adjustment.date; avvm.voucherID = adjustment.voucherId; avvm.adjustmentValue = adjustment.adjustmentValue; avvm.itemList = new List <AdjustmentVoucherViewModelDetail>(); List <AdjustmentDetail> adjustmentDetails = db.AdjustmentDetails.Where(x => x.voucherId == adjustmentID).ToList(); foreach (AdjustmentDetail adjDet in adjustmentDetails) { AdjustmentVoucherViewModelDetail avvmd = new AdjustmentVoucherViewModelDetail(); avvmd.itemID = adjDet.itemId; avvmd.itemDescription = db.Catalogues.Find(adjDet.itemId).description; avvmd.itemQty = adjDet.quantity; avvmd.remark = adjDet.remark; avvm.itemList.Add(avvmd); } return(avvm); } return(null); } return(null); }
private AdjustmentVoucherViewModel ConvertDetailToViewModel(Voucher_Detail detail) { Stationery stationery = stationeryService.FindStationeryByItemCode(detail.itemCode); AdjustmentVoucherViewModel vm = new AdjustmentVoucherViewModel(); // Stationery information vm.ItemCode = detail.itemCode; vm.StationeryDescription = stationery.description; vm.UOM = stationery.unitOfMeasure; vm.Price = stationery.price; // Voucher Record information vm.VoucherNo = detail.voucherID; vm.Requester = userService.FindNameByID(detail.Adjustment_Voucher_Record.handlingStaffID); vm.VoucherTotalAmount = 0.00M; vm.IssueDate = detail.Adjustment_Voucher_Record.issueDate; vm.ApprovalDate = detail.Adjustment_Voucher_Record.approvalDate; if (!String.IsNullOrEmpty(detail.Adjustment_Voucher_Record.authorisingStaffID)) { vm.Approver = userService.FindNameByID(detail.Adjustment_Voucher_Record.authorisingStaffID); } vm.Causes = detail.Adjustment_Voucher_Record.remarks; vm.Status = detail.Adjustment_Voucher_Record.status; // Voucher Detail information vm.Quantity = detail.adjustedQty; vm.Reason = detail.remarks; return(vm); }
public string CreateAdjustmentVoucher(AdjustmentVoucherViewModel avvm) { //ItemInventoryLocation - 1 - StockQty, 2 - DisburseQty, 3 - AdjustQty (not used) decimal totalAdjAmt = 0M; //Initiate Adjustment entry Adjustment adjustment = new Adjustment(); adjustment.voucherId = avvm.voucherID; adjustment.clerk = new string(avvm.clerkIDName.Where(Char.IsDigit).ToArray()); adjustment.supervisor = new string(avvm.supervisorIDName.Where(Char.IsDigit).ToArray()); adjustment.date = avvm.voucherDate; adjustment.status = "Submitted"; foreach (AdjustmentVoucherViewModelDetail avvmd in avvm.itemList) { AdjustmentDetail adjustmentDetail = new AdjustmentDetail(); Inventory inventory = db.Inventories.Find(avvmd.itemID); //edit Adj detail adjustmentDetail.itemId = avvmd.itemID; adjustmentDetail.quantity = avvmd.itemQty; adjustmentDetail.voucherId = avvm.voucherID; if (avvmd.itemInventoryLocation == 1) { //Adj inventory inventory.storeQuantity = avvmd.itemQty < 0 ? inventory.storeQuantity - Math.Abs(avvmd.itemQty) : inventory.storeQuantity + avvmd.itemQty; inventory.adjQuantity -= avvmd.itemQty; avvmd.remark += (" Adjusted Item code : " + avvmd.itemID + " Qty : " + avvmd.itemQty + " from StoreQty"); } else if (avvmd.itemInventoryLocation == 2) { inventory.disburseQuantity += avvmd.itemQty < 0 ? inventory.disburseQuantity - Math.Abs(avvmd.itemQty) : inventory.disburseQuantity + avvmd.itemQty; inventory.adjQuantity -= avvmd.itemQty; avvmd.remark += (" Adjusted Item code : " + avvmd.itemID + " Qty : " + avvmd.itemQty + " from DisburseQty"); } string supplier = db.Catalogues.Find(avvmd.itemID).firstSupplier; decimal itemPrice = db.SupplierQuotations.Where(x => x.itemId == avvmd.itemID && x.supplierId == supplier).First().price; totalAdjAmt += (itemPrice * avvmd.itemQty); adjustmentDetail.remark = avvmd.remark; db.AdjustmentDetails.Add(adjustmentDetail); } avvm.needAuthority = totalAdjAmt > 250M ? true : false; avvm.status = "Submitted"; //Set need authority (Logic - if need manager approval, set manager id - else null) adjustment.needAuthority = avvm.needAuthority == true ? new string(avvm.managerIDName.Where(Char.IsDigit).ToArray()) : null; adjustment.adjustmentValue = totalAdjAmt; db.Adjustments.Add(adjustment); db.SaveChanges(); EmailBusinessLogic emailBizLogic = new EmailBusinessLogic(); string receipient = avvm.needAuthority == true ? adjustment.needAuthority : adjustment.supervisor; string sender = adjustment.clerk; string linkref = "http://" + ConstantsConfig.linkrefURLPartial + "/Adjustment/AdjustmentDetail?adjustmentID=" + avvm.voucherID; emailBizLogic.SendEmail("submitAdj", receipient, sender, null, null, linkref); return(adjustment.voucherId); }
public ActionResult RemoveVoucherItem(string itemCode, List <AdjustmentVoucherViewModel> vmList) { AdjustmentVoucherViewModel vm = vmList.Find(x => x.ItemCode == itemCode); vmList.Remove(vm); Session["NewVoucher"] = vmList; TempData["SuccessMessage"] = String.Format("{0} was removed.", itemCode); return(RedirectToAction("NewVoucher")); }
// GET: AdjustmentVouchers/Create public ActionResult Create() { //ViewBag.category = AdjustmentVoucherDAO.GetCategorySelectList(); List <InventoryViewModel> items = InventoryDAO.GetInventories(); ViewBag.stationeryList = new SelectList(items, "itemNo", "description"); AdjustmentVoucherViewModel model = new AdjustmentVoucherViewModel(); model.quantity = 1; model.remark = "0"; return(View(model)); }
public string CreateStockTakeAdjustmentVoucher(HttpSessionStateBase session, Dictionary <string, int> adjitems) { AdjustmentVoucherViewModel avvm = InitiateAdjustmentVoucher(session); string itemID = ""; int adjQty = 0; foreach (KeyValuePair <string, int> kvp in adjitems) { itemID = kvp.Key; adjQty = kvp.Value; avvm = AddItem(avvm, itemID, adjQty); } string AdjID = CreateAdjustmentVoucher(avvm); return(AdjID); }
public ActionResult AddItemIntoVoucher(string itemCode, int quantity, string reason) { Stationery s = stationeryService.FindStationeryByItemCode(itemCode); if ((s.stockQty + quantity) < 0) { // cannot minus more than current stock TempData["ErrorMessage"] = String.Format("Negative adjustment quantity cannot greater than current stock."); } else { List <AdjustmentVoucherViewModel> vmList = Session["NewVoucher"] as List <AdjustmentVoucherViewModel>; AdjustmentVoucherViewModel vm = new AdjustmentVoucherViewModel(); vm.ItemCode = itemCode; vm.Quantity = quantity; vm.Reason = reason; vm.StationeryDescription = s.description; vm.UOM = s.unitOfMeasure; vm.Price = s.price; bool contain = false; bool zeroQuantity = (quantity == 0) ? true : false; foreach (var item in vmList) { if (item.ItemCode == vm.ItemCode) { item.Quantity += vm.Quantity; contain = true; zeroQuantity = (item.Quantity == 0) ? true : false; // notify user if quantity become 0 break; } } if (!contain) { vmList.Add(vm); } Session["NewVoucher"] = vmList; TempData["SuccessMessage"] = String.Format("{0} was added.", itemCode); TempData["WarningMessage"] = (zeroQuantity) ? String.Format("Warning! Quantity of {0} is 0, which will not be submitted.", itemCode) : null; } return(RedirectToAction("NewVoucher")); }
private AdjustmentVoucherViewModel ConvertRecordToViewModel(Adjustment_Voucher_Record record) { AdjustmentVoucherViewModel vm = new AdjustmentVoucherViewModel(); vm.VoucherNo = record.voucherID; vm.Requester = userService.FindNameByID(record.handlingStaffID); vm.IssueDate = record.issueDate; vm.VoucherTotalAmount = 0.00M; // only Pending need this info vm.ApprovalDate = record.approvalDate; if (!String.IsNullOrEmpty(record.authorisingStaffID)) { vm.Approver = userService.FindNameByID(record.authorisingStaffID); } vm.Causes = record.remarks; vm.Status = record.status; return(vm); }
public List <AdjustmentVoucherViewModel> GetVoucherRecordsByCriteria(string approverID, string status, string sortOrder) { bool isManager = userService.IsStoreManager(approverID); bool isSupervisor = userService.IsStoreSupervisor(approverID); List <Adjustment_Voucher_Record> records = adjustmentVoucherDAO.GetVouchersByCriteria(status, sortOrder); List <AdjustmentVoucherViewModel> vmList = new List <AdjustmentVoucherViewModel>(); if (status == AdjustmentVoucherStatus.PENDING) { // calculate total amount // return sorted voucher records based on total Amount & user role // below 250 = supervisor | above 250 = manager foreach (var record in records) { AdjustmentVoucherViewModel vm = ConvertRecordToViewModel(record); vm.VoucherTotalAmount = GetVoucherRecordTotalAmount(record.voucherID); // only Pending need total amount if (isManager && vm.VoucherTotalAmount * -1 > 250) { // manager => voucher amount > 250 vmList.Add(vm); } else if ((isSupervisor && vm.VoucherTotalAmount * -1 <= 250) || isManager) { // supervisor, manager => voucher amount <= 250 vmList.Add(vm); } } } else // status == Approved / Rejected { // return sorted voucher records for other status // both supervisor and manager can retrieve all records foreach (var record in records) { AdjustmentVoucherViewModel vm = ConvertRecordToViewModel(record); vmList.Add(vm); } } return(vmList); }
public void DeleteItem(AdjustmentVoucherViewModel avvm, string itemIDComposite) { string itemID = itemIDComposite.Substring(itemIDComposite.Length - 4, 4); if (!avvm.itemList.Any()) { //nothing to delete return; } else { if (avvm.itemList.Where(x => x.itemID == itemID).Any()) { AdjustmentVoucherViewModelDetail avvmd = avvm.itemList.Where(x => x.itemID == itemID).First(); avvm.itemList.Remove(avvmd); } return; } }
public AdjustmentVoucherViewModel InitiateAdjustmentVoucher(HttpSessionStateBase session) { //Adjustment Voucher creation page first landing AdjustmentVoucherViewModel avvm = new AdjustmentVoucherViewModel(); Dictionary <string, string> storeEmpList = GetStoreEmployeeList(session["Username"].ToString(), session["Password"].ToString()); DateTime timenow = DateTime.Now; string timestamp = timenow.ToString("yyyyMMddhhmmss"); string storeClerkID = session["EmployeeID"].ToString(); avvm.voucherID = "ADJ" + storeClerkID + timestamp; avvm.voucherDate = timenow; avvm.clerkIDName = session["EmployeeName"].ToString() + " (" + storeClerkID + ")"; avvm.supervisorIDName = storeEmpList["supervisor"]; avvm.managerIDName = storeEmpList["manager"]; avvm.needAuthority = false; avvm.status = "Pending"; avvm.itemList = new List <AdjustmentVoucherViewModelDetail>(); return(avvm); }
public bool SubmitAdjustmentVoucherForInventoryCheckDiscrepancy(List <InventoryCheckViewModel> stockchecklist, string requesterID) { List <InventoryCheckViewModel> discrepancyList = ConvertStockChecklistToDiscrepancyList(stockchecklist); List <AdjustmentVoucherViewModel> vmList = new List <AdjustmentVoucherViewModel>(); foreach (var item in discrepancyList) { AdjustmentVoucherViewModel vm = new AdjustmentVoucherViewModel(); vm.ItemCode = item.ItemCode; vm.Quantity = item.Discrepancy; vm.Reason = item.Remarks; vmList.Add(vm); } adjustmentVoucherService.SubmitNewAdjustmentVoucher(vmList, AdjustmentVoucherRemarks.INV_CHECK, requesterID); return(true); }
public AdjustmentVoucherViewModel AddItem(AdjustmentVoucherViewModel avvm, string itemIDComposite, int ItemQty) { string itemID = itemIDComposite.Substring(itemIDComposite.Length - 4, 4); if (avvm.itemList.Any()) { if (avvm.itemList.Where(x => x.itemID == itemID).Any()) { AdjustmentVoucherViewModelDetail oldItem = avvm.itemList.Where(x => x.itemID == itemID).First(); if (oldItem != null) { oldItem.itemQty += ItemQty; return(null); } } } //prepare the substring since the addition is composite (only last 4 character is the itemcode) Catalogue catalog = db.Catalogues.Find(itemID); if (catalog is null) { return(null); } AdjustmentVoucherViewModelDetail newItem = new AdjustmentVoucherViewModelDetail(); newItem.itemID = itemID; newItem.itemDescription = catalog.description; newItem.itemInventoryLocation = 1; newItem.itemQty = ItemQty; newItem.itemStoreQty = db.Inventories.Find(itemID).storeQuantity; newItem.itemDisburseQty = db.Inventories.Find(itemID).disburseQuantity; newItem.remark = null; avvm.itemList.Add(newItem); AdjustmentVoucherViewModel newavvm = avvm; return(newavvm); }
/// <summary> /// Return voucher details if user is authorized to view the record /// </summary> /// <param name="voucherNo"></param> /// <param name="userID"></param> /// <param name="errorMessage"></param> /// <returns></returns> public List <AdjustmentVoucherViewModel> IsUserAuthorizedToViewVoucherDetail(int voucherNo, string userID, out string errorMessage) { errorMessage = null; List <AdjustmentVoucherViewModel> vmList = new List <AdjustmentVoucherViewModel>(); Adjustment_Voucher_Record record = FindVoucherRecordByVoucherNo(voucherNo); if (record == null) { errorMessage = String.Format("Non-existing voucher."); return(null); } decimal voucherTotalAmount = GetVoucherRecordTotalAmount(record); if (record.status == AdjustmentVoucherStatus.PENDING) { // check for current user bool isManager = userService.IsStoreManager(userID); bool isSupervisor = userService.IsStoreSupervisor(userID); if (isSupervisor && !(voucherTotalAmount * -1 <= 250)) { errorMessage = String.Format("You have not right to approve this voucher."); return(null); } } foreach (var detail in record.Voucher_Details) { AdjustmentVoucherViewModel vm = ConvertDetailToViewModel(detail); vm.VoucherTotalAmount = voucherTotalAmount; vmList.Add(vm); } return(vmList); }
public AdjustmentVoucherViewModel ApproveVoucher(AdjustmentVoucherViewModel avvm) { Adjustment adjustment = db.Adjustments.Find(avvm.voucherID); EmailBusinessLogic emailBizLogic = new EmailBusinessLogic(); if (avvm.needAuthority == true) { adjustment.status = "Approved by " + avvm.managerIDName; avvm.status = "Approved by " + avvm.managerIDName; } else { adjustment.status = "Approved by " + avvm.supervisorIDName; avvm.status = "Approved by " + avvm.supervisorIDName; } db.SaveChanges(); string receipient = adjustment.clerk; string sender = avvm.needAuthority == true ? adjustment.needAuthority : adjustment.supervisor; string linkref = "http://" + ConstantsConfig.linkrefURLPartial + "/Adjustment/AdjustmentDetail?adjustmentID=" + avvm.voucherID; emailBizLogic.SendEmail("approveAdj", receipient, sender, null, null, linkref); return(avvm); }
public bool CreateAdjustmentVoucher([FromBody] AdjustmentVoucherViewModel model) { bool bRes = AdjustmentVoucherDAO.CreateAdjustmentVoucher(model.itemNo, model.quantity, DateTime.Now.Date, MyReasonCode.Else, model.remark); return(bRes); }
public ActionResult AdjustmentVoucherSave(AdjustmentVoucherViewModel avvmnew) { avvm = avvmnew; return(View("AdjustmentVoucherCreation", avvm)); }
public ActionResult AdjustmentDetail(string adjustmentID) { AdjustmentVoucherViewModel avvm = adjBizLogic.GetAdjustmentVoucher(adjustmentID, Session); return(View(avvm)); }
public ActionResult AdjustmentVoucherConfirm(AdjustmentVoucherViewModel avvmnew) { adjBizLogic.CreateAdjustmentVoucher(avvmnew); return(RedirectToAction("AdjustmentDetail", new { adjustmentID = avvm.voucherID })); }
public ActionResult AdjustmentVoucherApprove(AdjustmentVoucherViewModel avvmnew) { avvm = adjBizLogic.ApproveVoucher(avvmnew); return(View("AdjustmentVoucherCreation", avvm)); }