jbms / beancount-import

Web UI for semi-automatically importing external data into beancount
GNU General Public License v2.0
393 stars 103 forks source link

Parsing/matching error - postings with only currency (no amount) #67

Open mbafford opened 4 years ago

mbafford commented 4 years ago

Problem

Having a posting entry with a currency, but no amount, causes beancount-import to raise an error and drop into the debugger. The file validates fine from beancount's perspective.

Problematic beancount data:

2020-09-12 ! "Chase"
  Assets:Checking                    -100.00 USD
  Liabilities:Credit-Cards:Chase             USD

bean-check and fava accept the file, but beancount-import raises an error:

Fixed data

(works fine with beancount-import and bean-check and fava)

2020-09-12 ! "Chase"
  Assets:Checking                    -100.00 USD
  Liabilities:Credit-Cards:Chase

beancount-import error

  File "beancount-import/beancount_import/webserver.py", line 502, in _handle_reconciler_loaded
    loaded_reconciler = loaded_future.result()
  File "python3.7/concurrent/futures/_base.py", line 428, in result
    return self.__get_result()
  File "python3.7/concurrent/futures/_base.py", line 384, in __get_result
    raise self._exception
  File "beancount-import/beancount_import/thread_helpers.py", line 13, in wrapper
    f.set_result(fn(*args, **kwargs))
  File "beancount-import/beancount_import/reconcile.py", line 397, in __init__
    self._preprocess_entries()
  File "beancount-import/beancount_import/reconcile.py", line 442, in _preprocess_entries
    posting_db.add_transaction(entry)
  File "beancount-import/beancount_import/matching.py", line 258, in add_transaction
    transaction, self.is_cleared):
  File "beancount-import/beancount_import/matching.py", line 779, in get_matchable_postings
    (p for p, _ in weighted_postings), is_cleared):
  File "beancount-import/beancount_import/matching.py", line 724, in get_aggregate_posting_candidates
    posting.units.number > ZERO),
TypeError: '>' not supported between instances of 'type' and 'decimal.Decimal'
> beancount-import/beancount_import/matching.py(724)get_aggregate_posting_candidates()
-> posting.units.number > ZERO),

Comments

In my case this is just a typo when copying an existing record and editing manually, so I have no problem fixing the source data, but I imagine most people would turn to bean-check to validate their journal if they do encounter problems, so beancount-import would benefit from handling this the same way.

Herts commented 2 years ago

For those who cannot find where the trigger transaction is, use global search to look for regex [a-zA-Z] +USD .

hexhexD commented 1 year ago

For those who cannot find where the trigger transaction is, use global search to look for regex [a-zA-Z] +USD .

You the real mvp my guy.