Skip to content

Commit

Permalink
(fixed linter errors, fixing CI build)
Browse files Browse the repository at this point in the history
  • Loading branch information
blais committed May 7, 2019
1 parent e0a440c commit 468c802
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions beancount/plugins/forecast.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,25 +96,32 @@ def forecast_plugin(entries, options_map):
new_entries.append(entry)
continue
forecast_narration = match.group(1).strip()
forecast_interval = (rrule.YEARLY if match.group(2).strip() == 'YEARLY'
else rrule.WEEKLY if match.group(2).strip() == 'WEEKLY'
else rrule.DAILY if match.group(2).strip() == 'DAILY'
else rrule.MONTHLY)
forecast_interval = (
rrule.YEARLY if match.group(2).strip() == 'YEARLY'
else rrule.WEEKLY if match.group(2).strip() == 'WEEKLY'
else rrule.DAILY if match.group(2).strip() == 'DAILY'
else rrule.MONTHLY)
forecast_periodicity = {'dtstart': entry.date}
if match.group(6): # e.g., [MONTHLY REPEAT 3 TIMES]:
forecast_periodicity['count'] = int(match.group(6))
elif match.group(8): # e.g., [MONTHLY UNTIL 2020-01-01]:
forecast_periodicity['until'] = datetime.datetime.strptime(match.group(8),'%Y-%m-%d').date()
else: # e.g., [MONTHLY]
forecast_periodicity['until'] = datetime.date(datetime.date.today().year,12, 31)

if match.group(4): # SKIP
forecast_periodicity['until'] = datetime.datetime.strptime(
match.group(8), '%Y-%m-%d').date()
else:
# e.g., [MONTHLY]
forecast_periodicity['until'] = datetime.date(
datetime.date.today().year, 12, 31)

if match.group(4):
# SKIP
forecast_periodicity['interval'] = int(match.group(4)) + 1

# Generate a new entry for each forecast date.
forecast_dates = [dt.date() for dt in rrule.rrule(forecast_interval,**forecast_periodicity)]
forecast_dates = [dt.date() for dt in rrule.rrule(forecast_interval,
**forecast_periodicity)]
for forecast_date in forecast_dates:
forecast_entry = entry._replace(date=forecast_date,narration=forecast_narration)
forecast_entry = entry._replace(date=forecast_date,
narration=forecast_narration)
new_entries.append(forecast_entry)

# Make sure the new entries inserted are sorted.
Expand Down

0 comments on commit 468c802

Please sign in to comment.