public ActionResult AssetValueInHand() { ViewBag.Title = Constant.ASSET_VALUE_IN_HAND; var avihVm = new AssetValueInHandViewModel(); 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); } avihVm.YearList = lstYear.ToArray(); avihVm.TotalCurrentValue = lstTotalCurrentValue.ToArray(); return(View(avihVm)); }
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)); }