polarmutex / fava-envelope

A beancount fava extension to add a envelope budgeting capability
MIT License
112 stars 17 forks source link

When time filter is selected, fava-envelope will not work #32

Open czszj opened 3 years ago

czszj commented 3 years ago

I selected 2021 in the time filter box, fava-envelope will not work. following is the screen shot image

The exception is: File "/home/jason/miniconda3/lib/python3.9/site-packages/fava_envelope/modules/beancount_envelope.py", line 48, in init self.date_start = datetime.datetime.strptime(self.start_date, '%Y-%m').date() TypeError: strptime() argument 1 must be str, not None

egetzner commented 3 years ago

This issue is due to the way the plugin is dependent on the "start date" entry, which is bound to the date at the beginning:

2010-01-01 custom "fava-extension" "fava_envelope" "{}"
2010-01-01 custom "envelope" "start date" "2015-01"

Here you would get an error for each filter that would exclude this 2010-01-01 date (even though the budget starts in 2015).

I propose to move the start date to the options like so:

2010-01-01 custom "fava-extension" "fava_envelope" "{'start_date':'2015-01'}"

Potential downside: for the multi-currency version, it would mean that all currency budgets share the same start date.

We could just leave both of these, having the options: start_date as a fallback if no custom "envelope" "start date" entry exists in the current filter.