-
-
Notifications
You must be signed in to change notification settings - Fork 320
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
Add option to print with normalized output width #1045
Comments
Related: Automatically Sort and Align Ledger Transactions in VIM. It looks like the vim-ledger plugin has some pattern matching based tools for this. They do help with my use case, but they are not a substitute for |
Related code: https://github.com/simonmichael/hledger/blob/master/hledger-lib/Hledger/Data/Transaction.hs#L206 Thanks. I've wanted to do something about this for a long time. Here's a summary of current behaviour: input
hledger print
ledger print
ledger-mode C-tab (ledger-post-align-xact)
Or, with ledger-post-amount-alignment-at set to :decimal instead of :end :
|
Some impressions of pros and cons: hledgerPro
Con
ledgerPro
Con
ledger-mode (:end)Pro
Con
ledger-mode (:decimal)Pro
Con
|
What do y'all like about these ? My beancount is broken, do it or other ledgerlikes do anything interesting ? Here's a quick hledger proposal A
proposal B
Note these rules all try to produce mostly-tidy output while looking at just one transaction at a time; we could align perfectly by looking at the whole output, but presumably that's not good for efficiency. |
I won't mention what vim-ledger does with your example input because it's badly broken, but here is what I would like to see:
This is very similar to your proposal A, but tweaked as follows
|
Ie, align the decimal place of the rightmost amount, whether it be the posting amount or a price amount ? That seems weird to me. Also if we're going to align around column 50 it might as well be 52 to minimise change when converting between ledger/ledger-mode/hledger. |
I didn't have a better idea how to align price amounts that do not have a total amount shown in the posting, so the price seemed like the right thing to match. Did you have a better idea? I picked 50 out of a hat because for typical 2 digit precision currency that places the right edge of amounts at 52 to match |
ledger and ledger-mode align the main posting amount, allowing any unit/total price to hang off to the right. I see. Showing two decimal places is fairly common, so if we align the decimal point at 50, it may often match ledger's output. Whereas if we align the right-most digit, 52 would work better. Whether an amount-aligning option like You could also go all out and align each separate part for readability, at the cost of more screen space:
|
Just be sure that last suggestion is behind an For myself |
Ok, let's aim to align posting amount's decimal point at 50 for a start and see how that looks. Probably as a separate code path for now, to allow comparing old and new output for a while. |
Sure, but since when was the unit quantity EVER the most likely thing to be comparable to other posting amounts? The unit price may not match in amount, but at least it's more likely to be the same commodity (and hence more useful to align), while the total price is almost certainly going to correspond to something else in the transaction. Hence I don't think following |
You could be right. I more often have unit prices, not total prices, which are less comparable. And to me aligning two semantically different things feels weird. I think it will take some testing/real world use to know. We might even end up finding the simple right-align all behaviour is fastest and best after all. Are people really wanting to "sum up" amounts when reading print output ? |
It's a bit tricky! I believe I see how to do it, but I probably won't do it this month. If @alerque or anyone wants to tackle it sooner I can share WIP and notes. |
I can't promise my Haskell will get anywhere substantial, but I'd be happy to poke at WIP if you put it in a branch somewhere. I'll be doing lots more accounting this month so I might get ants in my pants and try to make something work. |
And use it. Plus some comments on decimal point aligning.
Great! Pushed as #1052. |
I use
hledger
itself to process and normalize all my ledgers whether imported from other sources or manually composed. Theprint
command makes sure the values for every posting in a transaction are aligned.Becomes the much nicer:
However the column at which this alignment happens varies from transaction to transaction. Consider this case:
Normalizing this using
print -x
will return each transaction aligned at a a different place:In this case
ledger print
is superior in that all transactions are aligned together:I considered normalizing through
ledger
, but there are many other ways in whichhledger print
is preferable, such as alignment of postings with commodity costs:Personally I really like having the final cost of the posting right aligned as in the
hledger
output.What I would like is some kind of format option that specifies the right edge to align to (if possible without truncation of course).
The reason this would be preferable to a fully automatic width guesser that spans multiple transactions is that I could standardize on a width such that future changes such as renaming an account or moving transactions from one ledger to another would not cause churn in my Git commit history just because the length of an account string changed. Right now running
git blame
on a Ledger file shows quite a bit of useless results as every posting in a transaction can change when just one posting is edited (because the column amounts are aligned to changes).The text was updated successfully, but these errors were encountered: