33 #include <glib/gi18n.h> 36 #include <guile-mappings.h> 37 #include <gnc-guile-utils.h> 38 #include "gnc-locale-tax.h" 43 gnc_locale_tax_init(
void)
49 gchar *thislocale = g_win32_getlocale();
50 gboolean is_de_DE = (strncmp(thislocale,
"de_DE", 5) == 0);
53 const char *thislocale = setlocale(LC_ALL, NULL);
54 gboolean is_de_DE = (strncmp(thislocale,
"de_DE", 5) == 0);
57 scm_c_use_module(
"gnucash locale de_DE tax");
59 scm_c_use_module(
"gnucash locale us tax");
64 gnc_ui_account_get_tax_info_string (
const Account *account)
66 static SCM get_form = SCM_UNDEFINED;
67 static SCM get_desc = SCM_UNDEFINED;
69 gboolean tax_related = FALSE;
93 return g_strdup (_(
"Tax-related but has no tax code"));
97 const gchar *tax_type;
101 gchar *num_code = NULL;
102 const gchar *prefix =
"N";
103 gchar *return_string = NULL;
105 tax_type = gnc_get_current_book_tax_type ();
106 if (tax_type == NULL || (g_strcmp0 (tax_type,
"") == 0))
107 return g_strdup (_(
"Tax entity type not specified"));
110 tax_entity_type = scm_from_utf8_string (tax_type);
112 if (get_form == SCM_UNDEFINED)
115 gnc_locale_tax_init ();
117 get_form = scm_c_eval_string
118 (
"(false-if-exception gnc:txf-get-form)");
119 get_desc = scm_c_eval_string
120 (
"(false-if-exception gnc:txf-get-description)");
123 g_return_val_if_fail (scm_is_procedure (get_form), NULL);
124 g_return_val_if_fail (scm_is_procedure (get_desc), NULL);
127 "txf-income-categories" :
129 "txf-expense-categories" :
136 "txf-asset-categories" :
141 "txf-liab-eq-categories" :
""))));
143 if (g_str_has_prefix (code, prefix))
145 const gchar *num_code_tmp;
146 num_code_tmp = g_strdup (code);
148 num_code = g_strdup (num_code_tmp);
150 g_free ((gpointer *) num_code_tmp);
154 num_code = g_strdup (code);
157 if (category == SCM_UNDEFINED)
160 return_string = g_strdup_printf
161 (_(
"Tax type %s: invalid code %s for account type"),
164 return_string = g_strdup_printf
165 (_(
"Not tax-related; tax type %s: invalid code %s for account type"),
172 code_scm = scm_from_locale_symbol (code);
173 form_scm = scm_call_3 (get_form, category, code_scm, tax_entity_type);
174 if (!scm_is_string (form_scm))
177 return_string = g_strdup_printf
178 (_(
"Invalid code %s for tax type %s"),
181 return_string = g_strdup_printf
182 (_(
"Not tax-related; invalid code %s for tax type %s"),
195 form = scm_to_utf8_stringn (form_scm, NULL);
199 return_string = g_strdup_printf
200 (_(
"No form: code %s, tax type %s"), num_code,
203 return_string = g_strdup_printf
204 (_(
"Not tax-related; no form: code %s, tax type %s"),
213 scm_dynwind_begin (0);
214 scm_dynwind_free (form);
215 desc_scm = scm_call_3 (get_desc, category, code_scm,
217 if (!scm_is_string (desc_scm))
220 return_string = g_strdup_printf
221 (_(
"No description: form %s, code %s, tax type %s"),
222 form, num_code, tax_type);
224 return_string = g_strdup_printf
225 (_(
"Not tax-related; no description: form %s, code %s, tax type %s"),
226 form, num_code, tax_type);
231 desc = gnc_scm_to_utf8_string (desc_scm);
235 return_string = g_strdup_printf
236 (_(
"No description: form %s, code %s, tax type %s"),
237 form, num_code, tax_type);
239 return_string = g_strdup_printf
240 (_(
"Not tax-related; no description: form %s, code %s, tax type %s"),
241 form, num_code, tax_type);
246 gchar *copy_txt = NULL;
248 copy_txt = (copy_number == 1) ?
250 g_strdup_printf (
"(%d)",
254 if (g_strcmp0 (form,
"") == 0)
255 return_string = g_strdup_printf (
"%s", desc);
257 return_string = g_strdup_printf (
"%s%s: %s",
258 form, copy_txt, desc);
262 return_string = g_strdup_printf
263 (_(
"Not tax-related; %s%s: %s (code %s, tax type %s)"),
264 form, copy_txt, desc, num_code, tax_type);
275 return return_string;
281 gnc_ui_account_get_tax_info_sub_acct_string (
const Account *account)
283 GList *descendant, *account_descendants;
289 if (account_descendants)
291 gint sub_acct_tax_number = 0;
292 for (descendant = account_descendants; descendant;
293 descendant = g_list_next(descendant))
296 sub_acct_tax_number++;
298 g_list_free (account_descendants);
299 g_list_free (descendant);
309 return (sub_acct_tax_number == 0) ? NULL :
310 g_strdup_printf (_(
"(Tax-related subaccounts: %d)"),
311 sub_acct_tax_number);
gint64 xaccAccountGetTaxUSCopyNumber(const Account *acc)
Returns copy_number stored in KVP; if KVP doesn't exist or copy_number is zero, returns 1...
utility functions for the GnuCash UI
Expense accounts are used to denote expenses.
GNCAccountType xaccAccountGetType(const Account *acc)
Returns the account's account type.
Mutual Fund accounts will typically be shown in registers which show three columns: price...
The cash account type is used to denote a shoe-box or pillowcase stuffed with * cash.
Stock accounts will typically be shown in registers which show three columns: price, number of shares, and value.
Account handling public routines.
Income accounts are used to denote income.
The bank account type denotes a savings or checking account held at a bank.
const char * xaccAccountGetTaxUSCode(const Account *acc)
DOCUMENT ME!
gboolean xaccAccountGetTaxRelated(const Account *acc)
DOCUMENT ME!
asset (and liability) accounts indicate generic, generalized accounts that are none of the above...
GNCAccountType
The account types are used to determine how the transaction data in the account is displayed...
GList * gnc_account_get_descendants(const Account *account)
This routine returns a flat list of all of the accounts that are descendants of the specified account...
liability (and asset) accounts indicate generic, generalized accounts that are none of the above...
Equity account is used to balance the balance sheet.
The Credit card account is used to denote credit (e.g.