Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
mkatsevVR opened this issue Apr 27, 2021 · 3 comments
Open

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

mkatsevVR opened this issue Apr 27, 2021 · 3 comments

Comments

@mkatsevVR
Copy link

mkatsevVR commented Apr 27, 2021

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 #26 (cc @doriath)

@ileodo
Copy link

ileodo commented Jul 4, 2023

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

so must be something special around

if inactive:
for base_quote in currencies:
if lifetimes_map[base_quote]:
# Use first date from lifetime
lifetimes_map[base_quote] = [(lifetimes_map[base_quote][0][0], None)]
else:
# Insert never active commodities into lifetimes
# Start from date of currency directive
base, _ = base_quote
commodity_entry = commodity_map.get(base, None)
lifetimes_map[base_quote] = [(commodity_entry.date, None)]

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

@mrlimacz
Copy link
Contributor

mrlimacz commented Jul 9, 2023

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

@ileodo
Copy link

ileodo commented Jul 31, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants