mirror of
https://github.com/Gnucash/gnucash.git
synced 2024-11-26 19:00:18 -06:00
Add routine to fix Account Color being set to "Not Set"
Previously the account color slot has been populated with "Not Set" when any field for the account has been edited and saved. This routine should run once and remove all such entries.
This commit is contained in:
parent
43beeca079
commit
5c524c31b2
@ -45,6 +45,7 @@
|
||||
#include "gnc-window.h"
|
||||
#include "gnc-plugin-file-history.h"
|
||||
#include "qof.h"
|
||||
#include "Scrub.h"
|
||||
#include "TransLog.h"
|
||||
#include "gnc-session.h"
|
||||
#include "gnc-state.h"
|
||||
@ -1023,6 +1024,12 @@ RESTART:
|
||||
gnc_warning_dialog(parent, "%s", message);
|
||||
g_free ( message );
|
||||
}
|
||||
|
||||
// Fix account color slots being set to 'Not Set', should run once on a book
|
||||
qof_event_suspend();
|
||||
xaccAccountScrubColorNotSet (gnc_get_current_book());
|
||||
qof_event_resume();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -1114,15 +1114,15 @@ xaccTransScrubCurrency (Transaction *trans)
|
||||
}
|
||||
else
|
||||
{
|
||||
gnc_commodity *currency = xaccAccountGetCommodity(split->acc);
|
||||
gnc_commodity *currency = xaccAccountGetCommodity(split->acc);
|
||||
PWARN ("setting to split=\"%s\" account=\"%s\" commodity=\"%s\"",
|
||||
split->memo, xaccAccountGetName(split->acc),
|
||||
gnc_commodity_get_mnemonic(currency));
|
||||
|
||||
xaccTransBeginEdit (trans);
|
||||
xaccTransSetCurrency (trans, currency);
|
||||
xaccTransCommitEdit (trans);
|
||||
return;
|
||||
xaccTransBeginEdit (trans);
|
||||
xaccTransSetCurrency (trans, currency);
|
||||
xaccTransCommitEdit (trans);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1354,6 +1354,42 @@ xaccAccountScrubKvp (Account *account)
|
||||
|
||||
/* ================================================================ */
|
||||
|
||||
void
|
||||
xaccAccountScrubColorNotSet (QofBook *book)
|
||||
{
|
||||
GValue value_s = G_VALUE_INIT;
|
||||
|
||||
// get the run-once value
|
||||
qof_instance_get_kvp (QOF_INSTANCE (book), &value_s, 1, "remove-color-not-set-slots");
|
||||
|
||||
if (G_VALUE_HOLDS_STRING (&value_s) && (strcmp(g_value_get_string (&value_s), "true") == 0))
|
||||
return;
|
||||
else
|
||||
{
|
||||
GValue value_b = G_VALUE_INIT;
|
||||
Account *root = gnc_book_get_root_account (book);
|
||||
GList *accts = gnc_account_get_descendants_sorted (root);
|
||||
GList *ptr;
|
||||
|
||||
for (ptr = accts; ptr; ptr = g_list_next (ptr))
|
||||
{
|
||||
const gchar *color = xaccAccountGetColor (ptr->data);
|
||||
|
||||
if (g_strcmp0 (color, "Not Set") == 0)
|
||||
xaccAccountSetColor (ptr->data, "");
|
||||
}
|
||||
g_list_free (accts);
|
||||
|
||||
g_value_init (&value_b, G_TYPE_BOOLEAN);
|
||||
g_value_set_boolean (&value_b, TRUE);
|
||||
|
||||
// set the run-once value
|
||||
qof_instance_set_kvp (QOF_INSTANCE (book), &value_b, 1, "remove-color-not-set-slots");
|
||||
}
|
||||
}
|
||||
|
||||
/* ================================================================ */
|
||||
|
||||
Account *
|
||||
xaccScrubUtilityGetOrMakeAccount (Account *root, gnc_commodity * currency,
|
||||
const char *accname, GNCAccountType acctype,
|
||||
|
@ -145,6 +145,11 @@ void xaccAccountTreeScrubQuoteSources (Account *root, gnc_commodity_table *table
|
||||
/** Removes empty "notes", "placeholder", and "hbci" KVP slots from Accounts. */
|
||||
void xaccAccountScrubKvp (Account *account);
|
||||
|
||||
/** Remove color slots that have a "Not Set" value, since 2.4.0, fixed in 3.4
|
||||
* This should only be run once on a book
|
||||
*/
|
||||
void xaccAccountScrubColorNotSet (QofBook *book);
|
||||
|
||||
/** Changes Transaction date_posted timestamps from 00:00 local to 11:00 UTC.
|
||||
* 11:00 UTC is the same day local time in almost all timezones, the exceptions
|
||||
* being the -12, +13, and +14 timezones along the International Date Line. If
|
||||
|
Loading…
Reference in New Issue
Block a user