Пример #1
0
 public decimal geteAllocatedAmount(ReliefRequisition req)
 {
     List<Cats.Models.ProjectCodeAllocation> pcAllocations = req.HubAllocations.ToList()[0].ProjectCodeAllocations.ToList();
     var siAllocation = pcAllocations.Where(item => item.SINumberID != null).Sum(item => item.Amount_FromSI);
     var pcAllocation = pcAllocations.Where(item => item.ProjectCodeID != null).Sum(item => item.Amount_FromProject);
     return (decimal)(siAllocation + pcAllocation);
 }
Пример #2
0
 public static ReliefRequisitionViewModel BindReliefRequisitionViewModel(ReliefRequisition reliefRequisition, List<WorkflowStatus> statuses, string datePref)
 {
     var requisition = new ReliefRequisitionViewModel();
     requisition.ProgramID = reliefRequisition.ProgramID;
     requisition.Program = reliefRequisition.Program.Name;
     requisition.Region = reliefRequisition.AdminUnit.Name;
     requisition.RequisitionNo = reliefRequisition.RequisitionNo;
     requisition.RegionID = reliefRequisition.RegionID;
     requisition.RegionalRequestID = reliefRequisition.RegionalRequestID;
     if (reliefRequisition.RequestedDate.HasValue)
         requisition.RequestedDateEt = reliefRequisition.RequestedDate.Value.ToCTSPreferedDateFormat(datePref);
     //);
     requisition.Round = reliefRequisition.Round;
     requisition.Status = statuses.Find(t => t.WorkflowID == (int)WORKFLOW.RELIEF_REQUISITION && t.StatusID == reliefRequisition.Status.Value).Description;
     requisition.RequestedDate = reliefRequisition.RequestedDate.Value;
     requisition.StatusID = reliefRequisition.Status;
     requisition.RequisitionID = reliefRequisition.RequisitionID;
     requisition.CommodityID = reliefRequisition.CommodityID;
     requisition.ZoneID = reliefRequisition.ZoneID;
     requisition.Zone = reliefRequisition.AdminUnit1.Name;
     requisition.Commodity = reliefRequisition.Commodity.Name;
     requisition.Month = RequestHelper.MonthName(reliefRequisition.Month);
     return requisition;
 }
Пример #3
0
 public bool AddReliefRequisition(ReliefRequisition reliefRequisition)
 {
     _unitOfWork.ReliefRequisitionRepository.Add(reliefRequisition);
     _unitOfWork.Save();
     return true;
 }
Пример #4
0
        public ReliefRequisition GenerateRequisition(RegionalRequest regionalRequest, List<RegionalRequestDetail> regionalRequestDetails, int commodityId, int zoneId)
        {
            var relifRequisition = new ReliefRequisition()
            {
                //TODO:Please Include Regional Request ID in Requisition
                RegionalRequestID = regionalRequest.RegionalRequestID,
                Round = regionalRequest.Round,
                Month = regionalRequest.Month,
                ProgramID = regionalRequest.ProgramId,
                CommodityID = commodityId,
                RequestedDate = DateTime.Today

                //TODO:Please find another way how to specify Requistion No
                ,
                RequisitionNo = Guid.NewGuid().ToString(),
                RegionID = regionalRequest.RegionID,
                ZoneID = zoneId,
                Status = (int)ReliefRequisitionStatus.Draft,
                //RequestedBy =itm.RequestedBy,
                //ApprovedBy=itm.ApprovedBy,
                //ApprovedDate=itm.ApprovedDate,

            };

            foreach (var regionalRequestDetail in regionalRequestDetails)
            {
                var relifRequistionDetail = new ReliefRequisitionDetail();
                var commodity = regionalRequestDetail.RequestDetailCommodities.First(t => t.CommodityID == commodityId);
                relifRequistionDetail.DonorID = regionalRequest.DonorID;
                relifRequistionDetail.FDPID = regionalRequestDetail.Fdpid;
                relifRequistionDetail.BenficiaryNo = regionalRequestDetail.Beneficiaries;
                relifRequistionDetail.CommodityID = commodity.CommodityID;
                relifRequistionDetail.Amount = commodity.Amount;
                relifRequisition.ReliefRequisitionDetails.Add(relifRequistionDetail);
            }
            return relifRequisition;
        }
