Move many expense accounts to Expense parent

Yawar Amin yawar.amin at gmail.com
Tue Dec 15 21:48:10 EST 2009


On 12/15/09 5:44 PM, Mike Roberts wrote:
> I just moved my data from Microsoft Money.  The imported .qif files left me
> with lots of top level accounts that should be under an Expenses parent.  Is
> there any way to move these as a group, or do I have to edit each account
> and change its Parent Account?
>   

The latter. Drag-and-drop doesn't work, so you can select each account,
click Edit in the toolbar, and set the parent.

If you're comfortable with HTML/XML, you could edit the GnuCash XML data
file yourself, assuming you're saving as XML (if you're on GnuCash 2.2.9
or below, then you are). Here's how:

GnuCash saves all your data in a single XML file and compresses it using
the Gzip compression scheme. You have complete control over the file
name, so it might be for example `My Accounts'. Whatever it is, you'll
need to uncompress it, and the easiest way to do that is copy the file
over to some folder you've created for the purpose, rename it to give it
a .gz extension, like MyAccounts.gz, and uncompress it. On Windows, any
of the zip programs can handle it, and on Linux/Mac, double-clicking
will do it.

Every account in the data file has a simple structure, with some pieces
of information listed like name, ID, parent ID, and so on. Say your main
Expenses account has an ID `51de73ad651e732f01d49cd09c0e2da9'. It will
look like this in the file:

<gnc:account version="2.0.0">
  <act:name>Expenses</act:name>
  <act:id type="guid">51de73ad651e732f01d49cd09c0e2da9</act:id>
  <act:type>EXPENSE</act:type>
  <act:commodity>
    <cmdty:space>ISO4217</cmdty:space>
    <cmdty:id>CAD</cmdty:id>
  </act:commodity>
  <act:commodity-scu>100</act:commodity-scu>
  <act:parent type="guid">721006df65f050d9e9c76b27b98c2609</act:parent>
</gnc:account>

The Expenses account doesn't have a parent account, so GnuCash gives it
an invisible account called ROOT as its parent. The ROOT account in my
case has an ID of 721006df65f050d9e9c76b27b98c2609.

You'll also have a bunch of accounts that should be under this main
Expenses account, e.g. Bank_Charges:

<gnc:account version="2.0.0">
  <act:name>Bank_Charges</act:name>
  <act:id type="guid">df72fb29f46e90e12c2ba10d582a6148</act:id>
  <act:type>EXPENSE</act:type>
  <act:commodity>
    <cmdty:space>ISO4217</cmdty:space>
    <cmdty:id>CAD</cmdty:id>
  </act:commodity>
  <act:commodity-scu>100</act:commodity-scu>
  <act:parent type="guid">721006df65f050d9e9c76b27b98c2609</act:parent>
</gnc:account>

Your problem is that instead of being under your main Expense account,
all these other expense accounts are under ROOT:

<act:parent type="guid">721006df65f050d9e9c76b27b98c2609</act:parent>

So all you do change the parent account ID for each of them to the ID of
the Expense account, in this case 51de73ad651e732f01d49cd09c0e2da9. It
should be a matter of copying and pasting in the right places. Of
course, you'll need to make sure all the expense accounts have account
type EXPENSE. So they should all have this line:

<act:type>EXPENSE</act:type>

Once you're finished changing all the parents, Gzip-compress the file
again and put it back where GnuCash expects it (back up the original
GnuCash file first!).

HTH,

Yawar


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 258 bytes
Desc: OpenPGP digital signature
URL: <http://lists.gnucash.org/pipermail/gnucash-user/attachments/20091215/8f0ec25a/attachment.bin>


More information about the gnucash-user mailing list