# Path: ledgerbil/schedulefile.py
# class ScheduleFile(LedgerFile):
#     def __init__(self, filename):
#         ScheduleThing.do_file_config = True
#         ScheduleThing.enter_days = 0
#         ScheduleThing.entry_boundary_date = None
#         super().__init__(filename, reconcile_account=None)
# 
#     def add_thing_from_lines(self, lines):
#         lines = remove_trailing_blank_lines(lines)
#         if lines:
#             thing = ScheduleThing(lines)
#             self.add_things([thing])
# 
#     def next_scheduled_date(self):
#         self.sort()
#         for thing in self.things:
#             if thing.is_transaction:
#                 return thing.get_date_string()
# 
#         return ""


from textwrap import dedent
from ..schedulefile import ScheduleFile
from . import filetester as FT


schedule_testdata = dedent(
    """\
    ;; scheduler ; enter 45 days

    2016/10/31 absolute insurance
        ;; schedule ; monthly ; 15 ; 6 ; auto
        e: car: insurance
        l: credit card                          $-425

    2007/07/07 lightning energy
        ;; schedule ; monthly ; 12th 21st; ; auto
        e: bills: electricity
        a: checking up                          $-75

    2018/03/23 lorem ipsum
        ;; schedule ; monthly ; 15 ; 6 ; auto
        e: dolor
        a: cash                                 $-45
    """
)


def test_next_scheduled_transaction():
    with FT.temp_file(schedule_testdata) as tempfilename:

# Path: ledgerbil/schedulefile.py
# class ScheduleFile(LedgerFile):
#     def __init__(self, filename):
#         ScheduleThing.do_file_config = True
#         ScheduleThing.enter_days = 0
#         ScheduleThing.entry_boundary_date = None
#         super().__init__(filename, reconcile_account=None)
# 
#     def add_thing_from_lines(self, lines):
#         lines = remove_trailing_blank_lines(lines)
#         if lines:
#             thing = ScheduleThing(lines)
#             self.add_things([thing])
# 
#     def next_scheduled_date(self):
#         self.sort()
#         for thing in self.things:
#             if thing.is_transaction:
#                 return thing.get_date_string()
# 
#         return ""


# Path: ledgerbil/tests/test_schedulefile.py
from textwrap import dedent
from ..schedulefile import ScheduleFile
from . import filetester as FT



schedule_testdata = dedent(
    """\
    ;; scheduler ; enter 45 days

    2016/10/31 absolute insurance
        ;; schedule ; monthly ; 15 ; 6 ; auto
        e: car: insurance
        l: credit card                          $-425

    2007/07/07 lightning energy
        ;; schedule ; monthly ; 12th 21st; ; auto
        e: bills: electricity
        a: checking up                          $-75

    2018/03/23 lorem ipsum
        ;; schedule ; monthly ; 15 ; 6 ; auto
        e: dolor
        a: cash                                 $-45
    """
)


def test_next_scheduled_transaction():
    with FT.temp_file(schedule_testdata) as tempfilename:

        schedulefile = ScheduleFile(tempfilename)