public async Task <IList <AdjustmentVocherInfo> > issueVoucher(StockAdjustSumById voc) { IList <AdjustmentVocherInfo> list = await getAllAdjustDetailLineByAdjustId(voc); List <AdjustmentVocherInfo> voucherResult = new List <AdjustmentVocherInfo>(); Employee empObj = unitOfWork .GetRepository <Employee>() .GetAllIncludeIQueryable(filter: x => x.Id == voc.empId).FirstOrDefault(); AdjustmentVoucher adjVoc = new AdjustmentVoucher() { StockAdjustmentId = voc.stockAdustmentId, EmployeeId = voc.empId, Employee = empObj, date = DateTime.Now }; unitOfWork.GetRepository <AdjustmentVoucher>().Insert(adjVoc); unitOfWork.SaveChanges(); foreach (AdjustmentVocherInfo eachInfo in list) { StockAdjustmentDetail stkDetail = unitOfWork .GetRepository <StockAdjustmentDetail>() .GetAllIncludeIQueryable(filter: x => x.Id == eachInfo.stockAdustmentDetailId).FirstOrDefault(); if (stkDetail != null) { stkDetail.Status = "Approved"; unitOfWork.GetRepository <StockAdjustmentDetail>().Update(stkDetail); unitOfWork.SaveChanges(); } AdjustmentVoucherDetail vocDetail = new AdjustmentVoucherDetail() { adjustmentVoucherId = adjVoc.Id, StockAdjustmentDetailId = eachInfo.stockAdustmentDetailId, price = eachInfo.amount, reason = eachInfo.reason, }; unitOfWork.GetRepository <AdjustmentVoucherDetail>().Insert(vocDetail); unitOfWork.SaveChanges(); AdjustmentVocherInfo obj = await getEachVoucherDetail(eachInfo); if (obj != null) { voucherResult.Add(obj); } } return(voucherResult); }
public async Task <IList <StockAdjustSumById> > rejectRequest(StockAdjustSumById voc, String comment) { IList <AdjustmentVocherInfo> list = await getAllAdjustDetailLineByAdjustId(voc); List <AdjustmentVocherInfo> voucherResult = new List <AdjustmentVocherInfo>(); foreach (AdjustmentVocherInfo eachInfo in list) { StockAdjustmentDetail stkDetail = unitOfWork .GetRepository <StockAdjustmentDetail>() .GetAllIncludeIQueryable(filter: x => x.Id == eachInfo.stockAdustmentDetailId).FirstOrDefault(); if (stkDetail != null) { stkDetail.Status = "Declined"; unitOfWork.GetRepository <StockAdjustmentDetail>().Update(stkDetail); unitOfWork.SaveChanges(); } StockAdjustment stkAdj = new StockAdjustment() { type = "Revert", date = eachInfo.date, EmployeeId = eachInfo.empId }; unitOfWork.GetRepository <StockAdjustment>().Insert(stkAdj); unitOfWork.SaveChanges(); StockAdjustmentDetail stkAdjDetail = new StockAdjustmentDetail() { stockAdjustmentId = stkAdj.Id, StationeryId = eachInfo.empId, discpQty = -(eachInfo.quantity), comment = comment, Status = "Reverted" }; unitOfWork.GetRepository <StockAdjustmentDetail>().Insert(stkAdjDetail); unitOfWork.SaveChanges(); Stationery stationery = unitOfWork .GetRepository <Stationery>() .GetAllIncludeIQueryable(filter: x => x.Id == eachInfo.itemCode).FirstOrDefault(); if (stationery != null) { stationery.inventoryQty += -(eachInfo.quantity); unitOfWork.GetRepository <Stationery>().Update(stationery); unitOfWork.SaveChanges(); } } return(await StockAdjustDetailInfo()); }
public async Task <ActionResult <List <StockAdjustSumById> > > RejectRequest([FromBody] StockAdjustSumById voc, String comment) { var result = await _supervisorService.rejectRequest(voc, comment); Employee emp = await _mgrService.findEmployeeByIdAsync(voc.empId); String emailBody = "Stock Adjustment Form #" + voc.stockAdustmentId + " is rejected. Could you please check again."; String str = await _emailService.SendMail(emp.email, "Rejected:Stock Adjustment Form #" + voc.stockAdustmentId, emailBody); if (result != null) { return(Ok(result)); } else { //this help to return a NOTfOUND result, u can customerize the string. return(NotFound("Empty")); } }
//end public async Task <IList <AdjustmentVocherInfo> > getAllAdjustDetailLineByAdjustId(StockAdjustSumById item) { float amounttotal = 0; IList <AdjustmentVocherInfo> voucherInfoList = new List <AdjustmentVocherInfo>(); IList <AdjustmentVoucherDetail> vocDetails = await findAllAdjustmentVoucherDetailAsync(); IList <StockAdjustmentDetail> list = unitOfWork .GetRepository <StockAdjustmentDetail>() .GetAllIncludeIQueryable(filter: x => x.stockAdjustmentId == item.stockAdustmentId && x.Status != "Reverted" && x.Status != "Declined" && x.Status != "Approved" && x.discpQty != 0).ToList(); IList <AdjustmentVoucherDetail> vocList = await findAllAdjustmentVoucherDetailAsync(); bool isApprove = false; foreach (StockAdjustmentDetail eachSAdjDetailRecord in list) { amounttotal = 0; isApprove = false; foreach (AdjustmentVoucherDetail eachVocDetailRecord in vocDetails) { if (eachVocDetailRecord.StockAdjustmentDetailId == eachSAdjDetailRecord.Id) { isApprove = true; } } if (!isApprove && eachSAdjDetailRecord.Status != "Reverted" && eachSAdjDetailRecord.Status != "Declined") { SupplierItem supplierItem = await findSupplierItemByIdAsync(eachSAdjDetailRecord.StationeryId); amounttotal = supplierItem.price * eachSAdjDetailRecord.discpQty; double eachItemAmount = (Math.Abs(supplierItem.price * eachSAdjDetailRecord.discpQty)); StockAdjustment stockAdjustment = await findStockAdjustmentByIdAsync(eachSAdjDetailRecord.stockAdjustmentId); if (stockAdjustment != null && Math.Abs(eachItemAmount) > 250) { Employee emp = await findEmployeeByIdAsync(stockAdjustment.EmployeeId); if (emp != null) { AdjustmentVocherInfo voucher = new AdjustmentVocherInfo() { stockAdustmentDetailId = eachSAdjDetailRecord.Id, stockAdustmentId = eachSAdjDetailRecord.stockAdjustmentId, reason = eachSAdjDetailRecord.comment, empId = emp.Id, empName = emp.name, itemCode = eachSAdjDetailRecord.StationeryId, quantity = eachSAdjDetailRecord.discpQty, amount = amounttotal }; voucherInfoList.Add(voucher); } } } } return(voucherInfoList); }
public async Task <IList <StockAdjustSumById> > StockAdjustDetailInfo() { IList <StockAdjustSumById> stockAdjustSumByIdList = new List <StockAdjustSumById>(); float amounttotal = 0; IList <StockAdjustment> stoAdjlist = await findAllStockAdjustmentAsync(); IList <StockAdjustmentDetail> stoAdjDetaillist = await findAllStockAdjustDetailAsync(); IList <AdjustmentVoucherDetail> vocDetails = await findAllAdjustmentVoucherDetailAsync(); IList <AdjustmentVoucher> vocList = await findAllAdjustmentVoucherAsync(); bool isApprove = false; StockAdjustSumById adjustSumbyId = new StockAdjustSumById() { }; foreach (StockAdjustment eachSAdjRecord in stoAdjlist) { adjustSumbyId = null; amounttotal = 0; List <StockAdjustmentDetail> stockAdjDetailList = unitOfWork .GetRepository <StockAdjustmentDetail>() .GetAllIncludeIQueryable(filter: x => x.stockAdjustmentId == eachSAdjRecord.Id && x.Status != "Reverted" && x.Status != "Declined" && x.Status != "Approved" && x.discpQty != 0).ToList(); if (stockAdjDetailList != null) { foreach (StockAdjustmentDetail eachSAdjDetailRecord in stockAdjDetailList) { isApprove = false; foreach (AdjustmentVoucherDetail eachVocRecord in vocDetails) { if (eachSAdjDetailRecord.Id == eachVocRecord.StockAdjustmentDetailId) { isApprove = true; } } SupplierItem supplierItem = await findSupplierItemByIdAsync(eachSAdjDetailRecord.StationeryId); amounttotal += (Math.Abs(supplierItem.price * eachSAdjDetailRecord.discpQty)); double eachItemAmount = supplierItem.price * eachSAdjDetailRecord.discpQty; if (Math.Abs(eachItemAmount) > 250) { StockAdjustment stockAdjustment = await findStockAdjustmentByIdAsync(eachSAdjDetailRecord.stockAdjustmentId); if (stockAdjustment != null) { Employee emp = await findEmployeeByIdAsync(stockAdjustment.EmployeeId); if (emp != null) { adjustSumbyId = new StockAdjustSumById() { stockAdustmentId = eachSAdjRecord.Id, empId = emp.Id, empName = emp.name, amount = amounttotal }; } } } } //End StockAdjustmentDetail loop if (!isApprove && adjustSumbyId != null) { stockAdjustSumByIdList.Add(adjustSumbyId); // Sum } } } return(stockAdjustSumByIdList); }
public Task <IList <AdjustmentVocherInfo> > issueVoucher(StockAdjustSumById voc) { throw new NotImplementedException(); }
public Task <IList <AdjustmentVocherInfo> > getAllAdjustDetailLineByAdjustId(StockAdjustSumById item) { throw new NotImplementedException(); }
public async Task <ActionResult <List <AdjustmentVocherInfo> > > SupervisorissueVoucher([FromBody] StockAdjustSumById voc) { var result = await _supervisorService.issueVoucher(voc); Employee emp = await _supervisorService.findEmployeeByIdAsync(voc.empId); String emailBody = "Stock Adjustment Form #" + voc.stockAdustmentId + " has been Approved."; String str = await _emailService.SendMail(emp.email, "Approved:Stock Adjustment Form #" + voc.stockAdustmentId, emailBody); //Console.WriteLine(str); if (result != null) { return(Ok(result)); } else { //this help to return a NOTfOUND result, u can customerize the string. return(NotFound("Error")); } }
public async Task <ActionResult <List <AdjustmentVocherInfo> > > getAllSupervisorAdjustDetailLine([FromBody] StockAdjustSumById item) { var result = await _supervisorService.getAllAdjustDetailLineByAdjustId(item); if (result != null) { //Docs says that Ok(...) will AUTO TRANSFER result into JSON Type return(Ok(result)); } else { //this help to return a NOTfOUND result, u can customerize the string. return(NotFound("Error")); } }