r23531 - gnucash/branches/2.4/src/engine - [r23522]Bug 632588 - Scrub doesn't fix missing currency

John Ralls jralls at code.gnucash.org
Tue Dec 10 13:46:17 EST 2013


Author: jralls
Date: 2013-12-10 13:46:17 -0500 (Tue, 10 Dec 2013)
New Revision: 23531
Trac: http://svn.gnucash.org/trac/changeset/23531

Modified:
   gnucash/branches/2.4/src/engine/Scrub.c
Log:
[r23522]Bug 632588 - Scrub doesn't fix missing currency

So assign the currency from the first split (that belongs to an account.)

Modified: gnucash/branches/2.4/src/engine/Scrub.c
===================================================================
--- gnucash/branches/2.4/src/engine/Scrub.c	2013-12-10 18:28:39 UTC (rev 23530)
+++ gnucash/branches/2.4/src/engine/Scrub.c	2013-12-10 18:46:17 UTC (rev 23531)
@@ -1089,7 +1089,7 @@
             SplitList *node;
             char guid_str[GUID_ENCODING_LENGTH+1];
             guid_to_string_buff(xaccTransGetGUID(trans), guid_str);
-            PWARN ("no common transaction currency found for trans=\"%s\" (%s)",
+            PWARN ("no common transaction currency found for trans=\"%s\" (%s);",
                    trans->description, guid_str);
 
             for (node = trans->splits; node; node = node->next)
@@ -1101,9 +1101,15 @@
                 }
                 else
                 {
-                    PWARN (" split=\"%s\" account=\"%s\" commodity=\"%s\"",
+		    gnc_commodity *currency = xaccAccountGetCommodity(split->acc);
+                    PWARN ("setting to split=\"%s\" account=\"%s\" commodity=\"%s\"",
                            split->memo, xaccAccountGetName(split->acc),
-                           gnc_commodity_get_mnemonic(xaccAccountGetCommodity(split->acc)));
+                           gnc_commodity_get_mnemonic(currency));
+
+		    xaccTransBeginEdit (trans);
+		    xaccTransSetCurrency (trans, currency);
+		    xaccTransCommitEdit (trans);
+		    return;
                 }
             }
         }



More information about the gnucash-changes mailing list