public PlanForTrackingDto Get(FilterPlanTracking filterPlanTracking) { PlanForTrackingDto planForTracking = new PlanForTrackingDto(); planForTracking.Plan = _planRepository.GetById(filterPlanTracking.IdPlan); List <VPlanGlobal> vPlanGlobal = _vPlanGlobalService.Get(filterPlanTracking); if (vPlanGlobal.Count > 0) { //recherche de tous les postes de la base et affectation au planTrackingDto planForTracking.Postes = GetPostesForTracking(vPlanGlobal, filterPlanTracking.IdPlan, filterPlanTracking.MonthYear.Month.Id == (int)EnumMonth.BalanceSheetYear); //somme pour le plan PlanTrackingAmountStoreDto planTrackingAmountStore = vPlanGlobal .GroupBy(x => new { x.PreviewAmount, x.IdPlan }) .Select(g => new PlanTrackingAmountStoreDto { Id = g.Key.IdPlan.Value, Label = planForTracking.Plan.Label, AmountPreview = g.Key.PreviewAmount.Value, AmountReal = g.Sum(a => a.AmountOperation.Value) }) .GroupBy(x => new { x.Id }) .Select(g => new PlanTrackingAmountStoreDto { Id = g.Key.Id, Label = planForTracking.Plan.Label, AmountPreview = g.Sum(ap => ap.AmountPreview), AmountReal = g.Sum(a => a.AmountReal) }) .First(); planForTracking.AmountPreview = Math.Round(planTrackingAmountStore.AmountPreview, 2); planForTracking.AmountReal = Math.Round(planTrackingAmountStore.AmountReal, 2); planForTracking.GaugeValue = CalculatePercentage(planTrackingAmountStore.AmountReal, planTrackingAmountStore.AmountPreview); } return(planForTracking); }
public List <VPlanGlobal> Get(FilterPlanTracking filter) { var planGlobals = Context.VPlanGlobal .AsQueryable(); planGlobals = planGlobals.Where(x => x.IdPlan == filter.IdPlan); //planGlobals = planGlobals.Where(x => x.Month.Value == 13); if (filter.MonthYear != null && filter.MonthYear.Month.Id != (int)EnumMonth.BalanceSheetYear) { //ajout systématique du mois 13 (prevision annuelle) planGlobals = planGlobals .Where( x => x.Month != null && ( x.Month == (int)EnumMonth.BalanceSheetYear && x.DateIntegration <= DateHelper .GetLastDayOfMonth(Convert.ToDateTime($"01/{filter.MonthYear.Month.Id}/{filter.MonthYear.Year}")) ) || (x.Month == filter.MonthYear.Month.Id && x.Year == filter.MonthYear.Year) ); //.Where(x => x.Month == 13 || (x.Month==filter.MonthYear.Month.Id //&& x.Year == filter.MonthYear.Year)); } var results = planGlobals.ToList(); return(results); }
public List <VPlanGlobal> Get(FilterPlanTracking filter) { return(_vPlanGlobalRepository.Get(filter)); }
public IActionResult GetPlanTrackingByIdPlan(int idPlan, [FromBody] FilterPlanTracking filter) { var planForDetailDto = _planTrackingService.Get(filter); return(Ok(planForDetailDto)); }