mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
* src/gnome/window-acct-tree.c: Disallow the deletion of accounts
with ReadOnly Transacation in them. You must first "delete" the RO Txns before you delete the account. Fix for bug# 100727 (although it requires invoice unposting to work). git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@7667 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
501e2589e9
commit
67243cd0ab
@ -1,3 +1,10 @@
|
|||||||
|
2002-12-09 Derek Atkins <derek@ihtfp.com>
|
||||||
|
|
||||||
|
* src/gnome/window-acct-tree.c: Disallow the deletion of accounts
|
||||||
|
with ReadOnly Transacation in them. You must first "delete" the
|
||||||
|
RO Txns before you delete the account. Fix for bug# 100727 (although
|
||||||
|
it requires invoice unposting to work).
|
||||||
|
|
||||||
2002-12-9 Benoit Grégoire <bock@step.polymtl.ca>
|
2002-12-9 Benoit Grégoire <bock@step.polymtl.ca>
|
||||||
* src/import-export/import-main-matcher.c:
|
* src/import-export/import-main-matcher.c:
|
||||||
* src/import-export/generic-import.glade: Change colors, remove
|
* src/import-export/generic-import.glade: Change colors, remove
|
||||||
|
@ -396,13 +396,32 @@ gnc_acct_tree_window_toolbar_add_account_cb (GtkWidget *widget, gpointer data)
|
|||||||
* and return the same value to stop walking the account tree if
|
* and return the same value to stop walking the account tree if
|
||||||
* appropriate.
|
* appropriate.
|
||||||
********************************************************************/
|
********************************************************************/
|
||||||
|
typedef struct _delete_helper {
|
||||||
|
gboolean has_splits;
|
||||||
|
gboolean has_ro_splits;
|
||||||
|
} delete_helper_t;
|
||||||
|
|
||||||
static gpointer
|
static gpointer
|
||||||
delete_account_helper (Account *account, gpointer data)
|
delete_account_helper (Account *account, gpointer data)
|
||||||
{
|
{
|
||||||
gboolean *has_splits = data;
|
delete_helper_t *helper_res = data;
|
||||||
|
GList *splits;
|
||||||
|
|
||||||
*has_splits = (xaccAccountGetSplitList(account) != NULL);
|
splits = xaccAccountGetSplitList(account);
|
||||||
return (gpointer)*has_splits;
|
if (splits) {
|
||||||
|
helper_res->has_splits = TRUE;
|
||||||
|
while (splits) {
|
||||||
|
Split *s = splits->data;
|
||||||
|
Transaction *txn = xaccSplitGetParent (s);
|
||||||
|
if (xaccTransGetReadOnly (txn)) {
|
||||||
|
helper_res->has_ro_splits = TRUE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
splits = splits->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (gpointer)(helper_res->has_splits || helper_res->has_ro_splits);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -421,22 +440,44 @@ gnc_acct_tree_window_delete_common (Account *account)
|
|||||||
_("One (or more) children of this account contain\n"
|
_("One (or more) children of this account contain\n"
|
||||||
"transactions. Are you sure you want to delete the\n"
|
"transactions. Are you sure you want to delete the\n"
|
||||||
"%s account and all its children?");
|
"%s account and all its children?");
|
||||||
|
const char *acct_has_ro_splits =
|
||||||
|
_("This account contains read-only transactions. You "
|
||||||
|
"may not delete %s.");
|
||||||
|
const char *child_has_ro_splits =
|
||||||
|
_("One (or more) children of this account contains "
|
||||||
|
"read-only transactions. You may not delete %s.");
|
||||||
const char *format;
|
const char *format;
|
||||||
char *name;
|
char *name;
|
||||||
|
GList *splits;
|
||||||
|
|
||||||
name = xaccAccountGetFullName(account, gnc_get_account_separator ());
|
name = xaccAccountGetFullName(account, gnc_get_account_separator ());
|
||||||
if (!name)
|
if (!name)
|
||||||
name = g_strdup ("");
|
name = g_strdup ("");
|
||||||
|
|
||||||
if (xaccAccountGetSplitList(account) != NULL) {
|
if ((splits = xaccAccountGetSplitList(account)) != NULL) {
|
||||||
|
/* Check for RO txns -- if there are any, disallow deletion */
|
||||||
|
for ( ; splits ; splits = splits->next) {
|
||||||
|
Split *s = splits->data;
|
||||||
|
Transaction *txn = xaccSplitGetParent (s);
|
||||||
|
if (xaccTransGetReadOnly (txn)) {
|
||||||
|
gnc_error_dialog (acct_has_ro_splits, name);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
format = acct_has_splits;
|
format = acct_has_splits;
|
||||||
} else {
|
} else {
|
||||||
AccountGroup *children;
|
AccountGroup *children;
|
||||||
gboolean has_splits = FALSE;
|
delete_helper_t delete_res = { FALSE, FALSE };
|
||||||
|
|
||||||
children = xaccAccountGetChildren(account);
|
children = xaccAccountGetChildren(account);
|
||||||
xaccGroupForEachAccount(children, delete_account_helper, &has_splits, TRUE);
|
xaccGroupForEachAccount(children, delete_account_helper, &delete_res, TRUE);
|
||||||
if (has_splits)
|
|
||||||
|
/* Check for RO txns in the children -- disallow deletion if there are any */
|
||||||
|
if (delete_res.has_ro_splits) {
|
||||||
|
gnc_error_dialog (child_has_ro_splits, name);
|
||||||
|
return;
|
||||||
|
|
||||||
|
} else if (delete_res.has_splits)
|
||||||
format= child_has_splits;
|
format= child_has_splits;
|
||||||
else
|
else
|
||||||
format = children ? no_splits : no_splits_no_children;
|
format = children ? no_splits : no_splits_no_children;
|
||||||
|
Loading…
Reference in New Issue
Block a user