protected override void UpdateTotals() { TotalQuantity = ItemsShowing.Sum(x => x.Quantity); TotalSales = ItemsShowing.Sum(x => x.Amount); TotalCost = ItemsShowing.Sum(x => x.Cost); TotalProfit = ItemsShowing.Sum(x => x.Profit); AverageCostPercent = totalSales == 0 ? 0 : totalCost / totalSales; }
protected void RemoveLine(int lineId) { var toRemove = ItemsShowing.Single(x => x.LineId == lineId); ItemsShowing.Remove(toRemove); UpdateTotals(); UpdateGraphDataAsync(); }
protected override void UpdateTotals() { var rootCategories = ItemsShowing.Where(x => x.Category == null || x.Category.ParentCategory == null); //sum only root categories TotalSales = rootCategories.Sum(x => x.Amount); TotalCost = rootCategories.Sum(x => x.Cost); TotalProfit = totalSales - totalCost; AverageCostPercent = totalSales == 0 ? 0 : totalCost / totalSales; }
protected override void UpdateTotals() { if (ItemsShowing.Count == 0) { AveragePreference = 0; AverageProfitMargin = 0; return; } AveragePreference = ItemsShowing.Average(x => x.Preference); AverageProfitMargin = ItemsShowing.Average(x => x.ProfitMargin); }
protected override void UpdateTotals() { int count = ItemsShowing.Count; if (count == 0) { MedianServiceTime = 0; return; } MedianServiceTime = ItemsShowing.OrderBy(x => x.ServiceTime).ElementAt(count / 2).ServiceTime; }
protected override List <ChartItemViewModel> GetGraphData() { List <ChartItemViewModel> result = new List <ChartItemViewModel>(); foreach (var item in ItemsShowing.OrderBy(x => - x.Amount)) { ChartItemViewModel scc = new ChartItemViewModel(); scc.X = item.SalesPersonName; scc.TotalSale = item.Amount; result.Add(scc); } return(result); }
protected override List <ChartItemViewModel> GetGraphData() { List <ChartItemViewModel> result = new List <ChartItemViewModel>(); foreach (var item in ItemsShowing.OrderBy(x => x.DayOfWeek == DayOfWeek.Sunday ? 7 : (int)x.DayOfWeek)) { ChartItemViewModel scc = new ChartItemViewModel(); scc.X = ((Dias)item.DayOfWeek).ToString(); scc.TotalSale = Math.Round(item.Amount); result.Add(scc); } return(result); }
protected override List <ChartItemViewModel> GetGraphData() { List <ChartItemViewModel> result = new List <ChartItemViewModel>(); foreach (var group in ItemsShowing.GroupBy(x => x.ProductClass).OrderBy(x => x.Key)) { ChartItemViewModel scc = new ChartItemViewModel(); scc.X = group.Key.ToString(); scc.Count = group.Count(); result.Add(scc); } return(result); }
protected override List <ChartItemViewModel> GetGraphData() { List <ChartItemViewModel> result = new List <ChartItemViewModel>(); foreach (var item in ItemsShowing.Where(x => x.ChildrenProductsTotalSale > 0).OrderBy(x => - x.ChildrenProductsTotalSale)) { ChartItemViewModel scc = new ChartItemViewModel(); scc.X = item.CategoryName; scc.TotalSale = Math.Round(item.ChildrenProductsTotalSale); result.Add(scc); } return(result); }
protected override void UpdateTotals() { if (ItemsShowing.Count() == 0) { Minimum = Maximum = Average = 0; return; } Minimum = ItemsShowing.Min(x => x.MinimumQuantity * x.MinimumUnitMeasure.ToBaseConversion); Maximum = ItemsShowing.Max(x => x.MaximumQuantity * x.MaximumUnitMeasure.ToBaseConversion); Average = Math.Round(ItemsShowing.Average(x => x.AverageQuantity * x.AverageUnitMeasure.ToBaseConversion)); //fit qtties var invSvc = base.GetService <IInventoryService>(); using (var unitOfWork = base.GetNewUnitOfWork()) { Product selectedProduct = Products.Single(x => x.Id == SelectedProductId); UMFamily umf = unitOfWork.UMFamilyRepository.GetById(selectedProduct.UMFamilyId); UnitMeasure bestUM = invSvc.GetBestUM(umf, Minimum); MinUnitMeasure = bestUM; Minimum = Minimum / bestUM.ToBaseConversion; bestUM = invSvc.GetBestUM(umf, Maximum); MaxUnitMeasure = bestUM; Maximum = Maximum / bestUM.ToBaseConversion; bestUM = invSvc.GetBestUM(umf, Average); AveUnitMeasure = bestUM; int decimalPlaces = umf.Id == 1 ? 0 : 2; Average = Math.Round(Average / bestUM.ToBaseConversion, decimalPlaces); } }
protected override void UpdateTotals() { TotalCost = ItemsShowing.Sum(x => x.Cost); TotalRealCost = ItemsShowing.Sum(x => x.RealCost);; }
protected override void UpdateTotals() { TotalSales = ItemsShowing.Sum(x => x.Amount); TotalClients = ItemsShowing.Sum(x => x.Clients); SpendingByClient = totalClients == 0 ? 0 : totalSales / totalClients; }