Exemplo n.º 1
0
        private List <Models.R4PpaymentDetails> paymentD(Guid id, Models.Request4Payment model)
        {
            Models.R4PpaymentDetails        pd;
            List <Models.R4PpaymentDetails> pdList = new List <R4PpaymentDetails>();

            using (var context = new SCMSEntities())
            {
                Model.PurchaseOrder po = context.PurchaseOrders.SingleOrDefault(p => p.Id == id);
                bool poHasRFP          = R4PSevice.PurchaseOrderHasRFP(po.Id);
                ICollection <PurchaseOrderItem> poitem = po.PurchaseOrderItems;
                foreach (PurchaseOrderItem item in poitem)
                {
                    if (item.BudgetCommitments.Count < 1)
                    {
                        continue;
                    }
                    var pb = context.ProjectBudgets.SingleOrDefault(p => p.Id == item.BudgetLineId);
                    pd = new R4PpaymentDetails();
                    //var commitAmt = exchangeRateService.GetForeignCurrencyValue(po.Currency, pb.BudgetCategory.ProjectDonor.Currency, itemBLCommit.AmountCommitted, countryProg.Id);
                    if (!poHasRFP)
                    {
                        pd.Amount = Math.Round(item.TotalPrice, 2);
                    }
                    else
                    {
                        pd.Amount = Math.Round(R4PSevice.GetPOItemRemainingBalance(item.Id), 2);
                    }
                    pd.BudgetLineId          = (Guid)item.BudgetLineId;
                    pd.BudgetLine            = pb.LineNumber;
                    pd.BudgetLineDescription = pb.Description;
                    pd.PorjectNoId           = (Guid)item.PurchaseOrder.ProjectDonorId;          //.ProjectNoId;
                    pd.PoItemId  = item.Id;
                    pd.projectNo = item.ProjectBudget.BudgetCategory.ProjectDonor.ProjectNumber; // context.ProjectDonors.SingleOrDefault(p => p.Id == item.ProjectNoId).ProjectNumber;
                    pdList.Add(pd);
                }
                model.EntityPaymentRqst.CurrencyId = po.CurrencyId;
                model.EntityPaymentRqst.SupplierId = po.SupplierId;
            }
            return(pdList);
        }
Exemplo n.º 2
0
        public ActionResult ViewR4PDetails(Guid id, bool checkPost = false)
        {
            using (var context = new SCMSEntities())
            {
                PaymentRequest PR = context.PaymentRequests.SingleOrDefault(p => p.Id == id);

                List <R4PpaymentDetails>        pdlist      = new List <R4PpaymentDetails>();
                List <PaymentRequestBudgetLine> ARBlineList = context.PaymentRequestBudgetLines.Where(p => p.PaymentRequestId == PR.Id).ToList();
                foreach (PaymentRequestBudgetLine item in ARBlineList)
                {
                    var pb      = context.ProjectBudgets.SingleOrDefault(p => p.Id == item.BudgetLineId);
                    var pdatils = new R4PpaymentDetails()
                    {
                        BudgetLine            = pb.LineNumber,
                        BudgetLineDescription = pb.Description,
                        projectNo             = context.ProjectDonors.SingleOrDefault(p => p.Id == item.ProjectBudget.BudgetCategory.ProjectDonorId).ProjectNumber,
                        Amount = (decimal)item.Amount
                    };
                    pdlist.Add(pdatils);
                }
                Currency      c     = PR.Currency;
                PaymentType   pt    = PR.PaymentType;
                Supplier      sup   = PR.Supplier;
                Staff         st    = PR.Staff1;
                Person        psn   = st.Person;
                Designation   d     = st.Designation;
                PaymentTerm   pterm = PR.PaymentTerm;
                PurchaseOrder po    = PR.PurchaseOrder;
                var           model = new ViewR4Payment()
                {
                    EntityPaymentRqst = PR,
                    paymentDetais     = pdlist
                };
                var mbcurr = model.EntityPaymentRqst.Currency1;
                if (model.EntityPaymentRqst.MBValue != null)
                {
                    ViewBag.MBValue = ((decimal)model.EntityPaymentRqst.MBValue).ToString("#,##0.00");
                }
                //Reviewer and Authorizer Details
                if (model.EntityPaymentRqst.ReviewedBy != null)
                {
                    Staff reviewer = staffService.GetStaffById((Guid)model.EntityPaymentRqst.ReviewedBy);
                    ViewBag.Reviewer      = reviewer.Person.FirstName + " " + reviewer.Person.OtherNames;
                    ViewBag.ReviewerTitle = reviewer.Designation.Name;
                    ViewBag.ReviewedOn    = model.EntityPaymentRqst.ReviewedOn;
                    if (reviewer.Person.SignatureImage != null)
                    {
                        ViewBag.ReviewerSignature = "<img src=\"/Person/Photo/" + reviewer.Person.Id + "\" style=\"max-width: 150px;\" />";
                    }
                }

                if (model.EntityPaymentRqst.AuthorizedBy != null)
                {
                    Staff authorizer = staffService.GetStaffById((Guid)model.EntityPaymentRqst.AuthorizedBy);
                    ViewBag.Authorizer      = authorizer.Person.FirstName + " " + authorizer.Person.OtherNames;
                    ViewBag.AuthorizerTitle = authorizer.Designation.Name;
                    ViewBag.AuthorizedOn    = model.EntityPaymentRqst.AuthorizedOn;
                    if (authorizer.Person.SignatureImage != null)
                    {
                        ViewBag.AuthorizerSignature = "<img src=\"/Person/Photo/" + authorizer.Person.Id + "\" style=\"max-width: 150px;\" />";
                    }
                }

                //Manage approval link
                string actionType = null;
                if (model.EntityPaymentRqst.IsReviewed == true && model.EntityPaymentRqst.IsAuthorized != true)
                {
                    actionType = NotificationHelper.authorizationCode;
                }
                else if (model.EntityPaymentRqst.IsSubmitted && model.EntityPaymentRqst.IsReviewed != true)
                {
                    actionType = NotificationHelper.reviewCode;
                }
                if (actionType != null)
                {
                    model.CanApprove = notificationService.CanApprove(currentUser, NotificationHelper.rfpCode, actionType, model.EntityPaymentRqst.Id);
                }
                else
                {
                    model.CanApprove = false;
                }

                //Manage Post Funds Button
                if (userContext.HasPermission(StandardPermissionProvider.RequestForPaymentPostFunds) && checkPost)
                {
                    foreach (var rfp in R4PSevice.GetPaymentRequestsForPosting(countryProg.Id, currentUser))
                    {
                        if (rfp.Id.Equals(model.EntityPaymentRqst.Id))
                        {
                            model.CanPostFunds = true;
                            break;
                        }
                    }
                }

                return(View(model));
            }
        }
