Esempio n. 1
0
        public async Task CallHouseTransactions()
        {
            List <Transaction> transactions = await ApiCore.GetHouseholdTransactions(Constants.APIConstants.HouseId, DateTimeOffset.Now.Month, DateTimeOffset.Now.Year).ConfigureAwait(false);

            entries = new List <Entry>();
            var categoryValues   = new Dictionary <string, decimal>();
            var uniqueCategories = transactions.Select(t => t.CatName).Distinct();

            foreach (var cat in uniqueCategories)
            {
                if (cat != "Transfer")
                {
                    decimal total = Math.Ceiling(transactions.Where(t => t.CatName == cat).Select(t => Math.Abs(t.Amount)).Sum());
                    categoryValues.Add(cat, total);
                }
            }
            categoryValues = categoryValues.OrderByDescending(c => c.Value).Take(6).ToDictionary(l => l.Key, v => v.Value);
            int counter = 0;

            foreach (KeyValuePair <string, decimal> category in categoryValues)
            {
                entries.Add(new Entry((float)category.Value)
                {
                    Color = SkiaSharp.SKColor.Parse(_colors[counter]), Label = category.Key, ValueLabel = $"{category.Value}"
                });
                counter++;
            }
        }
Esempio n. 2
0
        private void GetAllTransactions()
        {
            List <Transaction> allTransactions = ApiCore.GetHouseholdTransactions(APIConstants.HouseId, 0, 0).Result;

            allTransactions = allTransactions.OrderByDescending(t => t.Date).ToList();
            transactions    = new ObservableCollection <Transaction>(allTransactions);
        }