예제 #1
0
        public JsonResult RequestPie(int planId = -1)
        {
            var requests = _regionalRequestService.FindBy(t => t.PlanID == planId);

            var req = (from request in requests
                       group request by request.AdminUnit.AdminUnitID into g
                       let firstOrDefault = g.FirstOrDefault()
                                            where firstOrDefault != null select new
            {
                Region = g.First().AdminUnit.Name,
                Count = g.Count(),
                PlanId = g.First().PlanID,
                firstOrDefault.Plan.PlanName
            });

            return(Json(req, JsonRequestBehavior.AllowGet));
        }
예제 #2
0
        private IEnumerable <ReliefRequisitionDetailViewModel> GetDonorCoveredWoredas(IEnumerable <ReliefRequisitionDetailViewModel> reliefRequisitionDetailViewModels, int requisitionID)
        {
            var requisition = _reliefRequisitionService.FindById(requisitionID);


            if (requisition != null && requisition.ProgramID == (int)Programs.Releif)
            {
                var regionalRequest = _regionalRequestService.FindBy(m => m.RegionalRequestID == requisition.RegionalRequestID).FirstOrDefault();
                if (regionalRequest != null)
                {
                    var hrd = _planService.GetHrd(regionalRequest.PlanID);
                    if (hrd != null)
                    {
                        var donorCoveredWoredas = _planService.GetDonorCoverage(m => m.HRDID == hrd.HRDID, null,
                                                                                "HrdDonorCoverageDetails").ToList();

                        if (donorCoveredWoredas.Count != 0)
                        {
                            return(from reliefRequisitionDetailViewModel in reliefRequisitionDetailViewModels

                                   select new ReliefRequisitionDetailViewModel()
                            {
                                Zone = reliefRequisitionDetailViewModel.Zone,
                                Woreda = reliefRequisitionDetailViewModel.Woreda,
                                FDP = reliefRequisitionDetailViewModel.FDP,
                                Donor = _planService.FindHrdDonorCoverage(donorCoveredWoredas, reliefRequisitionDetailViewModel.FDPID) ?? "DRMFSS",
                                //_.DonorID.HasValue ? reliefRequisitionDetail.Donor.Name : "-",
                                Commodity = reliefRequisitionDetailViewModel.Commodity,
                                BenficiaryNo = reliefRequisitionDetailViewModel.BenficiaryNo,
                                Amount = reliefRequisitionDetailViewModel.Amount,
                                RequisitionID = reliefRequisitionDetailViewModel.RequisitionID,
                                RequisitionDetailID = reliefRequisitionDetailViewModel.RequisitionDetailID,
                                CommodityID = reliefRequisitionDetailViewModel.CommodityID,
                                FDPID = reliefRequisitionDetailViewModel.FDPID,
                                //DonorID = reliefRequisitionDetailViewModel.DonorID,
                                //RationAmount =RationAmount,
                                Contingency = reliefRequisitionDetailViewModel.Contingency
                            }

                                   );
                        }
                    }
                }
            }

            return(reliefRequisitionDetailViewModels);
        }
