public async Task <IActionResult> SummaryReportByLocation(ReportByLocationListModel model) { //dropdown model.AvailableLocations.Add(new SelectListItem { Text = "Show All Locations", Value = "1" }); foreach (var item in (await _inventoryManagementService.GetReportByLocation((int)_workContext.CurrentCustomer.ClientId))) { model.AvailableLocations.Add(new SelectListItem { Text = item.SName, Value = item.Sid.ToString() }); } var(locationReportListModel, totalCount) = await _inventoryManagementService.PrepareLocationReportListModel(model, 1, 10000); foreach (var item in locationReportListModel) { var IsNameExits = model.SummaryReportList.Any(x => x.VName == item.VName && x.SName == item.SName); if (!IsNameExits) { model.SummaryReportList.Add(new repInvValue_Total { VendorID = item.VendorID, VName = item.VName, SName = item.SName, Total = locationReportListModel.Where(x => x.VName == item.VName && x.SName == item.SName).ToList().Select(c => c.Total).Sum(), ILocationSId = item.ILocationSId }); } } return(View(model)); }
public async Task <IActionResult> DetailedReportByLocation(ReportByLocationListModel model) { //dropdown model.AvailableLocations.Add(new SelectListItem { Text = "Show All Locations", Value = "1" }); foreach (var item in (await _inventoryManagementService.GetReportByLocation((int)_workContext.CurrentCustomer.ClientId))) { model.AvailableLocations.Add(new SelectListItem { Text = item.SName, Value = item.Sid.ToString() }); } var(locationReportListModel, totalCount) = await _inventoryManagementService.PrepareLocationReportListModel(model, 1, 10000); foreach (var item in locationReportListModel) { //count value to display subtotal var count = locationReportListModel.Where(x => x.VName == item.VName && x.SName == item.SName).ToList().Count; var IsNameExits = model.DetailReportList.Any(x => x.VName == item.VName && x.SName == item.SName); var reports = new invreportlocationModel(); reports.VendorID = item.VendorID; reports.VItem = item.VItem; reports.Pkg = item.Pkg; reports.Qty = item.Qty; reports.SName = item.SName; reports.UOM = item.UOM; reports.VDescription = item.VDescription; reports.VName = IsNameExits == true ? "" : item.VName; reports.Total = item.Total; reports.ILocationSId = item.ILocationSId; if (!IsNameExits) { reports.Subtotal = locationReportListModel.Where(x => x.VName == item.VName && x.SName == item.SName).ToList().Select(c => c.Total).Sum(); //var currentCount = model.DetailReportList.Where(x => x.VName == item.VName && x.SName == item.SName).ToList().Count; //if (currentCount == count) // reports.Subtotal = locationReportListModel.Where(x => x.VName == item.VName && x.SName == item.SName).ToList().Select(c => c.Total).Sum(); } model.DetailReportList.Add(reports); } return(View(model)); }
public async Task <IActionResult> DetailedReportByLocation() { var model = new ReportByLocationListModel(); model.AvailableLocations.Add(new SelectListItem { Text = "Show All Locations", Value = "1" }); foreach (var item in (await _inventoryManagementService.GetReportByLocation((int)_workContext.CurrentCustomer.ClientId))) { model.AvailableLocations.Add(new SelectListItem { Text = item.SName, Value = item.Sid.ToString() }); } return(View(model)); }
public async Task <IActionResult> repInvVendorValue(int VendorID, int LocationID) { if (VendorID <= 0) { return(RedirectToAction("SummaryReportByLocation")); } var model = new ReportByLocationListModel(); model.intLocationSID = LocationID; var(locationReportListModel, totalCount) = await _inventoryManagementService.PrepareLocationReportListModel(model, 1, 10000); model.SummaryReportList = locationReportListModel.Where(c => c.VendorID == VendorID).ToList(); return(View(model)); }
public async Task <(IEnumerable <repInvValue_Total> locationReportListModel, int totalCount)> PrepareLocationReportListModel(ReportByLocationListModel model, int pageIndex, int pageSize) { var repInv = new List <repInvValue_Total>(); int totalCount = 0; try { SqlParameter[] pr = new SqlParameter[] { new SqlParameter("@intClientID", (int)_workContext.CurrentCustomer.ClientId), new SqlParameter("@intLocationSID", model.intLocationSID) }; var records = await _dbContext.Set <repInvValue_Total>().FromSqlRaw("exec [dbo].[repInvValue-Total] @intClientID,@intLocationSID", pr).ToListAsync(); totalCount = records.Count; int pageOffSet = (Convert.ToInt32(pageIndex) - 1) * 10; records = records.Skip(pageOffSet).Take(Convert.ToInt32(pageSize)).ToList(); ///Add from store procedure response to model foreach (var p in records) { repInv.Add(new repInvValue_Total { ILocationSId = p.ILocationSId, Pkg = p.Pkg, Qty = p.Qty, SName = p.SName, Total = p.Total, UOM = p.UOM, VDescription = p.VDescription, VendorID = p.VendorID, VItem = p.VItem, VName = p.VName }); } return(repInv, totalCount); } catch (Exception ex) { } return(repInv, totalCount); }