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
close command shows wrong transaction price for multi-priced balances #1035
Comments
Great bug report and workaround - thanks. As you point out, the close command's handling of transaction prices is sloppy. If the sum contained multiple different transaction prices, it shows only the first and discards the rest. What's the best behaviour I wonder ?
2 is what we do by default everywhere else, so I guess that's the answer. |
This gives output like:
|
Oh. Which has a wrong balance assertion. Maybe if I leave the transaction price in the asserted amounts it'll all work out.. |
Related: #824 |
|
Stepping back, the first question is do we want to preserve the "lots" formed by transaction prices (and the more sophisticated lots we hope to support in future) across close/open transactions, and eg from one year's file to the next ? I think the answer must be yes. (Note for #1022: this demonstrates how posting date and a lot's "acquisition date" can be different. Eg I acquire a lot on 2018-06-01, and start a new file in 2019, that lot appears in the 2019 journal via a 2019-01-01 opening balances posting.) |
I agree that preserving the lots across close/open transactions is what makes the most sense. It seems to me that whatever format one comes up with in #1022 for lot acquisition/deposit is what will eventually be used in |
Let's leave this one open, the close command really is showing bogus information here. An interim fix might be needed. Eg: when an account has a multi-price balance, show one posting per price and don't add balance assertions. |
Here's an example of more correctly closing a multi-priced balance.
Until now, we have left the equity posting's balance blank, so that only one equity posting was needed. I tried adding the -x/--explicit flag to make this optional. But I think it's best to just always show it explicitly. If someone prefers the implicit form it's an easy manual edit. Here's a more complex case that I found in the tests, updated for the new behaviour:
Let me know what you think. |
Transaction prices were being collapsed/misreported after close/open; this is fixed. Now each separately-priced amount gets its own posting, and only the last of these (for each commodity) gets a balance assertion. Also the equity posting's amount is now always shown explicitly, which in multicommodity situations means that multiple equity postings are shown. The upshot is that a balance -B report will be unchanged after closing & opening transactions.
Looks fine to me, thanks! |
I'm unable to explain the output I'm getting from
hledger close
hledger prices
correctly calculates the prices for a specific commodity whose purchase was done using total cost (ie@@
) postings. Buthledger close
does not produce a total cost in line with that price.I have journal entries where BTCs are purchased using total price (ie
@@
) postingsThe hledger-derived unit prices of said BTC commodity look fine too:
finance $ hledger prices --costs BTC | grep 2018-12-31 P 2018-12-31 BTC EUR3386,38673 P 2018-12-31 BTC EUR3366,153328
I do not have any 'P' directives anywhere in my journals, and am simply relying on transaction prices for the commodity prices to be determined by hledger automatically.
It's when I run
hledger close
command that I get what is (to me) unexpected.Expected behaviour
EUR720,543970317
is0,2140556 * 3366,153328(last price of 2018)
the manual section for hledger close does not say anything about how transaction prices are determined in
hledger close
postings, so my expectation may well be off the mark.If this issue is a known greyzone due to hledger not supporting proper priced lot tracking (#1022), feel free to close this one, and I'll revisit when #1022 is resolved.
Current workaround
I pipe the output of the hledger close command to
sed
, in order to clear closing transaction prices on problematic priced lots.The text was updated successfully, but these errors were encountered: