Example #1
0
        public static decimal GetCategoryAmount(HaushaltsbuchDS.BuchungssatzDataTable records, string category,
                                                DateTime input)
        {
            var result = from HaushaltsbuchDS.BuchungssatzRow r in records where r.Datum.Date <= input.Date && r.Kategorie == category orderby r.Datum select r;

            return(CalculateAmount(result));
        }
Example #2
0
        public static List <ViewModel.ViewModel> GetAllCategories(HaushaltsbuchDS.BuchungssatzDataTable table, DateTime date)
        {
            var result = new List <ViewModel.ViewModel>();
            var query  = (from HaushaltsbuchDS.BuchungssatzRow r in table where r.Typ == (int)Types.BookingTypeEnum.Outbound && r.Datum.Date <= date.Date orderby r.Kategorie select r).ToList();

            var previousCategory = query.FirstOrDefault()?.Kategorie ?? string.Empty;
            var previousAmount   = query.FirstOrDefault()?.Betrag ?? 0;

            foreach (var resultRow in query.Skip(1))
            {
                if (previousCategory == resultRow.Kategorie)
                {
                    previousAmount += resultRow.Betrag;
                }
                else
                {
                    result.Add(new ViewModel.ViewModel(0, previousAmount * (-1), previousCategory));
                    previousAmount = resultRow.Betrag;
                }
                previousCategory = resultRow.Kategorie;
            }
            if (previousCategory != string.Empty)
            {
                result.Add(new ViewModel.ViewModel(0, previousAmount * (-1), previousCategory));
            }
            return(result);
        }
 public void OneTimeSetup()
 {
     _testDataTable = new HaushaltsbuchDS.BuchungssatzDataTable();
     // Eingang1
     CreateTestRow(string.Empty, 1200, Functions.GetDate("01.01.1982"), string.Empty,
                   Types.BookingTypeEnum.Inbound);
     // Ausgang1-1
     CreateTestRow("Miete", 700, Functions.GetDate("02.01.1982"), string.Empty, Types.BookingTypeEnum.Outbound);
     // Ausgang1-2
     CreateTestRow("Lebensmittel", 100, Functions.GetDate("03.01.1982"), string.Empty,
                   Types.BookingTypeEnum.Outbound);
     // Ausgang1-3
     CreateTestRow("Getränke", 50, Functions.GetDate("04.01.1982"), string.Empty,
                   Types.BookingTypeEnum.Outbound);
     // Ausgang1-4
     CreateTestRow("Kino", 10, Functions.GetDate("05.01.1982"), "Star Wars Episode II",
                   Types.BookingTypeEnum.Outbound);
     // Eingang2
     CreateTestRow(string.Empty, 1150, Functions.GetDate("01.02.1982"), string.Empty,
                   Types.BookingTypeEnum.Inbound);
     // Ausgang2-1
     CreateTestRow("Miete", 700, Functions.GetDate("02.02.1982"), string.Empty, Types.BookingTypeEnum.Outbound);
     // Ausgang2-2
     CreateTestRow("Lebensmittel", 100, Functions.GetDate("03.02.1982"), string.Empty,
                   Types.BookingTypeEnum.Outbound);
 }