Bitcoin Forum

Bitcoin => Bitcoin Discussion => Topic started by: FatherMcGruder on July 18, 2011, 02:48:17 PM



Title: GnuCash support for alternative/non-ISO currencies
Post by: FatherMcGruder on July 18, 2011, 02:48:17 PM
"Make it easier for users to work with alternative/non-ISO/private currencies. (http://uservoice.com/a/35yKe)"

Folks, I made the above suggestion to the GnuCash developers to include better support for currencies that do not meet ISO requirements, like the bitcoin. I hope you'll all up vote it.


Title: Re: GnuCash support for alternative/non-ISO currencies
Post by: FatherMcGruder on September 20, 2011, 12:18:54 PM
Bump.


Title: Re: GnuCash support for alternative/non-ISO currencies
Post by: FatherMcGruder on September 29, 2011, 03:31:00 AM
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:
<iso_4217_entry letter_code="BTC" numeric_code="nil" currency_name="Bitcoin"/>
<iso_4217_entry letter_code="IHR" numeric_code="nil" currency_name="Ithaca HOUR"/>

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

http://farm7.static.flickr.com/6159/6193624745_22e3826313.jpg (http://www.flickr.com/photos/29358511@N07/6193624745/)Ta da!

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


Title: Re: GnuCash support for alternative/non-ISO currencies
Post by: julz on September 29, 2011, 03:40:31 AM
Thanks for drawing my attention to GnuCash - I'll be giving it a whirl for sure.

Upvoted.

I hope the changes get integrated into the main builds.


Title: Re: GnuCash support for alternative/non-ISO currencies
Post by: FatherMcGruder on September 29, 2011, 01:10:04 PM
I hope the changes get integrated into the main builds.
Well, if the GnuCash developers decide to do so, and I doubt they will, they won't take my route. I had to modify a system file, iso_4217.xml, after all. Furthermore, it works by pretending that the target non-ISO4217 currencies do qualify as ISO4217. That just strikes me as an undignified kludge.

I doubt that the developers will update GnuCash to include the bitcoin or any non-ISO4217 currency because they've stated (https://bugzilla.gnome.org/show_bug.cgi?id=648627) that they won't include currencies that ISO4217 doesn't recognize. They also seem content with forcing users to make do (https://bugzilla.gnome.org/show_bug.cgi?id=130920), rather than coding a proper feature that would users to easily define their own non-standard currencies. Someone needs to actually code the feature and submit it. If the developers reject it then we can just fork the project.


Title: Re: GnuCash support for alternative/non-ISO currencies
Post by: ne1 on September 29, 2011, 04:10:27 PM
Thanks for that.  Awsome work.


Title: Re: GnuCash support for alternative/non-ISO currencies
Post by: ripper234 on December 19, 2012, 10:07:04 PM
Reviving thread - there's also a Bitcoin specific ticket on UserVoice, please vote.

Any other alternatives that are better suited for Bitcoin? Any of those support price import from Mt. Gox (to view an entire account that's composed of BTC & USD)?


Title: Re: GnuCash support for alternative/non-ISO currencies
Post by: EskimoBob on January 24, 2013, 09:06:43 PM
Looks like people just did not get it over at http://gnucash.1415818.n4.nabble.com/For-The-Love-Of-Bitcoin-td4348895i20.html and wasted more time on arguing about ISO or not ISO, than it have taken to write the cod and get the BTC on the currency list.

FatherMcGruder, maybe you can write a batch and get it included in the next version?
If you do not mind, can you please add Litecoin too :)

(actually, add your own currency "module" is even better)

 


Title: Re: GnuCash support for alternative/non-ISO currencies
Post by: Sukrim on January 24, 2013, 11:04:15 PM
Please just mirror the sourcecode on github + create a branch that includes your "fix". Ideally also provide some compiled versions.

