mirror of
https://github.com/Gnucash/gnucash.git
synced 2024-11-23 01:16:43 -06:00
add group function to auto-insert an account code
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@1322 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
a20bc2b30b
commit
2b174a1f1a
@ -351,6 +351,7 @@ xaccRemoveAccount (Account *acc)
|
||||
|
||||
/********************************************************************\
|
||||
\********************************************************************/
|
||||
|
||||
void
|
||||
xaccInsertSubAccount( Account *adult, Account *child )
|
||||
{
|
||||
@ -467,6 +468,33 @@ xaccRecomputeGroupBalance (AccountGroup *grp)
|
||||
/********************************************************************\
|
||||
\********************************************************************/
|
||||
|
||||
void
|
||||
xaccGroupDepthAutoCode (AccountGroup *grp)
|
||||
{
|
||||
int depth;
|
||||
|
||||
/* get the depth */
|
||||
depth = xaccGroupGetDepth (grp);
|
||||
if (3>depth) depth = 3;
|
||||
|
||||
xaccGroupAutoCode (grp, depth);
|
||||
}
|
||||
|
||||
void
|
||||
xaccGroupAutoCode (AccountGroup *grp, int depth)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i=0; i<grp->numAcc; i++) {
|
||||
Account *acc = grp->account[i];
|
||||
xaccAccountAutoCode (acc, depth);
|
||||
xaccGroupAutoCode (acc->children, depth);
|
||||
}
|
||||
}
|
||||
|
||||
/********************************************************************\
|
||||
\********************************************************************/
|
||||
|
||||
void
|
||||
xaccConcatGroups (AccountGroup *togrp, AccountGroup *fromgrp)
|
||||
{
|
||||
@ -595,4 +623,22 @@ xaccGroupGetBalance (AccountGroup * grp)
|
||||
return (grp->balance);
|
||||
}
|
||||
|
||||
/********************************************************************\
|
||||
\********************************************************************/
|
||||
|
||||
int
|
||||
xaccGroupGetDepth (AccountGroup *grp)
|
||||
{
|
||||
int i, depth=0, maxdepth=0;
|
||||
if (!grp) return 0;
|
||||
|
||||
for (i=0; i<grp->numAcc; i++) {
|
||||
depth = xaccGroupGetDepth (grp->account[i]->children);
|
||||
if (depth > maxdepth) maxdepth = depth;
|
||||
}
|
||||
|
||||
maxdepth++;
|
||||
return maxdepth;
|
||||
}
|
||||
|
||||
/****************** END OF FILE *************************************/
|
||||
|
@ -36,11 +36,11 @@ void xaccFreeAccountGroup( AccountGroup *account_group );
|
||||
|
||||
/*
|
||||
* The xaccConcatGroups() subroutine will move all accounts
|
||||
* from the "from" group to the "to" group
|
||||
* from the "from" group to the "to" group
|
||||
*
|
||||
* The xaccMergeAccounts() subroutine will go through a group,
|
||||
* merging all accounts that have the same name and description.
|
||||
* This function is useful when importing Quicken(TM) files.
|
||||
* merging all accounts that have the same name and description.
|
||||
* This function is useful when importing Quicken(TM) files.
|
||||
*/
|
||||
void xaccConcatGroups (AccountGroup *to, AccountGroup *from);
|
||||
void xaccMergeAccounts (AccountGroup *grp);
|
||||
@ -59,18 +59,18 @@ void xaccAccountGroupMarkSaved (AccountGroup *grp);
|
||||
|
||||
/*
|
||||
* The xaccRemoveAccount() subroutine will remove the indicated
|
||||
* account from its parent account group. It will NOT free the
|
||||
* associated memory or otherwise alter the account: the account
|
||||
* can now be reparented to a new location.
|
||||
* Note, however, that it will mark the old parents as having
|
||||
* been modified.
|
||||
* account from its parent account group. It will NOT free the
|
||||
* associated memory or otherwise alter the account: the account
|
||||
* can now be reparented to a new location.
|
||||
* Note, however, that it will mark the old parents as having
|
||||
* been modified.
|
||||
*
|
||||
* The xaccRemoveGroup() subroutine will remove the indicated
|
||||
* account group from its parent account. It will NOT free the
|
||||
* associated memory or otherwise alter the account group: the
|
||||
* account group can now be reparented to a new location.
|
||||
* Note, however, that it will mark the old parents as having
|
||||
* been modified.
|
||||
* account group from its parent account. It will NOT free the
|
||||
* associated memory or otherwise alter the account group: the
|
||||
* account group can now be reparented to a new location.
|
||||
* Note, however, that it will mark the old parents as having
|
||||
* been modified.
|
||||
*/
|
||||
void xaccRemoveAccount (Account *);
|
||||
void xaccRemoveGroup (AccountGroup *);
|
||||
@ -79,15 +79,18 @@ void xaccInsertSubAccount( Account *parent, Account *child );
|
||||
|
||||
/*
|
||||
* The xaccGetNumAccounts() subroutine returns the number
|
||||
* of accounts, including subaccounts, in the account group
|
||||
* of accounts, including subaccounts, in the account group
|
||||
*
|
||||
* The xaccGroupGetNumAccounts() subroutine returns the number
|
||||
* of accounts in the indicated group only (children not counted).
|
||||
*
|
||||
* The xaccGroupGetDepth() subroutine returns the length of the
|
||||
* longest tree branch. Each link between an account and its
|
||||
* (non-null) children counts as one unit of length.
|
||||
*/
|
||||
int xaccGetNumAccounts (AccountGroup *grp);
|
||||
|
||||
/*
|
||||
* The xaccGroupGetNumAccounts() subroutine returns the number
|
||||
* of accounts in the indicated group only (children not counted).
|
||||
*/
|
||||
int xaccGroupGetNumAccounts (AccountGroup *grp);
|
||||
int xaccGroupGetDepth (AccountGroup *grp);
|
||||
|
||||
/*
|
||||
* The xaccGetAccountFromID() subroutine fetches the account
|
||||
@ -123,19 +126,19 @@ void xaccRecomputeGroupBalance (AccountGroup *);
|
||||
|
||||
/*
|
||||
* The xaccGetAccountRoot () subroutine will find the topmost
|
||||
* (root) group to which this account belongs.
|
||||
* (root) group to which this account belongs.
|
||||
*/
|
||||
|
||||
AccountGroup * xaccGetAccountRoot (Account *);
|
||||
|
||||
/* The xaccConsolidateGrpTrans() subroutine scans through
|
||||
* all of the transactions in an account, and compares them.
|
||||
* if any of them are exact duplicates, the duplicates are removed.
|
||||
* duplicates may occur when accounts from multiple sources are
|
||||
* merged. Note that this can be a dangerous operation to perform
|
||||
* all of the transactions in an account, and compares them.
|
||||
* if any of them are exact duplicates, the duplicates are removed.
|
||||
* duplicates may occur when accounts from multiple sources are
|
||||
* merged. Note that this can be a dangerous operation to perform
|
||||
*
|
||||
* Note that this suborutine merely walks the acount group
|
||||
* tree, and calls ConsolidateTransacations on each account
|
||||
* Note that this suborutine merely walks the acount group
|
||||
* tree, and calls ConsolidateTransacations on each account
|
||||
*/
|
||||
|
||||
void xaccConsolidateGrpTransactions (AccountGroup *);
|
||||
@ -143,4 +146,18 @@ void xaccConsolidateGrpTransactions (AccountGroup *);
|
||||
Account * xaccGroupGetAccount (AccountGroup *, int);
|
||||
double xaccGroupGetBalance (AccountGroup *);
|
||||
|
||||
/*
|
||||
* The xaccGroupAutoCode() method will traverse the group, automatically
|
||||
* inserting account codes into those accounts whose account codes
|
||||
* are blank. It uses the algorithm used in xaccAccountAutoCode()
|
||||
* to pick an account code.
|
||||
*
|
||||
* The xaccGroupDepthAutoCode() first measures teh depth of the account
|
||||
* tree, and uses that depth to pck the number of digits in the account
|
||||
* code.
|
||||
*/
|
||||
|
||||
void xaccGroupAutoCode (AccountGroup *grp, int num_digits);
|
||||
void xaccGroupDepthAutoCode (AccountGroup *grp);
|
||||
|
||||
#endif /* __XACC_ACCOUNT_GROUP_H__ */
|
||||
|
Loading…
Reference in New Issue
Block a user