r20039 - gnucash/trunk/src/app-utils - Add info about sub-accounts to Tax Info column on Accounts page.

J. Alex Aycinena alex.aycinena at code.gnucash.org
Sat Jan 8 18:52:14 EST 2011


Author: alex.aycinena
Date: 2011-01-08 18:52:13 -0500 (Sat, 08 Jan 2011)
New Revision: 20039
Trac: http://svn.gnucash.org/trac/changeset/20039

Modified:
   gnucash/trunk/src/app-utils/gnc-ui-util.c
Log:
Add info about sub-accounts to Tax Info column on Accounts page.

Modified: gnucash/trunk/src/app-utils/gnc-ui-util.c
===================================================================
--- gnucash/trunk/src/app-utils/gnc-ui-util.c	2011-01-08 13:52:15 UTC (rev 20038)
+++ gnucash/trunk/src/app-utils/gnc-ui-util.c	2011-01-08 23:52:13 UTC (rev 20039)
@@ -464,32 +464,61 @@
     SCM category;
     SCM code_scm;
     SCM tax_entity_type;
-    const gchar *form, *desc, *copy_txt;
+    const gchar *form, *desc, *copy_txt, *descendant_txt;
     gint64 copy_number;
     SCM scm;
+    GList *descendant, *account_descendants;
 
     if (!account)
         return NULL;
 
+    account_descendants = gnc_account_get_descendants (account);
+    if (account_descendants)
+    {
+       gint sub_acct_tax_number = 0;
+       for (descendant = account_descendants; descendant;
+                             descendant = g_list_next(descendant))
+       {
+            if (xaccAccountGetTaxRelated (descendant->data))
+               sub_acct_tax_number++;
+       }
+      /* Translators: This and the following strings appear on
+       * the account tab if the Tax Info column is displayed,
+       * i.e. if the user wants to record the tax form number
+       * and location on that tax form which corresponds to this
+       * gnucash account. For the US Income Tax support in
+       * gnucash, each tax code that can be assigned to an
+       * account generally corresponds to a specific line number
+       * on a paper form and each form has a unique
+       * identification (e.g., Form 1040, Schedule A). */
+       descendant_txt = (sub_acct_tax_number == 0) ? "" :
+                 g_strdup_printf (_("(Tax-related subaccounts: %d)"),
+                                                 sub_acct_tax_number);
+    }
+    else
+       descendant_txt = "";
+
     tax_related = xaccAccountGetTaxRelated (account);
     code = xaccAccountGetTaxUSCode (account);
 
     if (!code)
     {
         if (!tax_related)
-            return NULL;
+        {
+           if (safe_strcmp (descendant_txt, "") == 0)
+              return NULL;
+           else
+              return g_strdup_printf ("%s", descendant_txt);
+        }
         /* tax_related && !code */
         else
-            /* Translators: This and the following strings appear on
-             * the account tab if the Tax Info column is displayed,
-             * i.e. if the user wants to record the tax form number
-             * and location on that tax form which corresponds to this
-             * gnucash account. For the US Income Tax support in
-             * gnucash, each tax code that can be assigned to an
-             * account generally corresponds to a specific line number
-             * on a paper form and each form has a unique
-             * identification (e.g., Form 1040, Schedule A). */
-            return g_strdup (_("Tax-related but has no tax code"));
+        {
+           if (safe_strcmp (descendant_txt, "") == 0)
+              return g_strdup (_("Tax-related but has no tax code"));
+           else
+              return g_strdup_printf
+                 (_("Tax-related but has no tax code; %s"), descendant_txt);
+        }
     }
     else  /* with tax code */
     {
@@ -498,7 +527,13 @@
 
         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"));
+        {
+           if (safe_strcmp (descendant_txt, "") == 0)
+              return g_strdup (_("Tax entity type not specified"));
+           else
+              return g_strdup_printf
+                   (_("Tax entity type not specified; %s"), descendant_txt);
+        }
         atype = xaccAccountGetType (account);
         /*    tax_entity_type = scm_from_locale_string (tax_type); <- requires guile 1.8*/
         tax_entity_type = scm_makfrom0str (tax_type); /* <-guile 1.6  */
@@ -563,12 +598,27 @@
         if (category == SCM_UNDEFINED)
         {
             if (tax_related)
-                return g_strdup_printf
-                       (_("Tax type %s: invalid code %s for account type"), tax_type, num_code);
+            {
+               if (safe_strcmp (descendant_txt, "") == 0)
+                  return g_strdup_printf
+                       (_("Tax type %s: invalid code %s for account type"),
+                                                        tax_type, num_code);
+               else
+                  return g_strdup_printf
+                    (_("Tax type %s: invalid code %s for account type; %s"),
+                                        tax_type, num_code, descendant_txt);
+            }
             else
-                return g_strdup_printf
+            {
+               if (safe_strcmp (descendant_txt, "") == 0)
+                  return g_strdup_printf
                        (_("Not tax-related; tax type %s: invalid code %s for account type"),
-                        tax_type, num_code);
+                                                       tax_type, num_code);
+               else
+                  return g_strdup_printf
+                       (_("Not tax-related; tax type %s: invalid code %s for account type; %s"),
+                                        tax_type, num_code, descendant_txt);
+            }
         }
 
         code_scm = scm_str2symbol (code);
