From 7003a561712d104e6b72dc5be2c6bdaff0ff20a7 Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Thu, 10 Mar 2016 12:08:40 +0100 Subject: [PATCH] Make gnucash 2.7+ rerun bayesian data conversion whenever needed Whenever recent 2.6.x versions of gnucash store bayesian data in the old format (full account name based), gnucash 2.7+ should perform a conversion the the new format (guid based) on subsequent opening of the file. --- src/import-export/import-match-map.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/import-export/import-match-map.c b/src/import-export/import-match-map.c index 19b1222777..4a66e968dc 100644 --- a/src/import-export/import-match-map.c +++ b/src/import-export/import-match-map.c @@ -558,8 +558,17 @@ void gnc_imap_add_account_bayes(GncImportMatchMap *imap, GList *tokens, Account * /imap->frame/IMAP_FRAME/token_string/account_fullname or guid */ if (use_fullname == TRUE) + { + KvpFrame *book_frame = qof_book_get_slots (imap->book); + const gchar *book_path = "changed-bayesian-to-guid"; + kvp_frame_set_slot_path(imap->frame, new_value, IMAP_FRAME_BAYES, (char*)current_token->data, account_fullname, NULL); + + /* Reset the run once kvp flag for versions 2.7.0 and later */ + if (kvp_frame_get_string(book_frame, book_path) != NULL) + kvp_frame_set_string(book_frame, book_path, "false"); + } else kvp_frame_set_slot_path(imap->frame, new_value, IMAP_FRAME_BAYES, (char*)current_token->data, guid_string, NULL);