Skip to content

Commit

Permalink
Make sure to properly parent auto-created accounts.
Browse files Browse the repository at this point in the history
Make sure to properly set account commodity.
Make sure a currency sub-account doesn't already exist before creating one.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@16715 57a11ea4-9604-0410-9ed3-97b8803252fd
  • Loading branch information
derekatkins committed Dec 24, 2007
1 parent fe28cce commit 244a779
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions src/gnome-utils/dialog-book-close.c
Expand Up @@ -167,14 +167,26 @@ static void finish_txn_cb(gnc_commodity* cmdty,
acc = cacb->base_acct;
else
{
acc = xaccMallocAccount(cacb->cbw->book);
xaccAccountBeginEdit(acc);
xaccAccountSetType(acc, ACCT_TYPE_EQUITY);
xaccAccountSetName(acc, gnc_commodity_get_mnemonic(cmdty));
xaccAccountSetDescription(acc, gnc_commodity_get_mnemonic(cmdty));
xaccAccountCommitEdit(acc);
/* See if we already have an account by that name */
acc = gnc_account_lookup_by_name(cacb->base_acct,
gnc_commodity_get_mnemonic(cmdty));

/* If not, then create one */
if (!acc)
{
acc = xaccMallocAccount(cacb->cbw->book);
xaccAccountBeginEdit(acc);
xaccAccountSetType(acc, ACCT_TYPE_EQUITY);
xaccAccountSetName(acc, gnc_commodity_get_mnemonic(cmdty));
xaccAccountSetDescription(acc, gnc_commodity_get_mnemonic(cmdty));
xaccAccountSetCommodity(acc, cmdty);
gnc_account_append_child(cacb->base_acct, acc);
xaccAccountCommitEdit(acc);
}
}
/* Make sure the account exists and is of the correct commodity */
g_assert(acc);
g_assert(gnc_commodity_equal(cmdty, xaccAccountGetCommodity(acc)));

/* Create the split for the Equity account to balance out
* all the accounts of this. Use the "total".
Expand Down

0 comments on commit 244a779

Please sign in to comment.