mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
2001-07-11 Dave Peticolas <dave@krondo.com>
* src/engine/io-gncxml-v2.c: same as below * src/engine/io-gncbin-r.c: same as below * src/engine/io-example-account.c: same as below * src/engine/Ledger-xml-parser-v1.c: remove autocode * src/engine/Group.[ch]: remove autocode api. This hasn't really been used in a while, and account codes are generally assigned based on account function, not just hierarchy position. * src/engine/Account.[ch]: remove autocode api * src/guile/gnc.gwp: remove auto code api * src/scm/commodity-utilities.scm: fix function calls git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@4944 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
47e7d75848
commit
c8fcd36996
18
ChangeLog
18
ChangeLog
@ -1,5 +1,23 @@
|
||||
2001-07-11 Dave Peticolas <dave@krondo.com>
|
||||
|
||||
* src/engine/io-gncxml-v2.c: same as below
|
||||
|
||||
* src/engine/io-gncbin-r.c: same as below
|
||||
|
||||
* src/engine/io-example-account.c: same as below
|
||||
|
||||
* src/engine/Ledger-xml-parser-v1.c: remove autocode
|
||||
|
||||
* src/engine/Group.[ch]: remove autocode api. This hasn't
|
||||
really been used in a while, and account codes are generally
|
||||
assigned based on account function, not just hierarchy position.
|
||||
|
||||
* src/engine/Account.[ch]: remove autocode api
|
||||
|
||||
* src/guile/gnc.gwp: remove auto code api
|
||||
|
||||
* src/scm/commodity-utilities.scm: fix function calls
|
||||
|
||||
* src/test/test-xml-transaction.c: CIT (currency-in-transaction)
|
||||
|
||||
* src/test/test-xml-account.c: CIT
|
||||
|
@ -911,27 +911,6 @@ xaccAccountOrder (Account **aa, Account **ab) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/********************************************************************\
|
||||
\********************************************************************/
|
||||
/* account codes will be assigned base-36, with three digits */
|
||||
|
||||
#define BASE 36
|
||||
|
||||
void
|
||||
xaccAccountAutoCode (Account *acc, int digits) {
|
||||
if (!acc) return;
|
||||
if (acc->accountCode) return; /* no-op if code already assinged */
|
||||
if (!(acc->parent)) return;
|
||||
|
||||
xaccAccountBeginEdit(acc);
|
||||
{
|
||||
acc->accountCode = xaccGroupGetNextFreeCode (acc->parent, digits);
|
||||
acc->parent->saved = FALSE;
|
||||
acc->core_dirty = TRUE;
|
||||
}
|
||||
xaccAccountCommitEdit(acc);
|
||||
}
|
||||
|
||||
/********************************************************************\
|
||||
\********************************************************************/
|
||||
|
||||
|
@ -177,16 +177,6 @@ void xaccTransFixSplitDateOrder (Transaction *trans);
|
||||
*/
|
||||
int xaccAccountOrder (Account **account_1, Account **account_2);
|
||||
|
||||
/* The xaccAccountAutoCode() method will assign an automatically
|
||||
* generated account code to the account, if one does not already
|
||||
* exist. Account codes will have the indicated number of digits
|
||||
* in them. The numbering scheme roughly follows generally
|
||||
* accepted accounting practice, in that top-level accounts
|
||||
* will be number 100, 200, etc., second level accounts 110, 120,
|
||||
* .. 210, 220, ...etc. and third level accounts 111, 112, .. etc.
|
||||
*/
|
||||
void xaccAccountAutoCode (Account *account, int digits);
|
||||
|
||||
void xaccAccountSetType (Account *account, int);
|
||||
void xaccAccountSetName (Account *account, const char *name);
|
||||
void xaccAccountSetCode (Account *account, const char *code);
|
||||
|
@ -651,160 +651,6 @@ xaccGroupInsertAccount (AccountGroup *grp, Account *acc)
|
||||
gnc_engine_generate_event (&acc->guid, GNC_EVENT_MODIFY);
|
||||
}
|
||||
|
||||
/********************************************************************\
|
||||
\********************************************************************/
|
||||
/* account codes will be assigned base-36, with three digits */
|
||||
|
||||
#define BASE 36
|
||||
|
||||
char *
|
||||
xaccGroupGetNextFreeCode (AccountGroup *grp, int digits)
|
||||
{
|
||||
GList *node;
|
||||
Account *acc;
|
||||
int maxcode = 0;
|
||||
int i;
|
||||
|
||||
if (!grp) return NULL;
|
||||
|
||||
/* count levels to top */
|
||||
acc = grp->parent;
|
||||
while (acc)
|
||||
{
|
||||
digits --;
|
||||
assert (acc->parent);
|
||||
acc = acc->parent->parent;
|
||||
}
|
||||
|
||||
/* if (0>digits) we could insert a decimal place, but I am too lazy
|
||||
* to write this code. It doesn't seem important at the moment ... */
|
||||
|
||||
/* find the largest used code */
|
||||
acc = grp->parent;
|
||||
if (acc && acc->accountCode)
|
||||
maxcode = strtol (acc->accountCode, NULL, BASE);
|
||||
|
||||
for (node = grp->accounts; node; node = node->next)
|
||||
{
|
||||
Account *account = node->data;
|
||||
|
||||
if (account->accountCode)
|
||||
{
|
||||
int code = strtol (account->accountCode, NULL, BASE);
|
||||
if (code > maxcode) maxcode = code;
|
||||
}
|
||||
}
|
||||
|
||||
/* right-shift */
|
||||
for (i = 1; i < digits; i++)
|
||||
maxcode /= BASE;
|
||||
|
||||
maxcode++;
|
||||
|
||||
/* left-shift */
|
||||
for (i = 1; i < digits; i++)
|
||||
maxcode *= BASE;
|
||||
|
||||
/* print */
|
||||
return ultostr ((unsigned long) maxcode, BASE);
|
||||
}
|
||||
|
||||
/********************************************************************\
|
||||
\********************************************************************/
|
||||
/* almost identical code to above, but altered to deal with
|
||||
* specified account */
|
||||
|
||||
char *
|
||||
xaccAccountGetNextChildCode (Account *parent_acc, int digits)
|
||||
{
|
||||
GList *node;
|
||||
Account *acc;
|
||||
int maxcode = 0;
|
||||
AccountGroup *grp;
|
||||
int i;
|
||||
|
||||
if (!parent_acc) return NULL;
|
||||
|
||||
/* count levels to top */
|
||||
acc = parent_acc;
|
||||
while (acc)
|
||||
{
|
||||
digits --;
|
||||
assert (acc->parent); /* all acounts must be in a group */
|
||||
acc = acc->parent->parent;
|
||||
}
|
||||
|
||||
/* if (0>digits) we could insert a decimal place, but I am too lazy
|
||||
* to write this code. It doesn't seem important at the moment ... */
|
||||
|
||||
/* find the largest used code */
|
||||
acc = parent_acc;
|
||||
if (acc && acc->accountCode)
|
||||
maxcode = strtol (acc->accountCode, NULL, BASE);
|
||||
|
||||
grp = parent_acc->children;
|
||||
if (grp)
|
||||
{
|
||||
for (node = grp->accounts; node; node = node->next)
|
||||
{
|
||||
Account *account = node->data;
|
||||
|
||||
if (account->accountCode)
|
||||
{
|
||||
int code = strtol (account->accountCode, NULL, BASE);
|
||||
if (code > maxcode) maxcode = code;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* right-shift */
|
||||
for (i = 1; i < digits; i++)
|
||||
maxcode /= BASE;
|
||||
|
||||
maxcode++;
|
||||
|
||||
/* left-shift */
|
||||
for (i = 1; i < digits; i++)
|
||||
maxcode *= BASE;
|
||||
|
||||
/* print */
|
||||
return ultostr ((unsigned long) maxcode, BASE);
|
||||
}
|
||||
|
||||
/********************************************************************\
|
||||
\********************************************************************/
|
||||
|
||||
void
|
||||
xaccGroupDepthAutoCode (AccountGroup *grp)
|
||||
{
|
||||
int depth;
|
||||
|
||||
if (!grp) return;
|
||||
|
||||
/* get the depth */
|
||||
depth = xaccGroupGetDepth (grp);
|
||||
|
||||
if (depth < 3) depth = 3;
|
||||
|
||||
xaccGroupAutoCode (grp, depth);
|
||||
}
|
||||
|
||||
void
|
||||
xaccGroupAutoCode (AccountGroup *grp, int depth)
|
||||
{
|
||||
GList *node;
|
||||
|
||||
if (!grp || (depth < 0)) return;
|
||||
|
||||
for (node = grp->accounts; node; node = node->next)
|
||||
{
|
||||
Account *account = node->data;
|
||||
|
||||
xaccAccountAutoCode (account, depth);
|
||||
xaccGroupAutoCode (account->children, depth);
|
||||
}
|
||||
}
|
||||
|
||||
/********************************************************************\
|
||||
\********************************************************************/
|
||||
|
||||
|
@ -164,32 +164,6 @@ AccountGroup * xaccGetAccountRoot (Account *account);
|
||||
*/
|
||||
Account * xaccGroupGetParentAccount (AccountGroup *group);
|
||||
|
||||
/*
|
||||
* The xaccGroupGetNextFreeCode() method will try to guess a reasonable
|
||||
* candidate for the next unused account code in this group.
|
||||
* The returned string is malloced, you must free the returned
|
||||
* pointer when done.
|
||||
*
|
||||
* The xaccAccountGetNextChildCode() method does same as above,
|
||||
* except that it returns a value appropriate for a child account.
|
||||
* The returned string is malloced, you must free the returned
|
||||
* pointer when done.
|
||||
*
|
||||
* 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 the depth of the account
|
||||
* tree, and uses that depth to pick the number of digits in the account
|
||||
* code.
|
||||
*/
|
||||
|
||||
char * xaccGroupGetNextFreeCode (AccountGroup *grp, int num_digits);
|
||||
char * xaccAccountGetNextChildCode (Account *acc, int num_digits);
|
||||
void xaccGroupAutoCode (AccountGroup *grp, int num_digits);
|
||||
void xaccGroupDepthAutoCode (AccountGroup *grp);
|
||||
|
||||
/* if the function returns null for a given item, it won't show up in
|
||||
the result list */
|
||||
GSList *xaccGroupMapAccounts(AccountGroup *grp,
|
||||
|
@ -127,9 +127,6 @@ ledger_data_end_handler(gpointer data_for_children,
|
||||
*/
|
||||
xaccGroupMarkSaved (ag);
|
||||
|
||||
/* auto-number the accounts, if they are not already numbered */
|
||||
xaccGroupDepthAutoCode (ag);
|
||||
|
||||
/* commit all groups, this completes the BeginEdit started when the
|
||||
* account_end_handler finished reading the account.
|
||||
*/
|
||||
|
@ -301,7 +301,6 @@ gnc_read_example_account(const gchar *filename)
|
||||
}
|
||||
|
||||
xaccGroupMarkSaved(gea->group);
|
||||
xaccGroupDepthAutoCode(gea->group);
|
||||
xaccAccountGroupCommitEdit(gea->group);
|
||||
|
||||
return gea;
|
||||
|
@ -465,9 +465,6 @@ gnc_load_financials_from_fd(GNCBook *book, int fd)
|
||||
holder = xaccMallocAccountGroup();
|
||||
grp = readGroup (fd, NULL, token);
|
||||
|
||||
/* auto-number the accounts, if they are not already numbered */
|
||||
xaccGroupDepthAutoCode (grp);
|
||||
|
||||
/* the number of unclaimed accounts should be zero if the
|
||||
* read succeeded. But just in case of a very unlikely
|
||||
* error, try to continue anyway. */
|
||||
|
@ -453,9 +453,6 @@ gnc_book_load_from_xml_file_v2(
|
||||
/* also mark the pricedb as saved for the same reasons */
|
||||
gnc_pricedb_mark_clean (gnc_book_get_pricedb (book));
|
||||
|
||||
/* auto-number the accounts, if they are not already numbered */
|
||||
xaccGroupDepthAutoCode (gnc_book_get_group(book));
|
||||
|
||||
/* Fix account and transaction commodities */
|
||||
xaccGroupScrubCommodities (gnc_book_get_group(book));
|
||||
|
||||
|
@ -59,7 +59,7 @@
|
||||
;; which have two *different* commodities
|
||||
;; involved.
|
||||
(lambda (s) (let ((trans-comm
|
||||
(gnc:transaction-get-commodity
|
||||
(gnc:transaction-get-currency
|
||||
(gnc:split-get-parent s)))
|
||||
(acc-comm
|
||||
(gnc:account-get-commodity
|
||||
@ -127,7 +127,7 @@
|
||||
(total-domestic (gnc:numeric-zero)))
|
||||
(map-in-order
|
||||
(lambda (a)
|
||||
(let* ((transaction-comm (gnc:transaction-get-commodity
|
||||
(let* ((transaction-comm (gnc:transaction-get-currency
|
||||
(gnc:split-get-parent a)))
|
||||
(account-comm (gnc:account-get-commodity
|
||||
(gnc:split-get-account a)))
|
||||
@ -224,7 +224,7 @@
|
||||
;; go through all splits; convert all splits into a price.
|
||||
(map-in-order
|
||||
(lambda (a)
|
||||
(let* ((transaction-comm (gnc:transaction-get-commodity
|
||||
(let* ((transaction-comm (gnc:transaction-get-currency
|
||||
(gnc:split-get-parent a)))
|
||||
(account-comm (gnc:account-get-commodity
|
||||
(gnc:split-get-account a)))
|
||||
@ -491,7 +491,7 @@
|
||||
;; and share-amounts
|
||||
(for-each
|
||||
(lambda (a)
|
||||
(let* ((transaction-comm (gnc:transaction-get-commodity
|
||||
(let* ((transaction-comm (gnc:transaction-get-currency
|
||||
(gnc:split-get-parent a)))
|
||||
(account-comm (gnc:account-get-commodity
|
||||
(gnc:split-get-account a)))
|
||||
|
Loading…
Reference in New Issue
Block a user