Esempio n. 1
0
        public ActionResult EditChequeInfo(Models.TransporterChequeViewModel transporterChequeViewModel, int transporterID)
        {
            var transporterChequeObj = _transporterChequeService.FindById(transporterChequeViewModel.TransporterChequeId);

            transporterChequeObj.CheckNo          = transporterChequeViewModel.CheckNo;
            transporterChequeObj.PaymentVoucherNo = transporterChequeViewModel.PaymentVoucherNo;
            transporterChequeObj.BankName         = transporterChequeViewModel.BankName;
            _transporterChequeService.EditTransporterCheque(transporterChequeObj);
            return(RedirectToAction("Cheques", "Cheque", new { Area = "Finance", transporterID }));
        }
        public ActionResult LoadCheque(int transporterId, string refNo)
        {
            var user = UserAccountHelper.GetUser(User.Identity.Name);
            var approvedPaymentRequests = _transporterPaymentRequestService.Get(t => t.BusinessProcess.CurrentState.BaseStateTemplate.StateNo == 3 && t.TransportOrder.TransporterID == transporterId);

            if (refNo != "")
            {
                approvedPaymentRequests = _transporterPaymentRequestService.Get(t => t.BusinessProcess.CurrentState.BaseStateTemplate.StateNo == 3 && t.TransportOrder.TransporterID == transporterId && t.ReferenceNo == refNo);
            }


            //var transporterChequeObj = _transporterChequeService.Get(t => t.TransporterPaymentRequestID == paymentRequestID, null, "UserProfile").FirstOrDefault();
            var transporterChequeViewModel = new Models.TransporterChequeViewModel();

            foreach (var approvedPaymentRequest in approvedPaymentRequests)
            {
                var request  = approvedPaymentRequest;
                var dispatch = _dispatchService.Get(t => t.DispatchID == request.Delivery.DispatchID, null, "Hub, FDP").FirstOrDefault();
                var bidId    = _bidWinnerService.FindBy(b => b.Bid.BidNumber == dispatch.BidNumber).Select(d => d.BidID).FirstOrDefault();

                var firstOrDefault = _transportOrderDetailService.Get(t => t.SourceWarehouseID == dispatch.HubID && t.FdpID == dispatch.FDPID &&
                                                                      t.TransportOrder.TransporterID == request.TransportOrder.TransporterID && t.BidID == bidId).FirstOrDefault();
                //var firstOrDefault = _bidWinnerService.Get(t => t.SourceID == dispatch.HubID && t.DestinationID == dispatch.FDPID
                //    && t.TransporterID == request.TransportOrder.TransporterID && t.Bid.BidNumber == dispatch.BidNumber).FirstOrDefault();
                var tarrif         = (decimal)0.00;
                var deliveryDetail = request.Delivery.DeliveryDetails.FirstOrDefault() ?? new DeliveryDetail();
                if (request.LabourCost == null)
                {
                    request.LabourCost = (decimal)0.00;
                }
                if (request.RejectedAmount == null)
                {
                    request.RejectedAmount = (decimal)0.00;
                }
                if (firstOrDefault != null)
                {
                    tarrif = (decimal)firstOrDefault.TariffPerQtl;
                }
                transporterChequeViewModel.Transporter         = request.TransportOrder.Transporter.Name;
                transporterChequeViewModel.PaymentRequestsList = transporterChequeViewModel.PaymentRequestsList + " [" + approvedPaymentRequest.ReferenceNo + "] ";
                transporterChequeViewModel.Amount = transporterChequeViewModel.Amount +
                                                    (decimal)
                                                    (approvedPaymentRequest.ShortageBirr != null
                                                         ? (deliveryDetail.ReceivedQuantity.ToQuintal() * tarrif)
                                                     - approvedPaymentRequest.ShortageBirr + approvedPaymentRequest.LabourCost -
                                                     approvedPaymentRequest.RejectedAmount
                                                         : (deliveryDetail.ReceivedQuantity.ToQuintal() * tarrif) +
                                                     approvedPaymentRequest.LabourCost - approvedPaymentRequest.RejectedAmount);
            }
            transporterChequeViewModel.PreparedByID = user.UserProfileID;
            transporterChequeViewModel.PreparedBy   = user.FullName;
            return(Json(transporterChequeViewModel, JsonRequestBehavior.AllowGet));
        }
