//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 <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 <ActionResult <AdjustmentVocherInfo> > getVoucher([FromBody] AdjustmentVocherInfo voc) { var result = await _mgrService.getEachVoucherDetail(voc); 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")); } }
public async Task <AdjustmentVocherInfo> getEachVoucherDetail(AdjustmentVocherInfo info) { AdjustmentVoucherDetail vocDetail = unitOfWork .GetRepository <AdjustmentVoucherDetail>() .GetAllIncludeIQueryable(filter: x => x.StockAdjustmentDetailId == info.stockAdustmentDetailId).FirstOrDefault(); if (vocDetail != null) { Employee empObj = unitOfWork .GetRepository <Employee>() .GetAllIncludeIQueryable(filter: x => x.Id == info.empId).FirstOrDefault(); AdjustmentVoucher voc = unitOfWork .GetRepository <AdjustmentVoucher>() .GetAllIncludeIQueryable(filter: x => x.Id == vocDetail.adjustmentVoucherId).FirstOrDefault(); if (voc != null && empObj != null) { AdjustmentVocherInfo obj = new AdjustmentVocherInfo() { vocNo = voc.Id, stockAdustmentDetailId = vocDetail.Id, stockAdustmentId = voc.StockAdjustmentId, empId = voc.EmployeeId, date = voc.date, reason = vocDetail.reason, empName = empObj.name, itemCode = info.itemCode, quantity = info.quantity, amount = vocDetail.price }; return(obj); } } return(null); }
public Task <AdjustmentVocherInfo> getEachVoucherDetail(AdjustmentVocherInfo info) { throw new NotImplementedException(); }