mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Bug #554394: Income Tax Enhancements
Patch by J. Alex Aycinena. Patch does the following: - update the tax information in 'txf.scm', which is based on V037 of the TXF Spec, to V041, the last version issued (bug #554394) - provide support for multiple copies of certain tax Forms/Schedules (e.g., Schedule C(1), Schedule C(2), etc.) - support multiple types of tax entities: partnerships, corporations and S corporations, in addition to individual tax payers - support balance sheet accounts, required for these new tax entity types - add the term 'Income' in several places to avoid confusion with sales or VAT style taxes in the business features (e.g., change the menu from 'Tax Options' to 'Income Tax Options') The following files were changed, as follows, to implement these changes: 1. src/engine/Account.c and 2. src/engine/Account.h: add copy number capability (define 'xaccAccountGetTaxUSCopyNumber' and 'xaccAccountSetTaxUSCopyNumber'); modify 'xaccAccountSetTaxUSCode' to remove KVP when no tax-code assigned, clean up tax-source descriptions 3. src/gnome/gnc-plugin-basic-commands.c: change 'Tax Options' to 'Income Tax Options' 4. src/app-utils/gnc-ui-util.c and 5. src/app-utils/gnc-ui-util.h: add setter and getter functions for book tax name and book tax type which are stored in a book KVP, show copy information in accounts page, tax column, show error messages for various conditions 6. src/app-utils/app-utils.i: add 'gnc_get_current_book_tax_name' and 'gnc_get_current_book_tax_type' functions 7. src/gnome/dialog-tax-info.c: add copy number and tax entity name and type, and balance sheet account handling capability 8. src/gnome/glade/tax.glade: add tax entity name, tax entity type, asset, liability/equity and copy number widgets 9. src/tax/us/txf.scm: update to V041 for individuals, add V041 support for multiple additional tax entity types and balance sheet accounts and related tax codes, add tax form line data 10. src/tax/us/us.scm: export new functions defined in txf.scm 11. src/report/locale-specific/us/taxtxf.scm: add support for multiple copies of Forms/Schedules, add support for Format 6, use Form/Schedule line #'s to sort report, update from "V037" to "V041", add support for taxpayer types other than F1040, add warning messages if there are some inconsistent codes assigned and list 12. src/tax/us/txf-de_DE.scm: make functions called from outside (e.g., from dialog-tax-info.c) have a consistent signature with those same functions in txf.scm (define tax-entity-type , define getters/setters, add tax-entity-type as an argument to existing functions) 13. src/tax/us/de_DE.scm: export new functions added to txf-de_DE.scm 14. src/report/locale-specific/us/taxtxf-de_DE.scm: add "" as tax-entity-type argument to functions called on txf-de_DE.scm (which defaults to existing codes) git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18413 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
127638e440
commit
b5e09a6685
@ -24,6 +24,8 @@ typedef void (*GNCOptionChangeCallback) (gpointer user_data);
|
||||
typedef int GNCOptionDBHandle;
|
||||
|
||||
QofBook * gnc_get_current_book (void);
|
||||
const gchar * gnc_get_current_book_tax_name (void);
|
||||
const gchar * gnc_get_current_book_tax_type (void);
|
||||
Account * gnc_get_current_root_account (void);
|
||||
|
||||
%newobject gnc_gettext_helper;
|
||||
|
@ -200,6 +200,34 @@ gnc_get_current_book (void)
|
||||
return qof_session_get_book (gnc_get_current_session ());
|
||||
}
|
||||
|
||||
void
|
||||
gnc_set_current_book_tax_name (const gchar *tax_name)
|
||||
{
|
||||
kvp_frame_set_string (qof_book_get_slots (gnc_get_current_book()),
|
||||
"book/tax_US/name", tax_name);
|
||||
}
|
||||
|
||||
const gchar *
|
||||
gnc_get_current_book_tax_name (void)
|
||||
{
|
||||
return kvp_frame_get_string (qof_book_get_slots (gnc_get_current_book()),
|
||||
"book/tax_US/name");
|
||||
}
|
||||
|
||||
void
|
||||
gnc_set_current_book_tax_type (const gchar *tax_type)
|
||||
{
|
||||
kvp_frame_set_string(qof_book_get_slots(gnc_get_current_book()),
|
||||
"book/tax_US/type", tax_type);
|
||||
}
|
||||
|
||||
const gchar *
|
||||
gnc_get_current_book_tax_type (void)
|
||||
{
|
||||
return kvp_frame_get_string(qof_book_get_slots(gnc_get_current_book()),
|
||||
"book/tax_US/type");
|
||||
}
|
||||
|
||||
Account *
|
||||
gnc_get_current_root_account (void)
|
||||
{
|
||||
@ -430,85 +458,163 @@ gnc_ui_account_get_tax_info_string (const Account *account)
|
||||
static SCM get_form = SCM_UNDEFINED;
|
||||
static SCM get_desc = SCM_UNDEFINED;
|
||||
|
||||
GNCAccountType atype;
|
||||
gboolean tax_related = FALSE;
|
||||
const char *code;
|
||||
QofBook *this_book;
|
||||
KvpFrame *book_frame;
|
||||
const gchar *tax_type;
|
||||
GNCAccountType atype;
|
||||
SCM category;
|
||||
SCM code_scm;
|
||||
const gchar *form, *desc;
|
||||
SCM tax_entity_type;
|
||||
const gchar *form, *desc, *copy_txt;
|
||||
gint64 copy_number;
|
||||
SCM scm;
|
||||
|
||||
if (get_form == SCM_UNDEFINED)
|
||||
if (!account)
|
||||
return NULL;
|
||||
|
||||
tax_related = xaccAccountGetTaxRelated (account);
|
||||
code = xaccAccountGetTaxUSCode (account);
|
||||
|
||||
if (!code)
|
||||
{
|
||||
GNCModule module;
|
||||
const gchar *tax_module;
|
||||
if (!tax_related)
|
||||
return NULL;
|
||||
else /* tax_related && !code */
|
||||
return g_strdup (_("Tax-related but has no tax code"));
|
||||
}
|
||||
else /* with tax code */
|
||||
{
|
||||
tax_type = gnc_get_current_book_tax_type ();
|
||||
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 */
|
||||
|
||||
if (get_form == SCM_UNDEFINED)
|
||||
{
|
||||
GNCModule module;
|
||||
const gchar *tax_module;
|
||||
/* load the tax info */
|
||||
#ifdef LOCALE_SPECIFIC_TAX
|
||||
/* This is a very simple hack that loads the (new, special) German
|
||||
tax definition file in a German locale, or (default) loads the
|
||||
previous US tax file. */
|
||||
# ifdef G_OS_WIN32
|
||||
gchar *thislocale = g_win32_getlocale();
|
||||
gboolean is_de_DE = (strncmp(thislocale, "de_DE", 5) == 0);
|
||||
g_free(thislocale);
|
||||
gchar *thislocale = g_win32_getlocale();
|
||||
gboolean is_de_DE = (strncmp(thislocale, "de_DE", 5) == 0);
|
||||
g_free(thislocale);
|
||||
# else /* !G_OS_WIN32 */
|
||||
const char *thislocale = setlocale(LC_ALL, NULL);
|
||||
gboolean is_de_DE = (strncmp(thislocale, "de_DE", 5) == 0);
|
||||
const char *thislocale = setlocale(LC_ALL, NULL);
|
||||
gboolean is_de_DE = (strncmp(thislocale, "de_DE", 5) == 0);
|
||||
# endif /* G_OS_WIN32 */
|
||||
#else /* LOCALE_SPECIFIC_TAX */
|
||||
gboolean is_de_DE = FALSE;
|
||||
gboolean is_de_DE = FALSE;
|
||||
#endif /* LOCALE_SPECIFIC_TAX */
|
||||
tax_module = is_de_DE ?
|
||||
"gnucash/tax/de_DE" :
|
||||
"gnucash/tax/us";
|
||||
tax_module = is_de_DE ?
|
||||
"gnucash/tax/de_DE" :
|
||||
"gnucash/tax/us";
|
||||
|
||||
module = gnc_module_load ((char *)tax_module, 0);
|
||||
module = gnc_module_load ((char *)tax_module, 0);
|
||||
|
||||
g_return_val_if_fail (module, NULL);
|
||||
g_return_val_if_fail (module, NULL);
|
||||
|
||||
get_form = scm_c_eval_string ("(false-if-exception gnc:txf-get-form)");
|
||||
get_desc = scm_c_eval_string ("(false-if-exception gnc:txf-get-description)");
|
||||
get_form = scm_c_eval_string ("(false-if-exception gnc:txf-get-form)");
|
||||
get_desc = scm_c_eval_string
|
||||
("(false-if-exception gnc:txf-get-description)");
|
||||
}
|
||||
|
||||
g_return_val_if_fail (SCM_PROCEDUREP (get_form), NULL);
|
||||
g_return_val_if_fail (SCM_PROCEDUREP (get_desc), NULL);
|
||||
|
||||
category = scm_c_eval_string (atype == ACCT_TYPE_INCOME ?
|
||||
"txf-income-categories" :
|
||||
(atype == ACCT_TYPE_EXPENSE ?
|
||||
"txf-expense-categories" :
|
||||
(((atype == ACCT_TYPE_BANK) ||
|
||||
(atype == ACCT_TYPE_CASH) ||
|
||||
(atype == ACCT_TYPE_ASSET) ||
|
||||
(atype == ACCT_TYPE_STOCK) ||
|
||||
(atype == ACCT_TYPE_MUTUAL) ||
|
||||
(atype == ACCT_TYPE_RECEIVABLE)) ?
|
||||
"txf-asset-categories" :
|
||||
(((atype == ACCT_TYPE_CREDIT) ||
|
||||
(atype == ACCT_TYPE_LIABILITY) ||
|
||||
(atype == ACCT_TYPE_EQUITY) ||
|
||||
(atype == ACCT_TYPE_PAYABLE)) ?
|
||||
"txf-liab-eq-categories" : ""))));
|
||||
|
||||
if (category == SCM_UNDEFINED)
|
||||
{
|
||||
if (tax_related)
|
||||
return g_strdup_printf
|
||||
(_("Tax type %s: invalid code %s for account type"), code, tax_type);
|
||||
else
|
||||
return g_strdup_printf
|
||||
(_("Not tax-related; tax type %s: invalid code %s for account type"),
|
||||
code, tax_type);
|
||||
}
|
||||
|
||||
code_scm = scm_str2symbol (code);
|
||||
scm = scm_call_3 (get_form, category, code_scm, tax_entity_type);
|
||||
if (!SCM_STRINGP (scm))
|
||||
{
|
||||
if (tax_related)
|
||||
return g_strdup_printf
|
||||
(_("Invalid code %s for tax type %s"), code, tax_type);
|
||||
else
|
||||
return g_strdup_printf
|
||||
(_("Not tax-related; invalid code %s for tax type %s"), code, tax_type);
|
||||
}
|
||||
|
||||
form = SCM_STRING_CHARS (scm);
|
||||
if (!form)
|
||||
{
|
||||
if (tax_related)
|
||||
return g_strdup_printf
|
||||
(_("No form: code %s, tax type %s"), code, tax_type);
|
||||
else
|
||||
return g_strdup_printf
|
||||
(_("Not tax-related; no form: code %s, tax type %s"), code, tax_type);
|
||||
}
|
||||
|
||||
scm = scm_call_3 (get_desc, category, code_scm, tax_entity_type);
|
||||
if (!SCM_STRINGP (scm))
|
||||
{
|
||||
if (tax_related)
|
||||
return g_strdup_printf
|
||||
(_("No description: form %s, code %s, tax type %s (1)"),
|
||||
form, code, tax_type);
|
||||
else
|
||||
return g_strdup_printf
|
||||
(_("Not tax-related; no description: form %s, code %s, tax type %s (1)"),
|
||||
form, code, tax_type);
|
||||
}
|
||||
|
||||
desc = SCM_STRING_CHARS (scm);
|
||||
if (!desc)
|
||||
{
|
||||
if (tax_related)
|
||||
return g_strdup_printf
|
||||
(_("No description: form %s, code %s, tax type %s (2)"),
|
||||
form, code, tax_type);
|
||||
else
|
||||
return g_strdup_printf
|
||||
(_("Not tax-related; no description: form %s, code %s, tax type %s (2)"),
|
||||
form, code, tax_type);
|
||||
}
|
||||
|
||||
copy_number = xaccAccountGetTaxUSCopyNumber (account);
|
||||
copy_txt = (copy_number == 1) ? "" : g_strdup_printf ("(%d)",
|
||||
(gint) copy_number);
|
||||
|
||||
if (tax_related)
|
||||
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);
|
||||
}
|
||||
|
||||
g_return_val_if_fail (SCM_PROCEDUREP (get_form), NULL);
|
||||
g_return_val_if_fail (SCM_PROCEDUREP (get_desc), NULL);
|
||||
|
||||
if (!account)
|
||||
return NULL;
|
||||
|
||||
if (!xaccAccountGetTaxRelated (account))
|
||||
return NULL;
|
||||
|
||||
atype = xaccAccountGetType (account);
|
||||
if (atype != ACCT_TYPE_INCOME && atype != ACCT_TYPE_EXPENSE)
|
||||
return NULL;
|
||||
|
||||
code = xaccAccountGetTaxUSCode (account);
|
||||
if (!code)
|
||||
return NULL;
|
||||
|
||||
category = scm_c_eval_string (atype == ACCT_TYPE_INCOME ?
|
||||
"txf-income-categories" :
|
||||
"txf-expense-categories");
|
||||
|
||||
code_scm = scm_str2symbol (code);
|
||||
|
||||
scm = scm_call_2 (get_form, category, code_scm);
|
||||
if (!SCM_STRINGP (scm))
|
||||
return NULL;
|
||||
|
||||
form = SCM_STRING_CHARS (scm);
|
||||
if (!form)
|
||||
return NULL;
|
||||
|
||||
scm = scm_call_2 (get_desc, category, code_scm);
|
||||
if (!SCM_STRINGP (scm))
|
||||
return NULL;
|
||||
|
||||
desc = SCM_STRING_CHARS (scm);
|
||||
if (!desc)
|
||||
return NULL;
|
||||
|
||||
return g_strdup_printf ("%s %s", form, desc);
|
||||
}
|
||||
|
||||
|
||||
|
@ -54,6 +54,10 @@ void gnc_set_default_directory (const gchar *gconf_section,
|
||||
|
||||
/* Engine enhancements & i18n ***************************************/
|
||||
QofBook * gnc_get_current_book (void);
|
||||
void gnc_set_current_book_tax_name (const gchar *tax_name);
|
||||
const gchar * gnc_get_current_book_tax_name (void);
|
||||
void gnc_set_current_book_tax_type (const gchar *tax_type);
|
||||
const gchar * gnc_get_current_book_tax_type (void);
|
||||
Account * gnc_get_current_root_account (void);
|
||||
gnc_commodity_table * gnc_get_current_commodities (void);
|
||||
|
||||
|
@ -78,6 +78,7 @@ enum {
|
||||
PROP_TAX_RELATED,
|
||||
PROP_TAX_CODE,
|
||||
PROP_TAX_SOURCE,
|
||||
PROP_TAX_COPY_NUMBER,
|
||||
|
||||
PROP_HIDDEN,
|
||||
PROP_PLACEHOLDER,
|
||||
@ -350,6 +351,10 @@ gnc_account_get_property (GObject *object,
|
||||
g_value_set_string(value,
|
||||
xaccAccountGetTaxUSPayerNameSource(account));
|
||||
break;
|
||||
case PROP_TAX_COPY_NUMBER:
|
||||
g_value_set_int64(value,
|
||||
xaccAccountGetTaxUSCopyNumber(account));
|
||||
break;
|
||||
case PROP_HIDDEN:
|
||||
g_value_set_boolean(value, xaccAccountGetHidden(account));
|
||||
break;
|
||||
@ -434,6 +439,10 @@ gnc_account_set_property (GObject *object,
|
||||
case PROP_TAX_SOURCE:
|
||||
xaccAccountSetTaxUSPayerNameSource(account,
|
||||
g_value_get_string(value));
|
||||
case PROP_TAX_COPY_NUMBER:
|
||||
xaccAccountSetTaxUSCopyNumber(account,
|
||||
g_value_get_int64(value));
|
||||
break;
|
||||
case PROP_HIDDEN:
|
||||
xaccAccountSetHidden(account, g_value_get_boolean(value));
|
||||
break;
|
||||
@ -733,10 +742,22 @@ gnc_account_class_init (AccountClass *klass)
|
||||
PROP_TAX_SOURCE,
|
||||
g_param_spec_string ("tax-source",
|
||||
"Tax Source",
|
||||
"This is an unknown tax related field.",
|
||||
"This specifies where exported name comes from.",
|
||||
NULL,
|
||||
G_PARAM_READWRITE));
|
||||
|
||||
g_object_class_install_property
|
||||
(gobject_class,
|
||||
PROP_TAX_COPY_NUMBER,
|
||||
g_param_spec_int ("tax-copy-number",
|
||||
"Tax Copy Number",
|
||||
"This specifies the copy number of the tax "
|
||||
"form/schedule.",
|
||||
1,
|
||||
G_MAXINT16,
|
||||
1,
|
||||
G_PARAM_READWRITE));
|
||||
|
||||
g_object_class_install_property
|
||||
(gobject_class,
|
||||
PROP_HIDDEN,
|
||||
@ -3482,6 +3503,11 @@ xaccAccountSetTaxUSCode (Account *acc, const char *code)
|
||||
|
||||
xaccAccountBeginEdit (acc);
|
||||
kvp_frame_set_string (acc->inst.kvp_data, "/tax-US/code", code);
|
||||
if (!code)
|
||||
{
|
||||
KvpFrame *frame = NULL;
|
||||
kvp_frame_set_frame (acc->inst.kvp_data, "/tax-US", frame);
|
||||
}
|
||||
mark_account (acc);
|
||||
xaccAccountCommitEdit (acc);
|
||||
}
|
||||
@ -3506,6 +3532,39 @@ xaccAccountSetTaxUSPayerNameSource (Account *acc, const char *source)
|
||||
xaccAccountCommitEdit (acc);
|
||||
}
|
||||
|
||||
gint64
|
||||
xaccAccountGetTaxUSCopyNumber (const Account *acc)
|
||||
{
|
||||
gint64 copy_number;
|
||||
|
||||
g_return_val_if_fail(GNC_IS_ACCOUNT(acc), 1);
|
||||
copy_number = kvp_frame_get_gint64(acc->inst.kvp_data,
|
||||
"tax-US/copy-number");
|
||||
return (copy_number == 0) ? 1: copy_number;
|
||||
}
|
||||
|
||||
void
|
||||
xaccAccountSetTaxUSCopyNumber (Account *acc, gint64 copy_number)
|
||||
{
|
||||
g_return_if_fail(GNC_IS_ACCOUNT(acc));
|
||||
|
||||
xaccAccountBeginEdit (acc);
|
||||
if (copy_number != 0)
|
||||
kvp_frame_set_gint64 (acc->inst.kvp_data, "/tax-US/copy-number", copy_number);
|
||||
else
|
||||
{
|
||||
KvpFrame * frame;
|
||||
KvpValue *value;
|
||||
|
||||
value = NULL;
|
||||
frame = kvp_frame_set_value_nc (acc->inst.kvp_data,
|
||||
"/tax-US/copy-number", value);
|
||||
if (!frame) kvp_value_delete (value);
|
||||
}
|
||||
mark_account (acc);
|
||||
xaccAccountCommitEdit (acc);
|
||||
}
|
||||
|
||||
/********************************************************************\
|
||||
\********************************************************************/
|
||||
|
||||
|
@ -1192,6 +1192,10 @@ void xaccAccountSetTaxUSCode (Account *account, const char *code);
|
||||
const char * xaccAccountGetTaxUSPayerNameSource (const Account *account);
|
||||
/** DOCUMENT ME! */
|
||||
void xaccAccountSetTaxUSPayerNameSource (Account *account, const char *source);
|
||||
/** DOCUMENT ME! */
|
||||
gint64 xaccAccountGetTaxUSCopyNumber (const Account *account);
|
||||
/** DOCUMENT ME! */
|
||||
void xaccAccountSetTaxUSCopyNumber (Account *account, gint64 copy_number);
|
||||
/** @} */
|
||||
|
||||
|
||||
|
@ -3,6 +3,9 @@
|
||||
* Copyright (C) 2001 Gnumatic, Inc. *
|
||||
* Author: Dave Peticolas <dave@krondo.com> *
|
||||
* *
|
||||
* *
|
||||
* updated by J. Alex Aycinena, July 2009 *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation; either version 2 of *
|
||||
@ -43,8 +46,14 @@
|
||||
#define GCONF_SECTION "dialogs/tax_info"
|
||||
#define PANED_POSITION "paned_position"
|
||||
|
||||
/* This static indicates the debugging module that this .o belongs to. */
|
||||
/* static short module = MOD_GUI; */
|
||||
enum
|
||||
{
|
||||
INCOME,
|
||||
EXPENSE,
|
||||
ASSET,
|
||||
LIAB_EQ,
|
||||
N_CATEGORIES
|
||||
};
|
||||
|
||||
static struct
|
||||
{
|
||||
@ -52,10 +61,26 @@ static struct
|
||||
SCM form;
|
||||
SCM description;
|
||||
SCM help;
|
||||
SCM line_data;
|
||||
SCM last_year;
|
||||
SCM copy;
|
||||
|
||||
SCM codes;
|
||||
|
||||
SCM tax_entity_type;
|
||||
SCM tax_entity_desc;
|
||||
|
||||
SCM tax_entity_types;
|
||||
} getters;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char *type_code;
|
||||
char *type;
|
||||
char *description;
|
||||
char *combo_box_entry;
|
||||
} TaxTypeInfo;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char *code;
|
||||
@ -63,48 +88,100 @@ typedef struct
|
||||
char *form;
|
||||
char *description;
|
||||
char *help;
|
||||
gboolean copy;
|
||||
} TXFInfo;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GtkWidget * dialog;
|
||||
|
||||
GtkWidget * entity_name_display;
|
||||
GtkWidget * entity_name_entry;
|
||||
GtkWidget * entity_type_display;
|
||||
GtkWidget * entity_type_combo;
|
||||
GtkWidget * tax_identity_edit_button;
|
||||
|
||||
GtkWidget * acct_info;
|
||||
GtkWidget * expense_radio;
|
||||
GtkWidget * asset_radio;
|
||||
GtkWidget * liab_eq_radio;
|
||||
GtkWidget * account_treeview;
|
||||
GtkWidget * select_button;
|
||||
|
||||
GtkWidget * txf_info;
|
||||
GtkWidget * tax_related_button;
|
||||
GtkWidget * txf_category_view;
|
||||
GtkWidget * txf_help_text;
|
||||
GtkWidget * current_account_button;
|
||||
GtkWidget * parent_account_button;
|
||||
GtkWidget * copy_spin_button;
|
||||
|
||||
GList * entity_type_infos;
|
||||
GList * income_txf_infos;
|
||||
GList * expense_txf_infos;
|
||||
GList * asset_txf_infos;
|
||||
GList * liab_eq_txf_infos;
|
||||
|
||||
const gchar * tax_name;
|
||||
const gchar * tax_type;
|
||||
const gchar * tax_type_combo_text;
|
||||
const gchar * default_tax_type;
|
||||
|
||||
QofBook *this_book;
|
||||
|
||||
gboolean income;
|
||||
gboolean changed;
|
||||
gboolean tax_type_changed;
|
||||
|
||||
GNCAccountType account_type;
|
||||
} TaxInfoDialog;
|
||||
|
||||
|
||||
static gboolean getters_initialized = FALSE;
|
||||
|
||||
|
||||
static void
|
||||
initialize_getters (void)
|
||||
{
|
||||
if (getters_initialized)
|
||||
return;
|
||||
|
||||
getters.payer_name_source = scm_c_eval_string ("gnc:txf-get-payer-name-source");
|
||||
getters.form = scm_c_eval_string ("gnc:txf-get-form");
|
||||
getters.description = scm_c_eval_string ("gnc:txf-get-description");
|
||||
getters.help = scm_c_eval_string ("gnc:txf-get-help");
|
||||
getters.line_data = scm_c_eval_string ("gnc:txf-get-line-data");
|
||||
getters.last_year = scm_c_eval_string ("gnc:txf-get-last-year");
|
||||
getters.copy = scm_c_eval_string ("gnc:txf-get-multiple");
|
||||
|
||||
getters.codes = scm_c_eval_string ("gnc:txf-get-codes");
|
||||
|
||||
getters_initialized = TRUE;
|
||||
getters.tax_entity_type = scm_c_eval_string ("gnc:txf-get-tax-entity-type");
|
||||
getters.tax_entity_desc = scm_c_eval_string
|
||||
("gnc:txf-get-tax-entity-type-description");
|
||||
|
||||
getters.tax_entity_types = scm_c_eval_string
|
||||
("gnc:txf-get-tax-entity-type-codes");
|
||||
}
|
||||
|
||||
static void
|
||||
destroy_tax_type_info (gpointer data, gpointer user_data)
|
||||
{
|
||||
TaxTypeInfo *tax_type = data;
|
||||
|
||||
g_free (tax_type->type_code);
|
||||
tax_type->type_code = NULL;
|
||||
|
||||
g_free (tax_type->type);
|
||||
tax_type->type = NULL;
|
||||
|
||||
g_free (tax_type->description);
|
||||
tax_type->description = NULL;
|
||||
|
||||
g_free (tax_type->combo_box_entry);
|
||||
tax_type->combo_box_entry = NULL;
|
||||
|
||||
g_free (tax_type);
|
||||
}
|
||||
|
||||
static void
|
||||
destroy_tax_type_infos (GList *types)
|
||||
{
|
||||
g_list_foreach (types, destroy_tax_type_info, NULL);
|
||||
g_list_free (types);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -144,24 +221,50 @@ gnc_tax_info_set_changed (TaxInfoDialog *ti_dialog, gboolean changed)
|
||||
}
|
||||
|
||||
static GList *
|
||||
load_txf_info (gboolean income)
|
||||
load_txf_info (gint acct_category, TaxInfoDialog *ti_dialog)
|
||||
{
|
||||
GList *infos = NULL;
|
||||
SCM tax_entity_type;
|
||||
SCM category;
|
||||
SCM codes;
|
||||
|
||||
initialize_getters ();
|
||||
if (ti_dialog->tax_type == NULL ||
|
||||
(safe_strcmp (ti_dialog->tax_type, "") == 0))
|
||||
{
|
||||
destroy_txf_infos (infos);
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* tax_entity_type = scm_from_locale_string (ti_dialog->tax_type); <- Req's guile 1.8 */
|
||||
tax_entity_type = scm_makfrom0str (ti_dialog->tax_type); /* <-guile 1.6 */
|
||||
}
|
||||
|
||||
switch (acct_category) {
|
||||
case INCOME:
|
||||
category = scm_c_eval_string ("txf-income-categories");
|
||||
break;
|
||||
case EXPENSE:
|
||||
category = scm_c_eval_string ("txf-expense-categories");
|
||||
break;
|
||||
case ASSET:
|
||||
category = scm_c_eval_string ("txf-asset-categories");
|
||||
break;
|
||||
case LIAB_EQ:
|
||||
category = scm_c_eval_string ("txf-liab-eq-categories");
|
||||
break;
|
||||
default:
|
||||
destroy_txf_infos (infos);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
category = scm_c_eval_string (income ?
|
||||
"txf-income-categories" :
|
||||
"txf-expense-categories");
|
||||
if (category == SCM_UNDEFINED)
|
||||
{
|
||||
destroy_txf_infos (infos);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
codes = scm_call_1 (getters.codes, category);
|
||||
codes = scm_call_2 (getters.codes, category, tax_entity_type);
|
||||
if (!SCM_LISTP (codes))
|
||||
{
|
||||
destroy_txf_infos (infos);
|
||||
@ -173,12 +276,18 @@ load_txf_info (gboolean income)
|
||||
TXFInfo *txf_info;
|
||||
SCM code_scm;
|
||||
const gchar *str;
|
||||
const gchar *last_yr = _("Last Valid Year: ");
|
||||
const gchar *form_line = _("Form Line Data: ");
|
||||
gchar *form_line_data = NULL;
|
||||
SCM scm;
|
||||
gint year;
|
||||
gboolean cpy;
|
||||
|
||||
code_scm = SCM_CAR (codes);
|
||||
codes = SCM_CDR (codes);
|
||||
|
||||
scm = scm_call_2 (getters.payer_name_source, category, code_scm);
|
||||
scm = scm_call_3 (getters.payer_name_source, category, code_scm,
|
||||
tax_entity_type);
|
||||
str = SCM_SYMBOL_CHARS (scm);
|
||||
if (safe_strcmp (str, "not-impl") == 0)
|
||||
{
|
||||
@ -195,17 +304,76 @@ load_txf_info (gboolean income)
|
||||
str = SCM_SYMBOLP(code_scm) ? SCM_SYMBOL_CHARS(code_scm) : "";
|
||||
txf_info->code = g_strdup (str);
|
||||
|
||||
scm = scm_call_2 (getters.form, category, code_scm);
|
||||
scm = scm_call_3 (getters.form, category, code_scm, tax_entity_type);
|
||||
str = SCM_STRINGP(scm) ? SCM_STRING_CHARS(scm) : "";
|
||||
txf_info->form = g_strdup (str);
|
||||
|
||||
scm = scm_call_2 (getters.description, category, code_scm);
|
||||
scm = scm_call_3 (getters.description, category, code_scm, tax_entity_type);
|
||||
str = SCM_STRINGP(scm) ? SCM_STRING_CHARS(scm) : "";
|
||||
txf_info->description = g_strdup (str);
|
||||
|
||||
scm = scm_call_2 (getters.help, category, code_scm);
|
||||
str = SCM_STRINGP(scm) ? SCM_STRING_CHARS(scm) : "";
|
||||
txf_info->help = g_strdup (str);
|
||||
scm = scm_call_3 (getters.last_year, category, code_scm, tax_entity_type);
|
||||
/* year = scm_is_bool (scm) ? 0 : scm_to_int(scm); <- Req's guile 1.8 */
|
||||
year = SCM_BOOLP (scm) ? 0 : SCM_INUM(scm); /* <-guile 1.6 */
|
||||
scm = scm_call_3 (getters.line_data, category, code_scm, tax_entity_type);
|
||||
if (SCM_LISTP (scm))
|
||||
{
|
||||
const gchar *until = _("now");
|
||||
|
||||
if (year != 0)
|
||||
until = g_strdup_printf ("%d", year);
|
||||
form_line_data = g_strconcat ("\n", "\n", form_line, NULL);
|
||||
while (!SCM_NULLP (scm))
|
||||
{
|
||||
SCM year_scm;
|
||||
gint line_year;
|
||||
const gchar *line;
|
||||
gchar *temp;
|
||||
|
||||
year_scm = SCM_CAR (scm);
|
||||
scm = SCM_CDR (scm);
|
||||
|
||||
/* line_year = scm_is_bool (SCM_CAR (year_scm)) ? 0 :
|
||||
scm_to_int (SCM_CAR (year_scm)); <- Req's guile 1.8 */
|
||||
line_year = SCM_BOOLP (SCM_CAR (year_scm)) ? 0 :
|
||||
SCM_INUM (SCM_CAR (year_scm)); /* <-guile 1.6 */
|
||||
line = SCM_STRINGP((SCM_CAR (SCM_CDR (year_scm))))
|
||||
? SCM_STRING_CHARS((SCM_CAR (SCM_CDR (year_scm)))) : "";
|
||||
temp = g_strconcat (form_line_data, "\n",
|
||||
g_strdup_printf ("%d", line_year), " - ", until,
|
||||
" ", line, NULL);
|
||||
until = g_strdup_printf ("%d", (line_year - 1));
|
||||
g_free(form_line_data);
|
||||
form_line_data = g_strdup (temp);
|
||||
g_free(temp);
|
||||
}
|
||||
}
|
||||
if (year != 0)
|
||||
{
|
||||
if (form_line_data != NULL)
|
||||
txf_info->help = g_strconcat (last_yr, g_strdup_printf ("%d", year),
|
||||
"\n", "\n", str, form_line_data, NULL);
|
||||
else
|
||||
txf_info->help = g_strconcat (last_yr, g_strdup_printf ("%d", year),
|
||||
"\n", "\n", str, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (form_line_data != NULL)
|
||||
txf_info->help = g_strconcat (str, form_line_data, NULL);
|
||||
else
|
||||
txf_info->help = g_strdup (str);
|
||||
}
|
||||
|
||||
if (form_line_data != NULL)
|
||||
g_free(form_line_data);
|
||||
|
||||
scm = scm_call_3 (getters.copy, category, code_scm, tax_entity_type);
|
||||
/* cpy = scm_is_bool (scm) ? (scm_is_false (scm) ? FALSE : TRUE): FALSE; <- Req's guile 1.8 */
|
||||
cpy = SCM_BOOLP (scm) ? (SCM_FALSEP (scm) ? FALSE : TRUE): FALSE; /* <-guile 1.6 */
|
||||
txf_info->copy = cpy;
|
||||
|
||||
infos = g_list_prepend (infos, txf_info);
|
||||
}
|
||||
@ -217,8 +385,66 @@ static GList *
|
||||
tax_infos (TaxInfoDialog *ti_dialog)
|
||||
{
|
||||
return
|
||||
ti_dialog->income ?
|
||||
ti_dialog->income_txf_infos : ti_dialog->expense_txf_infos;
|
||||
(ti_dialog->account_type == ACCT_TYPE_INCOME)
|
||||
? ti_dialog->income_txf_infos :
|
||||
((ti_dialog->account_type == ACCT_TYPE_EXPENSE)
|
||||
? ti_dialog->expense_txf_infos :
|
||||
(((ti_dialog->account_type == ACCT_TYPE_ASSET)
|
||||
? ti_dialog->asset_txf_infos :
|
||||
ti_dialog->liab_eq_txf_infos)));
|
||||
}
|
||||
|
||||
static void
|
||||
load_tax_entity_type_list (TaxInfoDialog *ti_dialog)
|
||||
{
|
||||
GList *types = NULL;
|
||||
SCM tax_types;
|
||||
|
||||
ti_dialog->tax_type_combo_text = NULL;
|
||||
tax_types = scm_call_0 (getters.tax_entity_types);
|
||||
if (!SCM_LISTP (tax_types))
|
||||
{
|
||||
destroy_tax_type_infos (types);
|
||||
return;
|
||||
}
|
||||
|
||||
while (!SCM_NULLP (tax_types))
|
||||
{
|
||||
TaxTypeInfo *tax_type_info;
|
||||
SCM type_scm;
|
||||
const gchar *str;
|
||||
SCM scm;
|
||||
|
||||
type_scm = SCM_CAR (tax_types);
|
||||
tax_types = SCM_CDR (tax_types);
|
||||
|
||||
ti_dialog->default_tax_type = NULL;
|
||||
|
||||
tax_type_info = g_new0 (TaxTypeInfo, 1);
|
||||
|
||||
str = SCM_SYMBOLP(type_scm) ? SCM_SYMBOL_CHARS(type_scm) : "";
|
||||
tax_type_info->type_code = g_strdup (str);
|
||||
|
||||
scm = scm_call_1 (getters.tax_entity_type, type_scm);
|
||||
str = SCM_STRINGP(scm) ? SCM_STRING_CHARS (scm) : "";
|
||||
tax_type_info->type = g_strdup (str);
|
||||
|
||||
scm = scm_call_1 (getters.tax_entity_desc, type_scm);
|
||||
str = SCM_STRINGP(scm) ? SCM_STRING_CHARS (scm) : "";
|
||||
tax_type_info->description = g_strdup (str);
|
||||
|
||||
tax_type_info->combo_box_entry = g_strconcat(tax_type_info->type, " - ",
|
||||
tax_type_info->description, NULL);
|
||||
/* save combo text for current tax type code */
|
||||
if (safe_strcmp (ti_dialog->tax_type, tax_type_info->type_code) == 0)
|
||||
ti_dialog->tax_type_combo_text = g_strdup (tax_type_info->combo_box_entry);
|
||||
/* the last will be default */
|
||||
ti_dialog->default_tax_type = g_strdup (tax_type_info->combo_box_entry);
|
||||
|
||||
types = g_list_prepend (types, tax_type_info);
|
||||
}
|
||||
|
||||
ti_dialog->entity_type_infos = g_list_reverse (types);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -267,6 +493,9 @@ clear_gui (TaxInfoDialog *ti_dialog)
|
||||
|
||||
gtk_toggle_button_set_active
|
||||
(GTK_TOGGLE_BUTTON (ti_dialog->current_account_button), TRUE);
|
||||
|
||||
gtk_spin_button_set_value
|
||||
(GTK_SPIN_BUTTON (ti_dialog->copy_spin_button), 1);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@ -274,8 +503,26 @@ gnc_tax_info_dialog_account_filter_func (Account *account,
|
||||
gpointer data)
|
||||
{
|
||||
TaxInfoDialog *dialog = data;
|
||||
gboolean included = FALSE;
|
||||
|
||||
return xaccAccountGetType (account) == dialog->account_type;
|
||||
if ((dialog->account_type == ACCT_TYPE_INCOME) ||
|
||||
(dialog->account_type == ACCT_TYPE_EXPENSE))
|
||||
included = (xaccAccountGetType (account) == dialog->account_type);
|
||||
else if (dialog->account_type == ACCT_TYPE_ASSET)
|
||||
included = ((xaccAccountGetType (account) == ACCT_TYPE_BANK) ||
|
||||
(xaccAccountGetType (account) == ACCT_TYPE_CASH) ||
|
||||
(xaccAccountGetType (account) == ACCT_TYPE_ASSET) ||
|
||||
(xaccAccountGetType (account) == ACCT_TYPE_STOCK) ||
|
||||
(xaccAccountGetType (account) == ACCT_TYPE_MUTUAL) ||
|
||||
(xaccAccountGetType (account) == ACCT_TYPE_RECEIVABLE));
|
||||
else if (dialog->account_type == ACCT_TYPE_LIABILITY)
|
||||
included = ((xaccAccountGetType (account) == ACCT_TYPE_CREDIT) ||
|
||||
(xaccAccountGetType (account) == ACCT_TYPE_LIABILITY) ||
|
||||
(xaccAccountGetType (account) == ACCT_TYPE_EQUITY) ||
|
||||
(xaccAccountGetType (account) == ACCT_TYPE_PAYABLE));
|
||||
else
|
||||
included = FALSE;
|
||||
return included;
|
||||
}
|
||||
|
||||
static TXFInfo *
|
||||
@ -302,7 +549,7 @@ account_to_gui (TaxInfoDialog *ti_dialog, Account *account)
|
||||
const char *str;
|
||||
TXFInfo *info;
|
||||
GList *infos;
|
||||
gint index;
|
||||
guint index;
|
||||
|
||||
if (!account)
|
||||
{
|
||||
@ -339,6 +586,10 @@ account_to_gui (TaxInfoDialog *ti_dialog, Account *account)
|
||||
else
|
||||
gtk_toggle_button_set_active
|
||||
(GTK_TOGGLE_BUTTON (ti_dialog->current_account_button), TRUE);
|
||||
|
||||
gtk_spin_button_set_value
|
||||
(GTK_SPIN_BUTTON (ti_dialog->copy_spin_button),
|
||||
(gdouble) xaccAccountGetTaxUSCopyNumber (account));
|
||||
}
|
||||
|
||||
static void
|
||||
@ -357,6 +608,7 @@ gui_to_accounts (TaxInfoDialog *ti_dialog)
|
||||
TXFInfo *info;
|
||||
GList *infos;
|
||||
GList *node;
|
||||
gint64 copy_number;
|
||||
|
||||
tax_related = gtk_toggle_button_get_active
|
||||
(GTK_TOGGLE_BUTTON (ti_dialog->tax_related_button));
|
||||
@ -387,6 +639,14 @@ gui_to_accounts (TaxInfoDialog *ti_dialog)
|
||||
else
|
||||
pns = NULL;
|
||||
|
||||
if (tax_related && info->copy)
|
||||
{
|
||||
copy_number = gtk_spin_button_get_value_as_int
|
||||
(GTK_SPIN_BUTTON (ti_dialog->copy_spin_button));
|
||||
}
|
||||
else
|
||||
copy_number = 0;/* setting to zero removes slot */
|
||||
|
||||
accounts = gnc_tree_view_account_get_selected_accounts
|
||||
(GNC_TREE_VIEW_ACCOUNT(ti_dialog->account_treeview));
|
||||
|
||||
@ -397,13 +657,26 @@ gui_to_accounts (TaxInfoDialog *ti_dialog)
|
||||
xaccAccountBeginEdit (account);
|
||||
|
||||
xaccAccountSetTaxRelated (account, tax_related);
|
||||
xaccAccountSetTaxUSCode (account, code);
|
||||
xaccAccountSetTaxUSPayerNameSource (account, pns);
|
||||
xaccAccountSetTaxUSCopyNumber (account, copy_number);
|
||||
/* USCode is last because it removes TaxUS KVP if not tax_related */
|
||||
xaccAccountSetTaxUSCode (account, code);
|
||||
|
||||
xaccAccountCommitEdit (account);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
identity_edit_destroy_cb (GtkObject *object, gpointer data)
|
||||
{
|
||||
TaxInfoDialog *ti_dialog = data;
|
||||
|
||||
ti_dialog->entity_name_entry = NULL;
|
||||
ti_dialog->entity_type_combo = NULL;
|
||||
|
||||
gtk_object_destroy (object);
|
||||
}
|
||||
|
||||
static void
|
||||
window_destroy_cb (GtkObject *object, gpointer data)
|
||||
{
|
||||
@ -411,12 +684,21 @@ window_destroy_cb (GtkObject *object, gpointer data)
|
||||
|
||||
gnc_unregister_gui_component_by_data (DIALOG_TAX_INFO_CM_CLASS, ti_dialog);
|
||||
|
||||
destroy_tax_type_infos (ti_dialog->entity_type_infos);
|
||||
ti_dialog->entity_type_infos = NULL;
|
||||
|
||||
destroy_txf_infos (ti_dialog->income_txf_infos);
|
||||
ti_dialog->income_txf_infos = NULL;
|
||||
|
||||
destroy_txf_infos (ti_dialog->expense_txf_infos);
|
||||
ti_dialog->expense_txf_infos = NULL;
|
||||
|
||||
destroy_txf_infos (ti_dialog->asset_txf_infos);
|
||||
ti_dialog->asset_txf_infos = NULL;
|
||||
|
||||
destroy_txf_infos (ti_dialog->liab_eq_txf_infos);
|
||||
ti_dialog->liab_eq_txf_infos = NULL;
|
||||
|
||||
g_free (ti_dialog);
|
||||
}
|
||||
|
||||
@ -468,22 +750,37 @@ gnc_tax_info_dialog_response (GtkDialog *dialog, gint response, gpointer data)
|
||||
}
|
||||
|
||||
static void
|
||||
tax_info_show_income_accounts (TaxInfoDialog *ti_dialog, gboolean show_income)
|
||||
tax_info_show_acct_type_accounts (TaxInfoDialog *ti_dialog)
|
||||
{
|
||||
GncTreeViewAccount *tree;
|
||||
AccountViewInfo info;
|
||||
GNCAccountType type;
|
||||
GNCAccountType show_type;
|
||||
|
||||
ti_dialog->income = show_income;
|
||||
|
||||
tree = GNC_TREE_VIEW_ACCOUNT (ti_dialog->account_treeview);
|
||||
show_type = show_income ? ACCT_TYPE_INCOME : ACCT_TYPE_EXPENSE;
|
||||
|
||||
gnc_tree_view_account_get_view_info (tree, &info);
|
||||
|
||||
for (type = 0; type < NUM_ACCOUNT_TYPES; type++)
|
||||
info.include_type[type] = (type == show_type);
|
||||
for (type = 0; type < NUM_ACCOUNT_TYPES; type++) /* from Account.h */
|
||||
{
|
||||
if (ti_dialog->account_type == ACCT_TYPE_EXPENSE)
|
||||
info.include_type[type] = (type == ACCT_TYPE_EXPENSE);
|
||||
else if (ti_dialog->account_type == ACCT_TYPE_INCOME)
|
||||
info.include_type[type] = (type == ACCT_TYPE_INCOME);
|
||||
else if (ti_dialog->account_type == ACCT_TYPE_ASSET)
|
||||
info.include_type[type] = ((type == ACCT_TYPE_BANK) ||
|
||||
(type == ACCT_TYPE_CASH) ||
|
||||
(type == ACCT_TYPE_ASSET) ||
|
||||
(type == ACCT_TYPE_STOCK) ||
|
||||
(type == ACCT_TYPE_MUTUAL) ||
|
||||
(type == ACCT_TYPE_RECEIVABLE));
|
||||
else if (ti_dialog->account_type == ACCT_TYPE_LIABILITY)
|
||||
info.include_type[type] = ((type == ACCT_TYPE_CREDIT) ||
|
||||
(type == ACCT_TYPE_LIABILITY) ||
|
||||
(type == ACCT_TYPE_EQUITY) ||
|
||||
(type == ACCT_TYPE_PAYABLE));
|
||||
else
|
||||
info.include_type[type] = FALSE;
|
||||
}
|
||||
|
||||
gnc_tree_view_account_set_view_info (tree, &info);
|
||||
|
||||
@ -518,21 +815,32 @@ gnc_tax_info_update_accounts (TaxInfoDialog *ti_dialog)
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_tax_info_income_cb (GtkWidget *w, gpointer data)
|
||||
gnc_tax_info_acct_type_cb (GtkWidget *w, gpointer data)
|
||||
{
|
||||
TaxInfoDialog *ti_dialog = data;
|
||||
gboolean show_income;
|
||||
const gchar *button_name;
|
||||
|
||||
show_income = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (w));
|
||||
|
||||
tax_info_show_income_accounts (ti_dialog, show_income);
|
||||
|
||||
ti_dialog->account_type = show_income ? ACCT_TYPE_INCOME : ACCT_TYPE_EXPENSE;
|
||||
gnc_tree_view_account_refilter (GNC_TREE_VIEW_ACCOUNT (ti_dialog->account_treeview));
|
||||
|
||||
gnc_tax_info_update_accounts (ti_dialog);
|
||||
|
||||
clear_gui (ti_dialog);
|
||||
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (w)))
|
||||
{
|
||||
button_name = gtk_widget_get_name (w);
|
||||
if (safe_strcmp (button_name, "income_radio") == 0)
|
||||
ti_dialog->account_type = ACCT_TYPE_INCOME;
|
||||
else if (safe_strcmp (button_name, "expense_radio") == 0)
|
||||
ti_dialog->account_type = ACCT_TYPE_EXPENSE;
|
||||
else if (safe_strcmp (button_name, "asset_radio") == 0)
|
||||
ti_dialog->account_type = ACCT_TYPE_ASSET;
|
||||
else if (safe_strcmp (button_name, "liab_eq_radio") == 0)
|
||||
ti_dialog->account_type = ACCT_TYPE_LIABILITY;
|
||||
else
|
||||
return;
|
||||
tax_info_show_acct_type_accounts (ti_dialog);
|
||||
gnc_tree_view_account_refilter
|
||||
(GNC_TREE_VIEW_ACCOUNT (ti_dialog->account_treeview));
|
||||
gnc_tax_info_update_accounts (ti_dialog);
|
||||
clear_gui (ti_dialog);
|
||||
}
|
||||
else
|
||||
return;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -629,23 +937,234 @@ txf_code_select_row_cb (GtkTreeSelection *selection,
|
||||
(GTK_TOGGLE_BUTTON (ti_dialog->current_account_button), TRUE);
|
||||
}
|
||||
|
||||
vbox = gnc_glade_lookup_widget (GTK_WIDGET (ti_dialog->dialog),
|
||||
"copy_number_vbox");
|
||||
|
||||
if (txf_info && txf_info->copy)
|
||||
{
|
||||
gtk_widget_set_sensitive (vbox, TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_widget_set_sensitive (vbox, FALSE);
|
||||
}
|
||||
|
||||
gnc_tax_info_set_changed (ti_dialog, TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
set_focus_sensitivity (TaxInfoDialog *ti_dialog)
|
||||
{
|
||||
if ((ti_dialog->tax_type == NULL) ||
|
||||
(safe_strcmp (ti_dialog->tax_type, "Other") == 0) ||
|
||||
(safe_strcmp (ti_dialog->tax_type, "") == 0))
|
||||
{
|
||||
gtk_widget_grab_focus (ti_dialog->tax_identity_edit_button);
|
||||
gtk_widget_set_sensitive (ti_dialog->acct_info, FALSE);
|
||||
gtk_widget_set_sensitive (ti_dialog->txf_info, FALSE);
|
||||
gtk_widget_hide (ti_dialog->txf_help_text); /* doesn't go insensitive!? */
|
||||
}
|
||||
else if (ti_dialog->tax_type_changed)
|
||||
{
|
||||
gtk_widget_set_sensitive (ti_dialog->acct_info, TRUE);
|
||||
gtk_widget_set_sensitive (ti_dialog->txf_info, TRUE);
|
||||
gtk_widget_show (ti_dialog->txf_help_text);
|
||||
gtk_widget_grab_focus (ti_dialog->account_treeview);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_widget_set_sensitive (ti_dialog->acct_info, TRUE);
|
||||
gtk_widget_grab_focus (ti_dialog->account_treeview);
|
||||
}
|
||||
if (ti_dialog->asset_txf_infos == NULL)
|
||||
gtk_widget_hide (ti_dialog->asset_radio);
|
||||
else
|
||||
gtk_widget_show (ti_dialog->asset_radio);
|
||||
if (ti_dialog->liab_eq_txf_infos == NULL)
|
||||
gtk_widget_hide (ti_dialog->liab_eq_radio);
|
||||
else
|
||||
gtk_widget_show (ti_dialog->liab_eq_radio);
|
||||
}
|
||||
|
||||
static void
|
||||
identity_edit_response_cb (GtkDialog *dialog, gint response, gpointer data)
|
||||
{
|
||||
TaxInfoDialog *ti_dialog = data;
|
||||
const gchar *entry_name = NULL;
|
||||
const gchar *entry_type = NULL;
|
||||
gint active_item = 0;
|
||||
TaxTypeInfo *selected_type = NULL;
|
||||
|
||||
if (response == GTK_RESPONSE_APPLY)
|
||||
{
|
||||
entry_name = gtk_entry_get_text (GTK_ENTRY (ti_dialog->entity_name_entry));
|
||||
active_item = gtk_combo_box_get_active
|
||||
(GTK_COMBO_BOX (ti_dialog->entity_type_combo));
|
||||
if (active_item != -1) /* -1 if there's no active item */
|
||||
{
|
||||
selected_type = g_list_nth_data (ti_dialog->entity_type_infos,
|
||||
(guint) active_item);
|
||||
if (selected_type)
|
||||
{
|
||||
entry_type = selected_type->type_code;
|
||||
if (!(safe_strcmp (ti_dialog->tax_type, entry_type) == 0))
|
||||
{
|
||||
ti_dialog->tax_type_changed = TRUE;
|
||||
gnc_set_current_book_tax_type (entry_type);
|
||||
qof_book_kvp_changed(ti_dialog->this_book);
|
||||
ti_dialog->tax_type = g_strdup (entry_type);
|
||||
if (entry_type != NULL)
|
||||
{
|
||||
gtk_label_set_text (GTK_LABEL (ti_dialog->entity_type_display),
|
||||
selected_type->combo_box_entry);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_label_set_text (GTK_LABEL (ti_dialog->entity_type_display),
|
||||
ti_dialog->default_tax_type);
|
||||
}
|
||||
ti_dialog->income_txf_infos = load_txf_info (INCOME, ti_dialog);
|
||||
ti_dialog->expense_txf_infos = load_txf_info (EXPENSE, ti_dialog);
|
||||
ti_dialog->asset_txf_infos = load_txf_info (ASSET, ti_dialog);
|
||||
ti_dialog->liab_eq_txf_infos = load_txf_info (LIAB_EQ, ti_dialog);
|
||||
gtk_toggle_button_set_active
|
||||
(GTK_TOGGLE_BUTTON(ti_dialog->expense_radio), TRUE);
|
||||
tax_info_show_acct_type_accounts (ti_dialog);
|
||||
gnc_tree_view_account_refilter
|
||||
(GNC_TREE_VIEW_ACCOUNT (ti_dialog->account_treeview));
|
||||
gnc_tax_info_update_accounts (ti_dialog);
|
||||
clear_gui (ti_dialog);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!(safe_strcmp (ti_dialog->tax_name, entry_name) == 0))
|
||||
{
|
||||
gnc_set_current_book_tax_name (entry_name);
|
||||
qof_book_kvp_changed(ti_dialog->this_book);
|
||||
ti_dialog->tax_name = g_strdup (entry_name);
|
||||
gtk_label_set_text (GTK_LABEL (ti_dialog->entity_name_display),
|
||||
entry_name);
|
||||
}
|
||||
set_focus_sensitivity (ti_dialog);
|
||||
ti_dialog->tax_type_changed = FALSE;
|
||||
}
|
||||
identity_edit_destroy_cb (GTK_OBJECT (dialog), ti_dialog);
|
||||
}
|
||||
|
||||
static void
|
||||
identity_edit_clicked_cb (GtkButton *button,
|
||||
gpointer user_data)
|
||||
{
|
||||
TaxInfoDialog *ti_dialog = user_data;
|
||||
GtkWidget *dialog;
|
||||
GtkWidget *content_area;
|
||||
GtkWidget *name_entry;
|
||||
GtkWidget *label;
|
||||
GtkWidget *alignment;
|
||||
GtkWidget *table;
|
||||
GtkListStore *store;
|
||||
GList *types = NULL;
|
||||
GtkTreeIter iter;
|
||||
gint current_item = -1;
|
||||
gint item = 0;
|
||||
GtkCellRenderer *renderer;
|
||||
GtkWidget *type_combo;
|
||||
|
||||
dialog = gtk_dialog_new_with_buttons (_("Income Tax Identity"),
|
||||
(GtkWindow *)ti_dialog->dialog,
|
||||
GTK_DIALOG_MODAL |
|
||||
GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
GTK_STOCK_CANCEL,
|
||||
GTK_RESPONSE_CANCEL,
|
||||
GTK_STOCK_APPLY,
|
||||
GTK_RESPONSE_APPLY,
|
||||
NULL);
|
||||
content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
|
||||
name_entry = gtk_entry_new();
|
||||
ti_dialog->entity_name_entry = name_entry;
|
||||
gtk_entry_set_text (GTK_ENTRY (name_entry), ti_dialog->tax_name);
|
||||
label = gtk_label_new (_("Name"));
|
||||
gtk_misc_set_alignment (GTK_MISC (label), 1.00, 0.50);
|
||||
alignment = gtk_alignment_new(1.00, 0.50, 1.00, 0.00);
|
||||
gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 0, 0, 12, 0);
|
||||
gtk_container_add (GTK_CONTAINER (alignment), label);
|
||||
table = gtk_table_new (3, 2, FALSE);
|
||||
gtk_table_attach_defaults (GTK_TABLE (table), alignment, 0, 1, 0, 1);
|
||||
alignment = gtk_alignment_new(0.00, 0.50, 1.00, 0.00);
|
||||
gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 0, 0, 12, 0);
|
||||
gtk_container_add (GTK_CONTAINER (alignment), name_entry);
|
||||
gtk_table_attach_defaults (GTK_TABLE (table), alignment, 1, 2, 0, 1);
|
||||
store = gtk_list_store_new (1, G_TYPE_STRING);
|
||||
gtk_list_store_clear(store);
|
||||
types = ti_dialog->entity_type_infos;
|
||||
for ( ; types; types = types->next)
|
||||
{
|
||||
TaxTypeInfo *tax_type_info = types->data;
|
||||
|
||||
gtk_list_store_append(store, &iter);
|
||||
gtk_list_store_set(store, &iter, 0, tax_type_info->combo_box_entry, -1);
|
||||
if (safe_strcmp (ti_dialog->tax_type, tax_type_info->type_code) == 0)
|
||||
current_item = item;
|
||||
item++;
|
||||
}
|
||||
type_combo = gtk_combo_box_new_with_model (GTK_TREE_MODEL(store));
|
||||
g_object_unref(G_OBJECT (store));
|
||||
renderer = gtk_cell_renderer_text_new();
|
||||
gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(type_combo), renderer, TRUE);
|
||||
gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(type_combo), renderer,
|
||||
"text", 0, NULL);
|
||||
ti_dialog->entity_type_combo = type_combo;
|
||||
if (ti_dialog->tax_type) {
|
||||
gtk_combo_box_set_active (GTK_COMBO_BOX (type_combo), current_item);
|
||||
}
|
||||
else { /* set to no active item */
|
||||
gtk_combo_box_set_active (GTK_COMBO_BOX (type_combo), -1);
|
||||
}
|
||||
label = gtk_label_new (_("Type"));
|
||||
gtk_misc_set_alignment (GTK_MISC (label), 1.00, 0.50);
|
||||
alignment = gtk_alignment_new(1.00, 0.50, 1.00, 0.00);
|
||||
gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 0, 0, 12, 0);
|
||||
gtk_container_add (GTK_CONTAINER (alignment), label);
|
||||
gtk_table_attach_defaults (GTK_TABLE (table), alignment, 0, 1, 1, 2);
|
||||
alignment = gtk_alignment_new(0.00, 0.50, 1.00, 0.00);
|
||||
gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 0, 0, 12, 0);
|
||||
gtk_container_add (GTK_CONTAINER (alignment), type_combo);
|
||||
gtk_table_attach_defaults (GTK_TABLE (table), alignment, 1, 2, 1, 2);
|
||||
label = gtk_label_new (_("CAUTION: If you set TXF categories, and later change 'Type', you will need to manually reset those categories one at a time"));
|
||||
gtk_misc_set_alignment (GTK_MISC (label), 0.50, 0.50);
|
||||
alignment = gtk_alignment_new(0.50, 0.50, 1.00, 0.00);
|
||||
gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 6, 6, 4, 4);
|
||||
gtk_container_add (GTK_CONTAINER (alignment), label);
|
||||
gtk_table_attach_defaults (GTK_TABLE (table), alignment, 0, 2, 2, 3);
|
||||
gtk_container_add (GTK_CONTAINER (content_area), table);
|
||||
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_APPLY);
|
||||
g_signal_connect (G_OBJECT (dialog), "response",
|
||||
G_CALLBACK (identity_edit_response_cb), ti_dialog);
|
||||
g_signal_connect (G_OBJECT (dialog), "destroy",
|
||||
G_CALLBACK (identity_edit_destroy_cb), ti_dialog);
|
||||
gtk_widget_show_all (dialog);
|
||||
}
|
||||
|
||||
static void
|
||||
tax_related_toggled_cb (GtkToggleButton *togglebutton,
|
||||
gpointer user_data)
|
||||
{
|
||||
TaxInfoDialog *ti_dialog = user_data;
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *hbox;
|
||||
gboolean on;
|
||||
|
||||
on = gtk_toggle_button_get_active (togglebutton);
|
||||
|
||||
vbox = gnc_glade_lookup_widget (GTK_WIDGET (togglebutton),
|
||||
"txf_categories_vbox");
|
||||
hbox = gnc_glade_lookup_widget (GTK_WIDGET (togglebutton),
|
||||
"pns_copy_hbox");
|
||||
gtk_widget_set_sensitive (vbox, on);
|
||||
|
||||
gtk_widget_set_sensitive (hbox, on);
|
||||
|
||||
gnc_tax_info_set_changed (ti_dialog, TRUE);
|
||||
}
|
||||
|
||||
@ -658,6 +1177,15 @@ current_account_toggled_cb (GtkToggleButton *togglebutton,
|
||||
gnc_tax_info_set_changed (ti_dialog, TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
copy_number_value_changed_cb (GtkSpinButton *spinbutton,
|
||||
gpointer user_data)
|
||||
{
|
||||
TaxInfoDialog *ti_dialog = user_data;
|
||||
|
||||
gnc_tax_info_set_changed (ti_dialog, TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_tax_info_dialog_create (GtkWidget * parent, TaxInfoDialog *ti_dialog)
|
||||
{
|
||||
@ -674,9 +1202,7 @@ gnc_tax_info_dialog_create (GtkWidget * parent, TaxInfoDialog *ti_dialog)
|
||||
ti_dialog->dialog = dialog;
|
||||
tido = GTK_OBJECT (dialog);
|
||||
|
||||
ti_dialog->account_type = ACCT_TYPE_EXPENSE;
|
||||
ti_dialog->income_txf_infos = load_txf_info (TRUE);
|
||||
ti_dialog->expense_txf_infos = load_txf_info (FALSE);
|
||||
initialize_getters ();
|
||||
|
||||
g_signal_connect (G_OBJECT (dialog), "response",
|
||||
G_CALLBACK (gnc_tax_info_dialog_response), ti_dialog);
|
||||
@ -691,6 +1217,40 @@ gnc_tax_info_dialog_create (GtkWidget * parent, TaxInfoDialog *ti_dialog)
|
||||
/* default to ok */
|
||||
gtk_dialog_set_default_response (GTK_DIALOG(dialog), GTK_RESPONSE_OK);
|
||||
|
||||
/* tax identity */
|
||||
{
|
||||
GtkWidget *label;
|
||||
GtkWidget *edit_button;
|
||||
|
||||
ti_dialog->this_book = gnc_get_current_book();
|
||||
ti_dialog->tax_name = gnc_get_current_book_tax_name();
|
||||
ti_dialog->tax_type = gnc_get_current_book_tax_type();
|
||||
|
||||
label = glade_xml_get_widget (xml, "entity_name");
|
||||
ti_dialog->entity_name_display = label;
|
||||
gtk_label_set_text (GTK_LABEL (label), ti_dialog->tax_name);
|
||||
ti_dialog->entity_name_entry = NULL;
|
||||
|
||||
load_tax_entity_type_list (ti_dialog); /* initialize tax_type_combo_text */
|
||||
|
||||
label = glade_xml_get_widget (xml, "entity_type");
|
||||
ti_dialog->entity_type_display = label;
|
||||
if (ti_dialog->tax_type != NULL)
|
||||
gtk_label_set_text (GTK_LABEL (label), ti_dialog->tax_type_combo_text);
|
||||
ti_dialog->entity_type_combo = NULL;
|
||||
|
||||
edit_button = glade_xml_get_widget (xml, "identity_edit_button");
|
||||
ti_dialog->tax_identity_edit_button = edit_button;
|
||||
g_signal_connect (G_OBJECT (edit_button), "clicked",
|
||||
G_CALLBACK (identity_edit_clicked_cb), ti_dialog);
|
||||
ti_dialog->tax_type_changed = FALSE;
|
||||
}
|
||||
|
||||
ti_dialog->income_txf_infos = load_txf_info (INCOME, ti_dialog);
|
||||
ti_dialog->expense_txf_infos = load_txf_info (EXPENSE, ti_dialog);
|
||||
ti_dialog->asset_txf_infos = load_txf_info (ASSET, ti_dialog);
|
||||
ti_dialog->liab_eq_txf_infos = load_txf_info (LIAB_EQ, ti_dialog);
|
||||
|
||||
/* tax information */
|
||||
{
|
||||
GtkListStore *store;
|
||||
@ -699,6 +1259,7 @@ gnc_tax_info_dialog_create (GtkWidget * parent, TaxInfoDialog *ti_dialog)
|
||||
GtkWidget *button;
|
||||
GtkWidget *text;
|
||||
|
||||
ti_dialog->txf_info = glade_xml_get_widget (xml, "tax_info_vbox");
|
||||
button = glade_xml_get_widget (xml, "tax_related_button");
|
||||
ti_dialog->tax_related_button = button;
|
||||
|
||||
@ -739,12 +1300,20 @@ gnc_tax_info_dialog_create (GtkWidget * parent, TaxInfoDialog *ti_dialog)
|
||||
g_signal_connect (G_OBJECT (button), "toggled",
|
||||
G_CALLBACK (current_account_toggled_cb),
|
||||
ti_dialog);
|
||||
|
||||
button = glade_xml_get_widget (xml, "copy_spin_button");
|
||||
ti_dialog->copy_spin_button = button;
|
||||
|
||||
g_signal_connect (G_OBJECT (button), "value-changed",
|
||||
G_CALLBACK (copy_number_value_changed_cb),
|
||||
ti_dialog);
|
||||
}
|
||||
|
||||
/* account tree */
|
||||
{
|
||||
GtkWidget *income_radio, *expense_radio, *box;
|
||||
GtkWidget *income_radio, *expense_radio, *asset_radio, *liab_eq_radio, *box;
|
||||
|
||||
ti_dialog->acct_info = glade_xml_get_widget (xml, "acct_info_vbox");
|
||||
box = glade_xml_get_widget (xml, "account_scroll");
|
||||
tree_view = gnc_tree_view_account_new (FALSE);
|
||||
gnc_tree_view_account_set_filter (GNC_TREE_VIEW_ACCOUNT(tree_view),
|
||||
@ -766,12 +1335,26 @@ gnc_tax_info_dialog_create (GtkWidget * parent, TaxInfoDialog *ti_dialog)
|
||||
|
||||
income_radio = glade_xml_get_widget (xml, "income_radio");
|
||||
expense_radio = glade_xml_get_widget (xml, "expense_radio");
|
||||
ti_dialog->expense_radio = expense_radio;
|
||||
asset_radio = glade_xml_get_widget (xml, "asset_radio");
|
||||
ti_dialog->asset_radio = asset_radio;
|
||||
liab_eq_radio = glade_xml_get_widget (xml, "liab_eq_radio");
|
||||
ti_dialog->liab_eq_radio = liab_eq_radio;
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(expense_radio), TRUE);
|
||||
ti_dialog->account_type = ACCT_TYPE_EXPENSE;
|
||||
g_signal_connect (G_OBJECT (income_radio), "toggled",
|
||||
G_CALLBACK (gnc_tax_info_income_cb),
|
||||
G_CALLBACK (gnc_tax_info_acct_type_cb),
|
||||
ti_dialog);
|
||||
// gtk_button_clicked (GtkButton *button);
|
||||
}
|
||||
g_signal_connect (G_OBJECT (expense_radio), "toggled",
|
||||
G_CALLBACK (gnc_tax_info_acct_type_cb),
|
||||
ti_dialog);
|
||||
g_signal_connect (G_OBJECT (asset_radio), "toggled",
|
||||
G_CALLBACK (gnc_tax_info_acct_type_cb),
|
||||
ti_dialog);
|
||||
g_signal_connect (G_OBJECT (liab_eq_radio), "toggled",
|
||||
G_CALLBACK (gnc_tax_info_acct_type_cb),
|
||||
ti_dialog);
|
||||
}
|
||||
|
||||
/* select subaccounts button */
|
||||
{
|
||||
@ -788,7 +1371,7 @@ gnc_tax_info_dialog_create (GtkWidget * parent, TaxInfoDialog *ti_dialog)
|
||||
ti_dialog);
|
||||
}
|
||||
|
||||
tax_info_show_income_accounts (ti_dialog, FALSE);
|
||||
tax_info_show_acct_type_accounts (ti_dialog);
|
||||
gnc_tax_info_update_accounts (ti_dialog);
|
||||
clear_gui (ti_dialog);
|
||||
gnc_tax_info_set_changed (ti_dialog, FALSE);
|
||||
@ -822,8 +1405,6 @@ refresh_handler (GHashTable *changes, gpointer user_data)
|
||||
{
|
||||
TaxInfoDialog *ti_dialog = user_data;
|
||||
|
||||
/* gnc_account_tree_refresh (GNC_ACCOUNT_TREE (ti_dialog->account_tree));*/
|
||||
|
||||
gnc_tax_info_update_accounts (ti_dialog);
|
||||
}
|
||||
|
||||
@ -853,7 +1434,7 @@ gnc_tax_info_dialog (GtkWidget * parent)
|
||||
GNC_ID_ACCOUNT,
|
||||
QOF_EVENT_MODIFY | QOF_EVENT_DESTROY);
|
||||
|
||||
gtk_widget_grab_focus (ti_dialog->account_treeview);
|
||||
set_focus_sensitivity (ti_dialog);
|
||||
|
||||
gtk_widget_show (ti_dialog->dialog);
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -130,8 +130,8 @@ static GtkActionEntry gnc_plugin_actions [] = {
|
||||
{ "EditFindTransactionsAction", GTK_STOCK_FIND, N_("_Find..."), "<control>f",
|
||||
N_("Find transactions with a search"),
|
||||
G_CALLBACK (gnc_main_window_cmd_tools_find_transactions) },
|
||||
{ "EditTaxOptionsAction", NULL, N_("Ta_x Options"), NULL,
|
||||
N_("Setup tax information for all income and expense accounts"),
|
||||
{ "EditTaxOptionsAction", NULL, N_("Income Ta_x Options"), NULL,
|
||||
N_("Setup income tax information for relevant accounts"),
|
||||
G_CALLBACK (gnc_main_window_cmd_edit_tax_options) },
|
||||
|
||||
/* Actions menu */
|
||||
|
@ -206,7 +206,7 @@
|
||||
(gnc:txf-get-format (if income?
|
||||
txf-income-categories
|
||||
txf-expense-categories)
|
||||
code))
|
||||
code ""))
|
||||
|
||||
(define (gnc:account-get-txf-payer-source account)
|
||||
(let ((pns (xaccAccountGetTaxUSPayerNameSource account)))
|
||||
@ -341,9 +341,9 @@
|
||||
"Aufwendungen"))
|
||||
(category-key (if (eq? type ACCT-TYPE-INCOME)
|
||||
(gnc:txf-get-category-key
|
||||
txf-income-categories code)
|
||||
txf-income-categories code "")
|
||||
(gnc:txf-get-category-key
|
||||
txf-expense-categories code)))
|
||||
txf-expense-categories code "")))
|
||||
(value-name (if (equal? "ReinvD" action)
|
||||
(string-append
|
||||
(substring value 1 (string-length value))
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -9,12 +9,20 @@
|
||||
(export gnc:txf-get-format)
|
||||
(export gnc:txf-get-multiple)
|
||||
(export gnc:txf-get-category-key)
|
||||
(export gnc:txf-get-line-data)
|
||||
(export gnc:txf-get-last-year)
|
||||
(export gnc:txf-get-help)
|
||||
(export gnc:txf-get-codes)
|
||||
(export gnc:txf-get-tax-entity-type)
|
||||
(export gnc:txf-get-tax-entity-type-description)
|
||||
(export gnc:txf-get-tax-entity-type-codes)
|
||||
(export gnc:txf-get-code-info)
|
||||
(export txf-help-categories)
|
||||
|
||||
(export txf-income-categories)
|
||||
(export txf-expense-categories)
|
||||
(export txf-asset-categories)
|
||||
(export txf-liab-eq-categories)
|
||||
|
||||
(define gnc:*tax-label* (N_ "Tax"))
|
||||
(define gnc:*tax-nr-label* (N_ "Tax Number"))
|
||||
|
@ -15,31 +15,80 @@
|
||||
;; e.g. the Winston software
|
||||
;; http://www.felfri.de/winston/schnittstellen.htm
|
||||
;;
|
||||
(define (gnc:txf-get-payer-name-source categories code)
|
||||
(gnc:txf-get-code-info categories code 0))
|
||||
(define (gnc:txf-get-form categories code)
|
||||
(gnc:txf-get-code-info categories code 1))
|
||||
(define (gnc:txf-get-description categories code)
|
||||
(gnc:txf-get-code-info categories code 2))
|
||||
(define (gnc:txf-get-format categories code)
|
||||
(gnc:txf-get-code-info categories code 3))
|
||||
(define (gnc:txf-get-multiple categories code)
|
||||
(gnc:txf-get-code-info categories code 4))
|
||||
(define (gnc:txf-get-category-key categories code)
|
||||
(gnc:txf-get-code-info categories code 5))
|
||||
|
||||
(define txf-tax-entity-types
|
||||
(list
|
||||
(cons 'Ind #("Individual, Joint, etc." "Files Individual German Tax Return"))
|
||||
(cons 'Other #("None" "No Income Tax Options Provided"))))
|
||||
|
||||
(define (gnc:tax-type-txf-get-code-info tax-entity-types type-code index)
|
||||
(let ((tax-entity-type (assv type-code tax-entity-types)))
|
||||
(and tax-entity-type
|
||||
(vector-ref (cdr tax-entity-type) index))))
|
||||
|
||||
(define (gnc:txf-get-tax-entity-type type-code)
|
||||
(gnc:tax-type-txf-get-code-info txf-tax-entity-types type-code 0))
|
||||
|
||||
(define (gnc:txf-get-tax-entity-type-description type-code)
|
||||
(gnc:tax-type-txf-get-code-info txf-tax-entity-types type-code 1))
|
||||
|
||||
(define (gnc:txf-get-tax-entity-type-codes)
|
||||
(map car txf-tax-entity-types))
|
||||
|
||||
(define (gnc:txf-get-payer-name-source categories code tax-entity-type)
|
||||
(gnc:txf-get-code-info categories code 0 tax-entity-type))
|
||||
(define (gnc:txf-get-form categories code tax-entity-type)
|
||||
(gnc:txf-get-code-info categories code 1 tax-entity-type))
|
||||
(define (gnc:txf-get-description categories code tax-entity-type)
|
||||
(gnc:txf-get-code-info categories code 2 tax-entity-type))
|
||||
(define (gnc:txf-get-format categories code tax-entity-type)
|
||||
(gnc:txf-get-code-info categories code 3 tax-entity-type))
|
||||
(define (gnc:txf-get-multiple categories code tax-entity-type)
|
||||
(gnc:txf-get-code-info categories code 4 tax-entity-type))
|
||||
(define (gnc:txf-get-category-key categories code tax-entity-type)
|
||||
(gnc:txf-get-code-info categories code 5 tax-entity-type))
|
||||
(define (gnc:txf-get-line-data categories code tax-entity-type)
|
||||
(let* ((tax-entity-codes (cdr (assv (string->symbol tax-entity-type)
|
||||
categories)))
|
||||
(category (assv code tax-entity-codes)))
|
||||
(if (or (not category) (< (vector-length (cdr category)) 7))
|
||||
#f
|
||||
(gnc:txf-get-code-info categories code 6 tax-entity-type))))
|
||||
(define (gnc:txf-get-last-year categories code tax-entity-type)
|
||||
(let* ((tax-entity-codes (cdr (assv (string->symbol tax-entity-type)
|
||||
categories)))
|
||||
(category (assv code tax-entity-codes)))
|
||||
(if (or (not category) (< (vector-length (cdr category)) 8))
|
||||
#f
|
||||
(gnc:txf-get-code-info categories code 7 tax-entity-type))))
|
||||
|
||||
(define (gnc:txf-get-help categories code)
|
||||
(let ((pair (assv code txf-help-strings)))
|
||||
(if pair
|
||||
(cdr pair)
|
||||
"No help available.")))
|
||||
|
||||
(define (gnc:txf-get-codes categories)
|
||||
(map car categories))
|
||||
(define (gnc:txf-get-codes categories tax-entity-type)
|
||||
(let* ((tax-entity-code-list-pair (assv (if (eqv? tax-entity-type "")
|
||||
'Ind
|
||||
(string->symbol tax-entity-type))
|
||||
categories))
|
||||
(tax-entity-codes (if tax-entity-code-list-pair
|
||||
(cdr tax-entity-code-list-pair)
|
||||
'())))
|
||||
(map car tax-entity-codes)))
|
||||
|
||||
;;;; Private
|
||||
|
||||
(define (gnc:txf-get-code-info categories code index)
|
||||
(let ((category (assv code categories)))
|
||||
(define (gnc:txf-get-code-info categories code index tax-entity-type)
|
||||
(let* ((tax-entity-code-list-pair (assv (if (eqv? tax-entity-type "")
|
||||
'Ind
|
||||
(string->symbol tax-entity-type))
|
||||
categories))
|
||||
(tax-entity-codes (if tax-entity-code-list-pair
|
||||
(cdr tax-entity-code-list-pair)
|
||||
'()))
|
||||
(category (assv code tax-entity-codes)))
|
||||
(and category
|
||||
(vector-ref (cdr category) index))))
|
||||
|
||||
@ -56,7 +105,9 @@
|
||||
|
||||
;; Format: (name-source form description format multiple category-key)
|
||||
(define txf-income-categories
|
||||
(list
|
||||
(list
|
||||
(cons 'Ind
|
||||
(list
|
||||
(cons 'N000 #(none "" "Nur zur Voransicht im Steuer-Bericht -- kein Export" 0 #f ""))
|
||||
|
||||
(cons 'K35 #(none "35" "Umsätze, die anderen Steuersätzen unterliegen (Bemessungsgrundlage)" 2 #f "35"))
|
||||
@ -82,7 +133,9 @@
|
||||
(cons 'K97 #(none "97" "Steuerpflichtige innergemeinschaftliche Erwerbe zum Steuersatz von 16 v.H." 2 #f "97"))
|
||||
(cons 'K98 #(none "98" "Steuerpflichtige innergemeinschaftliche Erwerbe zu anderen Steuersätzen (Steuer)" 1 #f "98"))
|
||||
|
||||
))
|
||||
)
|
||||
)
|
||||
))
|
||||
|
||||
|
||||
;; We use several formats; nr. 1 means Euro+Cent, nr. 2 means only full Euro
|
||||
@ -92,7 +145,9 @@
|
||||
|
||||
;; Format: (name-source form description format multiple category-key)
|
||||
(define txf-expense-categories
|
||||
(list
|
||||
(list
|
||||
(cons 'Ind
|
||||
(list
|
||||
(cons 'N000 #(none "" "Nur zur Voransicht im Steuer-Bericht -- kein Export" 0 #f ""))
|
||||
|
||||
(cons 'K52 #(none "52" "Leistungen eines im Ausland ansässigen Unternehmers (Bemessungsgrundlage)" 2 #f "52"))
|
||||
@ -114,10 +169,28 @@
|
||||
(cons 'K94 #(none "94" "Innergemeinschaftliche Erwerbe neuer Fahrzeuge von Lieferern ohne USt-IdNr. (Bemessungsgrundlage)" 2 #f "94"))
|
||||
(cons 'K95 #(none "95" "Steuerpflichtige innergemeinschaftliche Erwerbe zu anderen Steuersätzen (Bemessungsgrundlage)" 2 #f "95"))
|
||||
(cons 'K96 #(none "96" "Innergemeinschaftliche Erwerbe neuer Fahrzeuge von Lieferern ohne USt-IdNr. (Steuer)" 1 #f "96"))
|
||||
)
|
||||
)
|
||||
|
||||
))
|
||||
|
||||
(define txf-asset-categories
|
||||
(list
|
||||
(cons 'Ind
|
||||
(list
|
||||
(cons 'N000 #(none "" "Nur zur Voransicht im Steuer-Bericht -- kein Export" 0 #f ""))
|
||||
)
|
||||
)
|
||||
))
|
||||
|
||||
(define txf-liab-eq-categories
|
||||
(list
|
||||
(cons 'Ind
|
||||
(list
|
||||
(cons 'N000 #(none "" "Nur zur Voransicht im Steuer-Bericht -- kein Export" 0 #f ""))
|
||||
)
|
||||
)
|
||||
))
|
||||
|
||||
;;; Register global options in this book
|
||||
(define (book-options-generator options)
|
||||
|
1484
src/tax/us/txf.scm
1484
src/tax/us/txf.scm
File diff suppressed because it is too large
Load Diff
@ -6,12 +6,20 @@
|
||||
(export gnc:txf-get-format)
|
||||
(export gnc:txf-get-multiple)
|
||||
(export gnc:txf-get-category-key)
|
||||
(export gnc:txf-get-line-data)
|
||||
(export gnc:txf-get-last-year)
|
||||
(export gnc:txf-get-help)
|
||||
(export gnc:txf-get-codes)
|
||||
(export gnc:txf-get-tax-entity-type)
|
||||
(export gnc:txf-get-tax-entity-type-description)
|
||||
(export gnc:txf-get-tax-entity-type-codes)
|
||||
(export gnc:txf-get-code-info)
|
||||
(export txf-help-categories)
|
||||
|
||||
(export txf-income-categories)
|
||||
(export txf-expense-categories)
|
||||
(export txf-asset-categories)
|
||||
(export txf-liab-eq-categories)
|
||||
|
||||
(load-from-path "txf.scm")
|
||||
(load-from-path "txf-help.scm")
|
||||
|
Loading…
Reference in New Issue
Block a user