A script to convert GNUCash's XML file to Ledger's dat file
convert.pl is the script to convert GnuCash's uncompressed XML file to a Ledger journal. I run it using Perl 5.26 on a computer running Ubuntu 18.04.
The file formats for ledger and hledger are very similar, I have been able to generate repors using hledger for the dat file created by the conversion script.
Note: There are other scripts which do the same thing as the Perl script in this repository.
hledger () {
docker run --rm -v `pwd`:/data -w /data dastapov/hledger hledger $@
}
ledger () {
docker run --rm -v `pwd`:/data -w /data dcycle/ledger:1 $@
}
Commodity directives can be used to ensure that numbers are always displayed in the appropriate format.
$ cat commodities.dat
commodity JPY 1,000,000.
commodity EUR 1,000,000.00
commodity USD 1,000,000.00
commodity INR 10,00,000.
; Enter the appropriate exchange rate for the various commodities here
P 2020-02-08 EUR 0.001 USD
hledger -f simple.dat incomestatement
hledger -f simple.dat balancesheet
hledger -f simple.dat cashflow
# You _must_ have the exchange rate in USD for all the commodities in the
# commodities.dat file
hledger -f simple.dat bal Assets -Y --value=now,USD
Code in this repository is licensed under MIT.
Copyright (C) 2020 Siddharth Kannan [email protected]