remove unnecessary KVPs and frames related to US Income Tax name and type

This commit is contained in:
Alex Aycinena 2019-01-27 15:58:46 -08:00
parent 69cc8fe282
commit 7d0adfd0c6
3 changed files with 145 additions and 42 deletions

View File

@ -1057,6 +1057,7 @@ identity_edit_response_cb (GtkDialog *dialog, gint response, gpointer data)
TaxInfoDialog *ti_dialog = data;
const gchar *entry_name = NULL;
const gchar *entry_type = NULL;
gboolean tax_name_changed = FALSE;
gint active_item = 0;
TaxTypeInfo *selected_type = NULL;
@ -1074,48 +1075,66 @@ identity_edit_response_cb (GtkDialog *dialog, gint response, gpointer data)
entry_type = selected_type->type_code;
if (!(g_strcmp0 (ti_dialog->tax_type, entry_type) == 0))
{
ti_dialog->tax_type_changed = TRUE;
gnc_set_current_book_tax_type (entry_type);
ti_dialog->tax_type = entry_type;
if (entry_type != NULL)
{
gtk_label_set_text (GTK_LABEL (ti_dialog->entity_type_display),
if (!((g_strcmp0 (ti_dialog->tax_type, "") == 0) &&
(g_strcmp0 (entry_type, "Other") == 0)))
{ /* tax type changed */
ti_dialog->tax_type_changed = TRUE;
ti_dialog->tax_type = entry_type;
if (entry_type != NULL)
{
gtk_label_set_text (GTK_LABEL (ti_dialog->entity_type_display),
selected_type->combo_box_entry);
}
else
{
gtk_label_set_text (GTK_LABEL (ti_dialog->entity_type_display),
}
else
{
gtk_label_set_text (GTK_LABEL (ti_dialog->entity_type_display),
ti_dialog->default_tax_type);
}
if (ti_dialog->income_txf_infos != NULL)
destroy_txf_infos (ti_dialog->income_txf_infos);
ti_dialog->income_txf_infos = load_txf_info (INCOME, ti_dialog);
if (ti_dialog->expense_txf_infos != NULL)
destroy_txf_infos (ti_dialog->expense_txf_infos);
ti_dialog->expense_txf_infos = load_txf_info (EXPENSE, ti_dialog);
if (ti_dialog->asset_txf_infos != NULL)
destroy_txf_infos (ti_dialog->asset_txf_infos);
ti_dialog->asset_txf_infos = load_txf_info (ASSET, ti_dialog);
if (ti_dialog->liab_eq_txf_infos != NULL)
destroy_txf_infos (ti_dialog->liab_eq_txf_infos);
ti_dialog->liab_eq_txf_infos = load_txf_info (LIAB_EQ, ti_dialog);
gtk_toggle_button_set_active
(GTK_TOGGLE_BUTTON(ti_dialog->expense_radio), TRUE);
tax_info_show_acct_type_accounts (ti_dialog);
gnc_tree_view_account_refilter
(GNC_TREE_VIEW_ACCOUNT (ti_dialog->account_treeview));
gnc_tax_info_update_accounts (ti_dialog);
clear_gui (ti_dialog);
}
if (ti_dialog->income_txf_infos != NULL)
destroy_txf_infos (ti_dialog->income_txf_infos);
ti_dialog->income_txf_infos = load_txf_info (INCOME, ti_dialog);
if (ti_dialog->expense_txf_infos != NULL)
destroy_txf_infos (ti_dialog->expense_txf_infos);
ti_dialog->expense_txf_infos = load_txf_info (EXPENSE, ti_dialog);
if (ti_dialog->asset_txf_infos != NULL)
destroy_txf_infos (ti_dialog->asset_txf_infos);
ti_dialog->asset_txf_infos = load_txf_info (ASSET, ti_dialog);
if (ti_dialog->liab_eq_txf_infos != NULL)
destroy_txf_infos (ti_dialog->liab_eq_txf_infos);
ti_dialog->liab_eq_txf_infos = load_txf_info (LIAB_EQ, ti_dialog);
gtk_toggle_button_set_active
(GTK_TOGGLE_BUTTON(ti_dialog->expense_radio), TRUE);
tax_info_show_acct_type_accounts (ti_dialog);
gnc_tree_view_account_refilter
(GNC_TREE_VIEW_ACCOUNT (ti_dialog->account_treeview));
gnc_tax_info_update_accounts (ti_dialog);
clear_gui (ti_dialog);
else /* tax type changed but from "" to "Other" - doesn't count as change */
ti_dialog->tax_type_changed = FALSE;
}
else /* tax type not changed */
ti_dialog->tax_type_changed = FALSE;
}
}
if (!(g_strcmp0 (ti_dialog->tax_name, entry_name) == 0))
{
gnc_set_current_book_tax_name (entry_name);
ti_dialog->tax_name = g_strdup (entry_name);
gtk_label_set_text (GTK_LABEL (ti_dialog->entity_name_display),
if (!(((ti_dialog->tax_name == NULL) &&
(g_strcmp0 (entry_name, "") == 0))))
{
tax_name_changed = TRUE;
ti_dialog->tax_name = g_strdup (entry_name);
gtk_label_set_text (GTK_LABEL (ti_dialog->entity_name_display),
entry_name);
}
else /* tax name changed but from NULL to "" - doesn't count as change */
tax_name_changed = FALSE;
}
else /* tax name not changed */
tax_name_changed = FALSE;
if (tax_name_changed || ti_dialog->tax_type_changed)
gnc_set_current_book_tax_name_type (tax_name_changed, entry_name,
ti_dialog->tax_type_changed, entry_type);
set_focus_sensitivity (ti_dialog);
ti_dialog->tax_type_changed = FALSE;
}

View File

@ -233,9 +233,97 @@ gnc_is_new_book (void)
#define OLD_OPTION_TAXUS_TYPE "book/tax_US/type"
void
gnc_set_current_book_tax_name (const gchar *tax_name)
gnc_set_current_book_tax_name_type (gboolean name_changed, const gchar *tax_name,
gboolean type_changed, const gchar *tax_type)
{
qof_book_set_string_option(gnc_get_current_book(), OPTION_TAXUS_NAME, tax_name);
if (name_changed)
{
if (type_changed)
{
QofBook* book = gnc_get_current_book();
if ((g_strcmp0 (tax_name, "") == 0) ||
(tax_name == NULL))
{ /* change to no name */
if ((g_strcmp0 (tax_type, "Other") == 0) ||
(g_strcmp0 (tax_type, "") == 0) ||
(tax_type == NULL))
{ /* need to delete both name and type and the "tax_US" frame */
qof_book_set_string_option(book, OPTION_TAXUS_NAME, NULL);
qof_book_set_string_option(book, OPTION_TAXUS_TYPE, NULL);
qof_book_option_frame_delete(book, "tax_US");
}
else
{ /* delete the name & change the type; keep the "tax_US" frame */
qof_book_set_string_option(book, OPTION_TAXUS_NAME, NULL);
qof_book_set_string_option(book, OPTION_TAXUS_TYPE, tax_type);
}
}
else /* new name */
{
if ((g_strcmp0 (tax_type, "Other") == 0) ||
(g_strcmp0 (tax_type, "") == 0) ||
(tax_type == NULL))
{ /* delete the type & change the name; keep the "tax_US" frame */
qof_book_set_string_option(book, OPTION_TAXUS_TYPE, NULL);
qof_book_set_string_option(book, OPTION_TAXUS_NAME, tax_name);
}
else /* and new type */
{ /* change the name & change the type */
qof_book_set_string_option(book, OPTION_TAXUS_NAME, tax_name);
qof_book_set_string_option(book, OPTION_TAXUS_TYPE, tax_type);
}
}
}
else /* no type change but name changed */
{
QofBook* book = gnc_get_current_book();
if ((g_strcmp0 (tax_name, "") == 0) ||
(tax_name == NULL))
{ /* change to no name */
if ((g_strcmp0 (tax_type, "Other") == 0) ||
(g_strcmp0 (tax_type, "") == 0) ||
(tax_type == NULL))
{ /* delete the name; there is no type; deleted the "tax_US" frame */
qof_book_set_string_option(book, OPTION_TAXUS_NAME, NULL);
qof_book_option_frame_delete(book, "tax_US");
}
else
{ /* need to delete the name and keep "tax_US" frame */
qof_book_set_string_option(book, OPTION_TAXUS_NAME, NULL);
}
}
else
{ /* change the name & keep "tax_US" frame */
qof_book_set_string_option(book, OPTION_TAXUS_NAME, tax_name);
}
}
}
else /* no name change */
{
if (type_changed)
{
QofBook* book = gnc_get_current_book();
if ((g_strcmp0 (tax_type, "Other") == 0) ||
(g_strcmp0 (tax_type, "") == 0) ||
(tax_type == NULL))
{
if ((g_strcmp0 (tax_name, "") == 0) ||
(tax_name == NULL))
{/* delete the type; there is no name; delete the "tax_US" frame */
qof_book_set_string_option(book, OPTION_TAXUS_TYPE, NULL);
qof_book_option_frame_delete(book, "tax_US");
}
else
{ /* need to delete the type and keep "tax_US" frame */
qof_book_set_string_option(book, OPTION_TAXUS_TYPE, NULL);
}
}
else
{ /* change the type & keep "tax_US" frame */
qof_book_set_string_option(book, OPTION_TAXUS_TYPE, tax_type);
}
} /*else no name and no type change - do nothing */
}
}
const gchar *
@ -282,12 +370,6 @@ gnc_get_current_book_tax_name (void)
}
}
void
gnc_set_current_book_tax_type (const gchar *tax_type)
{
qof_book_set_string_option(gnc_get_current_book(), OPTION_TAXUS_TYPE, tax_type);
}
const gchar *
gnc_get_current_book_tax_type (void)
{

View File

@ -72,9 +72,11 @@ QofBook * gnc_get_current_book (void);
* need to check as well for a book with no accounts (root with no children). */
gboolean gnc_is_new_book (void);
void gnc_set_current_book_tax_name (const gchar *tax_name);
void gnc_set_current_book_tax_name_type (gboolean name_changed,
const gchar *tax_name,
gboolean type_changed,
const gchar *tax_type);
const gchar * gnc_get_current_book_tax_name (void);
void gnc_set_current_book_tax_type (const gchar *tax_type);
const gchar * gnc_get_current_book_tax_type (void);
/** Calls gnc_book_option_num_field_source_change to initiate registered
* callbacks when num_field_source book option changes so that