예제 #3
0
        public WoredaStockDistributionWithDetailViewModel CheckWoredaDistribution(int woredaID = -1, int planID = -1, int month = -1, int programId = -1)
        {
            if (woredaID == -1 || planID == -1 || month == -1 || programId == -1)
            {
                return(null);
            }
            //var woredaStockDistribution = _utilizationService.FindBy(m => m.WoredaID == woredaID && m.Month == month && m.PlanID == planID).FirstOrDefault();
            var             zoneID          = _commonService.GetZoneID(woredaID);
            var             regionID        = _commonService.GetRegion(zoneID);
            RegionalRequest regionalRequest = null;

            if (programId == (int)Programs.Releif)
            {
                regionalRequest =
                    _regionalRequestService.FindBy(m => m.PlanID == planID && m.Round == month && m.RegionID == regionID)
                    .FirstOrDefault();
            }
            else if (programId == (int)Programs.PSNP)
            {
                regionalRequest = _regionalRequestService.FindBy(m => m.PlanID == planID && m.Month == month && m.RegionID == regionID)
                                  .FirstOrDefault();
            }
            if (regionalRequest != null)
            {
                var requisition =
                    _reliefRequisitionService.FindBy(
                        m => m.RegionalRequestID == regionalRequest.RegionalRequestID && m.ZoneID == zoneID);

                if (requisition != null)
                {
                    var woredaStockDistribution = _utilizationService.FindBy(m => m.WoredaID == woredaID && m.Month == month && m.PlanID == planID).FirstOrDefault();
                    if (woredaStockDistribution == null)
                    {
                        var fdpStockDistribution = _commonService.GetFDPs(woredaID);

                        var woredaDistributionDetailViewModels = new List <WoredaDistributionDetailViewModel>();
                        foreach (var reliefRequisition in requisition)
                        {
                            var detail = GetWoredaStockDistribution(fdpStockDistribution, reliefRequisition);
                            if (detail != null)
                            {
                                woredaDistributionDetailViewModels.AddRange(detail);
                            }
                        }
                        var listOfFdps = new WoredaStockDistributionWithDetailViewModel
                        {
                            WoredaDistributionDetailViewModels = woredaDistributionDetailViewModels,
                        };

                        return(listOfFdps);
                    }

                    var woredaStockDistributionWithDetailViewModel = new WoredaStockDistributionWithDetailViewModel()
                    {
                        WoredaStockDistributionID = woredaStockDistribution.WoredaStockDistributionID,
                        WoredaID                           = woredaStockDistribution.WoredaID,
                        ProgramID                          = woredaStockDistribution.ProgramID,
                        PlanID                             = woredaStockDistribution.PlanID,
                        Month                              = woredaStockDistribution.WoredaStockDistributionID,
                        DirectSupport                      = woredaStockDistribution.DirectSupport,
                        PublicSupport                      = woredaStockDistribution.PublicSupport,
                        ActualBeneficairies                = woredaStockDistribution.ActualBeneficairies,
                        MaleBetween5And18Years             = woredaStockDistribution.MaleBetween5And18Years,
                        FemaleLessThan5Years               = woredaStockDistribution.FemaleLessThan5Years,
                        MaleAbove18Years                   = woredaStockDistribution.MaleAbove18Years,
                        MaleLessThan5Years                 = woredaStockDistribution.MaleLessThan5Years,
                        FemaleAbove18Years                 = woredaStockDistribution.FemaleAbove18Years,
                        FemaleBetween5And18Years           = woredaStockDistribution.FemaleBetween5And18Years,
                        WoredaDistributionDetailViewModels = (from woredaDistributionDetail in woredaStockDistribution.WoredaStockDistributionDetails
                                                              from reliefRequisition in requisition
                                                              where woredaDistributionDetail.CommodityID == reliefRequisition.CommodityID
                                                              let lossReason = woredaDistributionDetail.LossReason
                                                                               where lossReason != null
                                                                               select new WoredaDistributionDetailViewModel()
                        {
                            WoredaStockDistributionDetailID = woredaDistributionDetail.WoredaStockDistributionDetailID,
                            FdpId = woredaDistributionDetail.FdpId,
                            FDP = woredaDistributionDetail.FDP.Name,
                            CommodityID = GetRequisionInfo(reliefRequisition.RequisitionID, woredaDistributionDetail.FdpId).CommodityID,
                            CommodityName = GetRequisionInfo(reliefRequisition.RequisitionID, woredaDistributionDetail.FdpId).CommodityName,
                            AllocatedAmount = GetRequisionInfo(reliefRequisition.RequisitionID, woredaDistributionDetail.FdpId).AllocatedAmount,
                            NumberOfBeneficiaries = GetRequisionInfo(reliefRequisition.RequisitionID, woredaDistributionDetail.FdpId).BeneficaryNumber,
                            //RequisitionDetailViewModel = GetRequisionInfo(reliefRequisition.RequisitionID, woredaDistributionDetail.FdpId),
                            dispatched = GetDispatchAllocation(reliefRequisition.RequisitionNo, woredaDistributionDetail.FDP.FDPID),
                            delivered = GetDelivered(reliefRequisition.RequisitionNo, woredaDistributionDetail.FDP.FDPID),
                            RequistionNo = reliefRequisition.RequisitionNo,
                            Round = reliefRequisition.Round,
                            Month = RequestHelper.MonthName(reliefRequisition.Month),
                            BeginingBalance = woredaDistributionDetail.StartingBalance,
                            EndingBalance = woredaDistributionDetail.EndingBalance,
                            DistributedAmount = woredaDistributionDetail.DistributedAmount,
                            TotalIn = woredaDistributionDetail.TotalIn,
                            TotalOut = woredaDistributionDetail.TotoalOut,
                            LossAmount = woredaDistributionDetail.LossAmount,
                            LossReasonId = (int)lossReason,
                            RequisitionId = woredaDistributionDetail.RequisitionId,
                            DistributionStartDate = woredaDistributionDetail.DistributionStartDate,
                            DistributionEndDate = woredaDistributionDetail.DistributionEndDate
                        }
                                                              ).ToList()
                    };

                    return(woredaStockDistributionWithDetailViewModel);
                }
                return(null);
            }
            return(null);
        }
