Bug 554391 - Select account if Tax Options dialog opened from CoA

If the Tax options dialog is opened from the Chart of Accounts and an
account is selected then the tax dialog will preselect that account.
This commit is contained in:
Robert Fewell 2020-09-24 12:44:49 +01:00
parent 227bbda16c
commit 7f7ae2ef00
5 changed files with 67 additions and 4 deletions

View File

@ -111,7 +111,7 @@ int gnc_choose_radio_option_dialog (GtkWidget *parent,
int default_value,
GList *radio_list);
void gnc_tax_info_dialog (GtkWidget *parent);
void gnc_tax_info_dialog (GtkWidget *parent, Account *account);
void gnc_stock_split_dialog (GtkWidget *parent, Account * initial);
typedef enum

View File

@ -103,6 +103,7 @@ typedef struct
GtkWidget * tax_identity_edit_button;
GtkWidget * acct_info;
GtkWidget * income_radio;
GtkWidget * expense_radio;
GtkWidget * asset_radio;
GtkWidget * liab_eq_radio;
@ -883,6 +884,39 @@ gnc_tax_info_update_accounts (TaxInfoDialog *ti_dialog)
return num_accounts;
}
static void
gnc_tax_info_set_acct (TaxInfoDialog *ti_dialog, Account *account)
{
if (account == NULL)
return;
ti_dialog->account_type = xaccAccountGetType (account);
if (ti_dialog->account_type == ACCT_TYPE_INCOME)
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(ti_dialog->income_radio), TRUE);
else if (ti_dialog->account_type == ACCT_TYPE_EXPENSE)
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(ti_dialog->expense_radio), TRUE);
else if ((ti_dialog->account_type == ACCT_TYPE_ASSET) ||
(ti_dialog->account_type == ACCT_TYPE_BANK) ||
(ti_dialog->account_type == ACCT_TYPE_CASH) ||
(ti_dialog->account_type == ACCT_TYPE_STOCK) ||
(ti_dialog->account_type == ACCT_TYPE_MUTUAL) ||
(ti_dialog->account_type == ACCT_TYPE_RECEIVABLE))
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(ti_dialog->asset_radio), TRUE);
else if ((ti_dialog->account_type == ACCT_TYPE_LIABILITY) ||
(ti_dialog->account_type == ACCT_TYPE_EQUITY) ||
(ti_dialog->account_type == ACCT_TYPE_CREDIT) ||
(ti_dialog->account_type == ACCT_TYPE_PAYABLE))
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(ti_dialog->liab_eq_radio), TRUE);
else if (ti_dialog->account_type == ACCT_TYPE_EQUITY)
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(ti_dialog->liab_eq_radio), TRUE);
else
return;
gnc_tree_view_account_set_selected_account (GNC_TREE_VIEW_ACCOUNT(ti_dialog->account_treeview),
account);
}
static void
gnc_tax_info_acct_type_cb (GtkWidget *w, gpointer data)
{
@ -1440,6 +1474,7 @@ gnc_tax_info_dialog_create (GtkWidget * parent, TaxInfoDialog *ti_dialog)
gtk_label_set_mnemonic_widget(GTK_LABEL(label), GTK_WIDGET(tree_view));
income_radio = GTK_WIDGET(gtk_builder_get_object (builder, "income_radio"));
ti_dialog->income_radio = income_radio;
expense_radio = GTK_WIDGET(gtk_builder_get_object (builder, "expense_radio"));
ti_dialog->expense_radio = expense_radio;
asset_radio = GTK_WIDGET(gtk_builder_get_object (builder, "asset_radio"));
@ -1520,7 +1555,7 @@ refresh_handler (GHashTable *changes, gpointer user_data)
* Return: nothing *
\********************************************************************/
void
gnc_tax_info_dialog (GtkWidget * parent)
gnc_tax_info_dialog (GtkWidget * parent, Account * account)
{
TaxInfoDialog *ti_dialog;
gint component_id;
@ -1529,6 +1564,9 @@ gnc_tax_info_dialog (GtkWidget * parent)
gnc_tax_info_dialog_create (parent, ti_dialog);
if (account)
gnc_tax_info_set_acct (ti_dialog, account);
component_id = gnc_register_gui_component (DIALOG_TAX_INFO_CM_CLASS,
refresh_handler, close_handler,
ti_dialog);

View File

@ -524,7 +524,7 @@ gnc_main_window_cmd_edit_tax_options (GtkAction *action, GncMainWindowActionData
{
g_return_if_fail (data != NULL);
gnc_tax_info_dialog (GTK_WIDGET (data->window));
gnc_tax_info_dialog (GTK_WIDGET (data->window), NULL);
}
static void

View File

@ -165,6 +165,7 @@ static void gnc_plugin_page_account_tree_cmd_refresh (GtkAction *action, GncPlug
static void gnc_plugin_page_account_tree_cmd_autoclear (GtkAction *action, GncPluginPageAccountTree *page);
static void gnc_plugin_page_account_tree_cmd_transfer (GtkAction *action, GncPluginPageAccountTree *page);
static void gnc_plugin_page_account_tree_cmd_stock_split (GtkAction *action, GncPluginPageAccountTree *page);
static void gnc_plugin_page_account_tree_cmd_edit_tax_options (GtkAction *action, GncPluginPageAccountTree *page);
static void gnc_plugin_page_account_tree_cmd_lots (GtkAction *action, GncPluginPageAccountTree *page);
static void gnc_plugin_page_account_tree_cmd_scrub (GtkAction *action, GncPluginPageAccountTree *page);
static void gnc_plugin_page_account_tree_cmd_scrub_sub (GtkAction *action, GncPluginPageAccountTree *page);
@ -272,7 +273,18 @@ static GtkActionEntry gnc_plugin_page_account_tree_actions [] =
N_("Renumber the children of the selected account"),
G_CALLBACK (gnc_plugin_page_account_tree_cmd_renumber_accounts)
},
{
"EditTaxOptionsAction", NULL,
/* Translators: remember to reuse this *
* translation in dialog-account.glade */
N_("Ta_x Report Options"), NULL,
/* Translators: currently implemented are *
* US: income tax and *
* DE: VAT *
* So adjust this string */
N_("Setup relevant accounts for tax reports, e.g. US income tax"),
G_CALLBACK (gnc_plugin_page_account_tree_cmd_edit_tax_options)
},
/* View menu */
{
"ViewFilterByAction", NULL, N_("_Filter By..."), NULL, NULL,
@ -1922,6 +1934,18 @@ gnc_plugin_page_account_tree_cmd_stock_split (GtkAction *action,
gnc_stock_split_dialog (window, account);
}
static void
gnc_plugin_page_account_tree_cmd_edit_tax_options (GtkAction *action,
GncPluginPageAccountTree *page)
{
GtkWidget *window;
Account *account;
account = gnc_plugin_page_account_tree_get_current_account (page);
window = GNC_PLUGIN_PAGE (page)->window;
gnc_tax_info_dialog (window, account);
}
static void
gnc_plugin_page_account_tree_cmd_lots (GtkAction *action,
GncPluginPageAccountTree *page)

View File

@ -10,6 +10,7 @@
<separator name="EditSep2"/>
<menuitem name="FileOpenAccount" action="FileOpenAccountAction"/>
<menuitem name="FileOpenSubaccounts" action="FileOpenSubaccountsAction"/>
<menuitem name="EditTaxOptions" action="EditTaxOptionsAction"/>
</placeholder>
</menu>
<menu name="Actions" action="ActionsAction">