Issue #357: Cannot run booking_full.book on transactions created with data.create_simple_posting (blais/beancount)

9 views
Skip to first unread message

Robert Sesek

unread,
Dec 31, 2018, 12:16:30 AM12/31/18
to bean...@googlegroups.com
New issue 357: Cannot run booking_full.book on transactions created with data.create_simple_posting
https://bitbucket.org/blais/beancount/issues/357/cannot-run-booking_fullbook-on

Robert Sesek:

In creating a one-time converter for some account data files, I wrote code that basically did this:

```python
txn = data.Transaction(…)
data.create_simple_posting(txn, 'Assets', 100.00 'USD')
data.create_simple_posting(txn, 'Expenses', None, None)
booking_full.book([txn], …)
```

My converter ultimately uses printer to produce a beancount file. But I want to run book() manually to determine when a transaction does not balance. If an error exists between two specific accounts in specific currencies, the script inserts an additional posting to assume the rounding error.

But when running the book() on data like the above, I encountered two errors:

```
> if units.currency is MISSING:
E AttributeError: 'NoneType' object has no attribute 'currency'
beancount/parser/booking_full.py:451: AttributeError
```

```
> new_posting.meta[interpolate.AUTOMATIC_META] = True
E TypeError: 'NoneType' object does not support item assignment
beancount/parser/booking_full.py:894: TypeError
```

These errors occur because the Postings created by create_simple_posting() have None for fields (`units` and `meta` respectively).

The booking algorithm normally runs on parser-produced data, which do not have this problem. Since the transaction's postings were created with the data API, I think the booking algorithm should be able to handle them.

Patch and test forthcoming.


Reply all
Reply to author
Forward
0 new messages