Пример #5
0
 public bool DeleteReliefRequisition(ReliefRequisition reliefRequisition)
 {
     if (reliefRequisition == null) return false;
     _unitOfWork.ReliefRequisitionRepository.Delete(reliefRequisition);
     _unitOfWork.Save();
     return true;
 }
Пример #6
0
 public List<FDPRequestViewModel> getRequestDetail(ReliefRequisition Request)
 {
     var result = Request.ReliefRequisitionDetails.ToList().Select(item => new FDPRequestViewModel
     {
         RequisitionId=Request.RequisitionID,
         RequestDetailId = item.RequisitionDetailID,
         FDPId=item.FDPID,
         FDPName=item.FDP.Name,
         Name = item.FDP.Name,
         RequestedAmount=item.Amount.ToPreferedWeightUnit(),
         WoredaId=item.FDP.AdminUnitID,
         WoredaName=item.FDP.AdminUnit.Name,
         Commodity = item.Commodity.Name,
         Allocations = ToAllocationViewModel(item.SIPCAllocations.ToList())
     }).ToList();
     return result;
 }
Пример #7
0
        private void SendNotification(ReliefRequisition requisition)
        {
            try
            {
                string destinationURl;
                if (Request.Url.Host != null)
                {
                    if (Request.Url.Host == "localhost")
                    {
                        destinationURl = "http://" + Request.Url.Authority +
                                         "/Logistics/DispatchAllocation/IndexFromNotification?paramRegionId=" +
                                         requisition.RegionID +
                                         "&recordId=" + requisition.RequisitionID;
                    }
                    else
                    {
                        destinationURl = "http://" + Request.Url.Authority +
                                        Request.ApplicationPath +
                                         "/Logistics/DispatchAllocation/IndexFromNotification?paramRegionId=" +
                                         requisition.RegionID +
                                         "&recordId=" + requisition.RequisitionID;
                    }

                    _notificationService.AddNotificationForLogistcisFromEarlyWaring(destinationURl,
                                                                                    requisition.RequisitionID,
                                                                                    (int) requisition.RegionID,
                                                                                    requisition.RequisitionNo);
                }
            }
            catch (Exception)
            {

                throw;
            }
        }
Пример #8
0
        public ActionResult Requisition_Destroy([DataSourceRequest] DataSourceRequest request,
                                                  ReliefRequisition reliefRequisition)
        {
            if (reliefRequisition != null)
            {
                _reliefRequisitionDetailService.DeleteById(reliefRequisition.RequisitionID);
            }

            return Json(ModelState.ToDataSourceResult());
        }
