def test_one_date_range(self):
     self.assertEqual(
         datetools.DateSequence([
                 datetools.DateRange(
                     datetime.date(2018, 9, 13),
                     datetime.date(2018, 9, 14))]),
         datetools.parse_date_sequence('2018-09-13..2018-09-14'))
Esempio n. 2
0
def filter_transactions(xactions, options):
    '''
    Filter a list of transactions by certain criteria.
    '''

    filtered_xactions = xactions

    date_sequence = datetools.DateSequence([])
    if hasattr(options, 'dates') and options.dates is not None:
        date_sequence.extend(options.dates)
    if hasattr(options, 'dates_files'):
        for dates_file in options.dates_files:
            date_sequence.extend(
                datetools.parse_date_sequence_file(dates_file))
    if not date_sequence.is_empty:
        filtered_xactions = _filter_transactions_with_non_matching_dates(
            filtered_xactions, date_sequence)

    if hasattr(options, 'include_regexs') and len(options.include_regexs) > 0:
        filtered_xactions = _filter_transactions_with_non_matching_descriptions(
            filtered_xactions, options.include_regexs)

    if hasattr(options, 'exclude_regexs') and len(options.exclude_regexs) > 0:
        filtered_xactions = _filter_transactions_with_matching_descriptions(
            filtered_xactions, options.exclude_regexs)

    if hasattr(options, 'no_tags') and options.no_tags:
        filtered_xactions = _filter_transactions_without_tags(
            filtered_xactions)

    return filtered_xactions
 def test_comma_only(self):
     self.assertEqual(
         datetools.DateSequence([]),
         datetools.parse_date_sequence(',')
     )
 def test_empty_string(self):
     self.assertEqual(
         datetools.DateSequence([]),
         datetools.parse_date_sequence('')
     )
 def test_empty(self):
     test_file_path = self._create_test_file('')
     self.assertEqual(
         datetools.DateSequence([]),
         datetools.parse_date_sequence_file(test_file_path)
     )
 def test_None(self):
     with self.assertRaises(TypeError):
         None in datetools.DateSequence([])
 def test_two_dates(self):
     self.assertEqual(
         datetools.DateSequence(
             [datetime.date(2018, 9, 13), datetime.date(2018, 9, 14)]),
         datetools.parse_date_sequence('2018-09-13,2018-09-14'))
Esempio n. 8
0
 def test_dates(self):
     options = pecuniacli._parse_options(['list', '--dates=2019-05-03'])
     self.assertEqual('list', options.command)
     self.assertEqual(
         datetools.DateSequence([datetools.parse_date('2019-05-03')]),
         options.dates)
Esempio n. 9
0
 def test_dates_after_date(self):
     options = pecuniacli._parse_options(['tags', '--dates=2018-09-14..'])
     self.assertEqual(
         datetools.DateSequence([
             datetools.DateRange(datetime.date(2018, 9, 14), None),
         ]), options.dates)
Esempio n. 10
0
 def test_dates_one_date(self):
     options = pecuniacli._parse_options(['tags', '--dates=2018-09-14'])
     self.assertEqual(datetools.DateSequence([datetime.date(2018, 9, 14)]),
                      options.dates)