view for Dispatches view and Wrapping filtering criteria objects
        public void CanBackPostDispatchesReport()
        {
            //ACT
            //TODO: Seed data into DispatchesViewModel before proceding with testing
            var viewModel = new DispatchesViewModel { };
            var viewResult = _stockManagementController.DispatchesReport(viewModel) as ViewResult;

            //ASSERT
            Assert.NotNull(viewResult);
            Assert.IsInstanceOf<IEnumerable<Program>>(viewResult.ViewBag.Program);
            Assert.IsInstanceOf<IEnumerable<CommodityType>>(viewResult.ViewBag.CommodityTypes);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets the offloading report.
        /// </summary>
        /// <param name="hubID">The hub ID.</param>
        /// <param name="dispatchesViewModel">The dispatches view model.</param>
        /// <returns></returns>
        public List<ViewModels.Report.Data.OffloadingReport> GetOffloadingReport(int hubID, DispatchesViewModel dispatchesViewModel)
        {
            DateTime sTime = DateTime.Now;
            DateTime eTime = DateTime.Now;

            if (!dispatchesViewModel.PeriodId.HasValue || dispatchesViewModel.PeriodId == 6)
            {
                //filter it to only the current week
                //sTime = DateTime.Now.StartOfWeek(DayOfWeek.Monday);
                eTime = sTime.AddDays(7).Date;
            }
            else
            {
                //start end date filters
                if (dispatchesViewModel.PeriodId == 8)
                {
                    sTime = dispatchesViewModel.StartDate ?? sTime;
                    eTime = dispatchesViewModel.EndDate ?? eTime;
                }
                //allocation round
                else if (dispatchesViewModel.PeriodId == 9)
                {
                }
                //allocation year + month
                else if (dispatchesViewModel.PeriodId == 9)
                {
                }
            }

            string StartTime = sTime.ToShortDateString();
            string EndTime = eTime.ToShortDateString();
            // string HUbName = repository.Hub.FindById(hubID).HubNameWithOwner;
            var dbGetOffloadingReport = _unitOfWork.ReportRepository.RPT_Offloading(hubID, sTime, eTime).ToList();

            if (dispatchesViewModel.ProgramId.HasValue && dispatchesViewModel.ProgramId != 0)
            {
                dbGetOffloadingReport = dbGetOffloadingReport.Where(p => p.ProgramID == dispatchesViewModel.ProgramId).ToList();
            }
            if (dispatchesViewModel.AreaId.HasValue && dispatchesViewModel.AreaId != 0)
            {
                dbGetOffloadingReport = dbGetOffloadingReport.Where(p => p.RegionID == dispatchesViewModel.AreaId).ToList();
            }
            if (dispatchesViewModel.bidRefId != null)
            {
                dbGetOffloadingReport = dbGetOffloadingReport.Where(p => p.BidRefNo == dispatchesViewModel.bidRefId).ToList();
            }

            return (from t in dbGetOffloadingReport
                    group t by new { t.BidRefNo, t.ProgramName, t.Round, t.PeriodMonth, t.PeriodYear, t.RegionName }
                        into b
                        select new OffloadingReport()
                        {
                            ContractNumber = b.Key.BidRefNo,
                            EndDate = EndTime,
                            StartDate = StartTime,
                            Month = Convert.ToString(b.Key.PeriodMonth),
                            Round = Convert.ToString(b.Key.Round),
                            Year = b.Key.PeriodYear,//??0, modified Banty 23_5_13
                            Region = b.Key.RegionName,
                            Program = b.Key.ProgramName,
                            OffloadingDetails = b.Select(t1 => new OffloadingDetail()
                            {
                                RequisitionNumber = t1.RequisitionNo,
                                Product = t1.CommodityName,
                                Zone = t1.ZoneName,
                                Woreda = t1.WoredaName,
                                Destination = t1.FDPName,
                                Allocation = t1.AllocatedInMT ?? 0,
                                Dispatched = t1.DispatchedQuantity ?? 0,
                                Remaining = t1.RemainingAmount ?? 0,
                                Transporter = t1.TransaporterName,
                                Donor = t1.DonorName
                            }).ToList()

                        }).ToList();
            //return (from t in db.Dispatches.Where(p=>p.DispatchAllocationID != null)
            //                 .Select(q=>q.DispatchDetails.FirstOrDefault().TransactionGroup.Transactions.FirstOrDefault())
            //                 .Where(p => p.HubID == hubID
            //                    && p.LedgerID == Ledger.Constants.GOODS_DISPATCHED
            //                    && p.QuantityInMT > 0
            //                    ).ToList()

            //        group t by new {t.Program,
            //                        t.Hub,
            //                        t.TransactionGroup.DispatchDetails.FirstOrDefault().Dispatch,
            //                        t.TransactionGroup.DispatchDetails.FirstOrDefault().Dispatch.DispatchAllocation}
            //        into b
            //        select new OffloadingReport()
            //                   {
            //                       ContractNumber = b.Key.DispatchAllocation.BidRefNo,
            //                       EndDate = "today",
            //                       HubName = b.Key.Hub.HubNameWithOwner,
            //                       StartDate = "yesterday",
            //                       Month = Convert.ToString(b.Key.Dispatch.PeriodMonth),
            //                       Round = Convert.ToString(b.Key.DispatchAllocation.Round),
            //                       Year = (b.Key.Dispatch.PeriodYear),
            //                       OffloadingDetails = b.Select(t1 => new OffloadingDetail()
            //                       {
            //                           RequisitionNumber = b.Key.DispatchAllocation.BidRefNo,
            //                           Product = t1.Commodity.Name,
            //                           Zone = b.Key.DispatchAllocation.FDP.AdminUnit.AdminUnit2.Name,
            //                           Woreda = b.Key.DispatchAllocation.FDP.AdminUnit.Name,
            //                           Destination = b.Key.DispatchAllocation.FDP.Name,
            //                           Allocation = b.Key.DispatchAllocation.Amount*10,
            //                           Dispatched = b.Key.DispatchAllocation.DispatchedAmount*10,
            //                           Remaining = b.Key.DispatchAllocation.RemainingQuantityInQuintals * 10,
            //                           Transporter = b.Key.Dispatch.Transporter.Name,
            //                           Donor = "DOn",//b.Key.DispatchAllocation.DonorID

            //                       }).ToList(),
            //                       Region = "afar",
            //                       Program = b.Key.Program.Name,

            //                   }).ToList();
        }
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public ActionResult Dispatches()
        {
            var user = _userProfileService.GetUser(User.Identity.Name);
            var codesViewModels = ConstantsService.GetAllCodes();
            var commodityTypeViewModels = _commodityTypeService.GetAllCommodityTypeForReprot();
            var programViewModels = _programService.GetAllProgramsForReport();
            var storeViewModels = _hubService.GetAllStoreByUser(user);
            var areaViewModels = _adminUnitService.GetAllAreasForReport();
            var bidRefViewModels = _dispatchAllocationService.GetAllBidRefsForReport();
            var viewModel = new DispatchesViewModel( codesViewModels, commodityTypeViewModels, programViewModels, storeViewModels,
                areaViewModels, bidRefViewModels);

            return View(viewModel);
        }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="viewModel"></param>
 /// <returns></returns>
 public ActionResult DispatchesReport(DispatchesViewModel viewModel)
 {
     ViewBag.Program = viewModel.ProgramId == null ? "All" : _programService.GetAllProgram().Where(c => c.ProgramID == viewModel.ProgramId).Select(c => c.Name).Single();
     ViewBag.CommodityTypes = viewModel.CommodityTypeId == null ? "All" : _commodityTypeService.GetAllCommodityType().Where(c => c.CommodityTypeID == viewModel.CommodityTypeId).Select(c => c.Name).Single();
     return PartialView();
 }
        public void ShouldDisplayOffloadingReportPartial()
        {
            //Act
            var filter=new DispatchesViewModel();
            var result = _reportsController.OffloadingReportPartial(filter);

            //Assert

            Assert.IsInstanceOf<PartialViewResult>(result);
        }
 public ActionResult OffloadingReportViewerExportTo(DispatchesViewModel dispatchesViewModel)
 {
     DRMFSS.Web.Reports.MasterReportBound rep = GetOffloading(dispatchesViewModel);
     return DevExpress.Web.Mvc.ReportViewerExtension.ExportTo(rep);
 }
 public ActionResult OffloadingReportPartial(DispatchesViewModel dispatchesViewModel)
 {
     MasterReportBound report = GetOffloading(dispatchesViewModel);
        return PartialView("OffloadingReportPartial", report);
 }
        public ActionResult OffloadingReport()
        {
            MasterReportBound report = GetOffloading(new DispatchesViewModel());
            BLL.UserProfile user = _userProfileService.GetUser(User.Identity.Name);

             var codes =ConstantsService.GetAllCodes();
             var commodityTypes =_commodityTypeService.GetAllCommodityTypeForReprot();;
             var programs =_programService.GetAllProgramsForReport();
             var stores =_hubService.GetAllStoreByUser(user);
             var areas = _adminUnitService.GetAllAreasForReport();
             var bidRefs = _dispatchAllocationService.GetAllBidRefsForReport();
            DispatchesViewModel ViewModel = new DispatchesViewModel(codes,commodityTypes,programs,stores,areas,bidRefs);
            ViewBag.Filters = ViewModel;
            return View(report);
        }
 public MasterReportBound GetOffloading(DispatchesViewModel dispatchesViewModel)
 {
     BLL.UserProfile user = _userProfileService.GetUser(User.Identity.Name);
        OffloadingReportMain main = new OffloadingReportMain();
        List<OffloadingReport> reports = _transactionService.GetOffloadingReport(user.DefaultHub.HubID, dispatchesViewModel);
        main.reports = reports;
        main.PreparedBy = user.GetFullName();
        main.HubName = user.DefaultHub.HubNameWithOwner;
        main.ReportDate = DateTime.Now;
        main.ReportName = "OffloadingReport";
        main.ReportTitle = "Offloading";
        List<OffloadingReportMain> coll = new List<OffloadingReportMain>();
        coll.Add(main);
        OffLoadingReport rpt = new OffLoadingReport() { DataSource = reports };
        // XtraReport1 rpt = new XtraReport1() { DataSource = freestockreport.Programs[2].Details };
        MasterReportBound report = new MasterReportBound() { Name = "Offloading Report " + DateTime.Now.ToShortDateString(), DataSource = coll };
        report.rptSubReport.ReportSource = rpt;
        return report;
 }