public ActionResult MBHeader()
        {
            Models.MasterBudgetHeader mbh        = new Models.MasterBudgetHeader();
            List <Currency>           currencies = projectService.GetCurrencies(countryProg.Id);
            List <MBCategory>         mbcList    = masterBudgetService.GenerateMasterBudget(mbCurrency, countryProg);

            ComputeTotals(mbcList);
            ViewBag.Currency           = mbCurrency.ShortName;
            ViewBag.CurrencyId         = mbCurrency.Id;
            ViewBag.CountryProgrammeId = countryProg.Id;
            ViewBag.CPName             = countryProg.ProgrammeName;
            mbh.MBCList    = mbcList;
            mbh.Currencies = new SelectList(currencies, "Id", "Name", mbCurrency.Id);
            return(View("MasterBudgetHeader", mbh));
        }
Exemple #2
0
        public ActionResult MasterBudget()
        {
            List <MBCategory> mbcList = masterBudgetService.GenerateMasterBudget(mbCurrency, countryProg);

            ViewBag.Currency   = mbCurrency.ShortName;
            ViewBag.CurrencyId = mbCurrency.Id;
            ComputeTotals(mbcList);
            return(View("DashboardMasterBudget", mbcList));
        }
Exemple #3
0
        public ActionResult Summary(Guid currencyId, Guid countryProgrammeId)
        {
            Dictionary <String, String> data = new Dictionary <string, string>();

            Currency currency = currencyService.GetCurrency(currencyId);

            data.Add("{CURRENCY}", currency.Name);

            CountryProgramme cp = countryProgrammeSvc.GetCountryProgrammeById(countryProgrammeId);

            List <MBCategory> mbcList = mbService.GenerateMasterBudget(currency, cp);

            this.ComputeTotals(mbcList);

            decimal totalCommitted = 0;

            if (mbcList[mbcList.Count - 1].TotalCommitted.HasValue)
            {
                totalCommitted = (decimal)mbcList[mbcList.Count - 1].TotalCommitted;
            }

            decimal totalPosted = 0;

            if (mbcList[mbcList.Count - 1].TotalPosted.HasValue)
            {
                totalPosted = (decimal)mbcList[mbcList.Count - 1].TotalPosted;
            }

            decimal remBal = 0;

            if (mbcList[mbcList.Count - 1].RemainingBalance.HasValue)
            {
                remBal = (decimal)mbcList[mbcList.Count - 1].RemainingBalance;
            }

            float pctSpent = 0;

            if (mbcList[mbcList.Count - 1].PercentageSpent.HasValue)
            {
                pctSpent = (float)mbcList[mbcList.Count - 1].PercentageSpent;
            }

            decimal costP = 0;

            if (mbcList[mbcList.Count - 1].CostProjection.HasValue)
            {
                costP = (decimal)mbcList[mbcList.Count - 1].CostProjection;
            }


            decimal surplus = 0;
            string  style   = " style='color:red;' ";

            if (mbcList[mbcList.Count - 1].Surplus.HasValue)
            {
                surplus = (decimal)mbcList[mbcList.Count - 1].Surplus;
            }

            if (surplus > 0)
            {
                style = "";
            }

            data.Add("{TOTAL_BUDGET}", mbcList[mbcList.Count - 1].TotalBudget.ToString("###,###.00"));
            data.Add("{TOTAL_COMMITTED}", totalCommitted.ToString("###,###.00"));
            data.Add("{TOTAL_POSTED}", totalPosted.ToString("###,###.00"));
            data.Add("{REMAINING_FUNDS}", remBal.ToString("###,###.00"));
            data.Add("{%_ACTUAL_SPENT}", pctSpent.ToString("0.00"));
            data.Add("{FUNDS_AVAILABLE}", remBal.ToString("###,###.00"));
            data.Add("{EXPENDITURE_PROJECTION}", costP.ToString("###,###.00"));
            data.Add("{SHORTFALL_SURPLUS}", "<span" + style + ">" + surplus.ToString("###,###.00") + "</span>");

            string tbody = "";

            for (int i = 0; i < mbcList.Count - 1; i++)
            {
                tbody += "<tr><td>";
                tbody += mbcList[i].EntityBudgetCategory.Description + "</td><td>";
                tbody += mbcList[i].Projects[0].EntityProjectDonor.ProjectNumber + "</td><td>";
                tbody += mbcList[i].Projects[0].EntityProjectDonor.Donor.ShortName + "</td><td>";
                tbody += mbcList[i].Projects[0].TotalBudget.ToString("###,###.00") + "</td><td>";
                tbody += ND2S(mbcList[i].Projects[0].TotalCommitted) + "</td><td>";
                tbody += ND2S(mbcList[i].Projects[0].TotalPosted) + "</td><td>";
                tbody += ND2S(mbcList[i].Projects[0].RemainingBalance) + "</td><td>";
                tbody += FD2S(mbcList[i].Projects[0].PercentageSpent) + "</td><td>";
                tbody += ND2S(mbcList[i].CostProjection) + "</td><td>";
                tbody += "</tr>";
            }

            data.Add("{DETAIL}", tbody);

            List <String> options = new List <string>();

            options.Add(" --orientation Landscape ");

            Byte[] output = WkHtml2Pdf.CreateReport(data, "master-budget.html", options);

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