Also to make the patch cleaner you might wanna look into extending GnuCash to include http://tools.ietf.org/html/draft-stanish-x-iso4217-a3-01 instead of just ISO4217, which would be the preferred solution by the BTC (BTCX) community anyways. Having a patch ready once the gnuCash developers decide to go along with that would be great.

It's OpenSource after all...


Title: Re: GnuCash support for alternative/non-ISO currencies
Post by: bitcoinsrule on January 25, 2013, 01:37:27 AM
Ledger.

Do a search for "ledger" on the reddit subereddit /r/bitcoin. Works great for bitcoin, has a script that pulls spot price from mtgox and has gotten me to get off gnucash completely. Takes some getting used to but is awesome.  Won't be for everyone.


Title: Re: GnuCash support for alternative/non-ISO currencies
Post by: EskimoBob on January 27, 2013, 08:45:57 PM
I am going to use FIM for LTC "place holder" because it ceased to be legal tender on 28 February 2002.
I think this is a really good example why gnucash developers obsession with ISO labels is a bit strange. Yes, those labels are useful but there is no need to exclude the option for adding a custom currencies to gnucash.


Title: Re: GnuCash support for alternative/non-ISO currencies
Post by: Sukrim on January 28, 2013, 07:44:24 PM
Ledger.

Do a search for "ledger" on the reddit subereddit /r/bitcoin. Works great for bitcoin, has a script that pulls spot price from mtgox and has gotten me to get off gnucash completely. Takes some getting used to but is awesome.  Won't be for everyone.

...or just use this link:
http://www.ledger-cli.org/

