예제 #1
0
 public bool DeleteTransporterCheque(TransporterCheque transporterCheque)
 {
     if (transporterCheque == null) return false;
     _unitOfWork.TransporterChequeRepository.Delete(transporterCheque);
     _unitOfWork.Save();
     return true;
 }
예제 #2
0
        private TransporterChequeViewModel BindTransporterChequeViewModel(TransporterCheque transporterCheque)
        {
            TransporterChequeViewModel transporterChequeViewModel = null;
            if (transporterCheque != null)
            {
                var transporterChequeDetailObj = transporterCheque.TransporterChequeDetails.FirstOrDefault();
                if (transporterChequeDetailObj != null)
                {
                    var transporterObj = transporterChequeDetailObj.TransporterPaymentRequest.TransportOrder.Transporter;

                    transporterChequeViewModel = new TransporterChequeViewModel
                                                     {
                                                         TransporterChequeId = transporterCheque.TransporterChequeId,
                                                         CheckNo = transporterCheque.CheckNo,
                                                         PaymentVoucherNo = transporterCheque.PaymentVoucherNo,
                                                         BankName = transporterCheque.BankName,
                                                         PaymentDate = transporterCheque.PaymentDate,
                                                         Amount = transporterCheque.Amount,
                                                         TransporterId = transporterObj.TransporterID,
                                                         Transporter = _transporterService.FindById(transporterObj.TransporterID).Name,
                                                         PreparedBy =
                                                             _userProfileService.FindById(
                                                                 (int) transporterCheque.PreparedBy).FirstName + " " +
                                                             _userProfileService.FindById(
                                                                 (int) transporterCheque.PreparedBy).LastName,
                                                         AppovedBy = transporterCheque.AppovedBy != null
                                                                         ? _userProfileService.FindById(
                                                                             (int) transporterCheque.AppovedBy).
                                                                               FirstName + " " +
                                                                           _userProfileService.FindById(
                                                                               (int) transporterCheque.AppovedBy).
                                                                               LastName
                                                                         : string.Empty,
                                                         AppovedDate = transporterCheque.AppovedDate,
                                                         Status = (int) transporterCheque.Status
                                                     };
                }
            }
            return transporterChequeViewModel;
        }