Exemplo n.º 3
0
        public ActionResult Pdf(Guid RFPid)
        {
            Dictionary <String, String> data = new Dictionary <string, string>();

            using (var context = new SCMSEntities())
            {
                PaymentRequest PR = context.PaymentRequests.SingleOrDefault(p => p.Id == RFPid);

                List <R4PpaymentDetails>        pdlist      = new List <R4PpaymentDetails>();
                List <PaymentRequestBudgetLine> ARBlineList = context.PaymentRequestBudgetLines.Where(p => p.PaymentRequestId == PR.Id).ToList();
                foreach (PaymentRequestBudgetLine item in ARBlineList)
                {
                    var pb      = context.ProjectBudgets.SingleOrDefault(p => p.Id == item.BudgetLineId);
                    var pdatils = new R4PpaymentDetails()
                    {
                        BudgetLine            = pb.LineNumber,
                        BudgetLineDescription = pb.Description,
                        projectNo             = context.ProjectDonors.SingleOrDefault(p => p.Id == item.ProjectBudget.BudgetCategory.ProjectDonorId).ProjectNumber,
                        Amount = (decimal)item.Amount
                    };
                    pdlist.Add(pdatils);
                }
                Currency    c     = PR.Currency;
                PaymentType pt    = PR.PaymentType;
                Supplier    sup   = PR.Supplier;
                Staff       st    = PR.Staff1;
                Person      psn   = st.Person;
                Designation d     = st.Designation;
                PaymentTerm pterm = PR.PaymentTerm;

                data.Add("{VOUCHER_NO.}", PR.VoucherNumber);
                data.Add("{REQ_NO.}", PR.RefNumber);
                data.Add("{POSPMNO.}", PR.PurchaseOrder.RefNumber);
                data.Add("{DATE}", PR.PreparedOn.ToShortDateString());
                data.Add("{CURRENCY}", PR.Currency.ShortName);
                data.Add("{PAYMENT_TERMS}", PR.PaymentTerm.Code);
                data.Add("{PAYMENT_TYPE}", PR.PaymentType.Description);
                data.Add("{TOTAL_PAYMENT}", PR.TotalAmount.ToString("##,###.00"));

                data.Add("{SUBJECT}", PR.Subject);
                data.Add("{PAYMENT_TO}", PR.Supplier.Name);
                data.Add("{CHOICE_FP}", PR.RequestFor == "FullPayment" ? "\" checked=\"checked\"" : "");
                data.Add("{CHOICE_RI}", PR.RequestFor == "Rate_Instalment" ? "\" checked=\"checked\"" : "");
                data.Add("{CHOICE_AP}", PR.RequestFor == "Adv_Payment_percentage" ? "\" checked=\"checked\"" : "");
                data.Add("{CHOICE_AFP}", PR.RequestFor == "Adv_Final_Payment_percentage" ? "\" checked=\"checked\"" : "");

                String payHtml = "";
                int    t       = 1;
                foreach (R4PpaymentDetails pd in pdlist)
                {
                    payHtml += "<tr><td align=\"center\">" +
                               t + "</td><td>" +
                               pd.projectNo + "</td><td>" + pd.BudgetLine + " " +
                               pd.BudgetLineDescription + "</td><td align=\"right\">" +
                               pd.Amount.ToString("##,##0.00") + "</td><td align=\"center\">" +
                               PR.Currency.ShortName + "</td></tr>";
                    t++;
                }
                while (t < 11)
                {
                    payHtml += "<tr><td align=\"center\">" + t++ + "</td><td></td><td></td><td></td><td></td></tr>";
                }
                data.Add("{PAYMENT_DETAILS}", payHtml);

                data.Add("{REMARKS}", PR.Remarks);

                string masterBUdgetCurrency = "";

                if (PR.Currency1 != null)
                {
                    masterBUdgetCurrency = PR.Currency1.ShortName;
                }

                data.Add("{MB_CURRENCY}", masterBUdgetCurrency);
                string total = "";

                if (PR.MBValue != null)
                {
                    total = ((decimal)PR.MBValue).ToString("#,##0.00");
                }

                data.Add("{TOTAL}", total);


                data.Add("{PREPAROR_NAME}", PR.Staff1.Person.FirstName + " " + PR.Staff1.Person.OtherNames);
                data.Add("{PREPAROR_TITLE}", PR.Staff1.Designation.Name);
                data.Add("{PREPAROR_DATE}", PR.PreparedOn.ToString("dd/MM/yyyy"));
                data.Add("{PREPAROR_SIG}", this.signatureFilePath(PR.Staff1.Person.SignatureImage));


                String reviewerName      = "";
                String reviewerTitle     = "";
                String reviewedOn        = "";
                String reviewerSignature = "";

                if (PR.ReviewedOn.HasValue)
                {
                    reviewedOn = ((DateTime)PR.ReviewedOn).ToString("dd/MMM/yyyy");
                }

                if (PR.ReviewedBy != null)
                {
                    Staff reviewer = staffService.GetStaffById((Guid)PR.ReviewedBy);
                    reviewerName      = reviewer.Person.FirstName + " " + reviewer.Person.OtherNames;
                    reviewerTitle     = reviewer.Designation.Name;
                    reviewerSignature = this.signatureFilePath(reviewer.Person.SignatureImage);
                }

                data.Add("{REVIEWER_NAME}", reviewerName);
                data.Add("{REVIEWER_TITLE}", reviewerTitle);
                data.Add("{REVIEWER_DATE}", reviewedOn);
                data.Add("{REVIEWER_SIG}", reviewerSignature);


                String authorizerName      = "";
                String authorizerTitle     = "";
                String authorizedOn        = "";
                String authorizerSignature = "";

                if (PR.AuthorizedOn.HasValue)
                {
                    authorizedOn = ((DateTime)PR.AuthorizedOn).ToString("dd-MMM-yyyy");
                }

                if (PR.AuthorizedBy != null)
                {
                    Staff authorizer = staffService.GetStaffById((Guid)PR.AuthorizedBy);
                    authorizerName      = authorizer.Person.FirstName + " " + authorizer.Person.OtherNames;
                    authorizerTitle     = authorizer.Designation.Name;
                    authorizerSignature = this.signatureFilePath(authorizer.Person.SignatureImage);
                }

                data.Add("{AUTHORIZER_NAME}", authorizerName);
                data.Add("{AUTHORIZER_TITLE}", authorizerTitle);
                data.Add("{AUTHORIZER_DATE}", reviewedOn);
                data.Add("{AUTHORIZER_SIG}", authorizerSignature);
            }
            List <String> options = new List <string>();

            options.Add(" --copies 2 ");
            Byte[] output = WkHtml2Pdf.CreateReport(data, "request4payment.html", options);

            return(File(output, "application/pdf", "RRP_" + DateTime.Now.FormatDDMMMYYYYHHmm()));
        }