r23522 - gnucash/trunk/src/engine - Bug 632588 - Scrub doesn't fix missing currency

John Ralls jralls at code.gnucash.org
Sun Dec 8 21:02:41 EST 2013


Author: jralls
Date: 2013-12-08 21:02:41 -0500 (Sun, 08 Dec 2013)
New Revision: 23522
Trac: http://svn.gnucash.org/trac/changeset/23522

Modified:
   gnucash/trunk/src/engine/Scrub.c
Log:
Bug 632588 - Scrub doesn't fix missing currency

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

Modified: gnucash/trunk/src/engine/Scrub.c
===================================================================
--- gnucash/trunk/src/engine/Scrub.c	2013-12-09 02:02:31 UTC (rev 23521)
+++ gnucash/trunk/src/engine/Scrub.c	2013-12-09 02:02:41 UTC (rev 23522)
@@ -1018,7 +1018,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)
@@ -1030,9 +1030,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