r19616 - gnucash/trunk/src - Remove leading character N from tax code, but only if it is there, and remove leading blank character when no tax code.

J. Alex Aycinena alex.aycinena at code.gnucash.org
Mon Sep 27 11:58:52 EDT 2010


Author: alex.aycinena
Date: 2010-09-27 11:58:52 -0400 (Mon, 27 Sep 2010)
New Revision: 19616
Trac: http://svn.gnucash.org/trac/changeset/19616

Modified:
   gnucash/trunk/src/app-utils/gnc-ui-util.c
   gnucash/trunk/src/gnome/dialog-tax-info.c
Log:
Remove leading character N from tax code, but only if it is there, and remove leading blank character when no tax code.

Modified: gnucash/trunk/src/app-utils/gnc-ui-util.c
===================================================================
--- gnucash/trunk/src/app-utils/gnc-ui-util.c	2010-09-27 04:58:09 UTC (rev 19615)
+++ gnucash/trunk/src/app-utils/gnc-ui-util.c	2010-09-27 15:58:52 UTC (rev 19616)
@@ -493,6 +493,9 @@
     }
     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 @@
                                           (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 @@
         {
             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 @@
         {
             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 @@
             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 @@
             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 @@
                    (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);
     }
 }
 

Modified: gnucash/trunk/src/gnome/dialog-tax-info.c
===================================================================
--- gnucash/trunk/src/gnome/dialog-tax-info.c	2010-09-27 04:58:09 UTC (rev 19615)
+++ gnucash/trunk/src/gnome/dialog-tax-info.c	2010-09-27 15:58:52 UTC (rev 19616)
@@ -281,7 +281,8 @@
         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 @@
         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) : "";



More information about the gnucash-changes mailing list