예제 #4
0
        private bool IsRequestCreatedFromThisPlan(int id)
        {
            var regionalRequest = _reqService.FindBy(p => p.PlanID == id).FirstOrDefault();

            return(regionalRequest != null);
        }
예제 #5
0
        public JsonResult RegionalData(int regionID)
        {
            var requests      = _regionalRequestService.FindBy(t => t.RegionID == regionID);
            var requisitions  = _reliefRequisitionService.FindBy(t => t.RegionID == regionID);
            var totalRequests = requests.Count();
            var currentPlan   = _hrdService.FindBy(t => t.Status == 3).FirstOrDefault().PlanID;
            var utilizations  = _utilization.FindBy(t => t.PlanID == currentPlan);

            var sum18  = 0;
            var sum518 = 0;
            var sum5   = 0;
            var female = 0;
            var male   = 0;

            if (utilizations != null)
            {
                foreach (var i in utilizations)
                {
                    sum18  = +(i.FemaleAbove18Years + i.MaleAbove18Years);
                    sum5   = +(i.FemaleLessThan5Years + i.MaleLessThan5Years);
                    sum518 = +(i.FemaleBetween5And18Years + i.MaleBetween5And18Years);
                    female = +(i.FemaleAbove18Years + i.FemaleBetween5And18Years + i.FemaleLessThan5Years);
                    male   = +(i.MaleAbove18Years + i.MaleBetween5And18Years + i.MaleLessThan5Years);
                }
            }


            var draft = (from r in requests
                         where r.Status == 1
                         select r).Count();

            var approved = (from r in requests
                            where r.Status == 2
                            select r).Count();

            var closed = (from r in requests
                          where r.Status == 3
                          select r).Count();

            var federalApp = (from r in requests
                              where r.Status >= 4
                              select r).Count();

            var reqApp = (from r in requisitions
                          where r.Status == 2
                          select r).Count();

            var reqDraft = (from r in requisitions
                            where r.Status == 1
                            select r).Count();

            var reqHub = (from r in requisitions
                          where r.Status >= 3
                          select r).Count();

            var d = new DashboardData();

            if (totalRequests != 0)
            {
                d.ApprovedRequests    = (decimal)approved;
                d.PendingRequests     = (decimal)(draft);
                d.HubAssignedRequests = (decimal)(closed);
                d.FederalApproved     = (decimal)(federalApp);
            }
            if (requisitions.Count() != 0)
            {
                d.ApprovedRequisitions    = ((decimal)(reqApp));
                d.HubAssignedRequisitions = ((decimal)(reqHub));
                d.PendingRequisitions     = ((decimal)(reqDraft));
            }

            d.Above18  = sum18;
            d.Bet5And8 = sum518;
            d.Below5   = sum5;
            d.Female   = female;
            d.Male     = male;

            d.IncomingCommodity  = 25131;
            d.IncomingDispatches = 2142;

            return(Json(d, JsonRequestBehavior.AllowGet));
        }