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

imp:print: zero posting amounts are now shown with commodity & style #2075

Merged
merged 8 commits into from
Aug 27, 2023

Conversation

simonmichael
Copy link
Owner

I noticed that print strips the commodity symbol from zero posting amounts, transforming eg $0 to 0. This can be awkward when trying to clean up/regenerate a journal, eg. This PR makes print (and print-like) reports preserve the commodity of zeroes more carefully. Other reports like balance and register are expected to work as before, but any additional testing is welcome.

print now shows zero posting amounts with their original commodity
symbol and the corresponding style (instead of stripping the symbol).

If an inferred amount has multiple zeroes in different commodities,
a posting is displayed for each of these.

Possible breaking changes:

showMixedAmountLinesB, showAmountB, showAmountPrice now preserve
commodityful zeroes when rendering. This is intended to improve print output,
but it seems possible it might also affect balance and register reports,
though our tests show no change in those.

Example:

# 1. print preserves the commodity symbol of zero amounts.
2023-01-01
  (a)    0 A @ 0 B = 0 A @ 0 B

# 2. The inferred balancing amount for zeros in multiple commodities
# is preserved and shown accurately, with a posting for each commodity.
2023-01-01
  a   0 A
  b   0 B
  z
$ hledger print -x
2023-01-01
    (a)       0 A @ 0 B = 0 A @ 0 B

2023-01-01
    a             0 A
    b             0 B
    z             0 A
    z             0 B

print now shows zero posting amounts with their original commodity
symbol and the corresponding style (instead of stripping the symbol).

If an inferred amount has multiple zeroes in different commodities,
a posting is displayed for each of these.

Possible breaking changes:

showMixedAmountLinesB, showAmountB, showAmountPrice now preserve
commodityful zeroes when rendering. This is intended to improve print output,
but it seems possible it might also affect balance and register reports,
though our tests show no change in those.
@simonmichael simonmichael added A-WISH Some kind of improvement request, hare-brained proposal, or plea. print labels Aug 24, 2023
@simonmichael
Copy link
Owner Author

Merging this to get more testing.

@simonmichael simonmichael merged commit ff730f7 into master Aug 27, 2023
1 check passed
@simonmichael simonmichael deleted the 2023-08-print-zero-commodity branch August 27, 2023 06:34
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. print
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant