Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
Showing
5 changed files
with
67 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
Bob-IT
Author
Contributor
|
||
|
||
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); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
There are more (unused) types. Wouldn't the
xaccAccountTypeGetFundamental
be useful here? Also theti_dialog->account_type
is tested againstACCT_TYPE_EQUITY
twice.gnucash/libgnucash/engine/Account.cpp
Line 4453 in 7f7ae2e