Issue #190: Use of implicit_prices and operating_currency together leads to incorrect calculations of net worth (blais/beancount)

34 views
Skip to first unread message

Zhuoyun Wei

unread,
Sep 6, 2017, 8:45:10 AM9/6/17
to bean...@googlegroups.com
New issue 190: Use of implicit_prices and operating_currency together leads to incorrect calculations of net worth
https://bitbucket.org/blais/beancount/issues/190/use-of-implicit_prices-and

Zhuoyun Wei:

Hi,

if you have the following conditions to be true, the calculated net worth is wrong:

- Two operating currencies are defined;
- At least one transaction involves the two currencies with `@@`;
- The implicit_prices plugin is enabled.

Here is a minimal example:

```
plugin "beancount.plugins.implicit_prices"

option "operating_currency" "CNY"
option "operating_currency" "USD"

1970-01-01 open Liabilities:CC
1970-01-01 open Expenses:Food

2017-09-01 * ""
Liabilities:CC -660.00 CNY
Expenses:Food +100.00 USD @@ 660.00 CNY
```

Running bean-report:

```
Currency Net Worth
-------- ---------
CNY -660.00
USD -100.00
-------- ---------
```

Either:

- disabling one of the operating currencies

or

- disabling implicit_prices plugin

restores the correct calculation of net worth:

```
Currency Net Worth
-------- ---------
CNY -660.00
-------- ---------
```

I rooted the cause of this behavior in a very confusing situation. I was looking at the net worth graph in Fava and found something very strange:

- My ledger spans from 2013 to 2017.
- The ledger consists of only CNY transactions from 2013 to 2015. The net worth graph from 2013 to 2015 consists of a rising line of CNY and a flat line of USD which is always 0.
- In year 2015 I got my first international credit card and there were USD @@ CNY transactions from then on.
- On the day the first USD @@ CNY transaction occurs, the USD value in Fava net worth graph spikes from zero to a non-zero value, which roughly equals to all my CNY assets converted to USD.
- The USD line in the graph keeps a similar shape with CNY line from 2015 to 2017.

Attachment: the USD net worth spikes from zero to non-zero starting from the day the first USD @@ CNY transaction occurs, and keeps a similar shape with CNY value from then on.

Responsible: blais
Reply all
Reply to author
Forward
0 new messages