handle category sub-accounts

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@171 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Linas Vepstas 1997-11-28 08:33:39 +00:00
parent 1f38e5434e
commit 243464af30
2 changed files with 29 additions and 1 deletions

View File

@ -485,6 +485,7 @@ xaccGetRootGroupOfAcct (Account *acc)
/* recursively walk up the tree of parents */
grp = acc->parent;
if (!grp) return NULL;
acc = grp->parent;
while (acc) {
grp = acc->parent;

View File

@ -202,6 +202,7 @@ char * xaccReadQIFCatList (int fd, AccountGroup *grp)
{
char * qifline;
Account *acc;
char *str, *tok;
if (!grp) return 0x0;
do {
@ -217,10 +218,36 @@ char * xaccReadQIFCatList (int fd, AccountGroup *grp)
freeAccount(acc);
continue;
}
insertAccount( grp, acc );
/* check to see if this is a sub-account.
* Sub-accounts will have a colon in the name */
str = acc->accountName;
tok = strchr (str, ':');
if (tok) {
Account *parent;
/* find the parent account, and parent to it */
*tok = 0x0;
parent = xaccGetAccountFromName (grp, str);
*tok = ':';
if (parent) {
xaccInsertSubAccount( parent, acc );
/* trim off the parent account name ... */
/* tok += sizeof(char); leave behind the colon ... */
str = XtNewString (tok);
XtFree (acc->accountName);
acc->accountName = str;
} else {
insertAccount( grp, acc );
}
} else {
insertAccount( grp, acc );
}
} while (qifline);
return qifline;
}