Remove leading character N from tax code, but only if it is there, and remove leading blank character when no tax code.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@19616 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
J. Alex Aycinena 2010-09-27 15:58:52 +00:00
parent 9868279502
commit c44254c424
2 changed files with 28 additions and 14 deletions

View File

@ -493,6 +493,9 @@ gnc_ui_account_get_tax_info_string (const Account *account)
}
else /* with tax code */
{
const gchar *num_code = NULL;
const gchar *prefix = "N";
tax_type = gnc_get_current_book_tax_type ();
if (tax_type == NULL || (safe_strcmp (tax_type, "") == 0))
return g_strdup (_("Tax entity type not specified"));
@ -553,15 +556,19 @@ gnc_ui_account_get_tax_info_string (const Account *account)
(atype == ACCT_TYPE_PAYABLE)) ?
"txf-liab-eq-categories" : ""))));
num_code = g_strdup (code);
if (g_str_has_prefix (num_code, prefix))
num_code++; /* to lose the leading N */
if (category == SCM_UNDEFINED)
{
if (tax_related)
return g_strdup_printf
(_("Tax type %s: invalid code %s for account type"), tax_type, code);
(_("Tax type %s: invalid code %s for account type"), tax_type, num_code);
else
return g_strdup_printf
(_("Not tax-related; tax type %s: invalid code %s for account type"),
tax_type, code);
tax_type, num_code);
}
code_scm = scm_str2symbol (code);
@ -570,10 +577,10 @@ gnc_ui_account_get_tax_info_string (const Account *account)
{
if (tax_related)
return g_strdup_printf
(_("Invalid code %s for tax type %s"), code, tax_type);
(_("Invalid code %s for tax type %s"), num_code, tax_type);
else
return g_strdup_printf
(_("Not tax-related; invalid code %s for tax type %s"), code, tax_type);
(_("Not tax-related; invalid code %s for tax type %s"), num_code, tax_type);
}
form = scm_to_locale_string (scm);
@ -581,10 +588,10 @@ gnc_ui_account_get_tax_info_string (const Account *account)
{
if (tax_related)
return g_strdup_printf
(_("No form: code %s, tax type %s"), code, tax_type);
(_("No form: code %s, tax type %s"), num_code, tax_type);
else
return g_strdup_printf
(_("Not tax-related; no form: code %s, tax type %s"), code, tax_type);
(_("Not tax-related; no form: code %s, tax type %s"), num_code, tax_type);
}
scm = scm_call_3 (get_desc, category, code_scm, tax_entity_type);
@ -593,11 +600,11 @@ gnc_ui_account_get_tax_info_string (const Account *account)
if (tax_related)
return g_strdup_printf
(_("No description: form %s, code %s, tax type %s"),
form, code, tax_type);
form, num_code, tax_type);
else
return g_strdup_printf
(_("Not tax-related; no description: form %s, code %s, tax type %s"),
form, code, tax_type);
form, num_code, tax_type);
}
desc = scm_to_locale_string (scm);
@ -606,11 +613,11 @@ gnc_ui_account_get_tax_info_string (const Account *account)
if (tax_related)
return g_strdup_printf
(_("No description: form %s, code %s, tax type %s"),
form, code, tax_type);
form, num_code, tax_type);
else
return g_strdup_printf
(_("Not tax-related; no description: form %s, code %s, tax type %s"),
form, code, tax_type);
form, num_code, tax_type);
}
copy_number = xaccAccountGetTaxUSCopyNumber (account);
@ -618,11 +625,16 @@ gnc_ui_account_get_tax_info_string (const Account *account)
(gint) copy_number);
if (tax_related)
return g_strdup_printf ("%s%s %s", form, copy_txt, desc);
{
if (safe_strcmp (form, "") == 0)
return g_strdup_printf ("%s", desc);
else
return g_strdup_printf ("%s%s %s", form, copy_txt, desc);
}
else
return g_strdup_printf
(_("Not tax-related; %s%s %s (code %s, tax type %s)"),
form, copy_txt, desc, code, tax_type);
form, copy_txt, desc, num_code, tax_type);
}
}

View File

@ -281,7 +281,8 @@ load_txf_info (gint acct_category, TaxInfoDialog *ti_dialog)
const gchar *form_line = _("Form Line Data: ");
const gchar *code_line_word = _("Code");
const gchar *code_line_colon = ": ";
gchar *num_code = NULL;
const gchar *num_code = NULL;
const gchar *prefix = "N";
gchar *form_line_data = NULL;
SCM scm;
gint year;
@ -308,7 +309,8 @@ load_txf_info (gint acct_category, TaxInfoDialog *ti_dialog)
str = scm_is_symbol(code_scm) ? SCM_SYMBOL_CHARS(code_scm) : "";
txf_info->code = g_strdup (str);
num_code = g_strdup (str);
num_code++; /* to lose the leading N */
if (g_str_has_prefix (num_code, prefix))
num_code++; /* to lose the leading N */
scm = scm_call_3 (getters.form, category, code_scm, tax_entity_type);
str = scm_is_string(scm) ? scm_to_locale_string(scm) : "";