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

print: Align amounts even when account names are long #2289

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

gwymor
Copy link
Contributor

@gwymor gwymor commented Sep 6, 2023

When the account name is longer than the --account-width (default 36), the amounts stop aligning:

2023/01/01 Transaction with long account names
    Assets:Very:Long:Account:Name:That:Will:Push:The:Amount     -10 ABC
    Assets:Another:Long:Account:Name:That:Will:Push:The:Amount     -10 ABC
    Expenses:Short                            20 ABC

One can set a larger --account-width, but that is not a great solution for cases where you have only a few accounts with problematically long names. Instead, keep the current account width wherever possible, but when an account name is longer than the account width, account for that and still align the values:

2023/01/01 Transaction with short account names
    Assets:Short                             -10 ABC
    Assets:Short                             -10 ABC
    Expenses:Short                            20 ABC

2023/01/01 Transaction with long account names
    Assets:Very:Long:Account:Name:That:Will:Push:The:Amount        -10 ABC
    Assets:Another:Long:Account:Name:That:Will:Push:The:Amount     -10 ABC
    Expenses:Short                                                  20 ABC

This is similar to hledger's behavior.

When the account name is longer than the --account-width (default 36),
the amounts stop aligning:

    2023/01/01 Transaction with long account names
        Assets:Very:Long:Account:Name:That:Will:Push:The:Amount     -10 ABC
        Assets:Another:Long:Account:Name:That:Will:Push:The:Amount     -10 ABC
        Expenses:Short                            20 ABC

One can set a larger --account-width, but that is not a great solution
for cases where you have only a few accounts with problematically long
names. Instead, keep the current account width wherever possible, but
when an account name is longer than the account width, account for that
and still align the values:

    2023/01/01 Transaction with short account names
        Assets:Short                             -10 ABC
        Assets:Short                             -10 ABC
        Expenses:Short                            20 ABC

    2023/01/01 Transaction with long account names
        Assets:Very:Long:Account:Name:That:Will:Push:The:Amount        -10 ABC
        Assets:Another:Long:Account:Name:That:Will:Push:The:Amount     -10 ABC
        Expenses:Short                                                  20 ABC

This is similar to hledger's behavior.
@afh
Copy link
Member

afh commented Sep 7, 2023

What are your thoughts around this functionality in formats (--format option) rather than the default ledger behaviour?

@gwymor
Copy link
Contributor Author

gwymor commented Sep 8, 2023

To me it seems always aligning the amounts is sensible default behavior, and what the average user likely expects, but I wouldn't mind a dedicated --please-always-align-values-even-with-long-account-names option (working title). I would prefer not to carry around a long custom format string in my configuration (and watch if the upstream default ever changes so I can make corresponding changes to my config); in that case I might stick with the current default behavior.

@afh afh added the enhancement New feature or request label Dec 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants