Post
Topic
Board Bitcoin Discussion
Re: GnuCash support for alternative/non-ISO currencies
by
FatherMcGruder
on 29/09/2011, 03:31:00 UTC
Well, I decided to make GnuCash treat the bitcoin like a regular currency myself. I downloaded the source code and modified two files, iso-4217-currencies.scm and iso-4217-currencies.c, both in '/gnucash-2.4.7.1b/src/engine/'. To the former I added the following lines:
Code:
;; non-standard/private - Not ISO4217, but we designate it as such so that Gnucash will treat it as such.

( "Bitcoin" "bitcoin" "satoshi" "ISO4217" "BTC" "nil" 100000000 100000000 "BTC" ) ;; Would have used XBC as the mnemonic to conform with ISO4217, but it appears to have been taken.

( "Ithaca HOUR" "hour" "hour" "ISO4217" "IHR" "nil" 6 10 "" )
";;" indicates a comment.

To the latter I added:
Code:
  {
    const char *fullname = "Bitcoin";
    gnc_commodity *c = gnc_commodity_new(book,
CUR_I18N(fullname),
                                         "ISO4217",
                                         "BTC",
                                         "nil",
                                         100000000);

    if(!c) {
      PWARN("failed to create commodity for currency %s", fullname);
    } else {
      if(!gnc_commodity_table_insert(table, c)) {
        PWARN("failed to insert %s into commodity table", fullname);
      }
    }
  }

  {
    const char *fullname = "Ithaca HOUR";
    gnc_commodity *c = gnc_commodity_new(book,
CUR_I18N(fullname),
                                         "ISO4217",
                                         "IHR",
                                         "nil",
                                         10);

    if(!c) {
      PWARN("failed to create commodity for currency %s", fullname);
    } else {
      if(!gnc_commodity_table_insert(table, c)) {
        PWARN("failed to insert %s into commodity table", fullname);
      }
    }
Although I'm not sure if I needed to do so.

I also made sure to add the following lines to '/usr/share/xml/iso-codes/iso_4217.xml':
Code:


Then, I compiled GnuCash:
Code:
sudo apt-get build-dep gnucash
sudo sh configure --prefix=/opt/gnucash
sudo make
sudo make install

That puts an executable here: /opt/gnucash/bin/gnucash

Ta da!

Keep in mind that I started with GnuCash 2.4.7 and that I am running it on Ubuntu 11.04. YMMV.