Open tbm opened 9 years ago
Comment author: Pavel Yakunin (@lemmsh)
Hi.
When I run ledger on the correct.dat file I get all assets converted to USD that is expected
ledger --price-db bug/prices.db -f bug/correct.dat -V balance assets
USD 840.0 Assets:cash
USD 240.0 eur
USD 600.0 gbp
--------------------
USD 840.0
But running the same command on the incorrect.dat gives me the following:
ledger --price-db bug/prices.db -f bug/incorrect.dat -V balance assets
EUR 200.0
USD 600.0 Assets:cash
EUR 200.0 eur
USD 600.0 gbp
--------------------
EUR 200.0
USD 600.0
Please find attached two journal files below, the only difference is that lines 6 and 7 are swapped in the incorrect.dat
correct.dat
2013-10-24 Default
Assets:cash:eur EUR 400.0
Income:All USD -420.0
2013-10-24 Default
Assets:cash:eur EUR -200.0
Expenses:All USD 210.0
2013-10-24 Default
Assets:cash:gbp GBP 300.0
Income:All USD -600.0
incorrect.dat
2013-10-24 Default
Assets:cash:eur EUR 400.0
Income:All USD -420.0
2013-10-24 Default
Expenses:All USD 210.0
Assets:cash:eur EUR -200.0
2013-10-24 Default
Assets:cash:gbp GBP 300.0
Income:All USD -600.0
prices.db
P 2015-08-07 00:00:00 GBP USD 2
P 2015-08-07 00:00:00 EUR USD 1.2
I can confirm this behaviour.
I am not sure this is a bug. The ledger manual says:
"It is a general convention within Ledger that the 'top' postings in a transaction contain the target accounts, while the final posting contains the source account. Whenever a commodity is exchanged like this, the commodity moved to the target account is considered "secondary", while the commodity used for purchasing and tracked in the cost is "primary''.
Said another way, whenever Ledger sees a posting cost of the form "AMOUNT @@ AMOUNT", the commodity used in the second amount is marked "primary''.
The only meaning a primary commodity has is that the @option{--market (-V)} flag will never convert a primary commodity into any other commodity. @option{--exchange @var{COMMODITY} (-X)} still will, however. "
With -X USD it seems to work.
Note: the issue was created automatically with bugzilla2github
Bugzilla bug ID: BZ#1130 From: Pavel Yakunin (@lemmsh) CC: @lemmsh