beanprice icon indicating copy to clipboard operation
beanprice copied to clipboard

--update doesn't work for commodities not held at cost

Open mkatsevVR opened this issue 4 years ago • 3 comments

Input file:

plugin "beancount.plugins.auto_accounts"

2021-04-01 commodity EUR
  price: "USD:yahoo/EURUSD=X"

2021-04-01 *
  Assets:Cash 100.00 EUR @ 150.00 USD
  Equity:Opening-Balances

this works:

> bean-price test.beancount
2021-04-27 price EUR                                  1.21 USD

this does nothing:

> bean-price test.beancount --update

If I add {...} to the transaction, both commands work as expected.

I believe this bug has been previously pointed out in https://github.com/beancount/beanprice/pull/26 (cc @doriath)

mkatsevVR avatar Apr 27 '21 07:04 mkatsevVR

Got the same issue. but when trying with -i flag, it start to works well..

so must be something special around https://github.com/beancount/beanprice/blob/2122268e4696b40bdb565a31bc38eb831fe8d584/beanprice/price.py#L394-L404

also based on your description, it might be related to this function https://github.com/beancount/beancount/blob/24df7465413ed22dc9c500f4d781430cb1c9e655/beancount/ops/lifetimes.py#L21-L76

ileodo avatar Jul 04 '23 21:07 ileodo

It looks like an issue with how get_commodity_lifetimes (mentioned by @ileodo) determines currency pairs. It uses method currency_pair of Position class, which only considers cost currency.

https://github.com/beancount/beancount/blob/master/beancount/core/position.py#L255-L261

mrlimacz avatar Jul 09 '23 12:07 mrlimacz

@blais just wondering can you still recall was there any consideration on this?

ileodo avatar Jul 31 '23 17:07 ileodo