view model for Receipts view and Wrapping filtering criteria objects
コード例 #1
0
        public void CanReceiptsReport()
        {
            //ACT
            //TODO: Seed data into ReceiptsViewModel before proceding with testing
            var viewModel = new ReceiptsViewModel { };
            var viewResult = _stockManagementController.ReceiptsReport(viewModel) as ViewResult;

            //ASSERT
            Assert.NotNull(viewResult);
            Assert.IsInstanceOf<IEnumerable<Program>>(viewResult.ViewBag.Program);
            Assert.IsInstanceOf<IEnumerable<CommodityType>>(viewResult.ViewBag.CommodityTypes);
            Assert.IsInstanceOf<IEnumerable<CommoditySource>>(viewResult.ViewBag.CommoditySources);
        }
コード例 #2
0
 public ActionResult ReceiptsReport(ReceiptsViewModel viewModel)
 {
     ViewBag.Program = viewModel.ProgramId == null ? "All" : _programService.GetAllProgram().Where(c => c.ProgramID == viewModel.ProgramId).Select(c => c.Name).Single();
     ViewBag.CommodityTypes = viewModel.CommodityTypeId == 0 ? "All" : _commodityTypeService.GetAllCommodityType().Where(c => c.CommodityTypeID == viewModel.CommodityTypeId).Select(c => c.Name).Single();
     ViewBag.CommoditySources = viewModel.CommoditySourceId == 0 ? "All" : _commoditySourceService.GetAllCommoditySource().Where(c => c.CommoditySourceID == viewModel.CommoditySourceId).Select(c => c.Name).Single();
     return PartialView();
 }
コード例 #3
0
        /// <summary>
        /// Gets the receive report.
        /// </summary>
        /// <param name="hubID">The hub ID.</param>
        /// <param name="receiptsViewModel">The receipts view model.</param>
        /// <returns></returns>
        public List<ReceiveReport> GetReceiveReport(int hubID, ReceiptsViewModel receiptsViewModel)
        {
            DateTime sTime = DateTime.Now;
            DateTime eTime = DateTime.Now;

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

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

            if (receiptsViewModel.ProgramId.HasValue && receiptsViewModel.ProgramId != 0)
            {
                dbGetReceiptReport = dbGetReceiptReport.Where(p => p.ProgramID == receiptsViewModel.ProgramId).ToList();
            }
            if (receiptsViewModel.CommodityTypeId.HasValue && receiptsViewModel.CommodityTypeId != 0)
            {
                dbGetReceiptReport = dbGetReceiptReport.Where(p => p.CommodityTypeID == receiptsViewModel.CommodityTypeId).ToList();
            }

            return (from t in dbGetReceiptReport
                    group t by new { t.BudgetYear }
                        into b
                        select new ReceiveReport()
                        {
                            BudgetYear = b.Key.BudgetYear.Value,
                            rows = b.Select(t1 => new ReceiveRow()
                            {
                                Product = t1.CommodityName,
                                Program = t1.ProgramName,
                                Quantity = t1.BalanceInMt.Value,
                                Quarter = t1.Quarter.Value
                                /*MeasurementUnit = t1.BalanceInUnit.Value*/

                            }).ToList()

                        }).ToList();
        }
コード例 #4
0
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public ActionResult Receipts()
        {
            var user = _userProfileService.GetUser(User.Identity.Name);
            var commoditySourceViewModels = _commoditySourceService.GetAllCommoditySourceForReport();
            var portViewModels = _receiveService.GetALlPorts();
            var codesViewModels = ConstantsService.GetAllCodes();
            var commodityTypeViewModels = _commodityTypeService.GetAllCommodityTypeForReprot();
            var programViewModels = _programService.GetAllProgramsForReport();
            var storeViewModel = _hubService.GetAllStoreByUser(user);
            var viewModel = new ReceiptsViewModel(codesViewModels, commodityTypeViewModels, programViewModels,
                storeViewModel, commoditySourceViewModels, portViewModels);

            return View(viewModel);
        }
コード例 #5
0
 public ActionResult ReceiveReportViewerExportTo(ReceiptsViewModel receiptsViewModel)
 {
     //DRMFSS.Web.Reports.MasterReportBound rep = GetReceiveReport(receiptsViewModel);
     DRMFSS.Web.Reports.MasterReportBound rep = GetReceiveReportByBudgetYear(receiptsViewModel);
     return DevExpress.Web.Mvc.ReportViewerExtension.ExportTo(rep);
 }
コード例 #6
0
 public ActionResult ReceivePartial(ReceiptsViewModel receiptsViewModel)
 {
     MasterReportBound report = GetReceiveReportByBudgetYear(receiptsViewModel);
     return PartialView("ReceivePartial", report);
 }
コード例 #7
0
        public ActionResult Receive()
        {
            MasterReportBound report = GetReceiveReportByBudgetYear(new ReceiptsViewModel());
            BLL.UserProfile user = _userProfileService.GetUser(User.Identity.Name);

            var commoditySources = _commoditySourceService.GetAllCommoditySourceForReport();
               var ports = _receiveService.GetALlPorts();
               var codes =ConstantsService.GetAllCodes();
            var commodityTypes =  _commodityTypeService.GetAllCommodityTypeForReprot();
               var programs = _programService.GetAllProgramsForReport();
            var stores = _hubService.GetAllStoreByUser(user);
            var viewModel = new ReceiptsViewModel(codes,commodityTypes,programs,stores,commoditySources,ports);
            ViewBag.Filters = viewModel;
            return View(report);
        }
コード例 #8
0
        public MasterReportBound GetReceiveReportByBudgetYear(ReceiptsViewModel receiptsViewModel)
        {
            List<DRMFSS.BLL.ViewModels.Report.Data.ReceiveReportMain> reports = new List<ReceiveReportMain>();
            DRMFSS.BLL.ViewModels.Report.Data.ReceiveReportMain receivereport = new BLL.ViewModels.Report.Data.ReceiveReportMain();
            BLL.UserProfile user = _userProfileService.GetUser(User.Identity.Name);

            receivereport.receiveReports = _transactionService.GetReceiveReport(user.DefaultHub.HubID, receiptsViewModel);//new List<BLL.ViewModels.Report.Data.ReceiveReport>();
            receivereport.PreparedBy = user.GetFullName();
            receivereport.HubName = user.DefaultHub.HubNameWithOwner;
            receivereport.ReportDate = System.DateTime.Now;
            receivereport.ReportCode = DateTime.Now.ToString();
            receivereport.ReportName = "ReceiveReport";
            receivereport.ReportTitle = "Receive Report";
            reports.Add(receivereport);

            DRMFSS.Web.Reports.ReceiveReportByBudgetYear rpt = new Web.Reports.ReceiveReportByBudgetYear() { DataSource = receivereport.receiveReports };
            MasterReportBound report = new MasterReportBound() { Name = "Receive Report - " + DateTime.Now.ToShortDateString(), DataSource = reports };
            report.rptSubReport.ReportSource = rpt;
            return report;
        }