From 858a1b2fad41f968d5d8d3470629c0cbb20562b8 Mon Sep 17 00:00:00 2001 From: Gwyneth Morgan Date: Wed, 6 Sep 2023 02:45:48 +0000 Subject: print: Align amounts even when account names are long 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. --- test/regress/align-amounts.test | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 test/regress/align-amounts.test (limited to 'test') diff --git a/test/regress/align-amounts.test b/test/regress/align-amounts.test new file mode 100644 index 00000000..5e79beb7 --- /dev/null +++ b/test/regress/align-amounts.test @@ -0,0 +1,24 @@ +; Amounts should still align even though the account names are much longer than +; the default --account-width. + +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 + +test print +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 +end test -- cgit v1.2.3