public async Task <IHttpActionResult> PostReportInventoryTongHop(ParameterInventory para) { var result = new TransferObj <InventoryReport>(); try { var data = new List <InventoryExpImpLevel2>(); var reporter = new InventoryReport(); reporter.UnitCode = _servicePeriod.GetCurrentUnitCode(); reporter.Year = para.ToDate.Year; var period = _service.UnitOfWork.Repository <MdPeriod>().DbSet.Where(x => x.ToDate == para.ToDate).FirstOrDefault(); if (period != null) { reporter.Period = period.Period; } var unitCode = _servicePeriod.GetCurrentUnitCode(); reporter.CreateDateNow(); reporter.FromDay = para.FromDate.Day; reporter.FromMonth = para.FromDate.Month; reporter.FromYear = para.FromDate.Year; reporter.ToDay = para.ToDate.Day; reporter.ToMonth = para.ToDate.Month; reporter.ToYear = para.ToDate.Year; reporter.TenDonVi = CurrentSetting.GetUnitName(unitCode); reporter.DiaChiDonVi = CurrentSetting.GetUnitAddress(unitCode); //GetNhanVien if (HttpContext.Current != null && HttpContext.Current.User is ClaimsPrincipal) { var currentUser = (HttpContext.Current.User as ClaimsPrincipal); var name = currentUser.Identity.Name; var nhanVien = _service.UnitOfWork.Repository <AU_NGUOIDUNG>().DbSet.Where(x => x.Username == name).FirstOrDefault(); if (nhanVien != null) { reporter.Username = nhanVien.TenNhanVien; } else { reporter.Username = "******"; } } var tableName = ProcedureCollection.GetTableName(period.Year, period.Period); data = _service.ReportTonTongHop(para); switch (para.GroupBy) { case TypeGroupInventory.MADONVI: reporter.DetailData = data.ToList(); reporter.MapUnitUserName(_service.UnitOfWork); reporter.GroupType = "Mã đơn vị"; break; case TypeGroupInventory.WAREHOUSE: reporter.DetailData = data.ToList(); reporter.MapUnitUserName(_service.UnitOfWork); reporter.GroupType = "Kho hàng"; break; case TypeGroupInventory.TYPE: reporter.DetailData = data.ToList(); reporter.MapUnitUserName(_service.UnitOfWork); reporter.GroupType = "Loại hàng hóa"; break; case TypeGroupInventory.GROUP: reporter.DetailData = data.ToList(); reporter.MapUnitUserName(_service.UnitOfWork); reporter.GroupType = "Nhóm hàng hóa"; break; case TypeGroupInventory.NHACUNGCAP: reporter.DetailData = data.ToList(); reporter.MapUnitUserName(_service.UnitOfWork); reporter.GroupType = "Nhà cung cấp"; break; default: reporter.DetailData = data.ToList(); reporter.MapUnitUserName(_service.UnitOfWork); reporter.GroupType = "Hàng hóa"; break; } result.Data = reporter; result.Status = true; result.Message = "Xuất báo cáo thành công"; return(Ok(result)); } catch (Exception e) { return(InternalServerError()); } }
public async Task <IHttpActionResult> ReportInventoryByDay(ParameterInventory para) { var result = new TransferObj <InventoryReport>(); try { var reporter = new InventoryReport(); var data = new List <InventoryExpImpLevel2>(); reporter.UnitCode = _servicePeriod.GetCurrentUnitCode(); reporter.Year = para.ToDate.Year; var period = _service.UnitOfWork.Repository <MdPeriod>().DbSet.Where(x => x.ToDate == para.ToDate).FirstOrDefault(); if (period != null) { reporter.Period = period.Period; } var unitCode = _servicePeriod.GetCurrentUnitCode(); reporter.CreateDateNow(); reporter.FromDay = para.FromDate.Day; reporter.FromMonth = para.FromDate.Month; reporter.FromYear = para.FromDate.Year; reporter.ToDay = para.ToDate.Day; reporter.ToMonth = para.ToDate.Month; reporter.ToYear = para.ToDate.Year; reporter.TenDonVi = CurrentSetting.GetUnitName(unitCode); reporter.DiaChiDonVi = CurrentSetting.GetUnitAddress(unitCode); //GetNhanVien if (HttpContext.Current != null && HttpContext.Current.User is ClaimsPrincipal) { var currentUser = (HttpContext.Current.User as ClaimsPrincipal); var name = currentUser.Identity.Name; var nhanVien = _service.UnitOfWork.Repository <AU_NGUOIDUNG>().DbSet.Where(x => x.Username == name).FirstOrDefault(); if (nhanVien != null) { reporter.Username = nhanVien.TenNhanVien; } else { reporter.Username = "******"; } } switch (para.GroupBy) { case TypeGroupInventory.MADONVI: data = _service.CreateReportInventoryTongHop(InventoryGroupBy.MADONVI.ToString(), para.FromDate, para.ToDate, para.UnitCode, para.WareHouseCodes, para.MerchandiseTypeCodes, para.MerchandiseGroupCodes, para.MerchandiseCodes, para.NhaCungCapCodes); //data = _service.CreateReportInventoryByWareHouse( para.FromDate, para.ToDate, para.UnitCode, para.WareHouseCodes, para.MerchandiseTypeCodes, para.MerchandiseGroupCodes, para.MerchandiseCodes); reporter.DetailData = data.ToList(); reporter.MapUnitUserName(_service.UnitOfWork); reporter.GroupType = "Đơn vị"; break; case TypeGroupInventory.WAREHOUSE: data = _service.CreateReportInventoryTongHop(InventoryGroupBy.MAKHO.ToString(), para.FromDate, para.ToDate, para.UnitCode, para.WareHouseCodes, para.MerchandiseTypeCodes, para.MerchandiseGroupCodes, para.MerchandiseCodes, para.NhaCungCapCodes); //data = _service.CreateReportInventoryByWareHouse( para.FromDate, para.ToDate, para.UnitCode, para.WareHouseCodes, para.MerchandiseTypeCodes, para.MerchandiseGroupCodes, para.MerchandiseCodes); reporter.DetailData = data.ToList(); reporter.MapUnitUserName(_service.UnitOfWork); reporter.GroupType = "Kho hàng"; break; case TypeGroupInventory.TYPE: data = _service.CreateReportInventoryTongHop(InventoryGroupBy.MALOAIVATTU.ToString(), para.FromDate, para.ToDate, para.UnitCode, para.WareHouseCodes, para.MerchandiseTypeCodes, para.MerchandiseGroupCodes, para.MerchandiseCodes, para.NhaCungCapCodes); reporter.DetailData = data.ToList(); reporter.MapUnitUserName(_service.UnitOfWork); reporter.GroupType = "Loại hàng hóa"; break; case TypeGroupInventory.GROUP: data = _service.CreateReportInventoryTongHop(InventoryGroupBy.MANHOMVATTU.ToString(), para.FromDate, para.ToDate, para.UnitCode, para.WareHouseCodes, para.MerchandiseTypeCodes, para.MerchandiseGroupCodes, para.MerchandiseCodes, para.NhaCungCapCodes); reporter.DetailData = data.ToList(); reporter.MapUnitUserName(_service.UnitOfWork); reporter.GroupType = "Nhóm hàng hóa"; break; case TypeGroupInventory.MERCHANDISE: data = _service.CreateReportInventoryTongHop(InventoryGroupBy.MAVATTU.ToString(), para.FromDate, para.ToDate, para.UnitCode, para.WareHouseCodes, para.MerchandiseTypeCodes, para.MerchandiseGroupCodes, para.MerchandiseCodes, para.NhaCungCapCodes); //data = _service.CreateReportInventoryByMerchandise(para.FromDate, para.ToDate, para.UnitCode, para.WareHouseCodes, para.MerchandiseTypeCodes, para.MerchandiseGroupCodes, para.MerchandiseCodes); reporter.DetailData = data.ToList(); reporter.MapUnitUserName(_service.UnitOfWork); reporter.GroupType = "Hàng hóa"; break; case TypeGroupInventory.NHACUNGCAP: data = _service.CreateReportInventoryTongHop(InventoryGroupBy.MAKHACHHANG.ToString(), para.FromDate, para.ToDate, para.UnitCode, para.WareHouseCodes, para.MerchandiseTypeCodes, para.MerchandiseGroupCodes, para.MerchandiseCodes, para.NhaCungCapCodes); //data = _service.CreateReportInventoryByCustomer(para.FromDate, para.ToDate, para.UnitCode, para.WareHouseCodes, para.MerchandiseTypeCodes, para.MerchandiseGroupCodes, para.MerchandiseCodes, para.NhaCungCapCodes); reporter.DetailData = data.ToList(); reporter.MapUnitUserName(_service.UnitOfWork); reporter.GroupType = "Nhà cung cấp"; break; default: //data = _service.CreateReportInventoryByDay(para.FromDate, para.ToDate, para.UnitCode, para.WareHouseCodes, para.MerchandiseTypeCodes, para.MerchandiseGroupCodes, para.MerchandiseCodes); break; } result.Data = reporter; result.Status = true; result.Message = "Xuất báo cáo thành công"; return(Ok(result)); } catch (Exception e) { return(InternalServerError()); } }