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

[💰20$ bounty] Inconsistent alignment for currencies with long names #1148

Open
nobodyinperson opened this issue Dec 9, 2019 · 5 comments
Labels
A-WISH Some kind of improvement request, hare-brained proposal, or plea. balance

Comments

@nobodyinperson
Copy link
Contributor

Hi!

Situation

I am using hledger for inventory/asset management in my research project. It works great to keep track of where categories of things are and to a degree even for tracking individual objects (via identifying tags). The best solution for my application turned out to be quoted long currency names for types of things (better readability and searchability via cur:'.*keyword.*').

Problem

However, hledger balance seems to have a hard-coded (minimum?) currency column width which works fine for short currencies (like USD or EUR) and otherwise calculate the currency indentation per-account. This leads to weird indentations and breaks the nice accounts tree view. I didn't find anything concerning this in the online documentation.

Example

Cooked-up example journal test.hledger:

2019/12/09 Outdoor
    [room:workshop]      5 "80 watt solar panel" @@ 500.00 EUR
    [room:workshop]      1 "rugged outdoor laptop" @@ 1000.00 EUR
    [store]

2019/12/09 Car
    [room:garage]     4 "car tires" @@ 300.00 EUR
    [store]
lsb_release -a
# Distributor ID:	Ubuntu
# Description:	Ubuntu 18.04.3 LTS
# Release:	18.04
# Codename:	bionic
# docker image https://hub.docker.com/r/dastapov/hledger
hledger --version
# hledger 1.16.1
hledger -f test.hledger balance
#   5 "80 watt solar panel"
#             4 "car tires"
# 1 "rugged outdoor laptop"  room
#        4 "car tires"    garage
#   5 "80 watt solar panel"
# 1 "rugged outdoor laptop"    workshop
#         -1800.00 EUR  store
# --------------------
#   5 "80 watt solar panel"
#              -1800.00 EUR
#             4 "car tires"
# 1 "rugged outdoor laptop"

I'd rather expect an output like this (all currencies indented like in the total summary):

hledger -f test.hledger balance
#   5 "80 watt solar panel"
#             4 "car tires"
# 1 "rugged outdoor laptop"  room
#             4 "car tires"    garage
#   5 "80 watt solar panel"
# 1 "rugged outdoor laptop"    workshop
#              -1800.00 EUR  store
# --------------------
#   5 "80 watt solar panel"
#              -1800.00 EUR
#             4 "car tires"
# 1 "rugged outdoor laptop"

Solution

For example:

  • calculating the longest currency name in advance and using that as a currency column size
  • let user specify a forced currency column width via command-line flag

PS: hledger is really awesome!

@nobodyinperson nobodyinperson added the A-BUG Something wrong, confusing or sub-standard in the software, docs, or user experience. label Dec 9, 2019
@simonmichael
Copy link
Owner

Thanks! I'm going to note that this is about the balance command, and relabel it as an enhancement request. It may relate to issue #1045 and PR #1052 which are about aligning the output of print.

@simonmichael simonmichael added A-WISH Some kind of improvement request, hare-brained proposal, or plea. balance and removed A-BUG Something wrong, confusing or sub-standard in the software, docs, or user experience. labels Dec 9, 2019
@simonmichael
Copy link
Owner

Can you achieve anything useful with the --format option ? https://hledger.org/hledger.html#customising-the-classic-balance-report

@nobodyinperson
Copy link
Contributor Author

Ah, yes by slightly modifying the default format like balance --format "%100.100(total) %2(depth_spacer)%-(account) it is possible to force the currency column width. Must've jumped over that section in the docs, sorry.

Still, having hledger determine the optimal column width automatically would be nice, if that's feasible in terms of performance.

@simonmichael
Copy link
Owner

I see.. yes, I agree the simple balance report should widen the amounts column automatically so that account names are aligned.

@simonmichael
Copy link
Owner

Relevant code is near https://github.com/simonmichael/hledger/blob/master/hledger/Hledger/Cli/Commands/Balance.hs#L420, where it gets hard-coded to 20.

@nobodyinperson nobodyinperson changed the title Inconsistent alignment for currencies with long names [💰20$ bounty] Inconsistent alignment for currencies with long names Dec 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-WISH Some kind of improvement request, hare-brained proposal, or plea. balance
Projects
None yet
Development

No branches or pull requests

2 participants