It still is actively maintained + developed (https://github.com/ledger/ledger).

Anyways, seems VERY nice, if only there would be some nice frontends for reports, graphs and stuff. Also that text file approach sounds interesting, but might not be appealing to everyone.


Title: Re: GnuCash support for alternative/non-ISO currencies
Post by: bitcoinsrule on January 28, 2013, 09:31:28 PM
...or just use this link:
http://www.ledger-cli.org/

It still is actively maintained + developed (https://github.com/ledger/ledger).

Anyways, seems VERY nice, if only there would be some nice frontends for reports, graphs and stuff. Also that text file approach sounds interesting, but might not be appealing to everyone.

It's VERY VERY nice actually, (for me anyway). :) At any rate, here is the subreddit that introduced it to me, it gives out a very though explanation on how to get started and might be easier than the docs.

http://www.reddit.com/r/Bitcoin/comments/155gw5/heres_how_you_use_ledger_to_account_for_bitcoin/

Also, there's a link to a python script that will pull spot prices for silver, gold and BTC.

As far as the frontend support goes, it supports GNUplot for graphs and such.


Title: Re: GnuCash support for alternative/non-ISO currencies
Post by: Rassah on January 29, 2013, 03:48:03 PM
I was totally blasting Ledger as a crappy tool only suited for Linux command-line geeks, and was using GNUCash only, but Ledger still eventually won me over. It's still a bit of a pain to have to remember some of the commands when running reports, but the text file approach does make it somewhat easier to be more precise, and so far I've been able to find every accounting function and report that I've needed from GNUCash. Currently using Ledger for Bitcoin100.org's finances.


Title: Re: GnuCash support for alternative/non-ISO currencies
Post by: EskimoBob on January 29, 2013, 08:47:45 PM
I am going to give up on gnucash unless I find a workaround for problems I have with reports in multiple currencies.
I actually got the books looking and doing what we needed in the ART project (http://forum.litecoin.net/index.php/topic,980.0.html). When I wanted to generate reports, and this damn thing refused to use any of the exchange rates I had entered, I walked away.
To put it politely, cnugash is a joke when it comes to multiple currencies (and do not get me started on this "no user added currencies" BS they got going there!)

Rassah, thanks for the encouragement :) I think I am going to look in to Ledger too.  
We only have few transactions at the moment so this is a perfect time to test this stuff out.


Title: Re: GnuCash support for alternative/non-ISO currencies
Post by: Rassah on January 30, 2013, 02:31:49 AM
Just a tip, whenever I exchange some USD into BTC, I do something like
Assets:BTCWallet ฿20 @@ $384

The @@ tells it the total you paid for the currency and calculates the exchange rate for you (I can also use just one @ to give it the exchange rate directly). Then if I run a Ledger command with a -G or something, it tells me my gains and losses on each account. A prices command will also give me a list of exchange rates for every date available.


Title: Re: GnuCash support for alternative/non-ISO currencies
Post by: EskimoBob on January 30, 2013, 09:31:59 AM
Just a tip, whenever I exchange some USD into BTC, I do something like
Assets:BTCWallet ฿20 @@ $384

The @@ tells it the total you paid for the currency and calculates the exchange rate for you (I can also use just one @ to give it the exchange rate directly). Then if I run a Ledger command with a -G or something, it tells me my gains and losses on each account. A prices command will also give me a list of exchange rates for every date available.

Lets move all Ledger related questions ad discussion here: https://bitcointalk.org/index.php?topic=139995.msg1489920

Thank you


Title: Re: GnuCash support for alternative/non-ISO currencies
Post by: bitcoinsrule on January 30, 2013, 06:26:59 PM
Just a tip, whenever I exchange some USD into BTC, I do something like
Assets:BTCWallet  ฿20 @@ $384

What keystroke do you use to get "฿"?


Title: Re: GnuCash support for alternative/non-ISO currencies
Post by: Rassah on January 30, 2013, 06:36:01 PM
Just a tip, whenever I exchange some USD into BTC, I do something like
Assets:BTCWallet  ฿20 @@ $384

What keystroke do you use to get "฿"?

I google searched for Thai Baht, and copy/pasted the character. Sorry  :-\


Title: Re: GnuCash support for alternative/non-ISO currencies
Post by: ErebusBat on January 31, 2013, 03:45:49 AM
For what it's worth I spent 10 mins dinking around and think this might be possible without compiling your own version.

I downloaded GnuCash and created a new book (sqlite format).

Then I opened the file in my sqlite editor and ran:
Code:
insert into commodities
(guid, namespace, mnemonic, fullname, cusip, fraction, quote_flag, quote_source)
VALUES
('11f74daa3e324da18e8c1fb4871a0f70', 'CURRENCY', 'BTC', 'Bitcoin', '', 100000000, 1, 'currency')

The GUID is random, and the fraction doesn't appear to actually work as intendended; however this allows you to create accounts as BTC now.

Perhaps someone smarter than me can take this farther.  I used http://wiki.gnucash.org/wiki/SQL (http://wiki.gnucash.org/wiki/SQL) as inspiration.


Title: Re: GnuCash support for alternative/non-ISO currencies
Post by: bitcoinsrule on January 31, 2013, 03:55:19 AM
Just a tip, whenever I exchange some USD into BTC, I do something like
Assets:BTCWallet  ฿20 @@ $384

What keystroke do you use to get "฿"?

I google searched for Thai Baht, and copy/pasted the character. Sorry  :-\

No worries. :)



Title: Re: GnuCash support for alternative/non-ISO currencies
Post by: zhangweiwu on June 29, 2013, 11:51:15 AM
Well, if the GnuCash developers decide to do so, and I doubt they will, they won't take my route. I had to modify a system file, iso_4217.xml, after all. Furthermore, it works by pretending that the target non-ISO4217 currencies do qualify as ISO4217. That just strikes me as an undignified kludge.

They did it before. XAU (for gold) and XAG (for silver) are in iso_4217.xml, which are not part of iso_4217.


Title: Re: GnuCash support for alternative/non-ISO currencies
Post by: zhangweiwu on June 29, 2013, 12:07:40 PM
"Make it easier for users to work with alternative/non-ISO/private currencies. (http://uservoice.com/a/35yKe)"

Folks, I made the above suggestion to the GnuCash developers to include better support for currencies that do not meet ISO requirements, like the bitcoin. I hope you'll all up vote it.

It's being discussed in an onerous discussion here:
https://bugzilla.gnome.org/show_bug.cgi?id=130920

Before they decide to take any action, you may try to use these currency codes of gnucash to denote BTC:

-  XXX (unknown currency)
-  XTS (currency for testing purpose)
-  XPT (Platinum)

So, when they rolled out the real BTC support you can then update your ledger to use it. -- do a search-and-replace of your ledger file (*.gnucash)

There is nothing to do with ISO requirements. Developers do things at their will and update the system following engineering needs, not user requirements. Otherwise how do you explain XTS is not removed in the final release? Users don't have a stake there, in opensource developers rules, the quality is maintained by the fact that most developers happen to be also users. More often than not, if you managed to contributed 50% code, you have to insist on really really bad mistakes in order that other people consider forking your project, and before that you rule like a king. -> this paragraph is not a complaint, just a general description.


Title: Re: GnuCash support for alternative/non-ISO currencies
Post by: zhangweiwu on October 31, 2014, 10:48:39 AM
I use XXX as a place holder for mBTC, the reason why I don't use BTC, but mBTC, is because gnucash can't handle more than 4-digits after decimal point: it automatically change the number, hinders a user to balance in a split transaction. It won't work even if you configure precision to more than 4-digits after decimal.

I know I just replied a post 120 days old, but this is how long it took me to determine to book-keeping my BTC transactions.


Title: Re: GnuCash support for alternative/non-ISO currencies
Post by: EskimoBob on November 06, 2014, 11:37:30 AM
I gave up on doing accounting in LTC or BTC and moved everything to EUR while cryptocoins are held/accounted as investments - like stock. Problem solved!
It is completely pointless to use LTC or BTC because of absurdly high volatility and 99.999% of good (or equipment, materials, what ever) you buy or sell, are still fiat based even if you quote it in any of the cryptocoins.


Title: Re: GnuCash support for alternative/non-ISO currencies
Post by: Sukrim on November 06, 2014, 12:39:58 PM
I just use ledger-cli instead of GnuCash (which is slightly overkill for my taste anyways in some areas) for accounting, it still would be interesting to have at least a fork/patch available to extend precision to 8 digits + allow adding new currency abbreviations to be manually added.


Title: Re: GnuCash support for alternative/non-ISO currencies
Post by: zhangweiwu on November 15, 2014, 12:46:16 PM
I just use ledger-cli instead of GnuCash to have precision to 8 digits.

Maybe you can try to save GNUCash ledger onto MySQL database instead of text file and see if precision improves. It can happen that the devs stored numeric as string to simplify adaptation (toSQL), in which case there be no improvement on precision.

ledger-cli makes it difficult to assign the task to an accountant. all successful investors ends up hiring an accountant - since you invest in Bitcoin, chances are you will be successful and will hire an accoutant, and end up either switching away from ledger-cli or so rich that you hire an accountant who were trained in Unix too:)


Title: Re: GnuCash support for alternative/non-ISO currencies
Post by: mistercoin on November 15, 2014, 03:43:32 PM
Upvoted. Very nice indeed my friend.


Title: Re: GnuCash support for alternative/non-ISO currencies
Post by: Sukrim on November 15, 2014, 10:32:35 PM
ledger-cli makes it difficult to assign the task to an accountant. all successful investors ends up hiring an accountant - since you invest in Bitcoin, chances are you will be successful and will hire an accoutant, and end up either switching away from ledger-cli or so rich that you hire an accountant who were trained in Unix too:)
I'd rather do my accounting automatically and have an accountant assisting me with the layout of transactions etc. - with (nearly) all transactions available in machine-readable formats anyways, there is no real need to hire someone to enter numbers into a ledger manually.


Title: Re: GnuCash support for alternative/non-ISO currencies
Post by: Tuxavant on November 24, 2014, 11:32:38 PM
I have no idea why this just occurred to me, but GNUCash seems to work perfectly well when using bitcoin's bit/ubit denomination.