private CashFlow GetCashFlowStatisticItems(List<PaymentViewModel> payments) { var income = new StatisticItem { Category = Strings.RevenueLabel, Value = payments.Where(x => x.Type == PaymentType.Income).Sum(x => x.Amount) }; income.Label = income.Category + ": " + Math.Round(income.Value, 2, MidpointRounding.AwayFromZero).ToString("C"); var spent = new StatisticItem { Category = Strings.ExpenseLabel, Value = payments.Where(x => x.Type == PaymentType.Expense).Sum(x => x.Amount) }; spent.Label = spent.Category + ": " + Math.Round(spent.Value, 2, MidpointRounding.AwayFromZero).ToString("C"); var increased = new StatisticItem { Category = Strings.IncreaseLabel, Value = income.Value - spent.Value }; increased.Label = increased.Category + ": " + Math.Round(increased.Value, 2, MidpointRounding.AwayFromZero).ToString("C"); return new CashFlow { Income = income, Expense = spent, Revenue = increased }; }
private void AddOtherItem(IEnumerable<StatisticItem> tempStatisticList, ICollection<StatisticItem> statisticList) { if (statisticList.Count < 6) { return; } var othersItem = new StatisticItem { Category = "Others", Value = tempStatisticList .Where(x => !statisticList.Contains(x)) .Sum(x => x.Value) }; othersItem.Label = othersItem.Category + ": " + othersItem.Value; if (othersItem.Value > 0) { statisticList.Add(othersItem); } }