daniel-wells / beancount_balancechange Goto Github PK
View Code? Open in Web Editor NEWA Beancount plugin that performs an assertion (check) on the change in balance between two dates.
License: GNU General Public License v2.0
A Beancount plugin that performs an assertion (check) on the change in balance between two dates.
License: GNU General Public License v2.0
Hey there - thanks for writing this plugin; it's exactly what I'm looking for!
I've got a non-trivial setup that I've installed the plugin into via the option "insert_pythonpath" "True"
method. I.e. I've simply curl'd the plugin (at commit ee182fe2c703343969ec4fb396ae7e40ff2c2484
) into a subdir of my setup, which I mention solely to explain the slightly non-standard invocation you might see later in this Issue :-) Hopefully that's not related to the underlying problem - I've validated that the plugin is being invoked, and can demonstrate that if your hunch is User Error ... :-)
I've managed to reduce the journal that creates this error down to quite a small reproducer. Here's the content, and the shell session in action. I've added 2 lines to the plugin, for debugging:
print(entry)
'd as it starts being processedDONE
is printed if the line (update_t1_amounts(entry, t1_amounts, real_root)
) doesn't explode.This should demonstrate both the explosion, and the context in which it happens. It /seems/ to explode on the 2nd Txn it encounters, which I see when commenting out the 2.98GBP Txn, below, and then observing the 7.39GBP Txn explode in its place.
Any ideas?
$ bean-check --version
Beancount 2.3.5
$ python -V
Python 3.9.2
$ find . -type f
./plugins/balance_change.py
./test.beancount
$ cat test.beancount
option "operating_currency" "GBP"
option "insert_pythonpath" "True"
plugin "beancount.plugins.auto_accounts"
plugin "plugins.balance_change"
2020-11-03 custom "balance_change" Expenses:WebHosting 7.39 GBP
since: 2020-11-01
2020-11-02 * "Amazon" "Book" #ctax
Liabilities:OutOfPocketExpenses -1.98 GBP
Expenses:BooksAndJournals:Books:Digital 1.98 GBP
2020-11-02 * "Amazon" "Book" #ctax
Liabilities:OutOfPocketExpenses -2.98 GBP
Expenses:BooksAndJournals:Books:Physical 2.98 GBP
2020-11-02 * "Gandi" "Domain" #ctax
Liabilities:OutOfPocketExpenses -7.39 GBP
Expenses:WebHosting 7.39 GBP
$ bean-check test.beancount
Transaction(meta={'filename': '/home/user/code/company-beancount/tmp/plugin-bug/test.beancount', 'lineno': 11, '__tolerances__': {'GBP': Decimal('0.005')}}, date=datetime.date(2020, 11, 2), flag='*', payee='Amazon', narration='Book', tags=frozenset({'ctax'}), links=frozenset(), postings=[Posting(account='Liabilities:OutOfPocketExpenses', units=-1.98 GBP, cost=None, price=None, flag=None, meta={'filename': '/home/user/code/company-beancount/tmp/plugin-bug/test.beancount', 'lineno': 12}), Posting(account='Expenses:BooksAndJournals:Books:Digital', units=1.98 GBP, cost=None, price=None, flag=None, meta={'filename': '/home/user/code/company-beancount/tmp/plugin-bug/test.beancount', 'lineno': 13})])
DONE
Transaction(meta={'filename': '/home/user/code/company-beancount/tmp/plugin-bug/test.beancount', 'lineno': 15, '__tolerances__': {'GBP': Decimal('0.005')}}, date=datetime.date(2020, 11, 2), flag='*', payee='Amazon', narration='Book', tags=frozenset({'ctax'}), links=frozenset(), postings=[Posting(account='Liabilities:OutOfPocketExpenses', units=-2.98 GBP, cost=None, price=None, flag=None, meta={'filename': '/home/user/code/company-beancount/tmp/plugin-bug/test.beancount', 'lineno': 16}), Posting(account='Expenses:BooksAndJournals:Books:Physical', units=2.98 GBP, cost=None, price=None, flag=None, meta={'filename': '/home/user/code/company-beancount/tmp/plugin-bug/test.beancount', 'lineno': 17})])
<load>:0: Error applying plugin "plugins.balance_change": Traceback (most recent call last):
File "/home/user/.cache/pypoetry/virtualenvs/company-beancount-_c2fM7v6-py3.9/lib/python3.9/site-packages/beancount/loader.py", line 602, in run_transformations
entries, plugin_errors = callback(entries, options_map, *args)
File "/home/user/code/company-beancount/tmp/plugin-bug/plugins/balance_change.py", line 107, in balance_change
update_t1_amounts(entry, t1_amounts, real_root)
File "/home/user/code/company-beancount/tmp/plugin-bug/plugins/balance_change.py", line 89, in update_t1_amounts
entries_to_sum = [k for k,v in t1_amounts.items() if v == "NaN" and entry.date >= k[1]]
File "/home/user/code/company-beancount/tmp/plugin-bug/plugins/balance_change.py", line 89, in <listcomp>
entries_to_sum = [k for k,v in t1_amounts.items() if v == "NaN" and entry.date >= k[1]]
File "/home/user/.cache/pypoetry/virtualenvs/company-beancount-_c2fM7v6-py3.9/lib/python3.9/site-packages/beancount/core/amount.py", line 90, in __eq__
return (self.number, self.currency) == (other.number, other.currency)
AttributeError: 'str' object has no attribute 'number'
Thanks again for publishing this plugin! ๐ โค๏ธ
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.