Exemplo n.º 1
0
 public MBCategory GetMasterBudgetTotals(CountryProgramme cp)
 {
     try
     {
         List <MBCategory> mbcList = GenerateMasterBudget(cp.Currency, cp);
         MBCategory        mbc     = new MBCategory();
         mbc.TotalBudget    = 0;
         mbc.TotalCommitted = mbc.TotalPosted = mbc.RemainingBalance = mbc.CostProjection = 0;
         foreach (MBCategory mbCat in mbcList)
         {
             mbc.TotalBudget      += mbCat.TotalBudget;
             mbc.TotalCommitted   += mbCat.TotalCommitted;
             mbc.TotalPosted      += mbCat.TotalPosted;
             mbc.RemainingBalance += mbCat.RemainingBalance;
             mbc.CostProjection   += mbCat.CostProjection;
         }
         mbc.PercentageSpent = (float?)(mbc.TotalPosted / mbc.TotalBudget) * 100;
         mbc.Surplus         = mbc.RemainingBalance - mbc.CostProjection;
         return(mbc);
     }
     catch (Exception ex)
     {
         return(null);
     }
 }
Exemplo n.º 2
0
 private void ConvertToPercent(MBCategory mbc, out float tb, out float tc, out float tp, out float fr)
 {
     tb = 100;
     tc = (float)(mbc.TotalCommitted / mbc.TotalBudget) * 100;
     tp = (float)(mbc.TotalPosted / mbc.TotalBudget) * 100;
     fr = (float)(mbc.RemainingBalance / mbc.TotalBudget) * 100;
 }
Exemplo n.º 3
0
        private void ComputeTotals(List <MBCategory> mbcList)
        {
            MBCategory mbc = new MBCategory();

            mbc.TotalBudget    = 0;
            mbc.TotalCommitted = mbc.TotalPosted = mbc.RemainingBalance = mbc.CostProjection = mbc.Surplus = 0;
            foreach (MBCategory mbCat in mbcList)
            {
                mbc.TotalBudget      += mbCat.TotalBudget;
                mbc.TotalCommitted   += mbCat.TotalCommitted;
                mbc.TotalPosted      += mbCat.TotalPosted;
                mbc.RemainingBalance += mbCat.RemainingBalance;
                mbc.CostProjection   += mbCat.CostProjection;
            }
            if (mbc.TotalBudget <= 0)
            {
                mbc.PercentageSpent = 0;
            }
            else
            {
                mbc.PercentageSpent = (float?)(mbc.TotalPosted / mbc.TotalBudget) * 100;
            }
            mbc.Surplus = mbc.RemainingBalance - mbc.CostProjection;
            mbcList.Add(mbc);
        }
Exemplo n.º 4
0
        public ActionResult GetORChart()
        {
            DataTable dd = new DataTable("Chart");

            dd.Columns.Add("Type", typeof(string));
            dd.Columns.Add(Resources.Global_String_Values, typeof(float));

            DataRow Row = null;

            MBCategory mbc = masterBudgetService.GetMasterBudgetTotals(countryProg);

            if (mbc != null)
            {
                float tb, tc, tp, fr;
                this.ConvertToPercent(mbc, out tb, out tc, out tp, out fr);

                Row = dd.NewRow();
                dd.Rows.Add(Row);
                Row[0] = Resources.Budget_ViewBudget_TotalBudget;
                Row[1] = mbc.TotalBudget;

                Row = dd.NewRow();
                dd.Rows.Add(Row);
                Row[0] = Resources.Budget_ViewBudget_TotalCommitted;
                Row[1] = mbc.TotalCommitted;

                Row = dd.NewRow();
                dd.Rows.Add(Row);
                Row[0] = Resources.Budget_ViewBudget_TotalPosted;
                Row[1] = mbc.TotalPosted;

                Row = dd.NewRow();
                dd.Rows.Add(Row);
                Row[0] = Resources.Budget_ViewBudget_FundsRemaining;
                Row[1] = mbc.RemainingBalance;



                //var myChart = new Chart(width: 375, height: 300, theme: ChartTheme.Green)
                //        .AddTitle(Resources.General_String_MasterBudget)

                //        .AddLegend(title: "Key", name: null)
                //        .DataBindTable(dd.AsDataView(), dd.Columns[0].ColumnName)
                //        .Write("png");
            }
            return(null);
        }
Exemplo n.º 5
0
        public List <MBCategory> GenerateMasterBudget(Currency currency, CountryProgramme cp)
        {
            List <MBCategory>          mbCategories = new List <MBCategory>();
            MBCategory                 mbc;
            List <MasterBudgetProject> mbpList;

            try
            {
                List <ProjectDonor>         projectDonors    = projectService.GetCurrentProjectDonors(cp);
                List <MasterBudgetCategory> budgetCategories = GetMasterBudgetCategories(cp);
                foreach (MasterBudgetCategory budgetCategory in budgetCategories)
                {
                    mbpList = InitMasterBudgetProjects(budgetCategory, projectDonors, currency);
                    if (mbpList.Count > 0)
                    {
                        mbc = new MBCategory();
                        mbc.EntityBudgetCategory = budgetCategory;
                        mbc.TotalBudget          = mbpList[0].TotalBudget;
                        mbc.TotalCommitted       = mbpList[0].TotalCommitted;
                        mbc.TotalPosted          = mbpList[0].TotalPosted;
                        for (int i = 1; i < mbpList.Count; i++)
                        {
                            mbc.TotalBudget    += mbpList[i].TotalBudget;
                            mbc.TotalCommitted += mbpList[i].TotalCommitted;
                            mbc.TotalPosted    += mbpList[i].TotalPosted;
                        }
                        mbc.RemainingBalance = mbc.TotalBudget - mbc.TotalCommitted - mbc.TotalPosted;
                        mbc.PercentageSpent  = (float?)(mbc.TotalPosted / mbc.TotalBudget) * 100;
                        mbc.CostProjection   = GetMBCategoryProjection(mbc.EntityBudgetCategory.Id, cp.Id, currency);
                        mbc.Surplus          = mbc.RemainingBalance - mbc.CostProjection;
                        mbc.Projects         = mbpList;
                        mbCategories.Add(mbc);
                    }
                }
            }
            catch (Exception ex)
            {
            }
            return(mbCategories);
        }