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

Transaction does not balance with @@: -0.000000000000000000000001 #246

Closed
blais opened this issue Mar 20, 2018 · 6 comments
Closed

Transaction does not balance with @@: -0.000000000000000000000001 #246

blais opened this issue Mar 20, 2018 · 6 comments
Labels
BUG This is a bug, not a feature request; something isn't working. core-ops Component: Core data structures and stream ops P1 High priority, not breaking but hindering or lessening existing functionality

Comments

@blais
Copy link
Member

blais commented Mar 20, 2018

Original report by Martin Michlmayr (Bitbucket: tbm13, GitHub: tbm).


2014-01-01 open Assets:Test

2018-03-20 * "Test"
  Assets:Test                42.30 USD @@ 5640 MR
  Assets:Test                            -5640 MR

gives

Clearly it should balance but it doesn't because of rounding when you convert from a total price to a unit price.

Maybe beancount should automatically infer a tolerance of whatever the precsion of the datatype you use to store is.

Also, another argument for issue #194 to somehow store the total price/cost.

@blais
Copy link
Member Author

blais commented Mar 20, 2018

Original comment by Martin Michlmayr (Bitbucket: tbm13, GitHub: tbm).


I just noticed I was running an old version. Anyway, this is still there:

Transaction does not balance: (-0.000000000000000000000001 MR)

@blais
Copy link
Member Author

blais commented Mar 27, 2019

Original comment by Martin Michlmayr (Bitbucket: tbm13, GitHub: tbm).


Issue #384 has another test case for the same issue.

@blais
Copy link
Member Author

blais commented Apr 10, 2019

Original comment by Martin Blais (Bitbucket: blais, GitHub: blais).


This is due to inference; working as expected.
If you use bean-doctor context you will see the absence of an inferred tolerance for MR (understandably, there are no digits):

#!python

------------ Transaction

2018-03-20 * "Test"
  Assets:Test  42.30 USD @ 133 MR  ; 5639.999999999999999999999999 MR
  Assets:Test  -5640 MR            ;                         -5640 MR


Residual: (-0.000000000000000000000001 MR)
Tolerances: USD=0.005

You can get rid of the warning by setting a reasonable default for the inferred tolerance for currency MR:

#!python

option "inferred_tolerance_default" "MR:0.00001"

@blais
Copy link
Member Author

blais commented Apr 10, 2019

Original comment by Martin Blais (Bitbucket: blais, GitHub: blais).


Working as intended.

@blais blais closed this as completed Apr 10, 2019
@blais
Copy link
Member Author

blais commented Apr 10, 2019

Original comment by Martin Michlmayr (Bitbucket: tbm13, GitHub: tbm).


I think there are 2 problems here:

  1. I have 42.30 USD @@ 5640 MR, so why does bean-doctor show 42.30 USD @ 133 MR and not @ 133.3333 (which it clearly uses internally)

  2. I disagree this is invalid. I specified @@ 5640 MR, so it should balance just fine. As a user, this error doesn't make any sense and is not working as intended. I know you store things internally in a different way, but this is what's causing the problem. So I think if the residual is as small as the storage type of this variable, then beancount should automatically ignore it.

As a user, I shouldn't need to specify inferred_tolerance_default because the transaction I gave balances 100%. Same with issue #384. The fact that there are two bug reports show that this is not working for users.

@blais blais added P1 High priority, not breaking but hindering or lessening existing functionality core-ops Component: Core data structures and stream ops BUG This is a bug, not a feature request; something isn't working. labels May 22, 2020
@tbm
Copy link
Contributor

tbm commented Nov 30, 2022

Can this be opened?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BUG This is a bug, not a feature request; something isn't working. core-ops Component: Core data structures and stream ops P1 High priority, not breaking but hindering or lessening existing functionality
Projects
None yet
Development

No branches or pull requests

2 participants