mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-20 11:48:30 -06:00
Add info about sub-accounts to Tax Info column on Accounts page.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@20039 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
48f0ce9a37
commit
04078234c0
@ -464,32 +464,61 @@ gnc_ui_account_get_tax_info_string (const Account *account)
|
||||
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 @@ gnc_ui_account_get_tax_info_string (const Account *account)
|
||||
|
||||
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 @@ gnc_ui_account_get_tax_info_string (const Account *account)
|
||||
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 @@ gnc_ui_account_get_tax_info_string (const Account *account)
|
||||
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 @@ gnc_ui_account_get_tax_info_string (const Account *account)
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user