tbm / test

0 stars 0 forks source link

options_map misses entries from multiple import directives #91

Closed tbm closed 8 years ago

tbm commented 8 years ago

Original report by Dominik Aumayr (GitHub: aumayr).


This was first reported by yegle here.

It looks like beancount.loader.load_file does not return a correct options_map when using include directives: The keys operating_currency and commodities are missing or reporting the wrong value.

Here's a minimal test case that demonstrate the problem.

invest.bean

include "accounts.bean"
include "a.bean"
include "b.bean"

accounts.bean

2015-12-09 open Assets:AccountA
2015-12-09 open Assets:AccountB

a.bean

include "accounts.bean"

2015-12-09 *
    Assets:AccountA -1 USD
    Assets:AccountB 1 USD

b.bean

include "accounts.bean"

2015-12-10 *
    Assets:AccountA -1 USD
    Assets:AccountB 1 USD

beancount.loader.load_files returns an options_map without the key commodities. When defining option "operating_currency" "USD" in one of the included files this key is also missing from options_map.

Use bean-report -f beancount invest.bean print > /tmp/output.beancount to concatenate everything into a single file, and beancount.loader.load_files returns a correct options_map.

tbm commented 8 years ago

Original comment by Martin Blais (Bitbucket: blais, GitHub: blais).


This is a known issue. Only the top-level's options_map is filled in. I haven't defined a sensible way to aggregate multiple options_maps together, which is required to do this correctly. Another option would be for me to recycle the options_map across multiple files. This will require more thought and possibly some wide-ranging changes, not a small task I can address right now.

I'd rather pick and choose to address those specific fields you need in the meantime. Is the "commodities" the only field you need?

tbm commented 8 years ago

Original comment by Dominik Aumayr (GitHub: aumayr).


Only the two fields commodities and operating_currency are the ones I need for beancount-web to work properly.

tbm commented 8 years ago

Original comment by Martin Blais (Bitbucket: blais, GitHub: blais).


Fixed #91: Aggregated some of the attributes of the options_map across included files.

tbm commented 8 years ago

Original comment by Dominik Aumayr (GitHub: aumayr).


Works now, thanks!