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 can show unbalanced transactions with a commodity directive #931

Open
simonmichael opened this Issue Nov 29, 2018 · 1 comment

Comments

Projects
None yet
1 participant
@simonmichael
Copy link
Owner

simonmichael commented Nov 29, 2018

This frequently annoys me when I need to re-parse print's output, eg when doing a query that requires a pipeline. Time to do something about it.

; limit display precision to 2 places
commodity $0.00

1/1
   a  -$0.01
   b   $0.005
   c   $0.005

print shows an unbalanced transaction:

$ hledger print
2018/01/01
    a          $-0.01
    b               0
    c               0

which can not be re-parsed:

$ hledger print | hledger -f- print
hledger: "-" (lines 1-4)
could not balance this transaction (real postings are off by $-0.01)
2018/01/01
    a          $-0.01
    b               0
    c               0


@simonmichael

This comment has been minimized.

Copy link
Owner

simonmichael commented Nov 29, 2018

PS, a use case to justify this: fractions of a cent don't typically arise in day to day transactions, but they do arise eg when splitting shared expenses according to some rule, eg splitting an odd amount 50-50.

You can work around it by putting the extra cent on one amount or the other, but this requires thought and manual intervention and can cause disagreement with external systems - I would rather use the correct mathematical split.

You can also work around it by temporarily commenting out the commodity directive to allow unlimited display precision. But this is manual and annoying (and now all dollar amounts are rendered with three decimal places).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment