Ejemplo n.º 1
0
        /// <summary>
        /// This is used mainly for ViewBudget. It calculates the numbers (totals) for each category
        /// </summary>
        /// <param name="category"></param>
        /// <param name="budgetLines"></param>
        private static void AddCategoryLinesWithNumbers(IExchangeRateService exchangeRateService, Models.Category category,
                                                        List <ProjectBudget> budgetLines, Currency displayCurrency, CountryProgramme countryProg)
        {
            List <Models.BudgetLine> bsl = new List <Models.BudgetLine>();

            Models.BudgetLine subLine;
            decimal           budgetAmount;
            decimal?          committed, posted;

            budgetAmount = 0;
            committed    = posted = 0;
            foreach (ProjectBudget item in budgetLines)
            {
                subLine = new Models.BudgetLine();
                subLine.EntityBudgetLine     = item;
                subLine.SubLineId            = item.Id;
                subLine.BudgetCategoryId     = category.EntityBudgetCategory.Id.ToString();
                subLine.BudgetCategoryNumber = category.EntityBudgetCategory.Number;
                subLine.TotalBudget          = (decimal)exchangeRateService.GetForeignCurrencyValue(displayCurrency, item.BudgetCategory.ProjectDonor.Currency, item.TotalBudget, countryProg.Id);
                subLine.TotalCommitted       = (decimal)exchangeRateService.GetForeignCurrencyValue(displayCurrency, item.BudgetCategory.ProjectDonor.Currency, item.TotalCommitted, countryProg.Id);
                subLine.TotalPosted          = (decimal)exchangeRateService.GetForeignCurrencyValue(displayCurrency, item.BudgetCategory.ProjectDonor.Currency, item.TotalPosted, countryProg.Id);
                subLine.RemainingBalance     = subLine.TotalBudget - (subLine.TotalCommitted + subLine.TotalPosted);
                //Sum up for category
                budgetAmount += subLine.TotalBudget;
                committed    += subLine.TotalCommitted;
                posted       += subLine.TotalPosted;
                bsl.Add(subLine);
            }
            category.BudgetLines      = bsl;
            category.TotalBudget      = budgetAmount;
            category.TotalCommitted   = committed;
            category.TotalPosted      = posted;
            category.RemainingBalance = budgetAmount - (committed + posted);
        }
Ejemplo n.º 2
0
        public ActionResult UpdateLinkToMB(Models.BudgetLine bl)
        {
            ProjectBudget pb = new ProjectBudget();

            if (bl.BudgetLineId != null && bl.GeneralLedgerId != null)
            {
                pb = budgetService.GetProjectBudgetById(bl.BudgetLineId);
                budgetService.LinkBudgetLineToMasterBudget(bl.BudgetLineId, bl.GeneralLedgerId);
            }
            return(LinkToMB(pb.BudgetCategory.ProjectDonor.Id));
        }
Ejemplo n.º 3
0
        public ActionResult EditLinkToMB(Guid id)
        {
            ProjectBudget        pb     = budgetService.GetProjectBudgetById(id);
            List <GeneralLedger> mbList = budgetService.GetGeneralLedgers(countryProg.Id);

            Models.BudgetLine bl = new Models.BudgetLine();
            bl.EntityBudgetLine            = pb;
            bl.EntityBudgetLine.LineNumber = pb.LineNumber;
            bl.BudgetLineId       = id;
            bl.GeneralLedgerId    = pb.GeneralLedgerId;
            bl.GeneralLedgerCodes = new SelectList(mbList, "Id", "DataText");
            return(View("EditLinkToMB", bl));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Used for display views with the SCMS.UI.Models.SubLine class
        /// </summary>
        /// <param name="bc"></param>
        /// <returns></returns>
        private List <Models.BudgetLine> GetCategorySubLines(BudgetCategory bc, ProjectDonor pd)
        {
            List <Models.BudgetLine> subLines = new List <Models.BudgetLine>();
            List <ProjectBudget>     bsl      = budgetService.GetBudgetLinesNotInBudget(pd, bc);

            Models.BudgetLine subLine;
            foreach (ProjectBudget item in bsl)
            {
                subLine = new Models.BudgetLine();
                subLine.EntityBudgetLine     = item;
                subLine.SubLineId            = item.Id;
                subLine.BudgetCategoryId     = bc.Id.ToString();
                subLine.BudgetCategoryNumber = bc.Number;
                subLines.Add(subLine);
            }
            return(subLines);
        }
Ejemplo n.º 5
0
        private List <Models.BudgetLine> PopulateMBCategoryBudgetLines(MasterBudgetCategory mbc, ProjectDonor pd, List <MasterBudgetCategory> mbcList)
        {
            List <Models.BudgetLine> blList = new List <Models.BudgetLine>();

            Models.BudgetLine    bl;
            List <ProjectBudget> budgetLines = budgetService.GetBudgetLinesByMBCategory(mbc, pd);

            foreach (ProjectBudget budgetLine in budgetLines)
            {
                bl = new Models.BudgetLine();
                bl.BudgetCategoryId   = mbc.Id.ToString();
                bl.EntityBudgetLine   = budgetLine;
                bl.GeneralLedgerCodes = new SelectList(mbcList, "Id", "DataText");
                bl.BudgetLineId       = budgetLine.Id;
                blList.Add(bl);
            }
            return(blList);
        }
Ejemplo n.º 6
0
        private List <Models.BudgetLine> PopulateCategoryBudgetLines(BudgetCategory budgetCategory, List <GeneralLedger> glList)
        {
            List <Models.BudgetLine> blList = new List <Models.BudgetLine>();

            Models.BudgetLine    bl;
            List <ProjectBudget> budgetLines = budgetService.GetBudgetLinesNotInMB(budgetCategory);

            foreach (ProjectBudget budgetLine in budgetLines)
            {
                bl = new Models.BudgetLine();
                bl.BudgetCategoryId   = budgetCategory.Id.ToString();
                bl.EntityBudgetLine   = budgetLine;
                bl.GeneralLedgerCodes = new SelectList(glList, "Id", "DataText");
                bl.GeneralLedgers     = glList;
                bl.BudgetLineId       = budgetLine.Id;
                blList.Add(bl);
            }
            return(blList);
        }