GnuCash Daily Diff
Dave Peticolas
peticolas@linas.org
Fri, 18 May 2001 08:02:23 -0500 (CDT)
Index: gnucash/ChangeLog
diff -u gnucash/ChangeLog:1.486 gnucash/ChangeLog:1.490
--- gnucash/ChangeLog:1.486 Thu May 17 05:37:33 2001
+++ gnucash/ChangeLog Fri May 18 05:01:11 2001
@@ -1,4 +1,27 @@
+2001-05-18 Dave Peticolas <dave@krondo.com>
+
+ * src/engine/Group.h: fix prototype
+
+ * src/doc/design/engine.texinfo: update docs
+
+ * src/gnome/dialog-price-editor.c: add button to remove
+ prices before a user-entered date.
+
+ * src/gnome/file-history.c: fix for menu changes
+
+ * src/scm/report.scm: move reports menu to top-level
+
+2001-05-17 James LewisMoss <jimdres@mindspring.com>
+
+ * src/engine/Makefile.am (libgncengine_la_SOURCES): remove
+ io-gncxml-w.c.
+
2001-05-17 Dave Peticolas <dave@krondo.com>
+
+ * src/doc/design/engine.texinfo: update docs
+
+ * src/engine/Account.c (xaccAccountRecomputeBalance): include
+ frozen splits in reconciled balance. Fix variable names.
* accounts/C/*: tweak detailed descriptions
Index: gnucash/src/doc/design/engine.texinfo
diff -u gnucash/src/doc/design/engine.texinfo:1.35 gnucash/src/doc/design/engine.texinfo:1.38
--- gnucash/src/doc/design/engine.texinfo:1.35 Thu May 17 05:18:46 2001
+++ gnucash/src/doc/design/engine.texinfo Fri May 18 04:59:58 2001
@@ -1746,6 +1746,7 @@
* General Account API::
* Account Type API::
* Account Getters::
+* Account Tax API::
@end menu
@@ -1775,7 +1776,6 @@
@item ASSET
Denotes a generic asset account.
-
@item LIABILITY
Denotes a generic liability account.
@@ -1890,7 +1890,7 @@
@end deftypefun
-@node Account Getters, , Account Type API, Accounts
+@node Account Getters, Account Tax API, Account Type API, Accounts
@subsection Account Getters
@deftypefun GNCAccountType xaccAccountGetType (Account * @var{account})
@@ -1938,10 +1938,162 @@
be returned.
@end deftypefun
+@deftypefun {AccountGroup *} xaccAccountGetChildren (Account * @var{account})
+Return the child group of @var{account}. The child group may be @code{NULL},
+indicating @var{account} has no children.
+@end deftypefun
+
+@deftypefun {AccountGroup *} xaccAccountGetParent (Account * @var{account})
+Return the parent Group of @var{account}. The parent may be @code{NULL},
+indicating @var{account} is a top-level Account. However, even if the
+parent is not @code{NULL}, the account may still be top-level if the
+parent Group has no parent Account.
+@end deftypefun
+
+@deftypefun {Account *} xaccAccountGetParentAccount (Account * @var{account})
+Similar to @code{xaccAccountGetParent}, but returns the parent Account
+of the parent Group if the parent Group exists. Otherwise, returns
+@code{NULL}.
+@end deftypefun
+
+@deftypefun gnc_numeric xaccAccountGetBalance (Account * @var{account})
+Return the balance of @var{account}, which is also the balance of the
+last Split in @var{account}. If there are no Splits, the balance is
+zero. The balance is denominated in the Account currency.
+@end deftypefun
+
+@deftypefun gnc_numeric xaccAccountGetClearedBalance (Account * @var{account})
+Return the cleared balance of @var{account}. The cleared balance is the
+balance of all Splits in @var{account} which are either cleared or
+reconciled or frozen. The cleared balance is denominated in the Account
+currency.
+@end deftypefun
+
+@deftypefun gnc_numeric xaccAccountGetReconciledBalance (Account * @var{account})
+Return the reconciled balance of @var{account}. The reconciled balance
+is the balance of all Splits in @var{account} which are reconciled or
+frozen. The reconciled balance is denominated in the Account currency.
+@end deftypefun
+
+@deftypefun gnc_numeric xaccAccountGetShareBalance (Account *account)
+Return the share balance of @var{account}, which is also the share
+balance of the last Split in @var{account}. If there are no Splits, the
+balance is zero. The balance is denominated in the Account security, if
+the Account security exits; otherwise the share balance is denominated
+in the Account currency.
+@end deftypefun
+
+@deftypefun gnc_numeric xaccAccountGetShareClearedBalance (Account * @var{account})
+Return the cleared share balance of @var{account}. The cleared share
+balance is the share balance of all Splits in @var{account} which are
+either cleared or reconciled or frozen. The cleared share balance is
+denominated as the share balance.
+@end deftypefun
+
+@deftypefun gnc_numeric xaccAccountGetShareReconciledBalance (Account * @var{account})
+Return the reconciled share balance of @var{account}. The reconciled
+share balance is the share balance of all Splits in @var{account} which
+are reconciled or frozen. The reconciled sharea balance is denominated
+as the share balance.
+@end deftypefun
+
+@deftypefun gnc_numeric xaccAccountGetBalanceAsOfDate (Account * @var{account}, time_t @var{date})
+Return the balance of @var{account} including all Splits whose parent
+Transactions have posted dates on or before @var{date}.
+@end deftypefun
+
+@deftypefun gnc_numeric xaccAccountGetShareBalanceAsOfDate (Account * @var{account}, time_t @var{date})
+Return the share balance of @var{account} including all Splits whose
+parent Transactions have posted dates on or before @var{date}.
+@end deftypefun
+
+@deftypefun {Split *} xaccAccountGetSplit (Account * @var{account}, int @var{i})
+Return the @var{i}th Split in @var{account}. If @var{i} < 0 or @var{i}
+>= number of splits in @var{account}, then @code{NULL} is returned.
+This function is O(number of splits in account).
+@end deftypefun
+
+@deftypefun int xaccAccountGetNumSplits (Account * @var{account})
+Return the number of Splits in @var{account}. This function is
+O(number of splits in account).
+@end deftypefun
+@deftypefun {GList *} xaccAccountGetSplitList (Account * @var{account})
+Return a @code{GList} of the Splits in @var{account}. This list must
+not be modified in any way.
+@end deftypefun
+
+@deftypefun {char *} xaccAccountGetFullName (Account * @var{account}, const char @var{separator})
+Returns the fully qualified name of @var{account} using the given
+separator character. The name must be g_freed after use. The fully
+qualified name of an account is the concatenation of the names of the
+account and all its ancestor accounts starting with the topmost account
+and ending with the given account. Each name is separated by the given
+character.
+@end deftypefun
+
+
+@node Account Tax API, , Account Getters, Accounts
+@subsection Account Tax API
+
+This set of API calls is related to tax information. All accounts have a
+tax-related boolean flag that can be set or unset. There is an
+additional set of API calls related to United States taxes that have
+`US' in the function call names. Future API calls that are specific to
+other countries should include the appropriate 2-letter country code in
+the function names.
+
+@deftypefun gboolean xaccAccountGetTaxRelated (Account * @var{account})
+Return the tax-related flag of @var{account}.
+@end deftypefun
+
+@deftypefun void xaccAccountSetTaxRelated (Account * @var{account}, gboolean @var{tax_related})
+Set the tax-related flag of @var{account}.
+@end deftypefun
+
+@deftypefun {const char *} xaccAccountGetTaxUSCode (Account * @var{account})
+Get the US-specific tax code associated with @var{account}, or
+@code{NULL} if there is none. These codes are internal to GnuCash
+and currently defined in @file{src/scm/report/txf-export.scm}.
+@end deftypefun
+
+@deftypefun void xaccAccountSetTaxUSCode (Account * @var{account}, const char * @var{code})
+Set the US-specific tax code associated with @var{account}.
+@end deftypefun
+
+@deftypefun {const char *} xaccAccountGetTaxUSPayerNameSource (Account * @var{account})
+Get the payer name source associated with @var{account}. See
+@file{src/scm/repot/taxtxf.scm} for details.
+@end deftypefun
+
+@deftypefun void xaccAccountSetTaxUSPayerNameSource (Account * @var{account}, const char * @var{source})
+Set the payer name source associated with @var{account}.
+@end deftypefun
+
+
@node Account Groups, GNCBooks, Accounts, Engine
@section Account Groups
@tindex AccountGroup
+
+Account Groups are used by the Engine to connect Accounts
+together into an Account hierarchy. Account Groups do not
+correspond to any accounting concept -- they are specific
+to the GnuCash engine. Account Groups contain the following
+pieces of information:
+
+@table @asis
+
+@item A list of Accounts
+The list Accounts in the Group.
+
+@item A not-saved flag
+Indicates whether any information in the hierarchy
+rooted at the Group needs to be saved. That includes
+Accounts, Splits, and Transactions.
+
+@end table
+
+Account Groups do not have key-value frames or GUIDs.
@node GNCBooks, Scrub, Account Groups, Engine
Index: gnucash/src/engine/Account-xml-parser-v1.c
diff -u gnucash/src/engine/Account-xml-parser-v1.c:1.8 gnucash/src/engine/Account-xml-parser-v1.c:1.9
--- gnucash/src/engine/Account-xml-parser-v1.c:1.8 Wed May 9 18:03:35 2001
+++ gnucash/src/engine/Account-xml-parser-v1.c Thu May 17 22:02:01 2001
@@ -578,94 +578,3 @@
return ret;
}
-
-
-/***********************************************************************/
-/***********************************************************************/
-/* write out the xml for each of the fields in an account */
-
-static gboolean
-xml_add_account_restorer(xmlNodePtr p, Account* a) {
- xmlNodePtr acct_xml;
-
- g_return_val_if_fail(p, FALSE);
- g_return_val_if_fail(a, FALSE);
-
- acct_xml = xmlNewTextChild(p, NULL, "account", NULL);
- g_return_val_if_fail(acct_xml, FALSE);
-
- acct_xml = xmlNewTextChild(acct_xml, NULL, "restore", NULL);
- g_return_val_if_fail(acct_xml, FALSE);
-
- if(!xml_add_str(acct_xml, "name",
- xaccAccountGetName(a), FALSE))
- return(FALSE);
- if(!xml_add_guid(acct_xml, "guid",
- xaccAccountGetGUID(a)))
- return(FALSE);
- if(!xml_add_str(acct_xml, "type",
- xaccAccountTypeEnumAsString(xaccAccountGetType(a)), FALSE))
- return(FALSE);
- if(!xml_add_str(acct_xml, "code",
- xaccAccountGetCode(a), FALSE))
- return(FALSE);
- if(!xml_add_str(acct_xml, "description",
- xaccAccountGetDescription(a), FALSE))
- return(FALSE);
- /* Notes field is now in kvp table. */
- if(!xml_add_commodity_ref(acct_xml, "currency", xaccAccountGetCurrency(a)))
- return(FALSE);
- if(!xml_add_commodity_ref(acct_xml, "security", xaccAccountGetSecurity(a)))
- return(FALSE);
-
- if(a->kvp_data) {
- if(!xml_add_kvp_frame(acct_xml, "slots", a->kvp_data, FALSE))
- return(FALSE);
- }
-
- {
- Account *parent = xaccAccountGetParentAccount(a);
- if(parent) {
- xmlNodePtr parent_xml = xmlNewTextChild(acct_xml, NULL, "parent", NULL);
- g_return_val_if_fail(parent_xml, FALSE);
- if(!xml_add_guid(parent_xml, "guid", xaccAccountGetGUID(parent)))
- return(FALSE);
- }
- }
-
- {
- AccountGroup *g = xaccAccountGetChildren(a);
- if(g) {
- GList *list = xaccGroupGetAccountList (g);
- GList *node;
-
- for (node = list; node; node = node->next) {
- Account *current_acc = node->data;
-
- if(!xml_add_account_restorer(p, current_acc))
- return(FALSE);
- }
- }
- }
- return(TRUE);
-}
-
-/* ============================================================== */
-/* loop over all accounts in the group */
-
-gboolean
-xml_add_account_restorers(xmlNodePtr p, AccountGroup *g) {
- GList *list;
- GList *node;
-
- g_return_val_if_fail(p, FALSE);
- g_return_val_if_fail(g, FALSE);
-
- list = xaccGroupGetAccountList (g);
-
- for (node = list; node; node = node->next) {
- Account *current_acc = node->data;
- xml_add_account_restorer(p, current_acc);
- }
- return(TRUE);
-}
Index: gnucash/src/engine/Account.c
diff -u gnucash/src/engine/Account.c:1.150 gnucash/src/engine/Account.c:1.151
--- gnucash/src/engine/Account.c:1.150 Thu May 17 05:18:48 2001
+++ gnucash/src/engine/Account.c Thu May 17 17:53:53 2001
@@ -770,9 +770,9 @@
void
xaccAccountRecomputeBalance (Account * acc)
{
- gnc_numeric dbalance;
- gnc_numeric dcleared_balance;
- gnc_numeric dreconciled_balance;
+ gnc_numeric balance;
+ gnc_numeric cleared_balance;
+ gnc_numeric reconciled_balance;
gnc_numeric share_balance;
gnc_numeric share_cleared_balance;
gnc_numeric share_reconciled_balance;
@@ -784,9 +784,9 @@
if(!acc->balance_dirty) return;
if(acc->do_free) return;
- dbalance = acc->starting_balance;
- dcleared_balance = acc->starting_cleared_balance;
- dreconciled_balance = acc->starting_reconciled_balance;
+ balance = acc->starting_balance;
+ cleared_balance = acc->starting_cleared_balance;
+ reconciled_balance = acc->starting_reconciled_balance;
share_balance = acc->starting_share_balance;
share_cleared_balance = acc->starting_share_cleared_balance;
share_reconciled_balance = acc->starting_share_reconciled_balance;
@@ -796,20 +796,21 @@
/* compute both dollar and share balances */
share_balance = gnc_numeric_add_fixed(share_balance, split->damount);
- dbalance = gnc_numeric_add_fixed(dbalance, split->value);
+ balance = gnc_numeric_add_fixed(balance, split->value);
if( NREC != split -> reconciled ) {
share_cleared_balance =
gnc_numeric_add_fixed(share_cleared_balance, split->damount);
- dcleared_balance =
- gnc_numeric_add_fixed(dcleared_balance, split->value);
+ cleared_balance =
+ gnc_numeric_add_fixed(cleared_balance, split->value);
}
- if( YREC == split -> reconciled ) {
+ if( YREC == split -> reconciled ||
+ FREC == split -> reconciled ) {
share_reconciled_balance =
gnc_numeric_add_fixed(share_cleared_balance, split->damount);
- dreconciled_balance =
- gnc_numeric_add_fixed(dreconciled_balance, split->value);
+ reconciled_balance =
+ gnc_numeric_add_fixed(reconciled_balance, split->value);
}
/* For bank accounts, the invariant subtotal is the dollar
@@ -826,12 +827,12 @@
price_xfer(split, share_reconciled_balance);
}
else {
- split -> share_balance = dbalance;
- split -> share_cleared_balance = dcleared_balance;
- split -> share_reconciled_balance = dreconciled_balance;
- split -> balance = dbalance;
- split -> cleared_balance = dcleared_balance;
- split -> reconciled_balance = dreconciled_balance;
+ split -> share_balance = balance;
+ split -> share_cleared_balance = cleared_balance;
+ split -> share_reconciled_balance = reconciled_balance;
+ split -> balance = balance;
+ split -> cleared_balance = cleared_balance;
+ split -> reconciled_balance = reconciled_balance;
}
last_split = split;
@@ -846,21 +847,21 @@
if (last_split) {
acc -> balance = price_xfer(last_split, share_balance);
acc -> cleared_balance = price_xfer(last_split, share_cleared_balance);
- acc -> reconciled_balance =
+ acc -> reconciled_balance =
price_xfer(last_split, share_reconciled_balance);
}
else {
- acc -> balance = dbalance;
- acc -> cleared_balance = dcleared_balance;
- acc -> reconciled_balance = dreconciled_balance;
+ acc -> balance = balance;
+ acc -> cleared_balance = cleared_balance;
+ acc -> reconciled_balance = reconciled_balance;
}
} else {
- acc -> share_balance = dbalance;
- acc -> share_cleared_balance = dcleared_balance;
- acc -> share_reconciled_balance = dreconciled_balance;
- acc -> balance = dbalance;
- acc -> cleared_balance = dcleared_balance;
- acc -> reconciled_balance = dreconciled_balance;
+ acc -> share_balance = balance;
+ acc -> share_cleared_balance = cleared_balance;
+ acc -> share_reconciled_balance = reconciled_balance;
+ acc -> balance = balance;
+ acc -> cleared_balance = cleared_balance;
+ acc -> reconciled_balance = reconciled_balance;
}
Index: gnucash/src/engine/Commodity-xml-parser-v1.c
diff -u gnucash/src/engine/Commodity-xml-parser-v1.c:1.7 gnucash/src/engine/Commodity-xml-parser-v1.c:1.8
--- gnucash/src/engine/Commodity-xml-parser-v1.c:1.7 Wed May 9 18:03:35 2001
+++ gnucash/src/engine/Commodity-xml-parser-v1.c Thu May 17 22:02:01 2001
@@ -385,149 +385,3 @@
return(top_level);
}
-
-/***********************************************************************/
-/***********************************************************************/
-/* WRITING */
-
-gboolean
-xml_add_commodity_ref(xmlNodePtr p, const char *tag, const gnc_commodity *c)
-{
- xmlNodePtr c_xml = NULL;
- xmlNodePtr tmp_xml = NULL;
- const gchar *namestr;
- const gchar *idstr;
-
- if (!(p && tag)) return FALSE;
- if (!c) return TRUE;
-
- namestr = gnc_commodity_get_namespace(c);
- idstr = gnc_commodity_get_mnemonic(c);
-
- if(!(namestr && idstr)) return FALSE;
-
- c_xml= xmlNewNode(NULL, tag);
- if(!c_xml) return FALSE;
-
- tmp_xml = xmlNewTextChild(c_xml, NULL, "space", namestr);
- if(!tmp_xml) {
- xmlFreeNode(c_xml);
- return FALSE;
- }
- tmp_xml = xmlNewTextChild(c_xml, NULL, "id", idstr);
- if(!tmp_xml) {
- xmlFreeNode(c_xml);
- return FALSE;
- }
-
- xmlAddChild(p, c_xml);
- return TRUE;
-}
-
-/* ============================================================== */
-
-static gboolean
-xml_add_commodity_restorer(xmlNodePtr p, gnc_commodity *c) {
- xmlNodePtr comm_xml;
- xmlNodePtr rst_xml;
-
- g_return_val_if_fail(p, FALSE);
- g_return_val_if_fail(c, FALSE);
-
- comm_xml = xmlNewTextChild(p, NULL, "commodity", NULL);
- g_return_val_if_fail(comm_xml, FALSE);
-
- rst_xml = xmlNewTextChild(comm_xml, NULL, "restore", NULL);
- if(!rst_xml) {
- xmlFreeNode(comm_xml);
- return(FALSE);
- }
-
- if(!xml_add_str(rst_xml, "space", gnc_commodity_get_namespace(c), FALSE)) {
- xmlFreeNode(comm_xml);
- return(FALSE);
- }
- if(!xml_add_str(rst_xml, "id", gnc_commodity_get_mnemonic(c), FALSE)) {
- xmlFreeNode(comm_xml);
- return(FALSE);
- }
- if(!xml_add_str(rst_xml, "name", gnc_commodity_get_fullname(c), FALSE)) {
- xmlFreeNode(comm_xml);
- return(FALSE);
- }
- if(!xml_add_str(rst_xml, "xcode", gnc_commodity_get_exchange_code(c), FALSE)) {
- xmlFreeNode(comm_xml);
- return(FALSE);
- }
- if(!xml_add_gint64(rst_xml, "fraction", gnc_commodity_get_fraction(c))) {
- xmlFreeNode(comm_xml);
- return(FALSE);
- }
-
- return(TRUE);
-}
-
-
-static gint
-compare_namespaces(gconstpointer a, gconstpointer b) {
- const gchar *sa = (const gchar *) a;
- const gchar *sb = (const gchar *) b;
- return(safe_strcmp(sa, sb));
-}
-
-static gint
-compare_commodity_ids(gconstpointer a, gconstpointer b) {
- const gnc_commodity *ca = (const gnc_commodity *) a;
- const gnc_commodity *cb = (const gnc_commodity *) b;
- return(safe_strcmp(gnc_commodity_get_mnemonic(ca),
- gnc_commodity_get_mnemonic(cb)));
-}
-
-gboolean
-xml_add_commodity_restorers(xmlNodePtr p) {
- gnc_commodity_table *commodities;
- GList *namespaces;
- GList *lp;
-
- g_return_val_if_fail(p, FALSE);
-
- commodities = gnc_engine_commodities();
- g_return_val_if_fail(commodities, FALSE);
-
- namespaces = g_list_sort(gnc_commodity_table_get_namespaces(commodities),
- compare_namespaces);
-
-
- for(lp = namespaces; lp; lp = lp->next) {
- gchar *space;
-
- if(!lp->data) {
- g_list_free (namespaces);
- return(FALSE);
- }
-
- space = (gchar *) lp->data;
- if(strcmp(GNC_COMMODITY_NS_ISO, space) != 0) {
- GList *comms = gnc_commodity_table_get_commodities(commodities, space);
- GList *lp2;
-
- comms = g_list_sort(comms, compare_commodity_ids);
-
- for(lp2 = comms; lp2; lp2 = lp2->next) {
- gnc_commodity *com = (gnc_commodity *) lp2->data;
-
- if(!xml_add_commodity_restorer(p, com)) {
- g_list_free (comms);
- g_list_free (namespaces);
- return(FALSE);
- }
- }
-
- g_list_free (comms);
- }
- }
-
- g_list_free (namespaces);
-
- return(TRUE);
-}
Index: gnucash/src/engine/Group.h
diff -u gnucash/src/engine/Group.h:1.45 gnucash/src/engine/Group.h:1.46
--- gnucash/src/engine/Group.h:1.45 Thu May 10 11:12:28 2001
+++ gnucash/src/engine/Group.h Fri May 18 05:00:01 2001
@@ -172,7 +172,7 @@
* The xaccGetAccountRoot () subroutine will find the topmost
* (root) group to which this account belongs.
*/
-AccountGroup * xaccGetAccountRoot (Account *group);
+AccountGroup * xaccGetAccountRoot (Account *account);
/* The xaccGroupGetParentAccount() subroutine returns the parent
* account of the group, or NULL.
Index: gnucash/src/engine/Makefile.am
diff -u gnucash/src/engine/Makefile.am:1.36 gnucash/src/engine/Makefile.am:1.37
--- gnucash/src/engine/Makefile.am:1.36 Fri Apr 13 01:54:23 2001
+++ gnucash/src/engine/Makefile.am Thu May 17 22:03:21 2001
@@ -45,7 +45,6 @@
io-gncxml-gen.c \
io-gncxml-r.c \
io-gncxml-v2.c \
- io-gncxml-w.c \
io-utils.c \
kvp_frame.c \
md5.c \
Index: gnucash/src/engine/Query-xml-parser-v1.c
diff -u gnucash/src/engine/Query-xml-parser-v1.c:1.7 gnucash/src/engine/Query-xml-parser-v1.c:1.8
--- gnucash/src/engine/Query-xml-parser-v1.c:1.7 Sun Apr 8 19:37:26 2001
+++ gnucash/src/engine/Query-xml-parser-v1.c Thu May 17 22:02:01 2001
@@ -555,161 +555,3 @@
return(top_level);
}
-
-
-/***********************************************************************/
-/***********************************************************************/
-/* WRITING */
-/* push query terms into xml */
-/* XXX hack alert not all predicates currently implemented */
-
-static gboolean
-xml_add_qterm_restorer(xmlNodePtr qxml, QueryTerm *qt)
-{
- int rc;
- xmlNodePtr p = NULL;
-
- g_return_val_if_fail(qxml, FALSE);
- g_return_val_if_fail(qt, FALSE);
-
- /* we set the predicates names based on the info they record */
- switch (qt->data.base.term_type) {
- case PR_ACCOUNT:
- p = xmlNewTextChild(qxml, NULL, "account-pred", NULL);
- break;
-
- case PR_ACTION:
- p = xmlNewTextChild(qxml, NULL, "action-pred", NULL);
- break;
-
- case PR_AMOUNT:
- p = xmlNewTextChild(qxml, NULL, "amount-pred", NULL);
- break;
-
- case PR_BALANCE:
- p = xmlNewTextChild(qxml, NULL, "balance-pred", NULL);
- break;
-
- case PR_CLEARED:
- p = xmlNewTextChild(qxml, NULL, "cleared-pred", NULL);
- break;
-
- case PR_DATE:
- p = xmlNewTextChild(qxml, NULL, "date-pred", NULL);
- break;
-
- case PR_DESC:
- p = xmlNewTextChild(qxml, NULL, "description-pred", NULL);
- break;
-
- case PR_MEMO:
- p = xmlNewTextChild(qxml, NULL, "memo-pred", NULL);
- break;
-
- case PR_NUM:
- p = xmlNewTextChild(qxml, NULL, "num-pred", NULL);
- break;
-
- case PR_PRICE:
- p = xmlNewTextChild(qxml, NULL, "price-pred", NULL);
- break;
-
- case PR_SHRS:
- p = xmlNewTextChild(qxml, NULL, "shares-pred", NULL);
- break;
-
- case PR_MISC:
- PERR ("Misc terms are not transmittable");
- break;
-
- default:
- }
- if (!p) return (FALSE);
-
- rc = xml_add_gint32(p, "sense", qt->data.base.sense);
- if (!rc) return(FALSE);
-
-
- /* however, many of the types share a generic structure. */
- switch (qt->data.type) {
- case PD_ACCOUNT:
- PERR ("account query unimplemented");
- break;
-
- case PD_AMOUNT:
- PERR ("amount query unimplemented");
- break;
-
- case PD_BALANCE:
- PERR ("balance query unimplemented");
- break;
-
- case PD_CLEARED:
- PERR ("cleared query unimplemented");
- break;
-
- case PD_DATE:
- xml_add_gint32(p, "use-start", qt->data.date.use_start);
- xml_add_gint32(p, "use-end", qt->data.date.use_end);
- if (qt->data.date.use_start) {
- xml_add_editable_timespec(p, "start-date",
- &(qt->data.date.start), FALSE);
- }
- if (qt->data.date.use_end) {
- xml_add_editable_timespec(p, "end-date",
- &(qt->data.date.end), FALSE);
- }
- break;
-
- case PD_STRING:
- xml_add_gint32(p, "case-sens", qt->data.str.case_sens);
- xml_add_gint32(p, "use-regexp", qt->data.str.use_regexp);
- xml_add_str(p, "matchstring", qt->data.str.matchstring, TRUE);
- break;
-
- case PD_MISC:
- PERR ("Must not happen");
- break;
-
- default:
- }
-
- return(TRUE);
-}
-
-/* ============================================================== */
-/* loop over all terms in the query */
-/* XXX hack alert -- need to also send max-terms, sort-order,
- * and other mis query elements */
-
-gboolean
-xml_add_query_restorers(xmlNodePtr p, Query *q)
-{
- xmlNodePtr qxml, restore_xml, and_xml;
- GList *aterms, *oterms;
- GList *anode, *onode;
-
- g_return_val_if_fail(p, FALSE);
- g_return_val_if_fail(q, FALSE);
-
- oterms = xaccQueryGetTerms (q);
-
- /* write the nested <query> <restore> */
- qxml = xmlNewTextChild(p, NULL, "query", NULL);
- g_return_val_if_fail(qxml, FALSE);
-
- restore_xml = xmlNewTextChild(qxml, NULL, "restore", NULL);
- g_return_val_if_fail(restore_xml, FALSE);
-
- for (onode = oterms; onode; onode = onode->next) {
- aterms = onode->data;
- and_xml = xmlNewTextChild(restore_xml, NULL, "and-terms", NULL);
- g_return_val_if_fail(and_xml, FALSE);
-
- for (anode = aterms; anode; anode = anode->next) {
- QueryTerm *qt = anode->data;
- xml_add_qterm_restorer(and_xml, qt);
- }
- }
- return(TRUE);
-}
Index: gnucash/src/engine/Transaction-xml-parser-v1.c
diff -u gnucash/src/engine/Transaction-xml-parser-v1.c:1.6 gnucash/src/engine/Transaction-xml-parser-v1.c:1.7
--- gnucash/src/engine/Transaction-xml-parser-v1.c:1.6 Sun Mar 4 05:09:21 2001
+++ gnucash/src/engine/Transaction-xml-parser-v1.c Thu May 17 22:02:01 2001
@@ -858,136 +858,3 @@
return(top_level);
}
-
-/***********************************************************************/
-/***********************************************************************/
-/* WRITING */
-
-static gboolean
-xml_add_transaction_split(xmlNodePtr p, Split* s) {
- xmlNodePtr split_xml;
-
- g_return_val_if_fail(p, FALSE);
- g_return_val_if_fail(s, FALSE);
-
- split_xml = xmlNewTextChild(p, NULL, "split", NULL);
- g_return_val_if_fail(split_xml, FALSE);
-
- if(!xml_add_guid(split_xml, "guid", xaccSplitGetGUID(s)))
- return(FALSE);
-
- if(!xml_add_str(split_xml, "memo", xaccSplitGetMemo(s), FALSE))
- return(FALSE);
-
- if(!xml_add_str(split_xml, "action", xaccSplitGetAction(s), FALSE))
- return(FALSE);
-
- /* reconcile-state */
- {
- char state = xaccSplitGetReconcile(s);
- if(!xml_add_character(split_xml, "reconcile-state", state))
- return(FALSE);
- }
-
- {
- /* reconcile-date */
- Timespec ts;
- xaccSplitGetDateReconciledTS(s, &ts);
- if(!xml_add_editable_timespec(split_xml, "reconcile-date", &ts, FALSE))
- return(FALSE);
- }
-
- /* share-amount */
- if(!xml_add_gnc_numeric(split_xml, "value", xaccSplitGetValue(s)))
- return(FALSE);
-
- /* share-price */
- if(!xml_add_gnc_numeric(split_xml, "quantity", xaccSplitGetShareAmount(s)))
- return(FALSE);
-
- /* account */
- {
- Account *acct = xaccSplitGetAccount(s);
- if(acct) {
- if(!xml_add_guid(split_xml, "account", xaccAccountGetGUID(acct)))
- return(FALSE);
- }
- }
-
- if(s->kvp_data) {
- if(!xml_add_kvp_frame(split_xml, "slots", s->kvp_data, FALSE))
- return(FALSE);
- }
-
- return(TRUE);
-}
-
-/* ============================================================== */
-
-static gboolean
-xml_add_txn_restore(xmlNodePtr p, Transaction* t) {
-
- xmlNodePtr txn_xml;
- xmlNodePtr restore_xml;
-
- g_return_val_if_fail(p, FALSE);
- g_return_val_if_fail(t, FALSE);
-
- txn_xml = xmlNewTextChild(p, NULL, "transaction", NULL);
- g_return_val_if_fail(txn_xml, FALSE);
-
- restore_xml = xmlNewTextChild(txn_xml, NULL, "restore", NULL);
- g_return_val_if_fail(restore_xml, FALSE);
-
- if(!xml_add_guid(restore_xml, "guid", xaccTransGetGUID(t)))
- return(FALSE);
- if(!xml_add_str(restore_xml, "num", xaccTransGetNum(t), FALSE))
- return(FALSE);
- {
- Timespec ts;
- xaccTransGetDatePostedTS(t, &ts);
- if(!xml_add_editable_timespec(restore_xml, "date-posted", &ts, FALSE))
- return(FALSE);
- }
- {
- Timespec ts;
- xaccTransGetDateEnteredTS(t, &ts);
- if(!xml_add_editable_timespec(restore_xml, "date-entered", &ts, FALSE))
- return(FALSE);
- }
- if(!xml_add_str(restore_xml, "description", xaccTransGetDescription(t), FALSE))
- return(FALSE);
-
- if(t->kvp_data) {
- if(!xml_add_kvp_frame(restore_xml, "slots", t->kvp_data, FALSE))
- return(FALSE);
- }
-
- {
- guint32 n = 0;
- Split *s = xaccTransGetSplit(t, n);
-
- while(s) {
- if(!xml_add_transaction_split(restore_xml, s)) return(FALSE);
- n++;
- s = xaccTransGetSplit(t, n);
- }
- }
-
- return(TRUE);
-}
-
-/* ============================================================== */
-
-static gboolean
-xml_add_txn_restore_adapter(Transaction *t, gpointer data) {
- xmlNodePtr xml_node = (xmlNodePtr) data;
- return(xml_add_txn_restore(xml_node, t));
-}
-
-gboolean
-xml_add_txn_and_split_restorers(xmlNodePtr p, AccountGroup *g) {
- return(xaccGroupForEachTransaction(g,
- xml_add_txn_restore_adapter,
- (gpointer) p));
-}
Index: gnucash/src/engine/io-gncxml.h
diff -u gnucash/src/engine/io-gncxml.h:1.9 gnucash/src/engine/io-gncxml.h:1.10
--- gnucash/src/engine/io-gncxml.h:1.9 Wed May 9 18:03:36 2001
+++ gnucash/src/engine/io-gncxml.h Thu May 17 22:02:01 2001
@@ -43,36 +43,6 @@
/* read in an account group from a file */
gboolean gnc_book_load_from_xml_file(GNCBook *book);
-/* write all account info to a file */
-gboolean gnc_book_write_to_xml_file(GNCBook *book, const char *filename);
-
-#if 0
-
-/* read an account group from a buffer in memory
- * the pointer bufp must point at the ascii xml, and bufsz
- * must be the size of the buffer.
- */
-AccountGroup *gncxml_read_from_buf (char *bufp, int bufsz);
-
-/* write all account info into memory. This routine returns a
- * pointer to freshly malloced memory in bufp. You muse free
- * this memory when done. The size that was written out is
- * returned in sz
- */
-void gncxml_write_to_buf (AccountGroup *group, char **bufp, int *sz);
-
-/*
- * write only the account and currency info to the buf, do *not*
- * write any of the splits or transactions
- */
-void gncxml_write_group_to_buf (AccountGroup *group, char **bufp, int *sz);
-
-#endif
-
-/* write/read query terms to/from memory */
-void gncxml_write_query_to_buf (Query *q, char **bufp, int *sz);
-Query *gncxml_read_query (char *bufp, int bufsz);
-
/* The is_gncxml_file() routine checks to see if the first few
* chars of the file look like gnc-xml data.
*/
Index: gnucash/src/gnome/dialog-price-editor.c
diff -u gnucash/src/gnome/dialog-price-editor.c:1.7 gnucash/src/gnome/dialog-price-editor.c:1.9
--- gnucash/src/gnome/dialog-price-editor.c:1.7 Tue May 1 01:52:28 2001
+++ gnucash/src/gnome/dialog-price-editor.c Fri May 18 05:14:24 2001
@@ -58,6 +58,7 @@
GtkWidget * price_list;
GtkWidget * edit_button;
GtkWidget * remove_button;
+ GtkWidget * remove_old_button;
GtkWidget * commodity_edit;
GtkWidget * currency_edit;
@@ -242,6 +243,7 @@
gtk_widget_set_sensitive (pdb_dialog->edit_button, prices != NULL);
gtk_widget_set_sensitive (pdb_dialog->remove_button, prices != NULL);
+ gtk_widget_set_sensitive (pdb_dialog->remove_old_button, prices != NULL);
return g_list_length (prices);
}
@@ -524,6 +526,69 @@
}
static void
+remove_old_clicked (GtkWidget *widget, gpointer data)
+{
+ PricesDialog *pdb_dialog = data;
+ GtkWidget *dialog;
+ GtkWidget *label;
+ GtkWidget *date;
+ GtkWidget *vbox;
+ gint result;
+
+ dialog = gnome_dialog_new (_("Remove old prices"),
+ GNOME_STOCK_BUTTON_OK,
+ GNOME_STOCK_BUTTON_CANCEL,
+ NULL);
+
+ gnome_dialog_set_parent (GNOME_DIALOG (dialog),
+ GTK_WINDOW (pdb_dialog->dialog));
+ gnome_dialog_close_hides (GNOME_DIALOG (dialog), FALSE);
+
+ vbox = GNOME_DIALOG (dialog)->vbox;
+
+ gtk_box_set_spacing (GTK_BOX (vbox), 3);
+ gtk_container_set_border_width (GTK_CONTAINER (vbox), 3);
+
+ label = gtk_label_new (_("All prices before the date below "
+ "will be deleted."));
+
+ gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
+ gtk_widget_show (label);
+
+ date = gnc_date_edit_new (time (NULL), FALSE, FALSE);
+ gtk_object_ref (GTK_OBJECT (date));
+ gtk_object_sink (GTK_OBJECT (date));
+
+ gtk_box_pack_start (GTK_BOX (vbox), date, FALSE, FALSE, 0);
+ gtk_widget_show (date);
+
+ result = gnome_dialog_run_and_close (GNOME_DIALOG (dialog));
+ if (result == 0)
+ {
+ GNCBook *book = gncGetCurrentBook ();
+ GNCPriceDB *pdb = gnc_book_get_pricedb (book);
+ GList *node;
+ Timespec ts;
+
+ ts.tv_sec = gnc_date_edit_get_date (GNC_DATE_EDIT (date));
+ ts.tv_nsec = 0;
+
+ for (node = pdb_dialog->prices; node; node = node->next)
+ {
+ GNCPrice *price = node->data;
+ Timespec pt = gnc_price_get_time (price);;
+
+ if (timespec_cmp (&pt, &ts) < 0)
+ gnc_pricedb_remove_price (pdb, price);
+ }
+
+ gnc_gui_refresh_all ();
+ }
+
+ gtk_object_unref (GTK_OBJECT (date));
+}
+
+static void
add_clicked (GtkWidget *widget, gpointer data)
{
PricesDialog *pdb_dialog = data;
@@ -588,6 +653,8 @@
pdb_dialog->price != NULL);
gtk_widget_set_sensitive (pdb_dialog->remove_button,
pdb_dialog->price != NULL);
+ gtk_widget_set_sensitive (pdb_dialog->remove_old_button,
+ pdb_dialog->price != NULL);
gnc_prices_set_changed (pdb_dialog, FALSE);
}
@@ -605,6 +672,7 @@
gtk_widget_set_sensitive (pdb_dialog->edit_button, FALSE);
gtk_widget_set_sensitive (pdb_dialog->remove_button, FALSE);
+ gtk_widget_set_sensitive (pdb_dialog->remove_old_button, FALSE);
gnc_prices_set_changed (pdb_dialog, FALSE);
}
@@ -840,6 +908,12 @@
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (remove_clicked), pdb_dialog);
+
+ button = lookup_widget (dialog, "remove_old_button");
+ pdb_dialog->remove_old_button = button;
+
+ gtk_signal_connect (GTK_OBJECT (button), "clicked",
+ GTK_SIGNAL_FUNC (remove_old_clicked), pdb_dialog);
button = lookup_widget (dialog, "add_button");
Index: gnucash/src/gnome/file-history.c
diff -u gnucash/src/gnome/file-history.c:1.17 gnucash/src/gnome/file-history.c:1.18
--- gnucash/src/gnome/file-history.c:1.17 Mon May 14 03:38:23 2001
+++ gnucash/src/gnome/file-history.c Fri May 18 05:00:03 2001
@@ -197,7 +197,7 @@
if (!gnome_app_find_menu_pos (menushell, GNOME_MENU_FILE_PATH, &pos))
return;
- path = g_strdup_printf("%s%s", GNOME_MENU_FILE_PATH, "New _Report");
+ path = g_strdup_printf("%s%s", GNOME_MENU_FILE_PATH, "New _Account Tree");
if (!gnome_app_find_menu_pos (menushell, path, &pos))
return;
Index: gnucash/src/gnome/glade-gnc-dialogs.c
diff -u gnucash/src/gnome/glade-gnc-dialogs.c:1.81 gnucash/src/gnome/glade-gnc-dialogs.c:1.82
--- gnucash/src/gnome/glade-gnc-dialogs.c:1.81 Tue May 8 04:36:34 2001
+++ gnucash/src/gnome/glade-gnc-dialogs.c Fri May 18 05:00:03 2001
@@ -7327,6 +7327,7 @@
GtkWidget *hbuttonbox5;
GtkWidget *add_button;
GtkWidget *remove_button;
+ GtkWidget *remove_old_button;
GtkWidget *edit_button;
GtkWidget *get_quotes_button;
GtkWidget *hbuttonbox4;
@@ -7455,6 +7456,8 @@
gtk_widget_show (hbuttonbox5);
gtk_box_pack_start (GTK_BOX (vbox122), hbuttonbox5, FALSE, FALSE, 0);
gtk_button_box_set_layout (GTK_BUTTON_BOX (hbuttonbox5), GTK_BUTTONBOX_SPREAD);
+ gtk_button_box_set_spacing (GTK_BUTTON_BOX (hbuttonbox5), 20);
+ gtk_button_box_set_child_size (GTK_BUTTON_BOX (hbuttonbox5), 50, 27);
add_button = gtk_button_new_with_label (_("Add"));
gtk_widget_ref (add_button);
@@ -7473,6 +7476,15 @@
gtk_container_add (GTK_CONTAINER (hbuttonbox5), remove_button);
GTK_WIDGET_SET_FLAGS (remove_button, GTK_CAN_DEFAULT);
gtk_tooltips_set_tip (tooltips, remove_button, _("Remove the current price"), NULL);
+
+ remove_old_button = gtk_button_new_with_label (_("Remove Old..."));
+ gtk_widget_ref (remove_old_button);
+ gtk_object_set_data_full (GTK_OBJECT (Prices_Dialog), "remove_old_button", remove_old_button,
+ (GtkDestroyNotify) gtk_widget_unref);
+ gtk_widget_show (remove_old_button);
+ gtk_container_add (GTK_CONTAINER (hbuttonbox5), remove_old_button);
+ GTK_WIDGET_SET_FLAGS (remove_old_button, GTK_CAN_DEFAULT);
+ gtk_tooltips_set_tip (tooltips, remove_old_button, _("Remove prices older than a user-entered date"), NULL);
edit_button = gtk_button_new_with_label (_("Edit"));
gtk_widget_ref (edit_button);
Index: gnucash/src/gnome/gnc-dialogs.glade
diff -u gnucash/src/gnome/gnc-dialogs.glade:1.82 gnucash/src/gnome/gnc-dialogs.glade:1.83
--- gnucash/src/gnome/gnc-dialogs.glade:1.82 Tue May 8 04:36:37 2001
+++ gnucash/src/gnome/gnc-dialogs.glade Fri May 18 05:00:07 2001
@@ -11052,8 +11052,8 @@
<class>GtkHButtonBox</class>
<name>hbuttonbox5</name>
<layout_style>GTK_BUTTONBOX_SPREAD</layout_style>
- <spacing>30</spacing>
- <child_min_width>85</child_min_width>
+ <spacing>20</spacing>
+ <child_min_width>50</child_min_width>
<child_min_height>27</child_min_height>
<child_ipad_x>7</child_ipad_x>
<child_ipad_y>0</child_ipad_y>
@@ -11080,6 +11080,16 @@
<can_default>True</can_default>
<can_focus>True</can_focus>
<label>Remove</label>
+ <relief>GTK_RELIEF_NORMAL</relief>
+ </widget>
+
+ <widget>
+ <class>GtkButton</class>
+ <name>remove_old_button</name>
+ <tooltip>Remove prices older than a user-entered date</tooltip>
+ <can_default>True</can_default>
+ <can_focus>True</can_focus>
+ <label>Remove Old...</label>
<relief>GTK_RELIEF_NORMAL</relief>
</widget>
Index: gnucash/src/scm/report.scm
diff -u gnucash/src/scm/report.scm:1.49 gnucash/src/scm/report.scm:1.50
--- gnucash/src/scm/report.scm:1.49 Tue May 15 15:04:01 2001
+++ gnucash/src/scm/report.scm Fri May 18 05:00:14 2001
@@ -39,6 +39,7 @@
(define *gnc:_report-next-serial_* 0)
;; Define those strings here to make changes easier and avoid typos.
+(define gnc:menuname-reports (N_ "_Reports"))
(define gnc:menuname-asset-liability
(N_ "_Assets & Liabilities"))
(define gnc:menuname-income-expense
@@ -51,24 +52,22 @@
(define gnc:optname-reportname (N_ "Report name"))
-
(define (gnc:report-menu-setup)
;; since this menu gets added to every child window, we say it
;; comes after the "_File" menu.
- (define menu (gnc:make-menu (N_ "New _Report")
- (list "_File" "New _Account Tree")))
+ (define menu (gnc:make-menu gnc:menuname-reports (list "_File")))
(define menu-namer (gnc:new-menu-namer))
(define tax-menu (gnc:make-menu gnc:menuname-taxes
- (list "_File" "New _Report" "")))
+ (list gnc:menuname-reports "")))
(define income-expense-menu
(gnc:make-menu gnc:menuname-income-expense
- (list "_File" "New _Report" "")))
+ (list gnc:menuname-reports "")))
(define asset-liability-menu
(gnc:make-menu gnc:menuname-asset-liability
- (list "_File" "New _Report" "")))
+ (list gnc:menuname-reports "")))
(define utility-menu
(gnc:make-menu gnc:menuname-utility
- (list "_File" "New _Report" "")))
+ (list gnc:menuname-reports "")))
(define menu-hash (make-hash-table 23))
(define (add-report-menu-item name report)
@@ -84,7 +83,7 @@
(set! menu-path
(append menu-path '(""))))
- (set! menu-path (append (list "_File" "New _Report") menu-path))
+ (set! menu-path (append (list gnc:menuname-reports) menu-path))
(if menu-name (set! name menu-name))
@@ -127,7 +126,7 @@
(gnc:make-menu-item
((menu-namer 'add-name) (_ "Welcome Extravaganza"))
(_ "Welcome-to-GnuCash screen")
- (list "_File" "New _Report" gnc:menuname-utility "")
+ (list gnc:menuname-reports gnc:menuname-utility "")
(lambda ()
(gnc:make-welcome-report)))))