Пример #9
0
 public ActionResult Edit(ReliefRequisition reliefrequisition)
 {
     if (ModelState.IsValid)
     {
         _reliefRequisitionService.EditReliefRequisition(reliefrequisition);
         return RedirectToAction("Index", "ReliefRequisition");
     }
     return View(reliefrequisition);
 }
        private IEnumerable<WoredaDistributionDetailViewModel> GetWoredaStockDistributionDetail(IEnumerable<WoredaStockDistributionDetail> woredaStockDistributionDetails,ReliefRequisition requisition)
        {
            return (from woredaStockDistributionDetail in woredaStockDistributionDetails
                    select new WoredaDistributionDetailViewModel()
                        {
                            FdpId = woredaStockDistributionDetail.FdpId,
                            FDP = woredaStockDistributionDetail.FDP.Name,
                            WoredaStockDistributionID = woredaStockDistributionDetail.WoredaStockDistributionID,
                            WoredaStockDistributionDetailID = woredaStockDistributionDetail.WoredaStockDistributionDetailID,
                            DistributedAmount = woredaStockDistributionDetail.DistributedAmount,
                            BeginingBalance = woredaStockDistributionDetail.StartingBalance,
                            EndingBalance = woredaStockDistributionDetail.EndingBalance,
                            TotalIn = woredaStockDistributionDetail.TotalIn,
                            TotalOut = woredaStockDistributionDetail.TotoalOut,
                            LossAmount = woredaStockDistributionDetail.LossAmount,
                            RequistionNo = requisition.RequisitionNo,
                            Round = requisition.Round,
                            Month = RequestHelper.MonthName(requisition.RegionalRequest.Month),
                            CommodityName = requisition.Commodity.Name,
                            RequisitionDetailViewModel = GetRequisionInfo(requisition.RequisitionID, woredaStockDistributionDetail.FdpId)

                        });
        }
        private IEnumerable<WoredaDistributionDetailViewModel> GetWoredaStockDistribution(IEnumerable<FDP> fdps,ReliefRequisition reliefRequisition)
        {
            if (reliefRequisition != null)
            {
                return (from fdp in fdps
                        select new WoredaDistributionDetailViewModel()
                        {
                            FdpId = fdp.FDPID,
                            FDP = fdp.Name,
                            DistributedAmount = 0,
                            RequistionNo = reliefRequisition.RequisitionNo,
                            Round = reliefRequisition.Round,
                            Month = RequestHelper.MonthName(reliefRequisition.RegionalRequest.Month),
                            RequisitionDetailViewModel = GetRequisionInfo(reliefRequisition.RequisitionID, fdp.FDPID)

                        });
            }
            return (from fdp in fdps
                    select new WoredaDistributionDetailViewModel()
                    {
                        FdpId = fdp.FDPID,
                        FDP = fdp.Name,
                        DistributedAmount = 0,

                    });
        }
