Ejemplo n.º 1
0
 public bool DeleteTransfer(Transfer transfer)
 {
     if(transfer==null) return false;
        _unitOfWork.TransferRepository.Delete(transfer);
        _unitOfWork.Save();
        return true;
 }
Ejemplo n.º 2
0
        public bool Approve(Transfer transfer)
        {
            if (transfer!=null)
               {
                   transfer.StatusID = (int) LocalPurchaseStatus.Approved;
                   _unitOfWork.TransferRepository.Edit(transfer);
                   var reciptAllocaltion = new ReceiptAllocation()
                   {
                       ReceiptAllocationID = Guid.NewGuid(),
                       ProgramID = transfer.ProgramID,
                       CommodityID = transfer.CommodityID,
                       ETA = transfer.CreatedDate,
                       SINumber = transfer.ShippingInstruction.Value,
                       QuantityInMT = transfer.Quantity,
                       HubID = transfer.DestinationHubID,
                       CommoditySourceID = transfer.CommoditySourceID,
                       ProjectNumber = transfer.ProjectCode,
                       SourceHubID = transfer.SourceHubID,
                       PartitionID = 0,
                       IsCommited = false
                   };
                   _unitOfWork.ReceiptAllocationReository.Add(reciptAllocaltion);
                   _unitOfWork.Save();
                   return true;

               }
               return false;
        }
Ejemplo n.º 3
0
        private Transfer GetTransfer(TransferViewModel transferViewModel)
        {
            var transfer = new Transfer()
                {
                  ShippingInstructionID=_commonService.GetShippingInstruction(transferViewModel.SiNumber),
                  SourceHubID=transferViewModel.SourceHubID,
                  ProgramID=transferViewModel.ProgramID,
                  CommoditySourceID=5,
                  CommodityID =transferViewModel.CommodityID,
                  DestinationHubID =transferViewModel.DestinationHubID,
                  ProjectCode=transferViewModel.ProjectCode,
                  Quantity=transferViewModel.Quantity,
                  CreatedDate=DateTime.Today,
                  ReferenceNumber=transferViewModel.ReferenceNumber,
                  StatusID=(int)LocalPurchaseStatus.Draft

                };
            return transfer;
        }
Ejemplo n.º 4
0
 public ActionResult Edit(Transfer transfer)
 {
     if(ModelState.IsValid && transfer!=null)
        {
        transfer.CommoditySourceID = 5;//Commodity Source for transfer
        _transferService.EditTransfer(transfer);
        return RedirectToAction("detail", new {id = transfer.TransferID});
        }
        ViewBag.ProgramID = new SelectList(_commonService.GetPrograms(), "ProgramID", "Name", transfer.ProgramID);
        ViewBag.SourceHubID = new SelectList(_commonService.GetAllHubs(), "HubID", "Name", transfer.SourceHubID);
        ViewBag.CommodityID = new SelectList(_commonService.GetCommodities(), "CommodityID", "Name", transfer.CommodityID);
        ViewBag.CommodityTypeID = new SelectList(_commonService.GetCommodityTypes(), "CommodityTypeID", "Name");
        ViewBag.DestinationHubID = new SelectList(_commonService.GetAllHubs(), "HubID", "Name", transfer.DestinationHubID);
        ViewBag.CommoditySourceID = new SelectList(_commonService.GetCommoditySource(), "CommoditySourceID", "Name", transfer.CommoditySourceID);
        return View(transfer);
 }
Ejemplo n.º 5
0
 public bool EditTransfer(Transfer transfer)
 {
     _unitOfWork.TransferRepository.Edit(transfer);
        _unitOfWork.Save();
        return true;
 }
Ejemplo n.º 6
0
 public bool AddTransfer(Transfer transfer)
 {
     _unitOfWork.TransferRepository.Add(transfer);
        _unitOfWork.Save();
        return true;
 }
Ejemplo n.º 7
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;
        }