r19743 - gnucash/trunk/src/backend/xml - Revised handling of obsolete security elements, made log messages better.
John Ralls
jralls at code.gnucash.org
Tue Nov 2 14:21:50 EDT 2010
Author: jralls
Date: 2010-11-02 14:21:50 -0400 (Tue, 02 Nov 2010)
New Revision: 19743
Trac: http://svn.gnucash.org/trac/changeset/19743
Modified:
gnucash/trunk/src/backend/xml/gnc-account-xml-v2.c
Log:
Revised handling of obsolete security elements, made log messages better.
Accounts with security elements would only use the security to update the
commodity if there wasn't a commodity; however, the files in the tests had
accounts which had a security and a commodity, where the commodity was a
currency. That's wrong. so now if the commodity is a currency, the security
will overwrite it.
Added the account name and element name to the log message to assist in
troubleshooting, should that be needed.
Modified: gnucash/trunk/src/backend/xml/gnc-account-xml-v2.c
===================================================================
--- gnucash/trunk/src/backend/xml/gnc-account-xml-v2.c 2010-11-02 07:24:42 UTC (rev 19742)
+++ gnucash/trunk/src/backend/xml/gnc-account-xml-v2.c 2010-11-02 18:21:50 UTC (rev 19743)
@@ -301,7 +301,8 @@
struct account_pdata *pdata = act_pdata;
gnc_commodity *ref;
- PWARN("Obsolete xml tag will not be preserved.");
+ PWARN("Account %s: Obsolete xml tag 'act:currency' will not be preserved.",
+ xaccAccountGetName( pdata->account ));
ref = dom_tree_to_commodity_ref_no_engine(node, pdata->book);
DxaccAccountSetCurrency(pdata->account, ref);
@@ -311,7 +312,9 @@
static gboolean
deprecated_account_currency_scu_handler (xmlNodePtr node, gpointer act_pdata)
{
- PWARN("Obsolete xml tag will not be preserved.");
+ struct account_pdata *pdata = act_pdata;
+ PWARN("Account %s: Obsolete xml tag 'act:currency-scu' will not be preserved.",
+ xaccAccountGetName( pdata->account ));
return TRUE;
}
@@ -319,13 +322,22 @@
deprecated_account_security_handler (xmlNodePtr node, gpointer act_pdata)
{
struct account_pdata *pdata = act_pdata;
- gnc_commodity *ref;
+ gnc_commodity *ref, *orig = xaccAccountGetCommodity(pdata->account);
- PWARN("Obsolete xml tag will not be preserved.");
- if (!xaccAccountGetCommodity(pdata->account))
+ PWARN("Account %s: Obsolete xml tag 'act:security' will not be preserved.",
+ xaccAccountGetName( pdata->account ));
+ /* If the account has both a commodity and a security elemet, and
+ the commodity is a currecny, then the commodity is probably
+ wrong. In that case we want to replace it with the
+ security. jralls 2010-11-02 */
+ if (!orig || gnc_commodity_is_currency( orig ) )
{
ref = dom_tree_to_commodity_ref_no_engine(node, pdata->book);
xaccAccountSetCommodity(pdata->account, ref);
+ /* If the SCU was set, it was probably wrong, so zero it out
+ so that the SCU handler can fix it if there's a
+ security-scu element. jralls 2010-11-02 */
+ xaccAccountSetCommoditySCU(pdata->account, 0);
}
return TRUE;
@@ -337,7 +349,8 @@
struct account_pdata *pdata = act_pdata;
gint64 val;
- PWARN("Obsolete xml tag will not be preserved.");
+ PWARN("Account %s: Obsolete xml tag 'act:security-scu' will not be preserved.",
+ xaccAccountGetName( pdata->account ));
if (!xaccAccountGetCommoditySCU(pdata->account))
{
dom_tree_to_integer(node, &val);
More information about the gnucash-changes
mailing list