You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
empty table cells in multi-period balance reports [since 1.20] #1526
I don't understand what is going on here. The --yearly report has always worked for me, and that stopped recently.
Now I cannot decide whether my understanding is wrong, or hledger has regressed. In any case, it is surprising.
I use a lot of piped hledger print -f - commands, and commodity directives don't seem to be preserved in the output of those print commands. So tmp.journal does not have a commodity directive. Adding it back makes everything magically work.
There's a rather large count of digits after the decimal point for most amounts in the tmp.journal, since it came from unrealized gains calculations computed in beancount.
I'm curious: do you still get this issue in master, or with the branch in #1509? I've put some effort into refactoring the code so this sort of bug (easy to accidentally do in the past) is less likely/impossible to do now.
I'm curious: do you still get this issue in master, or with the branch in #1509? I've put some effort into refactoring the code so this sort of bug (easy to accidentally do in the past) is less likely/impossible to do now.
@Xitian9 tried your mixedamt branch. Same problem. I'm going to try to shrink the journal, and if not, i'll need to setup a matrix client to send @simonmichael the journal.
Here is the smallest journal that exhibits the problem on my end:
cat <<EOF | ~/.local/bin/hledger-1.21 bal -f - --yearly Income:Gains
2020-12-30 * Sold BTC to EUR
Income:Gains -0.08724382 EUR
Assets:XBT -0.00000437 XBT @ 2919.034429281334766023231553 EUR
Assets:EUR 0.10000000 EUR
Equity:Rounding ; rounding from beancount: 0.0000000004559594329275215219 EUR
2021-04-11 U Unrealized loss for 14.23000000 units of GBP (price: 1.1526 EUR as of 2021-04-09, average cost: 1.1680 EUR)
Assets:GBP:Unrealized -0.21871744220000000000000000 EUR
Income:GBP:Unrealized 0.21871744220000000000000000 EUR
Equity:Rounding ; rounding for hledger
EOF
@Xitian9, I think showAmountsOneLineB shows nothing if the rendered amount would exceed the hard-coded max width of 32 in Hledger.Cli.Commands.Balance.balanceOpts. (In this example, writing 25 instead of 26 decimal places makes it work.) It should show an elided amount instead, I guess.
changed the title [-]empty cells (not even value 0) where there should be a value present, in a --yearly bal report[/-][+]empty cells (not even value 0) where there should be a value present, in a --yearly bal report [since 1.20][/+]on Apr 13, 2021
changed the title [-]empty cells (not even value 0) where there should be a value present, in a --yearly bal report [since 1.20][/-][+]empty table cells in multi-period balance reports [since 1.20][/+]on Apr 13, 2021
It's not clear how to elide a single amount. Here are some options:
Elide from the left
Simple
May elide commodity symbol
Elides most significant digits
Elide from the right
Simple
May elide commodity symbol
If there is no visible decimal place, cannot determine the order of magnitude of the number
Elide from the left, but don't elide commodity symbol
Similar to (1), but doesn't elide commodity symbol.
Still runs into problems with long commodity symbols.
Elide from the right, but don't elide commodity symbol
Similar to (2), but doesn't elide commodity symbol.
Still runs into problems with long commodity symbols.
Use scientific notation for elided numbers
Number is clear
Still runs into problems with long commodity symbols
Or, as you say, we can just ignore the maximum width if it would cause nothing to display. This might mess up alignment unless we put some extra effort into that.
I was imagining just whatever kind of eliding we already do with too-wide amounts, even it it's not yet ideal it would be consistent. But what did 1.19 do - expand the column without limit to fit the widest amount ? That's not always super usable either but for now it's probably the most useful. Eliding can be bothersome.
So perhaps the best option is to elide according to the previous rules, but make sure we always display at least one commodity along with an elision string, even if that would put us over the hard-coded width. That width is pretty arbitrary in any case.
Activity
lestephane commentedon Apr 11, 2021
Forgot to mention that it's on 1.21.
simonmichael commentedon Apr 11, 2021
Thanks for the report. That's unfortunate! Would you be able to boil it down to an example journal ?
lestephane commentedon Apr 11, 2021
I'll try, but In the event that I'm unsuccessful, will you have a way to receive the tmp.journal securely?
gpg, onionshare, keybase, whatever...
lestephane commentedon Apr 11, 2021
I use a lot of piped
hledger print -f -commands, andcommoditydirectives don't seem to be preserved in the output of thoseprintcommands. Sotmp.journaldoes not have acommoditydirective. Adding it back makes everything magically work.So the failure mode seems formatting related.
lestephane commentedon Apr 11, 2021
There's a rather large count of digits after the decimal point for most amounts in the
tmp.journal, since it came from unrealized gains calculations computed in beancount.simonmichael commentedon Apr 11, 2021
Sure, if you have a matrix client set up, encrypted direct chat to me (simonmic:matrix.org) could be an easy way.
Xitian9 commentedon Apr 12, 2021
I'm curious: do you still get this issue in master, or with the branch in #1509? I've put some effort into refactoring the code so this sort of bug (easy to accidentally do in the past) is less likely/impossible to do now.
lestephane commentedon Apr 13, 2021
@Xitian9 I will check today, and let you know
lestephane commentedon Apr 13, 2021
@Xitian9 tried your mixedamt branch. Same problem. I'm going to try to shrink the journal, and if not, i'll need to setup a matrix client to send @simonmichael the journal.
lestephane commentedon Apr 13, 2021
Here is the smallest journal that exhibits the problem on my end:
Results in
simonmichael commentedon Apr 13, 2021
Thanks!
@Xitian9, I think
showAmountsOneLineBshows nothing if the rendered amount would exceed the hard-coded max width of 32 inHledger.Cli.Commands.Balance.balanceOpts. (In this example, writing 25 instead of 26 decimal places makes it work.) It should show an elided amount instead, I guess.simonmichael commentedon Apr 13, 2021
Or, allow cells to grow as wide as needed ?
[Start of a test:]
[-]empty cells (not even value 0) where there should be a value present, in a --yearly bal report[/-][+]empty cells (not even value 0) where there should be a value present, in a --yearly bal report [since 1.20][/+][-]empty cells (not even value 0) where there should be a value present, in a --yearly bal report [since 1.20][/-][+]empty table cells in multi-period balance reports [since 1.20][/+]Xitian9 commentedon Apr 14, 2021
It's not clear how to elide a single amount. Here are some options:
Or, as you say, we can just ignore the maximum width if it would cause nothing to display. This might mess up alignment unless we put some extra effort into that.
simonmichael commentedon Apr 14, 2021
Xitian9 commentedon Apr 14, 2021
We currently do eliding by displaying only some of the amounts in a MixedAmount; we don't ever elide the string representing a single amount.
In 1.19, exactly two quantities would be displayed, with no regard for their maximum width.
Xitian9 commentedon Apr 14, 2021
So perhaps the best option is to elide according to the previous rules, but make sure we always display at least one commodity along with an elision string, even if that would put us over the hard-coded width. That width is pretty arbitrary in any case.
lib: When displaying amounts on a single line, always display at leas…
simonmichael commentedon Apr 14, 2021
Sounds pretty good..
lib: When displaying amounts on a single line, always display at leas…
lib: When displaying amounts on a single line, always display at leas…
simonmichael commentedon Apr 14, 2021
Fixed in master by #1530.
lestephane commentedon Apr 14, 2021
I can confirm that it is fixed in master 0f4e462. Thanks!