hledger icon indicating copy to clipboard operation
hledger copied to clipboard

hledger-web --empty show 0 accounts if conversion exists

Open chaoxu opened this issue 2 years ago • 4 comments

Here is the simplest example:

2022-01-01 test
  assets:1  1 UNIT @ 1 USD
  assets:2

2022-01-02 test
  assets:1  -1 UNIT
  assets:3

The output: For both hledger-web -E and hledger-web, the output is the same:

image

Expected output: Just like the above picture, but assets:1 account should not appear at all in hledger-web -E, as it is now empty.

Related explorations

I've tested it in hledger, which is working correctly. Note in hledger, -E shows 0 account, but in hledger-web, -E hides 0 accounts.

hledger bal
              -1 USD  assets:2
              1 UNIT  assets:3
--------------------
              1 UNIT
              -1 USD
hledger bal -E
                   0  assets:1
              -1 USD  assets:2
              1 UNIT  assets:3
--------------------
              1 UNIT
              -1 USD

The version: hledger-web 1.32.1, mac-aarch64

chaoxu avatar Dec 18 '23 16:12 chaoxu

Yes, -E/--empty in hledger-web and hledger-ui works oppositely from hledger (hledger hides empty/zero things by default, hledger-ui/hledger-web show them by default).

simonmichael avatar Dec 19 '23 18:12 simonmichael

Thanks.

Just to be clear, the -E working opposite is expected.

What is not expected is that -E is not working correctly for hledger-web. As the example shows turning it on or not does not change the output.

chaoxu avatar Dec 19 '23 18:12 chaoxu

I don't really have a clear understanding of how hledger-web reacts to -E and how much of a bug there is here. Is it possible to reproduce with simpler data, eg without costs or currencies ?

simonmichael avatar Dec 19 '23 20:12 simonmichael

(I suspect hledger-web intentionally never hides zero-balance accounts, to minimise confusion. We should check the code and if that's so, clarify the docs.)

simonmichael avatar Jan 28 '24 05:01 simonmichael

Hello @chaoxu, I looked into this and I see what you mean. It is always showing "0" for assets:1 because it's not really zero at all, it only appears to be when costs are ignored.

If we showed costs in the sidebar, it would look like this:

image

But I suppose that would be too disruptive, eg for people with many priced lots the sidebar will become very long ?

simonmichael avatar Mar 02 '24 08:03 simonmichael

Yes, too disruptive if we show costs in the sidebar. (Current hledger-web doesn't show costs anywhere in fact.)

For now I am inclined to

  1. make it show zeros with their commodity symbol, which is slightly more informative, and
  2. document how some zeros in hledger-web are not actually zeros, just appearing that way because it doesn't show costs

simonmichael avatar Mar 02 '24 08:03 simonmichael

I made the change in master and updated the hledger-web manual (see end of https://hledger.org/dev/hledger-web.html#options). I think this issue can be closed for now.

simonmichael avatar Mar 02 '24 09:03 simonmichael