Giter Site home page Giter Site logo

gnucash-to-beancount's People

Contributors

henriquebastos avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

gnucash-to-beancount's Issues

'datetime.date' object has no attribute 'date'

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

sqlite3.DatabaseError file is not a database

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?

Is this project still maintained? There are several open pull requests, some of which are needed to even work on current systems.

ValueError: Unsupported table versions

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

TypeError: unsupported operand type(s) for *: 'Decimal' and 'cdecimal.Decimal'

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?

AttributeError: 'NoneType' object has no attribute 'fullname'

$ 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'

Exception when converting a transaction with a "zero" split

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.

Add support for Scheduled Transactions

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:

  1. Record all scheduled transactions as a beancount custom directive, persisting the details as meta.
  2. Link all occurred transactions to the custom directive created.

Here are some 1st thoughts on what needs to be done:

  • Add scheduled transactions to the sample file (1 st, 2 occurred, 1 due/pending);
  • Define which information about scheduled transactions will be persisted;
  • Define a standard for the link;
  • Write in text a resulting beancount statement;
  • Implement it.

decimal.InvalidOperation: [<class 'decimal.DivisionUndefined'>]

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?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.