@@ -576,48 +626,107 @@
         if (!scm_is_string (scm))
         {
             if (tax_related)
-                return g_strdup_printf
-                       (_("Invalid code %s for tax type %s"), num_code, tax_type);
+            {
+               if (safe_strcmp (descendant_txt, "") == 0)
+                  return g_strdup_printf
+                       (_("Invalid code %s for tax type %s"),
+                                                        num_code, tax_type);
+               else
+                  return g_strdup_printf
+                       (_("Invalid code %s for tax type %s; %s"),
+                                        num_code, tax_type, descendant_txt);
+            }
             else
-                return g_strdup_printf
-                       (_("Not tax-related; invalid code %s for tax type %s"), num_code, tax_type);
+            {
+               if (safe_strcmp (descendant_txt, "") == 0)
+                  return g_strdup_printf
+                     (_("Not tax-related; 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; %s"),
+                                        num_code, tax_type, descendant_txt);
+            }
         }
 
         form = scm_to_locale_string (scm);
         if (!form)
         {
             if (tax_related)
-                return g_strdup_printf
-                       (_("No form: code %s, tax type %s"), num_code, tax_type);
+            {
+               if (safe_strcmp (descendant_txt, "") == 0)
+                  return g_strdup_printf
+                   (_("No form: code %s, tax type %s"), num_code, tax_type);
+               else
+                  return g_strdup_printf
+                   (_("No form: code %s, tax type %s; %s"),
+                                        num_code, tax_type, descendant_txt);
+            }
             else
-                return g_strdup_printf
-                       (_("Not tax-related; no form: code %s, tax type %s"), num_code, tax_type);
+            {
+               if (safe_strcmp (descendant_txt, "") == 0)
+                  return g_strdup_printf
+                       (_("Not tax-related; 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; %s"),
+                                        num_code, tax_type, descendant_txt);
+            }
         }
 
         scm = scm_call_3 (get_desc, category, code_scm, tax_entity_type);
         if (!scm_is_string (scm))
         {
             if (tax_related)
-                return g_strdup_printf
-                       (_("No description: form %s, code %s, tax type %s"),
-                        form, num_code, tax_type);
+            {
+               if (safe_strcmp (descendant_txt, "") == 0)
+                  return g_strdup_printf
+                   (_("No description: form %s, code %s, tax type %s"),
+                                                  form, num_code, tax_type);
+               else
+                  return g_strdup_printf
+                    (_("No description: form %s, code %s, tax type %s; %s"),
+                                  form, num_code, tax_type, descendant_txt);
+            }
             else
-                return g_strdup_printf
-                       (_("Not tax-related; no description: form %s, code %s, tax type %s"),
-                        form, num_code, tax_type);
+            {
+               if (safe_strcmp (descendant_txt, "") == 0)
+                  return g_strdup_printf
+                     (_("Not tax-related; no description: form %s, code %s, tax type %s"),
+                                                 form, num_code, tax_type);
+               else
+                  return g_strdup_printf
+                     (_("Not tax-related; no description: form %s, code %s, tax type %s; %s"),
+                                 form, num_code, tax_type, descendant_txt);
+            }
         }
 
         desc = scm_to_locale_string (scm);
         if (!desc)
         {
             if (tax_related)
-                return g_strdup_printf
-                       (_("No description: form %s, code %s, tax type %s"),
-                        form, num_code, tax_type);
+            {
+               if (safe_strcmp (descendant_txt, "") == 0)
+                  return g_strdup_printf
+                   (_("No description: form %s, code %s, tax type %s"),
+                                                  form, num_code, tax_type);
+               else
+                  return g_strdup_printf
+                    (_("No description: form %s, code %s, tax type %s; %s"),
+                                  form, num_code, tax_type, descendant_txt);
+            }
             else
-                return g_strdup_printf
-                       (_("Not tax-related; no description: form %s, code %s, tax type %s"),
-                        form, num_code, tax_type);
+            {
+               if (safe_strcmp (descendant_txt, "") == 0)
+                  return g_strdup_printf
+                     (_("Not tax-related; no description: form %s, code %s, tax type %s"),
+                                                 form, num_code, tax_type);
+               else
+                  return g_strdup_printf
+                     (_("Not tax-related; no description: form %s, code %s, tax type %s; %s"),
+                                 form, num_code, tax_type, descendant_txt);
+            }
         }
 
         copy_number = xaccAccountGetTaxUSCopyNumber (account);
@@ -627,14 +736,32 @@
         if (tax_related)
         {
             if (safe_strcmp (form, "") == 0)
-                return g_strdup_printf ("%s", desc);
+            {
+               if (safe_strcmp (descendant_txt, "") == 0)
+                  return g_strdup_printf ("%s", desc);
+               else
+                  return g_strdup_printf ("%s; %s", desc, descendant_txt);
+            }
             else
-                return g_strdup_printf ("%s%s %s", form, copy_txt, desc);
+            {
+               if (safe_strcmp (descendant_txt, "") == 0)
+                  return g_strdup_printf ("%s%s: %s", form, copy_txt, desc);
+               else
+                  return g_strdup_printf ("%s%s: %s; %s",
+                                      form, copy_txt, desc, descendant_txt);
+            }
         }
         else
-            return g_strdup_printf
-                   (_("Not tax-related; %s%s %s (code %s, tax type %s)"),
+            {
+               if (safe_strcmp (descendant_txt, "") == 0)
+                  return g_strdup_printf
+                   (_("Not tax-related; %s%s: %s (code %s, tax type %s)"),
                     form, copy_txt, desc, num_code, tax_type);
+               else
+                  return g_strdup_printf
+                 (_("Not tax-related; %s%s: %s (code %s, tax type %s); %s"),
+                  form, copy_txt, desc, num_code, tax_type, descendant_txt);
+            }
     }
 }
 



More information about the gnucash-changes mailing list