예제 #3
0
 public bool EditTransporterCheque(TransporterCheque transporterCheque)
 {
     _unitOfWork.TransporterChequeRepository.Edit(transporterCheque);
     _unitOfWork.Save();
     return true;
 }
        public ActionResult EditCollectiveChequeInfo(Models.TransporterChequeViewModel transporterChequeViewModel, int transporterID)
        {
            var paymentRequestList = (IEnumerable<Cats.Models.TransporterPaymentRequest>)_transporterPaymentRequestService
                        .Get(t => t.BusinessProcess.CurrentState.BaseStateTemplate.StateNo == 3, null, "BusinessProcess")
                        .OrderByDescending(t => t.TransporterPaymentRequestID);
            //var transporterChequeObj = _transporterChequeService.Get(t => t.TransporterChequeId == transporterChequeViewModel.TransporterChequeId).FirstOrDefault();
            if (paymentRequestList.Any())
            {
                var transporterChequeDetails = new List<TransporterChequeDetail>();
                foreach(var paymentRequest in paymentRequestList)
                {
                    var transporterChequeDetail = new TransporterChequeDetail
                                                      {
                                                          TransporterPaymentRequestID = paymentRequest.TransporterPaymentRequestID
                                                      };
                    transporterChequeDetails.Add(transporterChequeDetail);
                }
                var user = UserAccountHelper.GetUser(User.Identity.Name);
                var transporterChequeObj = new TransporterCheque()
                                                {
                                                    CheckNo = transporterChequeViewModel.CheckNo,
                                                    PaymentVoucherNo = transporterChequeViewModel.PaymentVoucherNo,
                                                    BankName = transporterChequeViewModel.BankName,
                                                    Amount = transporterChequeViewModel.Amount,
                                                    PreparedBy = user.UserProfileID,
                                                    Status = 1,
                                                    TransporterChequeDetails = transporterChequeDetails
                                                };

                int BP_PR = _applicationSettingService.getTransporterChequeWorkflow();
                if (BP_PR != 0)
                {
                    BusinessProcessState createdstate = new BusinessProcessState
                    {
                        DatePerformed = DateTime.Now,
                        PerformedBy = "System",
                        Comment = "Created workflow for Transporter Cheque"

                    };
                    //_PaymentRequestservice.Create(request);

                    BusinessProcess bp = _businessProcessService.CreateBusinessProcess(BP_PR, transporterChequeObj.TransporterChequeId,
                                                                                        "ValidatedPaymentRequest", createdstate);
                    transporterChequeObj.BusinessProcessID = bp.BusinessProcessID;
                    transporterChequeObj.IssueDate = DateTime.Now;
                    _transporterChequeService.AddTransporterCheque(transporterChequeObj);
                    foreach (var paymentRequest in paymentRequestList)
                    {
                        var currFlowTemplate = paymentRequest.BusinessProcess.CurrentState.BaseStateTemplate.InitialStateFlowTemplates.FirstOrDefault();
                        if (currFlowTemplate != null)
                        {
                            var state = new BusinessProcessState()
                                            {
                                                StateID = currFlowTemplate.FinalStateID,
                                                PerformedBy = user.FullName,
                                                Comment = "Finance: Batch generated cheque for the payment request",
                                                DatePerformed = DateTime.Now,
                                                ParentBusinessProcessID = paymentRequest.BusinessProcess.CurrentState.ParentBusinessProcessID
                                            };
                            var item = _businessProcessService.FindById(state.ParentBusinessProcessID);
                            _businessProcessStateService.Add(state);
                            item.CurrentStateID = state.BusinessProcessStateID;
                            _businessProcessService.Update(item);
                        }
                    }
                }
            }
            return RedirectToAction("Cheques", "Cheque", new { Area = "Finance", transporterID });
        }
 public ActionResult EditChequeInfo(Models.TransporterChequeViewModel transporterChequeViewModel)
 {
     var paymentRequestObj = _paymentRequestservice.FindById(transporterChequeViewModel.PaymentRequestID);
     var transporterChequeObj = _transporterChequeService.Get(t => t.PaymentRequestID == transporterChequeViewModel.PaymentRequestID).FirstOrDefault();
     var user = UserAccountHelper.GetUser(User.Identity.Name);
     if(paymentRequestObj != null)
     {
         if(transporterChequeObj != null)
         {
             transporterChequeObj.CheckNo = transporterChequeViewModel.CheckNo;
             transporterChequeObj.PaymentVoucherNo = transporterChequeViewModel.PaymentVoucherNo;
             transporterChequeObj.BankName = transporterChequeViewModel.BankName;
             transporterChequeObj.Amount = transporterChequeViewModel.Amount;
             //transporterChequeObj.PreparedBy = user.UserProfileID;
             //transporterChequeObj.AppovedBy = transporterChequeViewModel.AppovedByID;
             //transporterChequeObj.AppovedDate = transporterChequeViewModel.AppovedDate;
             _transporterChequeService.EditTransporterCheque(transporterChequeObj);
         }
         else
         {
             transporterChequeObj = new TransporterCheque()
                                            {
                                                TransporterChequeId = Guid.NewGuid(),
                                                PaymentRequestID = transporterChequeViewModel.PaymentRequestID,
                                                CheckNo = transporterChequeViewModel.CheckNo,
                                                PaymentVoucherNo = transporterChequeViewModel.PaymentVoucherNo,
                                                BankName = transporterChequeViewModel.BankName,
                                                Amount = transporterChequeViewModel.Amount,
                                                PreparedBy = user.UserProfileID,
                                                Status = 1
                                                //AppovedBy = transporterChequeViewModel.AppovedByID,
                                                //AppovedDate = transporterChequeViewModel.AppovedDate,
                                            };
             _transporterChequeService.AddTransporterCheque(transporterChequeObj);
         }
     }
     return Json(BindTransporterChequeViewModel(transporterChequeObj), JsonRequestBehavior.AllowGet);
 }
 private TransporterChequeViewModel BindTransporterChequeViewModel(TransporterCheque transporterCheque)
 {
     TransporterChequeViewModel transporterChequeViewModel = null;
     if (transporterCheque != null)
     {
         transporterChequeViewModel = new TransporterChequeViewModel
         {
             TransporterChequeId = transporterCheque.TransporterChequeId,
             PaymentRequestID = transporterCheque.PaymentRequestID,
             CheckNo = transporterCheque.CheckNo,
             PaymentVoucherNo = transporterCheque.PaymentVoucherNo,
             BankName = transporterCheque.BankName,
             Amount = transporterCheque.Amount,
             TransporterId = _paymentRequestservice.FindById(transporterCheque.PaymentRequestID).TransportOrder.TransporterID,
             PreparedBy = _userProfileService.FindById((int)transporterCheque.PreparedBy).FirstName + " " +
                 _userProfileService.FindById((int)transporterCheque.PreparedBy).LastName,
             AppovedBy = transporterCheque.AppovedBy != null ?
                 _userProfileService.FindById((int)transporterCheque.AppovedBy).FirstName + " " +
                 _userProfileService.FindById((int)transporterCheque.AppovedBy).LastName : string.Empty,
             AppovedDate = transporterCheque.AppovedDate,
             Status = (int) transporterCheque.Status
         };
     }
     return transporterChequeViewModel;
 }