Esempio n. 3
0
        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 LoadCheque()
 {
     var user = UserAccountHelper.GetUser(User.Identity.Name);
     var approvedPaymentRequests = _transporterPaymentRequestService.Get(t => t.BusinessProcess.CurrentState.BaseStateTemplate.StateNo == 3);
     //var transporterChequeObj = _transporterChequeService.Get(t => t.TransporterPaymentRequestID == paymentRequestID, null, "UserProfile").FirstOrDefault();
     var transporterChequeViewModel = new Models.TransporterChequeViewModel();
     foreach (var approvedPaymentRequest in approvedPaymentRequests)
     {
         var request = approvedPaymentRequest;
         var dispatch = _dispatchService.Get(t => t.DispatchID == request.Delivery.DispatchID, null, "Hub, FDP").FirstOrDefault();
         var firstOrDefault = _bidWinnerService.Get(t => t.SourceID == dispatch.HubID && t.DestinationID == dispatch.FDPID
             && t.TransporterID == request.TransportOrder.TransporterID && t.Bid.BidNumber == dispatch.BidNumber).FirstOrDefault();
         var tarrif = (decimal)0.00;
         var deliveryDetail = request.Delivery.DeliveryDetails.FirstOrDefault() ?? new DeliveryDetail();
         if (request.LabourCost == null)
             request.LabourCost = (decimal)0.00;
         if (request.RejectedAmount == null)
             request.RejectedAmount = (decimal)0.00;
         if (firstOrDefault != null)
         {
             tarrif = firstOrDefault.Tariff != null ? (decimal)firstOrDefault.Tariff : (decimal)0.00;
         }
         transporterChequeViewModel.Transporter = request.TransportOrder.Transporter.Name;
         transporterChequeViewModel.PaymentRequestsList = transporterChequeViewModel.PaymentRequestsList + " [" + approvedPaymentRequest.ReferenceNo + "] ";
         transporterChequeViewModel.Amount = transporterChequeViewModel.Amount +
                                             (decimal)
                                             (approvedPaymentRequest.ShortageBirr != null
                                                  ? (deliveryDetail.ReceivedQuantity*tarrif)
                                                    - approvedPaymentRequest.ShortageBirr + approvedPaymentRequest.LabourCost -
                                                    approvedPaymentRequest.RejectedAmount
                                                  : (deliveryDetail.ReceivedQuantity*tarrif) +
                                                    approvedPaymentRequest.LabourCost - approvedPaymentRequest.RejectedAmount);
     }
     transporterChequeViewModel.PreparedByID = user.UserProfileID;
     transporterChequeViewModel.PreparedBy = user.FullName;
     return Json(transporterChequeViewModel, JsonRequestBehavior.AllowGet);
 }
        public ActionResult LoadCheque(int paymentRequestID)
        {
            var user = UserAccountHelper.GetUser(User.Identity.Name);
            var paymentRequestObj = _paymentRequestservice.FindById(paymentRequestID);
            var transporterChequeObj = _transporterChequeService.Get(t => t.PaymentRequestID == paymentRequestID, null, "UserProfile").FirstOrDefault();
            var transporterChequeViewModel = new Models.TransporterChequeViewModel();
            if (paymentRequestObj != null)
            {
                if (transporterChequeObj != null)
                {
                    transporterChequeViewModel.TransporterChequeId = transporterChequeObj.TransporterChequeId;
                    transporterChequeViewModel.PaymentRequestID = transporterChequeObj.PaymentRequestID;
                    transporterChequeViewModel.PaymentRequestRefNo = transporterChequeObj.PaymentRequest.ReferenceNo;
                    transporterChequeViewModel.CheckNo = transporterChequeObj.CheckNo;
                    transporterChequeViewModel.PaymentVoucherNo = transporterChequeObj.PaymentVoucherNo;
                    transporterChequeViewModel.BankName = transporterChequeObj.BankName;
                    transporterChequeViewModel.Amount = transporterChequeObj.Amount;
                    transporterChequeViewModel.TransporterId = paymentRequestObj.TransportOrder.Transporter.TransporterID;
                    transporterChequeViewModel.Transporter = paymentRequestObj.TransportOrder.Transporter.Name;

                    transporterChequeViewModel.PreparedByID = transporterChequeObj.PreparedBy;
                    transporterChequeViewModel.PreparedBy = _userProfileService.FindById((int)transporterChequeObj.PreparedBy).FirstName + " " +
                                                            _userProfileService.FindById((int)transporterChequeObj.PreparedBy).LastName;
                    transporterChequeViewModel.AppovedByID = transporterChequeObj.AppovedBy??0;
                    transporterChequeViewModel.AppovedBy = transporterChequeObj.AppovedBy != null ?
                        _userProfileService.FindById((int)transporterChequeObj.AppovedBy).FirstName + " " +
                        _userProfileService.FindById((int)transporterChequeObj.AppovedBy).LastName : null;
                    transporterChequeViewModel.AppovedDate = transporterChequeObj.AppovedDate;
                    transporterChequeViewModel.Status = (int) transporterChequeObj.Status;
                }
                else
                {
                    transporterChequeViewModel.PaymentRequestID = paymentRequestID;
                    transporterChequeViewModel.PaymentRequestRefNo = paymentRequestObj.ReferenceNo;
                    transporterChequeViewModel.PreparedBy = user.FirstName + " " + user.LastName;
                    transporterChequeViewModel.PreparedByID = user.UserProfileID;
                    if (paymentRequestObj.LabourCost != null && paymentRequestObj.RejectedAmount!=null)
                    {
                        transporterChequeViewModel.Amount = (decimal) (paymentRequestObj.RequestedAmount + paymentRequestObj.LabourCost -
                                                                      paymentRequestObj.RejectedAmount);
                    }

                    //transporterChequeViewModel.AppovedDate = "MM/DD/YYYY";
                    //transporterChequeViewModel.AppovedDate = DateTime.Parse("mm-dd-yyyy");
                }
            }
            return Json(transporterChequeViewModel, JsonRequestBehavior.AllowGet);
        }