mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
remove unnecesary 'home' level in path for US Income Tax book tax information
This commit is contained in:
parent
3a48672763
commit
fc15364326
@ -227,8 +227,10 @@ gnc_is_new_book (void)
|
|||||||
? TRUE : FALSE);
|
? TRUE : FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define OPTION_TAXUS_NAME "book/tax_US/name"
|
#define OPTION_TAXUS_NAME "tax_US/name"
|
||||||
#define OPTION_TAXUS_TYPE "book/tax_US/type"
|
#define OPTION_TAXUS_TYPE "tax_US/type"
|
||||||
|
#define OLD_OPTION_TAXUS_NAME "book/tax_US/name"
|
||||||
|
#define OLD_OPTION_TAXUS_TYPE "book/tax_US/type"
|
||||||
|
|
||||||
void
|
void
|
||||||
gnc_set_current_book_tax_name (const gchar *tax_name)
|
gnc_set_current_book_tax_name (const gchar *tax_name)
|
||||||
@ -239,7 +241,45 @@ gnc_set_current_book_tax_name (const gchar *tax_name)
|
|||||||
const gchar *
|
const gchar *
|
||||||
gnc_get_current_book_tax_name (void)
|
gnc_get_current_book_tax_name (void)
|
||||||
{
|
{
|
||||||
return qof_book_get_string_option(gnc_get_current_book(), OPTION_TAXUS_NAME);
|
QofBook* book = gnc_get_current_book();
|
||||||
|
const char* tax_name =
|
||||||
|
qof_book_get_string_option(book, OPTION_TAXUS_NAME);
|
||||||
|
if (tax_name)
|
||||||
|
{
|
||||||
|
return tax_name;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const char* old_option_taxus_name =
|
||||||
|
qof_book_get_string_option(book, OLD_OPTION_TAXUS_NAME);
|
||||||
|
if (old_option_taxus_name)
|
||||||
|
{
|
||||||
|
char* taxus_name = g_strdup(old_option_taxus_name);
|
||||||
|
const char* old_option_taxus_type =
|
||||||
|
qof_book_get_string_option(book, OLD_OPTION_TAXUS_TYPE);
|
||||||
|
if (old_option_taxus_type)
|
||||||
|
{ /* switch both name and type and remove unused frames */
|
||||||
|
char* taxus_type = g_strdup(old_option_taxus_type);
|
||||||
|
qof_book_set_string_option(book, OPTION_TAXUS_NAME, taxus_name);
|
||||||
|
qof_book_set_string_option(book, OLD_OPTION_TAXUS_NAME, '\0');
|
||||||
|
qof_book_set_string_option(book, OPTION_TAXUS_TYPE, taxus_type);
|
||||||
|
qof_book_set_string_option(book, OLD_OPTION_TAXUS_TYPE, '\0');
|
||||||
|
qof_book_option_frame_delete(book, "book/tax_US");
|
||||||
|
qof_book_option_frame_delete(book, "book");
|
||||||
|
g_free (taxus_type);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ /* switch just name and remove unused frames */
|
||||||
|
qof_book_set_string_option(book, OPTION_TAXUS_NAME, taxus_name);
|
||||||
|
qof_book_set_string_option(book, OLD_OPTION_TAXUS_NAME, '\0');
|
||||||
|
qof_book_option_frame_delete(book, "book/tax_US");
|
||||||
|
qof_book_option_frame_delete(book, "book");
|
||||||
|
}
|
||||||
|
g_free (taxus_name);
|
||||||
|
return qof_book_get_string_option(book, OPTION_TAXUS_NAME);
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -251,7 +291,45 @@ gnc_set_current_book_tax_type (const gchar *tax_type)
|
|||||||
const gchar *
|
const gchar *
|
||||||
gnc_get_current_book_tax_type (void)
|
gnc_get_current_book_tax_type (void)
|
||||||
{
|
{
|
||||||
return qof_book_get_string_option(gnc_get_current_book(), OPTION_TAXUS_TYPE);
|
QofBook* book = gnc_get_current_book();
|
||||||
|
const char* tax_type =
|
||||||
|
qof_book_get_string_option(book, OPTION_TAXUS_TYPE);
|
||||||
|
if (tax_type)
|
||||||
|
{
|
||||||
|
return tax_type;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const char* old_option_taxus_type =
|
||||||
|
qof_book_get_string_option(book, OLD_OPTION_TAXUS_TYPE);
|
||||||
|
if (old_option_taxus_type)
|
||||||
|
{
|
||||||
|
char* taxus_type = g_strdup(old_option_taxus_type);
|
||||||
|
const char* old_option_taxus_name =
|
||||||
|
qof_book_get_string_option(book, OLD_OPTION_TAXUS_NAME);
|
||||||
|
if (old_option_taxus_name)
|
||||||
|
{ /* switch both name and type and remove unused frames */
|
||||||
|
char* taxus_name = g_strdup(old_option_taxus_name);
|
||||||
|
qof_book_set_string_option(book, OPTION_TAXUS_NAME, taxus_name);
|
||||||
|
qof_book_set_string_option(book, OLD_OPTION_TAXUS_NAME, '\0');
|
||||||
|
qof_book_set_string_option(book, OPTION_TAXUS_TYPE, taxus_type);
|
||||||
|
qof_book_set_string_option(book, OLD_OPTION_TAXUS_TYPE, '\0');
|
||||||
|
qof_book_option_frame_delete(book, "book/tax_US");
|
||||||
|
qof_book_option_frame_delete(book, "book");
|
||||||
|
g_free (taxus_name);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ /* switch just type and remove unused frames */
|
||||||
|
qof_book_set_string_option(book, OPTION_TAXUS_TYPE, taxus_type);
|
||||||
|
qof_book_set_string_option(book, OLD_OPTION_TAXUS_TYPE, '\0');
|
||||||
|
qof_book_option_frame_delete(book, "book/tax_US");
|
||||||
|
qof_book_option_frame_delete(book, "book");
|
||||||
|
}
|
||||||
|
g_free (taxus_type);
|
||||||
|
return qof_book_get_string_option(book, OPTION_TAXUS_TYPE);
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Calls gnc_book_option_num_field_source_change to initiate registered
|
/** Calls gnc_book_option_num_field_source_change to initiate registered
|
||||||
|
@ -1171,6 +1171,20 @@ qof_book_set_string_option(QofBook* book, const char* opt_name, const char* opt_
|
|||||||
qof_book_commit_edit(book);
|
qof_book_commit_edit(book);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
qof_book_option_frame_delete (QofBook *book, const char* opt_name)
|
||||||
|
{
|
||||||
|
if (opt_name && (*opt_name != '\0'))
|
||||||
|
{
|
||||||
|
qof_book_begin_edit(book);
|
||||||
|
auto frame = qof_instance_get_slots(QOF_INSTANCE(book));
|
||||||
|
auto opt_path = opt_name_to_path(opt_name);
|
||||||
|
delete frame->set_path(opt_path, nullptr);
|
||||||
|
qof_instance_set_dirty (QOF_INSTANCE (book));
|
||||||
|
qof_book_commit_edit(book);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
qof_book_begin_edit (QofBook *book)
|
qof_book_begin_edit (QofBook *book)
|
||||||
{
|
{
|
||||||
|
@ -375,6 +375,7 @@ char *qof_book_get_counter_format (const QofBook *book,
|
|||||||
|
|
||||||
const char* qof_book_get_string_option(const QofBook* book, const char* opt_name);
|
const char* qof_book_get_string_option(const QofBook* book, const char* opt_name);
|
||||||
void qof_book_set_string_option(QofBook* book, const char* opt_name, const char* opt_val);
|
void qof_book_set_string_option(QofBook* book, const char* opt_name, const char* opt_val);
|
||||||
|
void qof_book_option_frame_delete (QofBook *book, const char* opt_name);
|
||||||
|
|
||||||
/** Access functions for reading and setting the used-features on this book.
|
/** Access functions for reading and setting the used-features on this book.
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user