joshuabach / gnucash-web

A simple, mobile-friendly webinterface for GnuCash
GNU General Public License v3.0
118 stars 18 forks source link

Error when root account does not have a defined commodity #42

Closed williamjacksn closed 10 months ago

williamjacksn commented 1 year ago
ERROR [gnucash_web] Exception on /book/accounts/ [GET]
Traceback (most recent call last):

  ... removed ...

  File "/home/python/venv/lib/python3.11/site-packages/gnucash_web/templates/forms.j2", line 26, in template
    step="{{ 1 / account.commodity.fraction }}"
    ^^^^^^^^^^^^^^^^^^^^^^^^^
jinja2.exceptions.UndefinedError: 'None' has no attribute 'fraction'

I'm using a SQLite GnuCash file. Somehow my root account does not have a defined commodity.

image

I haven't done anything strange with this book, so I don't know if this is normal or how to correct it.

joshuabach commented 1 year ago

Interesting, all my books seem to have a commodity in the root account. Maybe this has to do with the books default currency. But I thought that all books had those.

Either way, this only occurs in the new/edit transaction form, which should never be generated for the root account. I think I forgot to check for that case when generating the edit-transaction form.

See templates/account.j2:129

So should be an easy fix.