Пример #12
0
 public ActionResult Edit(ReliefRequisition reliefrequisition,FormCollection collection)
 {
     if (ModelState.IsValid)
     {
         var requisition = _reliefRequisitionService.FindById(reliefrequisition.RequisitionID);
         if (requisition.ReliefRequisitionDetails.Count > 0)
         {
             foreach (var oldRequisitionDetail in requisition.ReliefRequisitionDetails)
             {
                 var commodityAmount = (decimal)0.00;
                 if (reliefrequisition.RationID != null)
                 {
                     var detail = oldRequisitionDetail;
                     var ration = _rationDetailService.FindBy(t => t.RationID == (int)reliefrequisition.RationID && t.CommodityID == detail.CommodityID).FirstOrDefault();
                     if (ration != null) commodityAmount = ration.Amount/1000;
                 }
                 var newRequisitionDetail = new ReliefRequisitionDetail()
                                             {
                                                 RequisitionID = oldRequisitionDetail.RequisitionID,
                                                 RequisitionDetailID = oldRequisitionDetail.RequisitionDetailID,
                                                 CommodityID = oldRequisitionDetail.CommodityID,
                                                 BenficiaryNo = oldRequisitionDetail.BenficiaryNo,
                                                 Amount = oldRequisitionDetail.BenficiaryNo * commodityAmount,
                                                 FDPID = oldRequisitionDetail.FDPID,
                                                 DonorID = oldRequisitionDetail.DonorID,
                                                 Contingency = oldRequisitionDetail.Contingency
                                             };
                 //oldRequisitionDetail.Amount = oldRequisitionDetail.BenficiaryNo*commodityAmount;
                 _reliefRequisitionDetailService.DeleteById(oldRequisitionDetail.RequisitionDetailID);
                 _reliefRequisitionDetailService.AddReliefRequisitionDetail(newRequisitionDetail);
             }
         }
         requisition.RationID = reliefrequisition.RationID;
         requisition.RequisitionNo = reliefrequisition.RequisitionNo;
         requisition.RequestedDate = reliefrequisition.RequestedDate;
         _reliefRequisitionService.EditReliefRequisition(requisition);
         return RedirectToAction("Index", "ReliefRequisition");
     }
     return View(reliefrequisition);
 }
        private List<WoredaDistributionDetailViewModel> GetWoredaStockDistribution(IEnumerable<FDP> fdps, ReliefRequisition reliefRequisition)
        {
            return (from fdp in fdps
                        from detail in reliefRequisition.ReliefRequisitionDetails
                        where fdp.FDPID==detail.FDPID
                        select new WoredaDistributionDetailViewModel()
                        {
                            FdpId = fdp.FDPID,
                            FDP = fdp.Name,
                            DistributedAmount = 0,
                            RequistionNo = reliefRequisition.RequisitionNo,
                            Round = reliefRequisition.Round,
                            Month = RequestHelper.MonthName(reliefRequisition.RegionalRequest.Month),
                            CommodityID = detail.CommodityID,
                            CommodityName = detail.Commodity.Name,
                            AllocatedAmount = detail.Amount,
                            NumberOfBeneficiaries = detail.BenficiaryNo,
                            dispatched = GetDispatchAllocation(reliefRequisition.RequisitionNo, fdp.FDPID),
                            delivered = GetDelivered(reliefRequisition.RequisitionNo, fdp.FDPID),
                            RequisitionId = reliefRequisition.RequisitionID,
                            TotalIn = _utilizationService.GetTotalIn(fdp.FDPID, (int)reliefRequisition.RequisitionID) != 0 ? _utilizationService.GetTotalIn(fdp.FDPID, (int)reliefRequisition.RequisitionID) : 0,

                            //RequisitionDetailViewModel = new RequisitionDetailViewModel()
                            //    {
                            //        CommodityID = detail.CommodityID,
                            //        CommodityName = detail.Commodity.Name,
                            //        AllocatedAmount = detail.Amount,
                            //        BeneficaryNumber = detail.BenficiaryNo

                            //    },
                            //GetRequisionInfo(reliefRequisition.RequisitionID, fdp.FDPID)

                        }).ToList();

            //return (from fdp in fdps
            //        select new WoredaDistributionDetailViewModel()
            //        {
            //            FdpId = fdp.FDPID,
            //            FDP = fdp.Name,
            //            DistributedAmount = 0,

            //        }).ToList();
        }
        private WoredaDistributionDetailViewModel GetWoredaStockDistribution(IEnumerable<FDP> fdps, ReliefRequisition reliefRequisition)
        {
            return (from fdp in fdps
                        from detail in reliefRequisition.ReliefRequisitionDetails
                        where fdp.FDPID==detail.FDPID
                        select new WoredaDistributionDetailViewModel()
                        {
                            FdpId = fdp.FDPID,
                            FDP = fdp.Name,
                            DistributedAmount = 0,
                            RequistionNo = reliefRequisition.RequisitionNo,
                            Round = reliefRequisition.Round,
                            Month = RequestHelper.MonthName(reliefRequisition.RegionalRequest.Month),
                            CommodityID = detail.CommodityID,
                            CommodityName = detail.Commodity.Name,
                            AllocatedAmount = detail.Amount,
                            NumberOfBeneficiaries = detail.BenficiaryNo,
                            //RequisitionDetailViewModel = new RequisitionDetailViewModel()
                            //    {
                            //        CommodityID = detail.CommodityID,
                            //        CommodityName = detail.Commodity.Name,
                            //        AllocatedAmount = detail.Amount,
                            //        BeneficaryNumber = detail.BenficiaryNo

                            //    },
                            //GetRequisionInfo(reliefRequisition.RequisitionID, fdp.FDPID)

                        }).FirstOrDefault();

            //return (from fdp in fdps
            //        select new WoredaDistributionDetailViewModel()
            //        {
            //            FdpId = fdp.FDPID,
            //            FDP = fdp.Name,
            //            DistributedAmount = 0,

            //        }).ToList();
        }
