Example #1
0
        private List <BudgetViewModel> BudgetAdjustmentCommon()
        {
            var lstBudget  = new List <BudgetViewModel>();
            var budgetList = _repAnnualBudget.GetBudgetList().OrderByDescending(x => x.Id).ToList();

            foreach (var item in budgetList)
            {
                var bvm = new BudgetViewModel()
                {
                    Year            = item.Year,
                    BudgetProvision = item.BudgetProvision,
                    ExceedProvision = item.ExceedProvision,
                    TotalProvision  = item.BudgetProvision + _repAnnualBudget.GetExceedProvision(item.Id),
                    UsedBudget      = _repAnnualBudget.GetUsedBudget(item.Id),
                    RemainingAmount = item.BudgetProvision +
                                      _repAnnualBudget.GetExceedProvision(item.Id) -
                                      _repAnnualBudget.GetUsedBudget(item.Id),
                    StartDate = item.StartDate,
                    EndDate   = item.EndDate,
                    Status    = item.Status
                };
                lstBudget.Add(bvm);
            }

            return(lstBudget);
        }
        public ActionResult Index()
        {
            ViewBag.Title = Constant.BUDGET_LIST;
            var buvm       = new BudgetViewModel();
            var lstBudget  = new List <BudgetViewModel>();
            var budgetList = _repAnnualBudget.GetBudgetList().OrderByDescending(x => x.Id).ToList();

            foreach (var item in budgetList)
            {
                var ExceedSum = _repAnnualBudget.GetBudgetExceed()
                                .Where(x => x.BudgetId == item.Id)
                                .Select(x => x.ExceedAmountProvision)
                                .Sum();

                var bvm = new BudgetViewModel()
                {
                    Id              = item.Id,
                    Year            = item.Year,
                    BudgetProvision = item.BudgetProvision,
                    ExceedProvision = ExceedSum,
                    TotalProvision  = item.BudgetProvision + ExceedSum,
                    UsedBudget      = _repAnnualBudget.GetUsedBudget(item.Id), //Total Purchase - Total Purchase Return
                    RemainingAmount = item.BudgetProvision +
                                      _repAnnualBudget.GetExceedProvision(item.Id) -
                                      _repAnnualBudget.GetUsedBudget(item.Id),
                    StartDate = item.StartDate,
                    EndDate   = item.EndDate,
                    Status    = item.Status
                };
                lstBudget.Add(bvm);
            }

            buvm.BudgetList = lstBudget;

            var currentBudgetList = _repAnnualBudget.GetBudgetList().Where(x => x.Year == DateTime.Now.Year.ToString()).SingleOrDefault();

            buvm.RemainingAmount = currentBudgetList.BudgetProvision
                                   + _repAnnualBudget.GetExceedProvision(currentBudgetList.Id)
                                   - _repAnnualBudget.GetUsedBudget(currentBudgetList.Id);
            //buvm.RemainingAmount = 0;

            return(View(buvm));
        }