henriquebastos / gnucash-to-beancount Goto Github PK
View Code? Open in Web Editor NEWGnucash to Beancount Converter.
License: GNU General Public License v2.0
Gnucash to Beancount Converter.
License: GNU General Public License v2.0
While attempting to convert my gnucash file, I ran into this error. I was able to reproduce it using the data/sample.gnucash
file called by the projects ./tests.sh
script:
$ gnucash-to-beancount data/sample.gnucash
Traceback (most recent call last):
File "/Users/zzz/.virtualenvs/bean/bin/gnucash-to-beancount", line 11, in <module>
load_entry_point('gnucash-to-beancount', 'console_scripts', 'gnucash-to-beancount')()
File "/Users/zzz/dev/bean/gnucash-to-beancount/src/gnucash_to_beancount/cli.py", line 39, in main
entries = convert.load_entries(book)
File "/Users/zzz/dev/bean/gnucash-to-beancount/src/gnucash_to_beancount/convert.py", line 16, in load_entries
first_date = book.transactions[0].post_date.date()
AttributeError: 'datetime.date' object has no attribute 'date'
The error is occurring because three locations in the code appear to expect a datetime.datetime
object, and call its .date()
method to get a datetime.date
object. But they are already receiving a datetime.date
object.
Here is a (very rough) commit which works around the issue.
https://github.com/qqrs/gnucash-to-beancount/tree/fix_date_error
I saw the following error while attempting to convert a .gnucash
file.
sqlalchemy.exc.DatabaseError: (sqlite3.DatabaseError) file is not a database [SQL: 'SELECT gnclock.hostname, gnclock.pid \nFROM gnclock'] (Background on this error at: http://sqlalche.me/e/4xp6)
I believe this is because it was an xml gnucash file, not a sqlite gnucash file.
I opened the file in Gnucash and used "Save as" to save in sqlite format to get past this error.
Documenting here in case anyone else runs into the same issue.
Is this project still maintained? There are several open pull requests, some of which are needed to even work on current systems.
When trying to open a certain GnuCash SQLite database that has been edited with a recent version, this script, also in the version from https://github.com/AndrewStein/gnucash-to-beancount, throws:
Traceback (most recent call last):
File "/home/yala/.local/bin/gnucash-to-beancount", line 11, in <module>
load_entry_point('gnucash-to-beancount==1.0b0', 'console_scripts', 'gnucash-to-beancount')()
File "/home/yala/.local/lib/python3.7/site-packages/gnucash_to_beancount/cli.py", line 38, in main
with piecash.open_book(options.filename, open_if_lock=True) as book:
File "/home/yala/.local/lib/python3.7/site-packages/piecash/core/session.py", line 350, in open_book
raise ValueError("Unsupported table versions")
This is known and reported upstream as sdementen/piecash#126
Hi, I tested out your tool against my gnucash db file, and getting this stack trace.
File "/home/user/.local/lib/python3.6/site-packages/gnucash_to_beancount/directives.py", line 97, in units_for
number = split.quantity * data.Decimal('1.0')
TypeError: unsupported operand type(s) for *: 'Decimal' and 'cdecimal.Decimal'
Am I missing a package or something?
$ gnucash-to-beancount family.gnucash > family.beancount
Traceback (most recent call last):
File "/usr/local/bin/gnucash-to-beancount", line 11, in <module>
load_entry_point('gnucash-to-beancount==1.0b0', 'console_scripts', 'gnucash-to-beancount')()
File "/usr/local/lib/python3.7/site-packages/gnucash_to_beancount-1.0b0-py3.7.egg/gnucash_to_beancount/cli.py", line 39, in main
entries = convert.load_entries(book)
File "/usr/local/lib/python3.7/site-packages/gnucash_to_beancount-1.0b0-py3.7.egg/gnucash_to_beancount/convert.py", line 35, in load_entries
entries.append(TransactionWithPostings(txn))
File "/usr/local/lib/python3.7/site-packages/gnucash_to_beancount-1.0b0-py3.7.egg/gnucash_to_beancount/directives.py", line 144, in TransactionWithPostings
return Transaction(txn, [Posting(split) for split in txn.splits])
File "/usr/local/lib/python3.7/site-packages/gnucash_to_beancount-1.0b0-py3.7.egg/gnucash_to_beancount/directives.py", line 144, in <listcomp>
return Transaction(txn, [Posting(split) for split in txn.splits])
File "/usr/local/lib/python3.7/site-packages/gnucash_to_beancount-1.0b0-py3.7.egg/gnucash_to_beancount/directives.py", line 122, in Posting
account = account_name(split.account)
File "/usr/local/lib/python3.7/site-packages/gnucash_to_beancount-1.0b0-py3.7.egg/gnucash_to_beancount/directives.py", line 51, in account_name
name = account.fullname
AttributeError: 'NoneType' object has no attribute 'fullname'
Let's say you want to track a cash dividend and the commodity this dividend came from. In Gnucash you can simply add an empty split in the transaction indicating the commodity that originated the cash dividend (not reinvested).
I.e.:
Income:Dividends: 10 USD
Assets:Brokerage: 10 USD
Assets:Brokerage:Comodity
The third split does not do anything, but it is useful when generating reports to track the total return of a stock account.
The hack I am using is to modify directives.py to return number = split.value if split.quantity == 0 in price_for(split).
This is a hack that returns lines in the beancount file that I have to remove manually for reports to be correct.
This started as a discussion on the Beancount mailing list.
gnucash-to-beancount
already supports occurred transactions, but no reference to scheduled transactions are kept.
An idea to keep this information is:
custom
directive, persisting the details as meta
.custom
directive created.Here are some 1st thoughts on what needs to be done:
Hello,
attempt to convert my personal Guncash file to Benacount results in:
gnucash-to-beancount personal.db > personal.beancount
Traceback (most recent call last):
File "/home/gour/.virtualenvs/beancount/bin/gnucash-to-beancount", line 11, in <module>
sys.exit(main())
File "/home/gour/.virtualenvs/beancount/lib/python3.5/site-packages/gnucash_to_beancount/cli.py", line 39, in main
entries = convert.load_entries(book)
File "/home/gour/.virtualenvs/beancount/lib/python3.5/site-packages/gnucash_to_beancount/convert.py", line 35, in load_entries
entries.append(TransactionWithPostings(txn))
File "/home/gour/.virtualenvs/beancount/lib/python3.5/site-packages/gnucash_to_beancount/directives.py", line 140, in TransactionWithPostings
return Transaction(txn, [Posting(split) for split in txn.splits])
File "/home/gour/.virtualenvs/beancount/lib/python3.5/site-packages/gnucash_to_beancount/directives.py", line 140, in <listcomp>
return Transaction(txn, [Posting(split) for split in txn.splits])
File "/home/gour/.virtualenvs/beancount/lib/python3.5/site-packages/gnucash_to_beancount/directives.py", line 122, in Posting
price = price_for(split)
File "/home/gour/.virtualenvs/beancount/lib/python3.5/site-packages/gnucash_to_beancount/directives.py", line 110, in price_for
number = abs(split.value / split.quantity)
decimal.InvalidOperation: [<class 'decimal.DivisionUndefined'>]
Any idea without having the source file?
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.