Пример #15
0
        public bool CreateRequisitonForTransfer(Transfer transfer)
        {
            if (transfer != null)
               {
               var fdp = _unitOfWork.FDPRepository.FindBy(m => m.HubID == transfer.DestinationHubID).FirstOrDefault();
               if (fdp != null)
               {
                   List<LedgerService.AvailableShippingCodes> availableSINumbers=new List<LedgerService.AvailableShippingCodes>();
                   var relifRequisition = new ReliefRequisition()
                       {

                           //RegionalRequestID = regionalRequest.RegionalRequestID,
                           //Round = regionalRequest.Round,
                           Month = transfer.CreatedDate.Month,
                           ProgramID = transfer.ProgramID,
                           CommodityID = transfer.CommodityID,
                           RequestedDate = transfer.CreatedDate,
                           //RationID = regionalRequest.RationID

                           RequisitionNo = Guid.NewGuid().ToString(),
                           RegionID = fdp.AdminUnit.AdminUnit2.AdminUnit2.AdminUnitID,
                           ZoneID = fdp.AdminUnit.AdminUnit2.AdminUnitID,
                           Status = (int) ReliefRequisitionStatus.Draft,

                       };
                   _unitOfWork.ReliefRequisitionRepository.Add(relifRequisition);

                   var relifRequistionDetail = new ReliefRequisitionDetail();

                   relifRequistionDetail.DonorID = 1;

                   relifRequistionDetail.FDPID = fdp.FDPID;

                   relifRequistionDetail.BenficiaryNo = 0; //since there is no need of benficiaryNo on transfer
                   relifRequistionDetail.CommodityID = transfer.CommodityID;
                   relifRequistionDetail.Amount = transfer.Quantity;
                   relifRequisition.ReliefRequisitionDetails.Add(relifRequistionDetail);

                   // save hub allocation
                   var hubAllocation = new HubAllocation
                       {
                           AllocatedBy = 1,
                           RequisitionID = relifRequisition.RequisitionID,
                           AllocationDate = transfer.CreatedDate,
                           ReferenceNo = "001",
                           HubID = transfer.SourceHubID
                       };
                   _unitOfWork.HubAllocationRepository.Add(hubAllocation);
                   //relifRequisition.RequisitionNo = String.Format("REQ-{0}", relifRequisition.RequisitionID);
                   relifRequisition.RequisitionNo = transfer.ReferenceNumber;
                   relifRequisition.Status = (int)ReliefRequisitionStatus.HubAssigned;
                   if(transfer.Commodity.ParentID==null)
                   {
                       availableSINumbers = GetFreeSICodesByCommodity(transfer.SourceHubID, transfer.CommodityID);
                   }
                   else
                   {
                       availableSINumbers = GetFreeSICodesByCommodityChild(transfer.SourceHubID, transfer.CommodityID);
                   }

                   var siNumberExist = availableSINumbers.Any(availableShippingCode => availableShippingCode.siCodeId == transfer.ShippingInstructionID);

                   if (!siNumberExist)
                   {
                       return false;
                   }
                   _unitOfWork.Save();

                   SIPCAllocation allocation = new SIPCAllocation
                   {
                       Code = transfer.ShippingInstructionID,
                       AllocatedAmount = transfer.Quantity,
                       AllocationType = "SI",
                       RequisitionDetailID = relifRequistionDetail.RequisitionDetailID
                   };
                   _unitOfWork.SIPCAllocationRepository.Add(allocation);

                   relifRequisition.Status = (int) ReliefRequisitionStatus.ProjectCodeAssigned;
                   relifRequisition.RequisitionNo = String.Format("REQ-{0}", relifRequisition.RequisitionID);
                   _unitOfWork.Save();
                   if (!PostSIAllocation(relifRequisition.RequisitionID,transfer.CommoditySourceID))
                   {
                       return false;
                   }
                   return true;

               }
               }
               return false;
        }