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

decimal.InvalidOperation without inferred_tolerance_default #734

Open
wzyboy opened this issue Nov 9, 2022 · 0 comments
Open

decimal.InvalidOperation without inferred_tolerance_default #734

wzyboy opened this issue Nov 9, 2022 · 0 comments

Comments

@wzyboy
Copy link
Contributor

wzyboy commented Nov 9, 2022

I encountered this on a bean file generated by a script. Here's a minimal reproducible example:

plugin "beancount.plugins.auto"
;option "inferred_tolerance_default" "CAD:0.01"

2022-10-20 * ""
  Assets:A  -23.71666666666666666666666667 CAD
  Assets:A  -94.86666666666666666666666668 CAD
  Expenses:B

Doing bean-check raises decimal.InvalidOperation: [<class 'decimal.InvalidOperation'>] exception:

Traceback (most recent call last):
  File "/usr/bin/bean-check", line 33, in <module>
    sys.exit(load_entry_point('beancount==2.3.5', 'console_scripts', 'bean-check')())
  File "/usr/lib/python3.10/site-packages/beancount/scripts/check.py", line 49, in main
    entries, errors, _ = loader.load_file(
  File "/usr/lib/python3.10/site-packages/beancount/loader.py", line 90, in load_file
    entries, errors, options_map = _load_file(
  File "/usr/lib/python3.10/site-packages/beancount/loader.py", line 215, in wrapped
    result = function(toplevel_filename, *args, **kw)
  File "/usr/lib/python3.10/site-packages/beancount/loader.py", line 256, in _uncached_load_file
    return _load([(filename, True)], *args, **kw)
  File "/usr/lib/python3.10/site-packages/beancount/loader.py", line 507, in _load
    entries, balance_errors = booking.book(entries, options_map)
  File "/usr/lib/python3.10/site-packages/beancount/parser/booking.py", line 40, in book
    entries, booking_errors = booking_full.book(incomplete_entries, options_map,
  File "/usr/lib/python3.10/site-packages/beancount/parser/booking_full.py", line 112, in book
    entries, errors, _ = _book(entries, options_map, methods)
  File "/usr/lib/python3.10/site-packages/beancount/parser/booking_full.py", line 193, in _book
    interpolated) = interpolate_group(booked_postings, balances, currency,
  File "/usr/lib/python3.10/site-packages/beancount/parser/booking_full.py", line 855, in interpolate_group
    units_number = interpolate.quantize_with_tolerance(tolerances,
  File "/usr/lib/python3.10/site-packages/beancount/core/interpolate.py", line 354, in quantize_with_tolerance
    number = number.quantize(quantum)
decimal.InvalidOperation: [<class 'decimal.InvalidOperation'>]

Beancount version: Beancount 2.3.5 (git:b40819f4; 2022-07-28)

The exception is not raised if option "inferred_tolerance_default" "CAD:0.01" is enabled.

I'm not sure but this issue might be related to: #584

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant