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)); }
public ActionResult Dashboard() { ViewBag.Title = Constant.DASHBOARD; var currentAnnualBudgetId = new BaseController(_repAnnualBudget).budgetList; var dvm = new DashboardViewModel(); dvm.BudgetProvision = _repAnnualBudget.GetBudgetList() .Where(x => x.Year == DateTime.Now.Year.ToString()) .SingleOrDefault().BudgetProvision; var budgetList = _repAnnualBudget.GetBudgetList().OrderByDescending(x => x.Id).ToList(); decimal ExceedSum = 0; decimal TotalUsedBudget = 0; foreach (var item in budgetList) { ExceedSum = _repAnnualBudget.GetBudgetExceed() .Where(x => x.BudgetYear == DateTime.Now.Year.ToString()) .Select(x => x.ExceedAmountProvision) .Sum(); //TotalUsedBudget += _repAnnualBudget.GetUsedBudget(item.Id); //Total Purchase - Total Purchase Return decimal TotalPurchase = _repAnnualBudget.GetTotalPurchaseInAYear(item.Id); decimal TotalPurchaseReturn = _repAnnualBudget.GetTotalPurchaseReturnInAYear(item.Id); TotalUsedBudget += TotalPurchase - TotalPurchaseReturn; } dvm.ExceedProvision = ExceedSum; dvm.AmountUsed = TotalUsedBudget; dvm.AssetValueWithDepreciation = AssetValueWithDepreciation(); //dvm.AssetValueWithoutDepreciation = _repPurchaseAsset.AssetValueWithoutDepreciation(); decimal TotalPurchaseAmt = _repAnnualBudget.GetTotalPurchase(); decimal TotalReturnAmt = _repAnnualBudget.GetTotalPurchaseReturn(); decimal TotalScrap = _repAnnualBudget.GetTotalScrap(); dvm.AssetValueWithoutDepreciation = TotalPurchaseAmt - TotalReturnAmt - TotalScrap; dvm.LatestPurchase = _repPurchaseAsset.GetLatestPurchase(currentAnnualBudgetId).ToList(); //Minimum Stock List dvm.MinimumStockList = MinimumAssetStockList(currentAnnualBudgetId); dvm.LatestDepreciation = _repDepreciation.GetLatestCurrentDepreciation().ToList(); /********************************ASSET VALUE IN HAND********************************/ var yearList = _repDepreciation.GetYearOfDepreciation(); decimal totalCurrentValue = 0; var lstYear = new List <string>(); var lstTotalCurrentValue = new List <decimal>(); foreach (var item1 in yearList) { var purchaseDetails = _repPurchaseAsset.GetPurchaseDetailsByYear().Where(x => x.Year == item1.Year).ToList(); foreach (var item2 in purchaseDetails) { //Check if item is in Purchase Return var checkPurchaseReturnObj = _repPurchaseAsset.GetPurchaseReturnDetails() .Where(x => x.AssetPurchaseId == item2.AssetPurchaseId).SingleOrDefault(); //Check if item is in Scrap var checkScrapObj = _repAsset.GetScrap().Where(x => x.PurchaseId == item2.AssetPurchaseId).SingleOrDefault(); if (checkPurchaseReturnObj == null && checkScrapObj == null) { totalCurrentValue += Decimal.Parse(CurrentItemValue.GetCurrentValue(item2.AssetPurchaseId).ToString("#.##")); } } lstTotalCurrentValue.Add(totalCurrentValue); lstYear.Add(item1.Year); } dvm.YearList = lstYear.ToArray(); dvm.TotalCurrentValue = lstTotalCurrentValue.ToArray(); /********************************ASSET VALUE IN HAND********************************/ return(View(dvm)); }