diff --git a/gnucash/gnome-utils/dialog-account.c b/gnucash/gnome-utils/dialog-account.c
index f3936c2102..9556bc2591 100644
--- a/gnucash/gnome-utils/dialog-account.c
+++ b/gnucash/gnome-utils/dialog-account.c
@@ -116,6 +116,8 @@ typedef struct _AccountWindow
GtkWidget * tax_related_button;
GtkWidget * placeholder_button;
GtkWidget * hidden_button;
+ GtkWidget * auto_interest_button;
+ GtkWidget * auto_interest_button_label;
gint component_id;
} AccountWindow;
@@ -275,6 +277,10 @@ gnc_account_to_ui(AccountWindow *aw)
flag = xaccAccountGetHidden (account);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (aw->hidden_button),
flag);
+
+ flag = xaccAccountGetAutoInterest (account);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (aw->auto_interest_button),
+ flag);
LEAVE(" ");
}
@@ -443,6 +449,11 @@ gnc_ui_to_account(AccountWindow *aw)
if (xaccAccountGetHidden (account) != flag)
xaccAccountSetHidden (account, flag);
+ flag =
+ gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (aw->auto_interest_button));
+ if (xaccAccountGetAutoInterest (account) != flag)
+ xaccAccountSetAutoInterest (account, flag);
+
parent_account = gnc_tree_view_account_get_selected_account (GNC_TREE_VIEW_ACCOUNT (aw->parent_tree));
if (parent_account == NULL)
@@ -1083,6 +1094,18 @@ gnc_account_parent_changed_cb (GtkTreeSelection *selection, gpointer data)
gnc_account_window_set_name(aw);
}
+static void
+set_auto_interest_box(AccountWindow *aw)
+{
+ Account* account = aw_get_account (aw);
+ gboolean flag = account_type_has_auto_interest_xfer (aw->type);
+ gtk_widget_set_sensitive (GTK_WIDGET (aw->auto_interest_button), flag);
+ if (!flag)
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (aw->auto_interest_button), FALSE);
+ gtk_widget_set_sensitive (GTK_WIDGET (aw->auto_interest_button_label), flag);
+
+}
+
static void
gnc_account_type_changed_cb (GtkTreeSelection *selection, gpointer data)
{
@@ -1120,6 +1143,7 @@ gnc_account_type_changed_cb (GtkTreeSelection *selection, gpointer data)
gnc_amount_edit_set_amount (GNC_AMOUNT_EDIT (aw->opening_balance_edit),
gnc_numeric_zero ());
}
+ set_auto_interest_box(aw);
}
static void
@@ -1389,6 +1413,10 @@ gnc_account_window_create(GtkWindow *parent, AccountWindow *aw)
aw->tax_related_button = GTK_WIDGET(gtk_builder_get_object (builder, "tax_related_button"));
aw->placeholder_button = GTK_WIDGET(gtk_builder_get_object (builder, "placeholder_button"));
aw->hidden_button = GTK_WIDGET(gtk_builder_get_object (builder, "hidden_button"));
+ aw->auto_interest_button = GTK_WIDGET(gtk_builder_get_object (builder, "auto_interest_button"));
+ aw->auto_interest_button_label = GTK_WIDGET(gtk_builder_get_object (builder, "label405"));
+ set_auto_interest_box(aw);
+
box = GTK_WIDGET(gtk_builder_get_object (builder, "opening_balance_box"));
amount = gnc_amount_edit_new ();
diff --git a/gnucash/gnome-utils/dialog-account.h b/gnucash/gnome-utils/dialog-account.h
index 916f03e3f7..52c40058b2 100644
--- a/gnucash/gnome-utils/dialog-account.h
+++ b/gnucash/gnome-utils/dialog-account.h
@@ -26,6 +26,23 @@
#include "Account.h"
+/* Note: make sure to update the help text for this in prefs.scm if these
+ * change! These macros define the account types for which an auto interest
+ * xfer dialog could pop up, if the user's preferences allow it.
+ */
+#define account_type_has_auto_interest_charge(type) (((type) == ACCT_TYPE_CREDIT) || \
+((type) == ACCT_TYPE_LIABILITY) ||\
+((type) == ACCT_TYPE_PAYABLE))
+
+#define account_type_has_auto_interest_payment(type) (((type) == ACCT_TYPE_BANK) || \
+((type) == ACCT_TYPE_ASSET) || \
+((type) == ACCT_TYPE_MUTUAL) || \
+((type) == ACCT_TYPE_RECEIVABLE))
+
+#define account_type_has_auto_interest_xfer(type) \
+( account_type_has_auto_interest_charge(type) || \
+account_type_has_auto_interest_payment(type) )
+
/** @addtogroup GUI
@{ */
/** @addtogroup GuiAccount Creating and editing accounts in the GUI
diff --git a/gnucash/gnome/window-reconcile.c b/gnucash/gnome/window-reconcile.c
index 636aa14964..1eec321584 100644
--- a/gnucash/gnome/window-reconcile.c
+++ b/gnucash/gnome/window-reconcile.c
@@ -63,7 +63,6 @@
#endif
#define WINDOW_RECONCILE_CM_CLASS "window-reconcile"
-#define GNC_PREF_AUTO_INTEREST_TRANSFER "auto-interest-transfer"
#define GNC_PREF_AUTO_CC_PAYMENT "auto-cc-payment"
#define GNC_PREF_ALWAYS_REC_TO_TODAY "always-reconcile-to-today"
@@ -127,24 +126,6 @@ typedef struct _startRecnWindowData
time64 date; /* the interest xfer reconcile date */
} startRecnWindowData;
-
-/* Note: make sure to update the help text for this in prefs.scm if these
- * change! These macros define the account types for which an auto interest
- * xfer dialog could pop up, if the user's preferences allow it.
- */
-#define account_type_has_auto_interest_charge(type) (((type) == ACCT_TYPE_CREDIT) || \
- ((type) == ACCT_TYPE_LIABILITY) ||\
- ((type) == ACCT_TYPE_PAYABLE))
-
-#define account_type_has_auto_interest_payment(type) (((type) == ACCT_TYPE_BANK) || \
- ((type) == ACCT_TYPE_ASSET) || \
- ((type) == ACCT_TYPE_MUTUAL) || \
- ((type) == ACCT_TYPE_RECEIVABLE))
-
-#define account_type_has_auto_interest_xfer(type) \
- ( account_type_has_auto_interest_charge(type) || \
- account_type_has_auto_interest_payment(type) )
-
/** PROTOTYPES ******************************************************/
static gnc_numeric recnRecalculateBalance (RecnWindow *recnData);
@@ -424,21 +405,6 @@ gnc_start_recn_children_changed (GtkWidget *widget, startRecnWindowData *data)
}
-/* For a given account, determine if an auto interest xfer dialog should be
- * shown, based on both the per-account flag as well as the global reconcile
- * option. The global option is the default that is used if there is no
- * per-account option.
- */
-static gboolean
-gnc_recn_interest_xfer_get_auto_interest_xfer_allowed( Account *account )
-{
- gboolean auto_xfer;
-
- auto_xfer = gnc_prefs_get_bool(GNC_PREFS_GROUP_RECONCILE, GNC_PREF_AUTO_INTEREST_TRANSFER);
- return xaccAccountGetAutoInterestXfer( account, auto_xfer );
-}
-
-
/********************************************************************\
* recnInterestXferWindow *
* opens up a window to prompt the user to enter an interest *
@@ -472,27 +438,6 @@ gnc_recn_make_interest_window_name(Account *account, char *text)
}
-/* user clicked button in the interest xfer dialog entitled
- * "No Auto Interest Payments for this Account".
- */
-static void
-gnc_recn_interest_xfer_no_auto_clicked_cb(GtkButton *button,
- startRecnWindowData *data)
-{
- /* Indicate that the user doesn't want
- * an auto interest xfer for this account.
- */
- xaccAccountSetAutoInterestXfer( data->account, FALSE );
-
- /* shut down the interest xfer dialog */
- gnc_xfer_dialog_close( data->xferData );
-
- /* make the button clickable again */
- if ( data->xfer_button )
- gtk_widget_set_sensitive(GTK_WIDGET(data->xfer_button), TRUE);
-}
-
-
static void
recnInterestXferWindow( startRecnWindowData *data)
{
@@ -561,15 +506,6 @@ recnInterestXferWindow( startRecnWindowData *data)
gnc_xfer_dialog_quickfill_to_account( data->xferData, FALSE );
}
-
- /* add a button to disable auto interest payments for this account */
- gnc_xfer_dialog_add_user_specified_button( data->xferData,
- ( account_type_has_auto_interest_payment( data->account_type ) ?
- _("No Auto Interest Payments for this Account")
- : _("No Auto Interest Charges for this Account") ),
- G_CALLBACK(gnc_recn_interest_xfer_no_auto_clicked_cb),
- (gpointer) data );
-
/* no currency frame */
gnc_xfer_dialog_toggle_currency_table( data->xferData, FALSE );
@@ -627,10 +563,6 @@ gnc_reconcile_interest_xfer_run(startRecnWindowData *data)
void
gnc_start_recn_interest_clicked_cb(GtkButton *button, startRecnWindowData *data)
{
- /* indicate in account that user wants
- * an auto interest xfer for this account */
- xaccAccountSetAutoInterestXfer( data->account, TRUE );
-
/* make the button unclickable since we're popping up the window */
if ( data->xfer_button )
gtk_widget_set_sensitive(GTK_WIDGET(data->xfer_button), FALSE);
@@ -730,8 +662,7 @@ startRecnWindow(GtkWidget *parent, Account *account,
data.date = *statement_date;
/* whether to have an automatic interest xfer dialog or not */
- auto_interest_xfer_option =
- gnc_recn_interest_xfer_get_auto_interest_xfer_allowed( account );
+ auto_interest_xfer_option = xaccAccountGetAutoInterest (account);
data.include_children = !has_account_different_commodities(account) &&
xaccAccountGetReconcileChildrenStatus(account);
diff --git a/gnucash/gnome/window-reconcile2.c b/gnucash/gnome/window-reconcile2.c
index 1cd02dd71c..6887614098 100644
--- a/gnucash/gnome/window-reconcile2.c
+++ b/gnucash/gnome/window-reconcile2.c
@@ -56,9 +56,9 @@
#include "gnc-window.h"
#include "reconcile-view.h"
#include "window-reconcile2.h"
+#include "Account.h"
#define WINDOW_RECONCILE_CM_CLASS "window-reconcile"
-#define GNC_PREF_AUTO_INTEREST_TRANSFER "auto-interest-transfer"
#define GNC_PREF_AUTO_CC_PAYMENT "auto-cc-payment"
#define GNC_PREF_ALWAYS_REC_TO_TODAY "always-reconcile-to-today"
@@ -120,23 +120,6 @@ typedef struct _startRecnWindowData
} startRecnWindowData;
-/* Note: make sure to update the help text for this in prefs.scm if these
- * change! These macros define the account types for which an auto interest
- * xfer dialog could pop up, if the user's preferences allow it.
- */
-#define account_type_has_auto_interest_charge(type) (((type) == ACCT_TYPE_CREDIT) || \
- ((type) == ACCT_TYPE_LIABILITY) ||\
- ((type) == ACCT_TYPE_PAYABLE))
-
-#define account_type_has_auto_interest_payment(type) (((type) == ACCT_TYPE_BANK) || \
- ((type) == ACCT_TYPE_ASSET) || \
- ((type) == ACCT_TYPE_MUTUAL) || \
- ((type) == ACCT_TYPE_RECEIVABLE))
-
-#define account_type_has_auto_interest_xfer(type) \
- ( account_type_has_auto_interest_charge(type) || \
- account_type_has_auto_interest_payment(type) )
-
/** PROTOTYPES ******************************************************/
static gnc_numeric recnRecalculateBalance (RecnWindow2 *recnData);
@@ -366,21 +349,6 @@ gnc_start_recn2_children_changed (GtkWidget *widget, startRecnWindowData *data)
}
-/* For a given account, determine if an auto interest xfer dialog should be
- * shown, based on both the per-account flag as well as the global reconcile
- * option. The global option is the default that is used if there is no
- * per-account option.
- */
-static gboolean
-gnc_recn_interest_xfer_get_auto_interest_xfer_allowed (Account *account)
-{
- gboolean auto_xfer;
-
- auto_xfer = gnc_prefs_get_bool (GNC_PREFS_GROUP_RECONCILE, GNC_PREF_AUTO_INTEREST_TRANSFER);
- return xaccAccountGetAutoInterestXfer (account, auto_xfer);
-}
-
-
/********************************************************************\
* recnInterestXferWindow *
* opens up a window to prompt the user to enter an interest *
@@ -421,11 +389,6 @@ static void
gnc_recn_interest_xfer_no_auto_clicked_cb (GtkButton *button,
startRecnWindowData *data)
{
- /* Indicate that the user doesn't want
- * an auto interest xfer for this account.
- */
- xaccAccountSetAutoInterestXfer (data->account, FALSE);
-
/* shut down the interest xfer dialog */
gnc_xfer_dialog_close (data->xferData);
@@ -568,10 +531,6 @@ gnc_reconcile_interest_xfer_run (startRecnWindowData *data)
void
gnc_start_recn2_interest_clicked_cb (GtkButton *button, startRecnWindowData *data)
{
- /* indicate in account that user wants
- * an auto interest xfer for this account */
- xaccAccountSetAutoInterestXfer (data->account, TRUE);
-
/* make the button unclickable since we're popping up the window */
if (data->xfer_button)
gtk_widget_set_sensitive (GTK_WIDGET (data->xfer_button), FALSE);
@@ -671,8 +630,7 @@ startRecnWindow (GtkWidget *parent, Account *account,
data.date = *statement_date;
/* whether to have an automatic interest xfer dialog or not */
- auto_interest_xfer_option =
- gnc_recn_interest_xfer_get_auto_interest_xfer_allowed (account);
+ auto_interest_xfer_option = xaccAccountGetAutoInterest (account);
data.include_children = xaccAccountGetReconcileChildrenStatus (account);
diff --git a/gnucash/gtkbuilder/dialog-account.glade b/gnucash/gtkbuilder/dialog-account.glade
index 79118499ba..383070ad4f 100644
--- a/gnucash/gtkbuilder/dialog-account.glade
+++ b/gnucash/gtkbuilder/dialog-account.glade
@@ -1502,6 +1502,20 @@
8
+
+
+
+ 1
+ 10
+
+
+
+
+
+ 0
+ 10
+
+
0
diff --git a/libgnucash/engine/Account.cpp b/libgnucash/engine/Account.cpp
index 7654beee31..0cc63df107 100644
--- a/libgnucash/engine/Account.cpp
+++ b/libgnucash/engine/Account.cpp
@@ -106,6 +106,7 @@ enum
PROP_HIDDEN, /* Table slot exists, but in KVP in memory & xml */
PROP_PLACEHOLDER, /* Table slot exists, but in KVP in memory & xml */
+ PROP_AUTO_INTEREST,
PROP_FILTER, /* KVP */
PROP_SORT_ORDER, /* KVP */
PROP_SORT_REVERSED,
@@ -460,6 +461,9 @@ gnc_account_get_property (GObject *object,
case PROP_HIDDEN:
g_value_set_boolean(value, xaccAccountGetHidden(account));
break;
+ case PROP_AUTO_INTEREST:
+ g_value_set_boolean (value, xaccAccountGetAutoInterest (account));
+ break;
case PROP_PLACEHOLDER:
g_value_set_boolean(value, xaccAccountGetPlaceholder(account));
break;
@@ -585,6 +589,9 @@ gnc_account_set_property (GObject *object,
case PROP_HIDDEN:
xaccAccountSetHidden(account, g_value_get_boolean(value));
break;
+ case PROP_AUTO_INTEREST:
+ xaccAccountSetAutoInterest (account, g_value_get_boolean (value));
+ break;
case PROP_PLACEHOLDER:
xaccAccountSetPlaceholder(account, g_value_get_boolean(value));
break;
@@ -973,6 +980,16 @@ gnc_account_class_init (AccountClass *klass)
FALSE,
static_cast(G_PARAM_READWRITE)));
+ g_object_class_install_property
+ (gobject_class,
+ PROP_AUTO_INTEREST,
+ g_param_spec_boolean ("auto-interest-transfer",
+ "Auto Interest",
+ "Whether an interest transfer should be automatically "
+ "added before reconcile.",
+ FALSE,
+ static_cast(G_PARAM_READWRITE)));
+
g_object_class_install_property
(gobject_class,
PROP_PLACEHOLDER,
@@ -4092,6 +4109,21 @@ xaccAccountGetDescendantPlaceholder (const Account *acc)
return ret;
}
+/********************************************************************\
+ \********************************************************************/
+
+gboolean
+xaccAccountGetAutoInterest (const Account *acc)
+{
+ return boolean_from_key (acc, {KEY_RECONCILE_INFO, "auto-interest-transfer"});
+}
+
+void
+xaccAccountSetAutoInterest (Account *acc, gboolean val)
+{
+ set_boolean_key (acc, {KEY_RECONCILE_INFO, "auto-interest-transfer"}, val);
+}
+
/********************************************************************\
\********************************************************************/
@@ -4653,28 +4685,6 @@ xaccAccountClearReconcilePostpone (Account *acc)
/********************************************************************\
\********************************************************************/
-/* xaccAccountGetAutoInterestXfer: determine whether the auto interest
- * xfer option is enabled for this account, and return that value.
- * If it is not defined for the account, return the default value.
- */
-gboolean
-xaccAccountGetAutoInterestXfer (const Account *acc, gboolean default_value)
-{
- return boolean_from_key (acc, {KEY_RECONCILE_INFO, "auto-interest-transfer"});
-}
-
-/********************************************************************\
-\********************************************************************/
-
-void
-xaccAccountSetAutoInterestXfer (Account *acc, gboolean option)
-{
- set_boolean_key (acc, {KEY_RECONCILE_INFO, "auto-interest-transfer"}, option);
-}
-
-/********************************************************************\
-\********************************************************************/
-
const char *
xaccAccountGetLastNum (const Account *acc)
{
diff --git a/libgnucash/engine/Account.h b/libgnucash/engine/Account.h
index 04b7b35c72..2cc8160c36 100644
--- a/libgnucash/engine/Account.h
+++ b/libgnucash/engine/Account.h
@@ -455,18 +455,6 @@ void dxaccAccountSetPriceSrc (Account *account, const char *src);
* @deprecated Price quote information is now stored on the
* commodity, not the account. */
const char * dxaccAccountGetPriceSrc (const Account *account);
-
-/** Returns a per-account flag: Prior to reconciling an account which
- charges or pays interest, this flag tells whether to prompt the
- user to enter a transaction for the interest charge or
- payment. This per-account flag overrides the global preference. */
-gboolean xaccAccountGetAutoInterestXfer (const Account *account,
- gboolean default_value);
-/** Sets a per-account flag: Prior to reconciling an account which
- charges or pays interest, this flag tells whether to prompt the
- user to enter a transaction for the interest charge or
- payment. This per-account flag overrides the global preference. */
-void xaccAccountSetAutoInterestXfer (Account *account, gboolean value);
/** @} */
/** @name Account Commodity setters/getters
@@ -1223,6 +1211,29 @@ void xaccAccountSetHidden (Account *acc, gboolean val);
* @return Whether or not this account should be "hidden". */
gboolean xaccAccountIsHidden (const Account *acc);
/** @} */
+
+/** @name Account Auto Interest flag
+ @{
+ */
+
+/** Get the "auto interest" flag for an account. If this flag is set then
+ * the account (and any children) will trigger an interest transfer after reconciling.
+ *
+ * @param acc The account whose flag should be retrieved.
+ *
+ * @return The current state of the account's "auto interest" flag. */
+gboolean xaccAccountGetAutoInterest (const Account *acc);
+
+/** Set the "auto interest" flag for an account. If this flag is set then
+ * the account (and any children) will trigger an interest transfer after reconciling.
+ *
+ * @param acc The account whose flag should be retrieved.
+ *
+ * @param val The new state for the account's "auto interest" flag. */
+void xaccAccountSetAutoInterest (Account *acc, gboolean val);
+
+/** @} */
+
/** @name Account Tax related getters/setters
@{