mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
* src/gnome/dialog-tax-info.c: implement tax info api
* src/gnome/account-tree.c: same as below * src/gnome/window-acct-tree.c: add tax info field * src/scm/report.scm: add an export callback for reports * src/guile/gnc.gwp: wrap radio chooser api * src/scm/report/taxtxf.scm: use export callback to choose between html & txf * src/gnome/window-report.c: implement export callback git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@3995 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
cffa80d765
commit
05c143599a
27
ChangeLog
27
ChangeLog
@ -1,3 +1,30 @@
|
||||
2001-04-19 Dave Peticolas <dave@krondo.com>
|
||||
|
||||
* src/gnome/dialog-tax-info.c: implement tax info api
|
||||
|
||||
* src/gnome/account-tree.c: same as below
|
||||
|
||||
* src/gnome/window-acct-tree.c: add tax info field
|
||||
|
||||
* src/scm/report.scm: add an export callback for reports
|
||||
|
||||
* src/guile/gnc.gwp: wrap radio chooser api
|
||||
|
||||
* src/scm/report/taxtxf.scm: use export callback to choose
|
||||
between html & txf
|
||||
|
||||
* src/gnome/window-report.c: implement export callback
|
||||
|
||||
2001-04-18 Dave Peticolas <dave@krondo.com>
|
||||
|
||||
* src/SplitLedger.c: fix for api change below
|
||||
|
||||
* src/gnc-ui.h: api change below
|
||||
|
||||
* src/gnome/query-user.c
|
||||
(gnc_choose_radio_option_dialog_parented): use glist instead of
|
||||
pointer array for list of strings argument
|
||||
|
||||
2001-04-18 Bill Gribble <grib@billgribble.com>
|
||||
|
||||
* src/gnome/dialog-options.c: don't destroy options dialog twice.
|
||||
|
@ -809,7 +809,7 @@ sr_balance_trans (SplitRegister *reg, Transaction *trans)
|
||||
int default_value;
|
||||
Account *default_account;
|
||||
Account *other_account;
|
||||
char *radio_list[5] = { NULL, NULL, NULL, NULL, NULL };
|
||||
GList *radio_list = NULL;
|
||||
const char *title = _("Rebalance Transaction");
|
||||
const char *message = _("The current transaction is not balanced.");
|
||||
Split *split;
|
||||
@ -846,15 +846,19 @@ sr_balance_trans (SplitRegister *reg, Transaction *trans)
|
||||
if (default_account == other_account)
|
||||
two_accounts = FALSE;
|
||||
|
||||
radio_list[0] = _("Balance it manually");
|
||||
radio_list[1] = _("Let GnuCash add an adjusting split");
|
||||
radio_list = g_list_append (radio_list,
|
||||
_("Balance it manually"));
|
||||
radio_list = g_list_append (radio_list,
|
||||
_("Let GnuCash add an adjusting split"));
|
||||
|
||||
if (reg->type < NUM_SINGLE_REGISTER_TYPES)
|
||||
{
|
||||
radio_list[2] = _("Adjust current account split total");
|
||||
|
||||
radio_list = g_list_append (radio_list,
|
||||
_("Adjust current account split total"));
|
||||
|
||||
if (two_accounts)
|
||||
radio_list[3] = _("Adjust other account split total");
|
||||
radio_list = g_list_append (radio_list,
|
||||
_("Adjust other account split total"));
|
||||
|
||||
default_value = 2;
|
||||
}
|
||||
@ -866,6 +870,7 @@ sr_balance_trans (SplitRegister *reg, Transaction *trans)
|
||||
message,
|
||||
default_value,
|
||||
radio_list);
|
||||
g_list_free (radio_list);
|
||||
|
||||
switch (choice)
|
||||
{
|
||||
@ -3065,29 +3070,35 @@ sr_split_auto_calc (SplitRegister *reg, Split *split, guint32 changed)
|
||||
!recalc_value &&
|
||||
!gnc_numeric_same (value, calc_value, denom, GNC_RND_ROUND))
|
||||
{
|
||||
int i;
|
||||
int choice;
|
||||
int default_value;
|
||||
char *radio_list[4] = { NULL, NULL, NULL, NULL };
|
||||
GList *node;
|
||||
GList *radio_list = NULL;
|
||||
const char *title = _("Recalculate Transaction");
|
||||
const char *message = _("The values entered for this transaction "
|
||||
"are inconsistent.\nWhich value would you "
|
||||
"like to have recalculated?");
|
||||
|
||||
if (MOD_SHRS & changed)
|
||||
radio_list[0] = g_strdup_printf ("%s (%s)", _("Shares"), _("Changed"));
|
||||
radio_list = g_list_append (radio_list,
|
||||
g_strdup_printf ("%s (%s)",
|
||||
_("Shares"), _("Changed")));
|
||||
else
|
||||
radio_list[0] = g_strdup (_("Shares"));
|
||||
radio_list = g_list_append (radio_list, g_strdup (_("Shares")));
|
||||
|
||||
if (MOD_PRIC & changed)
|
||||
radio_list[1] = g_strdup_printf ("%s (%s)", _("Price"), _("Changed"));
|
||||
radio_list = g_list_append (radio_list,
|
||||
g_strdup_printf ("%s (%s)",
|
||||
_("Price"), _("Changed")));
|
||||
else
|
||||
radio_list[1] = g_strdup (_("Price"));
|
||||
radio_list = g_list_append (radio_list, g_strdup (_("Price")));
|
||||
|
||||
if (MOD_AMNT & changed)
|
||||
radio_list[2] = g_strdup_printf ("%s (%s)", _("Value"), _("Changed"));
|
||||
radio_list = g_list_append (radio_list,
|
||||
g_strdup_printf ("%s (%s)",
|
||||
_("Value"), _("Changed")));
|
||||
else
|
||||
radio_list[2] = g_strdup (_("Value"));
|
||||
radio_list = g_list_append (radio_list, g_strdup (_("Value")));
|
||||
|
||||
if (!(MOD_PRIC & changed))
|
||||
default_value = 1;
|
||||
@ -3104,8 +3115,10 @@ sr_split_auto_calc (SplitRegister *reg, Split *split, guint32 changed)
|
||||
default_value,
|
||||
radio_list);
|
||||
|
||||
for (i = 0; i < 3; i++)
|
||||
g_free (radio_list[i]);
|
||||
for (node = radio_list; node; node = node->next)
|
||||
g_free (node->data);
|
||||
|
||||
g_list_free (radio_list);
|
||||
|
||||
switch(choice)
|
||||
{
|
||||
|
@ -271,7 +271,7 @@ xaccQueryHasTerms(Query * q) {
|
||||
GList *
|
||||
xaccQueryGetTerms (Query *q)
|
||||
{
|
||||
if (!q) return 0x0;
|
||||
if (!q) return NULL;
|
||||
return q->terms;
|
||||
}
|
||||
|
||||
@ -2337,6 +2337,36 @@ xaccQuerySetSortOrder(Query * q, sort_type_t primary,
|
||||
q->changed = 1;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
* xaccQueryGetPrimarySortOrder
|
||||
*******************************************************************/
|
||||
sort_type_t
|
||||
xaccQueryGetPrimarySortOrder(Query * q)
|
||||
{
|
||||
if (!q) return BY_NONE;
|
||||
return q->primary_sort;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
* xaccQueryGetSecondarySortOrder
|
||||
*******************************************************************/
|
||||
sort_type_t
|
||||
xaccQueryGetSecondarySortOrder(Query * q)
|
||||
{
|
||||
if (!q) return BY_NONE;
|
||||
return q->secondary_sort;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
* xaccQueryGetTertiarySortOrder
|
||||
*******************************************************************/
|
||||
sort_type_t
|
||||
xaccQueryGetTertiarySortOrder(Query * q)
|
||||
{
|
||||
if (!q) return BY_NONE;
|
||||
return q->tertiary_sort;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
* xaccQuerySetSortIncreasing
|
||||
*******************************************************************/
|
||||
@ -2352,6 +2382,36 @@ xaccQuerySetSortIncreasing(Query * q, gboolean prim_increasing,
|
||||
return;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
* xaccQueryGetSortPrimaryIncreasing
|
||||
*******************************************************************/
|
||||
gboolean
|
||||
xaccQueryGetSortPrimaryIncreasing (Query *q)
|
||||
{
|
||||
if (!q) return TRUE;
|
||||
return q->primary_increasing;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
* xaccQueryGetSortSecondaryIncreasing
|
||||
*******************************************************************/
|
||||
gboolean
|
||||
xaccQueryGetSortSecondaryIncreasing (Query *q)
|
||||
{
|
||||
if (!q) return TRUE;
|
||||
return q->secondary_increasing;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
* xaccQueryGetSortTertiaryIncreasing
|
||||
*******************************************************************/
|
||||
gboolean
|
||||
xaccQueryGetSortTertiaryIncreasing (Query *q)
|
||||
{
|
||||
if (!q) return TRUE;
|
||||
return q->tertiary_increasing;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
* xaccQuerySetMaxSplits
|
||||
*******************************************************************/
|
||||
|
@ -303,9 +303,18 @@ void xaccQueryAddPredicate (Query * q, PredicateData *pred, QueryOp op);
|
||||
|
||||
void xaccQuerySetSortOrder(Query * q, sort_type_t primary,
|
||||
sort_type_t secondary, sort_type_t tertiary);
|
||||
void xaccQuerySetSortIncreasing(Query * q, gboolean prim_increasing,
|
||||
gboolean sec_increasing,
|
||||
sort_type_t xaccQueryGetPrimarySortOrder(Query * q);
|
||||
sort_type_t xaccQueryGetSecondarySortOrder(Query * q);
|
||||
sort_type_t xaccQueryGetTertiarySortOrder(Query * q);
|
||||
|
||||
void xaccQuerySetSortIncreasing(Query * q,
|
||||
gboolean prim_increasing,
|
||||
gboolean sec_increasing,
|
||||
gboolean tert_increasing);
|
||||
gboolean xaccQueryGetSortPrimaryIncreasing (Query *q);
|
||||
gboolean xaccQueryGetSortSecondaryIncreasing (Query *q);
|
||||
gboolean xaccQueryGetSortTertiaryIncreasing (Query *q);
|
||||
|
||||
void xaccQuerySetMaxSplits(Query * q, int n);
|
||||
int xaccQueryGetMaxSplits(Query * q);
|
||||
|
||||
|
@ -104,7 +104,7 @@ gnc_get_account_separator (void)
|
||||
|
||||
|
||||
const char *
|
||||
gnc_ui_get_account_field_name (AccountFieldCode field)
|
||||
gnc_ui_account_get_field_name (AccountFieldCode field)
|
||||
{
|
||||
g_return_val_if_fail ((field >= 0) && (field < NUM_ACCOUNT_FIELDS), NULL);
|
||||
|
||||
@ -143,6 +143,8 @@ gnc_ui_get_account_field_name (AccountFieldCode field)
|
||||
case ACCOUNT_TOTAL_EURO :
|
||||
return _("Total");
|
||||
break;
|
||||
case ACCOUNT_TAX_INFO :
|
||||
return _("Tax Info");
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -256,8 +258,8 @@ gnc_ui_account_get_balance (Account *account, gboolean include_children)
|
||||
}
|
||||
|
||||
|
||||
const char *
|
||||
gnc_ui_get_account_field_value_string (Account *account,
|
||||
char *
|
||||
gnc_ui_account_get_field_value_string (Account *account,
|
||||
AccountFieldCode field)
|
||||
{
|
||||
g_return_val_if_fail ((field >= 0) && (field < NUM_ACCOUNT_FIELDS), NULL);
|
||||
@ -268,34 +270,39 @@ gnc_ui_get_account_field_value_string (Account *account,
|
||||
switch (field)
|
||||
{
|
||||
case ACCOUNT_TYPE :
|
||||
return xaccAccountGetTypeStr(xaccAccountGetType(account));
|
||||
break;
|
||||
return g_strdup (xaccAccountGetTypeStr(xaccAccountGetType(account)));
|
||||
|
||||
case ACCOUNT_NAME :
|
||||
return xaccAccountGetName(account);
|
||||
break;
|
||||
return g_strdup (xaccAccountGetName(account));
|
||||
|
||||
case ACCOUNT_CODE :
|
||||
return xaccAccountGetCode(account);
|
||||
break;
|
||||
return g_strdup (xaccAccountGetCode(account));
|
||||
|
||||
case ACCOUNT_DESCRIPTION :
|
||||
return xaccAccountGetDescription(account);
|
||||
break;
|
||||
return g_strdup (xaccAccountGetDescription(account));
|
||||
|
||||
case ACCOUNT_NOTES :
|
||||
return xaccAccountGetNotes(account);
|
||||
break;
|
||||
return g_strdup (xaccAccountGetNotes(account));
|
||||
|
||||
case ACCOUNT_CURRENCY :
|
||||
return gnc_commodity_get_printname(xaccAccountGetCurrency(account));
|
||||
break;
|
||||
return
|
||||
g_strdup
|
||||
(gnc_commodity_get_printname(xaccAccountGetCurrency(account)));
|
||||
|
||||
case ACCOUNT_SECURITY :
|
||||
return gnc_commodity_get_printname(xaccAccountGetSecurity(account));
|
||||
break;
|
||||
return
|
||||
g_strdup
|
||||
(gnc_commodity_get_printname(xaccAccountGetSecurity(account)));
|
||||
|
||||
case ACCOUNT_BALANCE :
|
||||
{
|
||||
gnc_numeric balance = gnc_ui_account_get_balance(account, FALSE);
|
||||
|
||||
return xaccPrintAmount(balance,
|
||||
gnc_account_value_print_info (account, TRUE));
|
||||
return g_strdup
|
||||
(xaccPrintAmount (balance,
|
||||
gnc_account_value_print_info (account, TRUE)));
|
||||
}
|
||||
break;
|
||||
|
||||
case ACCOUNT_BALANCE_EURO :
|
||||
{
|
||||
gnc_commodity * account_currency =
|
||||
@ -304,19 +311,20 @@ gnc_ui_get_account_field_value_string (Account *account,
|
||||
gnc_numeric euro_balance = gnc_convert_to_euro(account_currency,
|
||||
balance);
|
||||
|
||||
return xaccPrintAmount(euro_balance,
|
||||
gnc_commodity_print_info (gnc_get_euro (),
|
||||
TRUE));
|
||||
return g_strdup
|
||||
(xaccPrintAmount(euro_balance,
|
||||
gnc_commodity_print_info (gnc_get_euro (), TRUE)));
|
||||
}
|
||||
break;
|
||||
|
||||
case ACCOUNT_TOTAL :
|
||||
{
|
||||
gnc_numeric balance = gnc_ui_account_get_balance(account, TRUE);
|
||||
|
||||
return xaccPrintAmount(balance,
|
||||
gnc_account_value_print_info (account, TRUE));
|
||||
return g_strdup
|
||||
(xaccPrintAmount(balance,
|
||||
gnc_account_value_print_info (account, TRUE)));
|
||||
}
|
||||
break;
|
||||
|
||||
case ACCOUNT_TOTAL_EURO :
|
||||
{
|
||||
gnc_commodity * account_currency =
|
||||
@ -325,11 +333,14 @@ gnc_ui_get_account_field_value_string (Account *account,
|
||||
gnc_numeric euro_balance = gnc_convert_to_euro(account_currency,
|
||||
balance);
|
||||
|
||||
return xaccPrintAmount(euro_balance,
|
||||
gnc_commodity_print_info (gnc_get_euro (),
|
||||
TRUE));
|
||||
return g_strdup
|
||||
(xaccPrintAmount(euro_balance,
|
||||
gnc_commodity_print_info (gnc_get_euro (), TRUE)));
|
||||
}
|
||||
break;
|
||||
|
||||
case ACCOUNT_TAX_INFO:
|
||||
return gnc_ui_account_get_tax_info_string (account);
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -59,13 +59,18 @@ typedef enum
|
||||
ACCOUNT_BALANCE_EURO,
|
||||
ACCOUNT_TOTAL, /* balance + children's balance with sign reversal */
|
||||
ACCOUNT_TOTAL_EURO,
|
||||
ACCOUNT_TAX_INFO,
|
||||
NUM_ACCOUNT_FIELDS
|
||||
} AccountFieldCode;
|
||||
|
||||
const char * gnc_ui_get_account_field_name (AccountFieldCode field);
|
||||
const char * gnc_ui_account_get_field_name (AccountFieldCode field);
|
||||
|
||||
const char * gnc_ui_get_account_field_value_string (Account *account,
|
||||
AccountFieldCode field);
|
||||
/* Must g_free string when done */
|
||||
char * gnc_ui_account_get_field_value_string (Account *account,
|
||||
AccountFieldCode field);
|
||||
|
||||
/* Must g_free string when done */
|
||||
char * gnc_ui_account_get_tax_info_string (Account *account);
|
||||
|
||||
gnc_numeric gnc_ui_account_get_balance (Account *account,
|
||||
gboolean include_children);
|
||||
|
@ -81,7 +81,7 @@ int gnc_choose_radio_option_dialog_parented(gncUIWidget parent,
|
||||
const char *title,
|
||||
const char *msg,
|
||||
int default_value,
|
||||
char **radio_list);
|
||||
GList *radio_list);
|
||||
|
||||
gboolean gnc_dup_trans_dialog (gncUIWidget parent, time_t *date_p,
|
||||
const char *num, char **out_num);
|
||||
|
@ -956,12 +956,13 @@ gnc_account_tree_set_view_info_real(GNCAccountTree *tree)
|
||||
tree->column_fields[i++] = ACCOUNT_TOTAL_EURO;
|
||||
|
||||
tree->column_fields[i++] = ACCOUNT_NOTES;
|
||||
tree->column_fields[i++] = ACCOUNT_TAX_INFO;
|
||||
|
||||
tree->num_columns = i;
|
||||
|
||||
for (i = 0; i < tree->num_columns; i++)
|
||||
tree->column_headings[i] =
|
||||
gnc_ui_get_account_field_name(tree->column_fields[i]);
|
||||
gnc_ui_account_get_field_name (tree->column_fields[i]);
|
||||
}
|
||||
|
||||
static gint
|
||||
@ -1159,7 +1160,7 @@ gnc_account_tree_insert_row(GNCAccountTree *tree,
|
||||
field = tree->column_fields[i];
|
||||
|
||||
if (tree->avi.show_field[field])
|
||||
text[i] = g_strdup(gnc_ui_get_account_field_value_string(acc, field));
|
||||
text[i] = gnc_ui_account_get_field_value_string(acc, field);
|
||||
else
|
||||
text[i] = NULL;
|
||||
|
||||
|
@ -706,12 +706,12 @@ fill_helper(gpointer key, gpointer value, gpointer data)
|
||||
if(!full_name)
|
||||
full_name = g_strdup("");
|
||||
|
||||
account_field_name = g_strdup(gnc_ui_get_account_field_name(fs->field));
|
||||
account_field_name = g_strdup(gnc_ui_account_get_field_name(fs->field));
|
||||
if (!account_field_name)
|
||||
account_field_name = g_strdup("");
|
||||
|
||||
account_field_value =
|
||||
g_strdup(gnc_ui_get_account_field_value_string(account, fs->field));
|
||||
account_field_value =
|
||||
gnc_ui_account_get_field_value_string(account, fs->field);
|
||||
if (!account_field_value)
|
||||
account_field_value = g_strdup("");
|
||||
|
||||
|
@ -142,6 +142,70 @@ gnc_tax_info_set_changed (TaxInfoDialog *ti_dialog, gboolean changed)
|
||||
ti_dialog->changed = changed;
|
||||
}
|
||||
|
||||
char *
|
||||
gnc_ui_account_get_tax_info_string (Account *account)
|
||||
{
|
||||
GNCAccountType atype;
|
||||
const char *code;
|
||||
SCM category;
|
||||
SCM code_scm;
|
||||
char *result;
|
||||
char *form;
|
||||
char *desc;
|
||||
SCM scm;
|
||||
|
||||
if (!account)
|
||||
return NULL;
|
||||
|
||||
if (!xaccAccountGetTaxRelated (account))
|
||||
return NULL;
|
||||
|
||||
atype = xaccAccountGetType (account);
|
||||
if (atype != INCOME && atype != EXPENSE)
|
||||
return NULL;
|
||||
|
||||
code = xaccAccountGetTaxUSCode (account);
|
||||
if (!code)
|
||||
return NULL;
|
||||
|
||||
initialize_getters ();
|
||||
|
||||
category = gh_eval_str (atype == INCOME ?
|
||||
"txf-income-categories" :
|
||||
"txf-expense-categories");
|
||||
|
||||
code_scm = gh_symbol2scm (code);
|
||||
|
||||
scm = gh_call2 (getters.form, category, code_scm);
|
||||
if (!gh_string_p (scm))
|
||||
return NULL;
|
||||
|
||||
form = gh_scm2newstr (scm, NULL);
|
||||
if (!form)
|
||||
return NULL;
|
||||
|
||||
scm = gh_call2 (getters.description, category, code_scm);
|
||||
if (!gh_string_p (scm))
|
||||
{
|
||||
free (form);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
desc = gh_scm2newstr (scm, NULL);
|
||||
if (!desc)
|
||||
{
|
||||
free (form);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
result = g_strdup_printf ("%s %s", form, desc);
|
||||
|
||||
free (form);
|
||||
free (desc);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static GList *
|
||||
load_txf_info (gboolean income)
|
||||
{
|
||||
|
@ -1452,7 +1452,7 @@ void
|
||||
gnc_html_export(gnc_html * html) {
|
||||
const char *filepath;
|
||||
FILE *fh;
|
||||
|
||||
|
||||
filepath = fileBox (_("Save HTML To File"), NULL, NULL);
|
||||
if (!filepath)
|
||||
return;
|
||||
@ -1469,7 +1469,7 @@ gnc_html_export(gnc_html * html) {
|
||||
if (buf) g_free (buf);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
gtk_html_save (GTK_HTML(html->html), raw_html_receiver, fh);
|
||||
fclose (fh);
|
||||
}
|
||||
|
@ -319,7 +319,7 @@ gnc_error_dialog_parented(GtkWindow *parent, const char *message)
|
||||
static void
|
||||
gnc_choose_radio_button_cb(GtkWidget *w, gpointer data)
|
||||
{
|
||||
int *result = (int *) data;
|
||||
int *result = data;
|
||||
|
||||
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w)))
|
||||
*result = GPOINTER_TO_INT(gtk_object_get_user_data(GTK_OBJECT(w)));
|
||||
@ -331,15 +331,13 @@ gnc_choose_radio_button_cb(GtkWidget *w, gpointer data)
|
||||
display a group of radio_buttons and return the index of
|
||||
the selected one
|
||||
|
||||
radio_list should be a NULL terminated array
|
||||
|
||||
*/
|
||||
int
|
||||
gnc_choose_radio_option_dialog_parented(gncUIWidget parent,
|
||||
const char *title,
|
||||
const char *msg,
|
||||
int default_value,
|
||||
char **radio_list)
|
||||
GList *radio_list)
|
||||
{
|
||||
int radio_result = 0; /* initial selected value is first one */
|
||||
GtkWidget *vbox;
|
||||
@ -350,6 +348,7 @@ gnc_choose_radio_option_dialog_parented(gncUIWidget parent,
|
||||
GtkWidget *dialog;
|
||||
GtkWidget *dvbox;
|
||||
GSList *group = NULL;
|
||||
GList *node;
|
||||
int i;
|
||||
|
||||
main_vbox = gtk_vbox_new(FALSE, 3);
|
||||
@ -371,9 +370,9 @@ gnc_choose_radio_option_dialog_parented(gncUIWidget parent,
|
||||
gtk_container_add(GTK_CONTAINER(frame), vbox);
|
||||
gtk_widget_show(vbox);
|
||||
|
||||
for(i = 0; radio_list[i] != NULL; i++)
|
||||
for (node = radio_list, i = 0; node; node = node->next, i++)
|
||||
{
|
||||
radio_button = gtk_radio_button_new_with_label(group, radio_list[i]);
|
||||
radio_button = gtk_radio_button_new_with_label(group, node->data);
|
||||
group = gtk_radio_button_group(GTK_RADIO_BUTTON(radio_button));
|
||||
|
||||
if (i == default_value) /* default is first radio button */
|
||||
|
@ -669,6 +669,9 @@ gnc_acct_tree_window_configure (GNCAcctTreeWin * info) {
|
||||
else if (safe_strcmp(node->data, "security") == 0)
|
||||
new_avi.show_field[ACCOUNT_SECURITY] = TRUE;
|
||||
|
||||
else if (safe_strcmp(node->data, "tax-info") == 0)
|
||||
new_avi.show_field[ACCOUNT_TAX_INFO] = TRUE;
|
||||
|
||||
else if (safe_strcmp(node->data, "balance") == 0)
|
||||
{
|
||||
new_avi.show_field[ACCOUNT_BALANCE] = TRUE;
|
||||
|
@ -294,8 +294,37 @@ gnc_report_window_stop_button_cb(GtkWidget * w, gpointer data) {
|
||||
static int
|
||||
gnc_report_window_export_button_cb(GtkWidget * w, gpointer data) {
|
||||
gnc_report_window * report = data;
|
||||
ENTER (" ");
|
||||
gnc_html_export(report->html);
|
||||
SCM get_export_thunk;
|
||||
SCM export_thunk;
|
||||
gboolean do_html;
|
||||
|
||||
get_export_thunk = gh_eval_str ("gnc:report-export-thunk");
|
||||
export_thunk = gh_call1 (get_export_thunk, report->scm_report);
|
||||
|
||||
if (gh_procedure_p (export_thunk))
|
||||
{
|
||||
SCM result;
|
||||
|
||||
result = gh_call1 (export_thunk, report->scm_report);
|
||||
|
||||
if (gh_symbol_p (result))
|
||||
{
|
||||
char *symbol = gh_symbol2newstr (result, NULL);
|
||||
|
||||
do_html = (safe_strcmp (symbol, "html") == 0);
|
||||
|
||||
if (symbol)
|
||||
free (symbol);
|
||||
}
|
||||
else
|
||||
do_html = FALSE;
|
||||
}
|
||||
else
|
||||
do_html = TRUE;
|
||||
|
||||
if (do_html)
|
||||
gnc_html_export (report->html);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -584,7 +584,8 @@ transaction.") #t))
|
||||
(list->vector (list 'currency (N_ "Currency") ""))
|
||||
(list->vector (list 'security (N_ "Security") ""))
|
||||
(list->vector (list 'balance (N_ "Balance") ""))
|
||||
(list->vector (list 'total (N_ "Total") "")))))
|
||||
(list->vector (list 'total (N_ "Total") ""))
|
||||
(list->vector (list 'tax-info (N_ "Tax Info") "")))))
|
||||
|
||||
options))
|
||||
|
||||
|
@ -66,11 +66,11 @@
|
||||
(define menu-hash (make-hash-table 23))
|
||||
|
||||
(define (add-report-menu-item name report)
|
||||
(if (gnc:report-in-menu? report)
|
||||
(if (gnc:report-template-in-menu? report)
|
||||
(let ((title (string-append (_ "Report") ": " (_ name)))
|
||||
(menu-path (gnc:report-menu-path report))
|
||||
(menu-name (gnc:report-menu-name report))
|
||||
(menu-tip (gnc:report-menu-tip report))
|
||||
(menu-path (gnc:report-template-menu-path report))
|
||||
(menu-name (gnc:report-template-menu-name report))
|
||||
(menu-tip (gnc:report-template-menu-tip report))
|
||||
(item #f))
|
||||
|
||||
(if (not menu-path)
|
||||
@ -96,7 +96,7 @@
|
||||
(gnc:report-template-name report))))
|
||||
(gnc:main-window-open-report rept #f)))))
|
||||
(gnc:add-extension item))))
|
||||
|
||||
|
||||
(gnc:add-extension menu)
|
||||
|
||||
;; add the menu option to edit style sheets
|
||||
@ -131,9 +131,9 @@
|
||||
;; The data items in a report record
|
||||
'(version name options-generator options-editor
|
||||
renderer in-menu? menu-path menu-name
|
||||
menu-tip)))
|
||||
menu-tip export-thunk)))
|
||||
|
||||
(define (gnc:define-report . args)
|
||||
(define (gnc:define-report . args)
|
||||
;; For now the version is ignored, but in the future it'll let us
|
||||
;; change behaviors without breaking older reports.
|
||||
;;
|
||||
@ -142,9 +142,18 @@
|
||||
;; return as its final value an <html-document> object.
|
||||
|
||||
(define (blank-report)
|
||||
;; Number of #f's == Number of data members
|
||||
((record-constructor <report-template>)
|
||||
#f #f #f gnc:default-options-editor #f #t #f #f #f))
|
||||
#f ;version
|
||||
#f ;name
|
||||
#f ;options-generator
|
||||
gnc:default-options-editor ;options-editor
|
||||
#f ;renderer
|
||||
#t ;in-menu?
|
||||
#f ;menu-path
|
||||
#f ;menu-name
|
||||
#f ;menu-tip
|
||||
#f ;export-thunk
|
||||
))
|
||||
|
||||
(define (args-to-defn in-report-rec args)
|
||||
(let ((report-rec (if in-report-rec
|
||||
@ -175,14 +184,16 @@
|
||||
(record-accessor <report-template> 'options-editor))
|
||||
(define gnc:report-template-renderer
|
||||
(record-accessor <report-template> 'renderer))
|
||||
(define gnc:report-in-menu?
|
||||
(define gnc:report-template-in-menu?
|
||||
(record-accessor <report-template> 'in-menu?))
|
||||
(define gnc:report-menu-path
|
||||
(define gnc:report-template-menu-path
|
||||
(record-accessor <report-template> 'menu-path))
|
||||
(define gnc:report-menu-name
|
||||
(define gnc:report-template-menu-name
|
||||
(record-accessor <report-template> 'menu-name))
|
||||
(define gnc:report-menu-tip
|
||||
(define gnc:report-template-menu-tip
|
||||
(record-accessor <report-template> 'menu-tip))
|
||||
(define gnc:report-template-export-thunk
|
||||
(record-accessor <report-template> 'export-thunk))
|
||||
|
||||
(define (gnc:report-template-new-options/name template-name)
|
||||
(let ((templ (hash-ref *gnc:_report-templates_* template-name)))
|
||||
@ -210,7 +221,7 @@
|
||||
(string-append (gnc:html-style-sheet-name ss)
|
||||
(_ " Stylesheet"))))
|
||||
(gnc:get-html-style-sheets)))))
|
||||
|
||||
|
||||
(if (procedure? generator)
|
||||
(let ((options (generator)))
|
||||
(gnc:register-option options stylesheet)
|
||||
@ -221,8 +232,8 @@
|
||||
(gnc:register-option options names)
|
||||
options))))
|
||||
|
||||
(define <report>
|
||||
(make-record-type "<report>"
|
||||
(define <report>
|
||||
(make-record-type "<report>"
|
||||
'(type id options parents children
|
||||
dirty? display-list editor-widget ctext)))
|
||||
|
||||
@ -339,10 +350,19 @@
|
||||
(lambda (rep)
|
||||
(gnc:report-unregister-display (gnc:find-report rep) window))
|
||||
(gnc:report-parents report)))))
|
||||
|
||||
|
||||
(define (gnc:make-report template-name . rest)
|
||||
(let ((r ((record-constructor <report>)
|
||||
template-name #f #f '() '() #t '() #f #f))
|
||||
template-name ;type
|
||||
#f ;id
|
||||
#f ;options
|
||||
'() ;parents
|
||||
'() ;children
|
||||
#t ;dirty
|
||||
'() ;display-list
|
||||
#f ;editor-widget
|
||||
#f ;ctext
|
||||
))
|
||||
(template (hash-ref *gnc:_report-templates_* template-name))
|
||||
(id *gnc:_report-next-serial_*))
|
||||
(gnc:report-set-id! r id)
|
||||
@ -378,6 +398,14 @@
|
||||
(gnc:report-template-options-editor template)
|
||||
#f)))
|
||||
|
||||
(define (gnc:report-export-thunk report)
|
||||
(let ((template
|
||||
(hash-ref *gnc:_report-templates_*
|
||||
(gnc:report-type report))))
|
||||
(if template
|
||||
(gnc:report-template-export-thunk template)
|
||||
#f)))
|
||||
|
||||
(define (gnc:report-name report)
|
||||
(gnc:option-value
|
||||
(gnc:lookup-option (gnc:report-options report)
|
||||
|
@ -356,10 +356,24 @@
|
||||
(list a))))
|
||||
accounts)))
|
||||
|
||||
;; returns 'html if html is chosen, 'txf if txf is chosen,
|
||||
;; and #f otherwise
|
||||
(define (choose-export-format)
|
||||
(let ((choice (gnc:choose_radio_option_dialog_parented
|
||||
#f
|
||||
(_ "Choose export format")
|
||||
(_ "Choose the export format for this report:")
|
||||
0
|
||||
(list (_ "HTML") (_ "TXF")))))
|
||||
(case choice
|
||||
((0) 'html)
|
||||
((1) 'txf)
|
||||
(else #f))))
|
||||
|
||||
(define (generate-tax-or-txf report-name
|
||||
report-description
|
||||
report-obj
|
||||
tax-mode-in)
|
||||
tax-mode?)
|
||||
|
||||
(define (get-option pagename optname)
|
||||
(gnc:option-value
|
||||
@ -388,7 +402,6 @@
|
||||
(suppress-0 (get-option tab-title "Suppress $0.00 values"))
|
||||
(full-names (get-option tab-title
|
||||
"Print Full account names"))
|
||||
(tax-mode tax-mode-in) ; these need to different later
|
||||
(user-sel-accnts (get-option tab-title
|
||||
"Select Accounts (none = all)"))
|
||||
(valid-user-sel-accnts (validate user-sel-accnts))
|
||||
@ -532,7 +545,7 @@
|
||||
(gnc:timepair-lt to-value tmp-date))
|
||||
to-value
|
||||
tmp-date)))
|
||||
(if tax-mode
|
||||
(if tax-mode?
|
||||
(render-level-x-account table lev max-level account
|
||||
value suppress-0 #f date #f)
|
||||
(render-txf-account account value date))))
|
||||
@ -564,9 +577,9 @@
|
||||
(- account-balance)
|
||||
account-balance)))
|
||||
(lx-collector level 'add account-balance)
|
||||
|
||||
|
||||
(let ((level-x-output
|
||||
(if tax-mode
|
||||
(if tax-mode?
|
||||
(render-level-x-account table level
|
||||
max-level account
|
||||
account-balance
|
||||
@ -584,11 +597,11 @@
|
||||
(handle-level-x-account (+ 1 level) x)))
|
||||
children))
|
||||
level-x-output)))))
|
||||
|
||||
|
||||
(let ((from-date (strftime "%Y-%b-%d" (localtime (car from-value))))
|
||||
(to-date (strftime "%Y-%b-%d" (localtime (car to-value))))
|
||||
(today-date (strftime "D%m/%d/%Y"
|
||||
(localtime
|
||||
(localtime
|
||||
(car (gnc:timepair-canonical-day-time
|
||||
(cons (current-time) 0))))))
|
||||
(txf-last-payer "")
|
||||
@ -611,28 +624,29 @@
|
||||
(lx-collector i 'reset #f))
|
||||
(set! txf-dups-alist '())
|
||||
|
||||
(if (not tax-mode-in) ; First do Txf mode, if set
|
||||
(if (not tax-mode?) ; First do Txf mode, if set
|
||||
(begin
|
||||
(set! file-name ; get file name from user
|
||||
(do ((fname (gnc:file-selection-dialog
|
||||
"Select file for .TXF export" ""
|
||||
"~/export.txf")
|
||||
(gnc:file-selection-dialog
|
||||
"Select file for .TXF export" ""
|
||||
"~/export.txf")))
|
||||
((if (not fname)
|
||||
#t ; no "Cancel" button, exit
|
||||
(if (access? fname F_OK)
|
||||
(if (gnc:verify-dialog
|
||||
(string-append
|
||||
"File: \"" fname
|
||||
"\" exists, Overwrite?")
|
||||
#f)
|
||||
(begin (delete-file fname)
|
||||
#t)
|
||||
#f)
|
||||
#t))
|
||||
fname)))
|
||||
(set!
|
||||
file-name ; get file name from user
|
||||
(do ((fname (gnc:file-selection-dialog
|
||||
(_ "Select file for .TXF export") ""
|
||||
"~/export.txf")
|
||||
(gnc:file-selection-dialog
|
||||
(_"Select file for .TXF export") ""
|
||||
"~/export.txf")))
|
||||
((if (not fname)
|
||||
#t ; no "Cancel" button, exit
|
||||
(if (access? fname F_OK)
|
||||
(if (gnc:verify-dialog
|
||||
(sprintf
|
||||
#f (_ "File: \"%s\" exists.\nOverwrite?")
|
||||
fname)
|
||||
#f)
|
||||
(begin (delete-file fname)
|
||||
#t)
|
||||
#f)
|
||||
#t))
|
||||
fname)))
|
||||
|
||||
(if file-name ; cancel TXF if no file selected
|
||||
(let* ((port (open-output-file file-name))
|
||||
@ -647,82 +661,73 @@
|
||||
"\n^"
|
||||
output)))
|
||||
|
||||
(display file-name) (newline)
|
||||
(display output-txf) (newline)
|
||||
(gnc:display-report-list-item output-txf port
|
||||
"taxtxf.scm - ")
|
||||
(newline port)
|
||||
(close-output-port port)))))
|
||||
(close-output-port port)
|
||||
#f)
|
||||
#t))
|
||||
|
||||
(set! tax-mode #t) ; now do tax mode to display report
|
||||
(begin
|
||||
(gnc:html-document-set-style!
|
||||
doc "blue"
|
||||
'tag "font"
|
||||
'attribute (list "color" "#0000ff"))
|
||||
|
||||
(gnc:html-document-set-style!
|
||||
doc "blue"
|
||||
'tag "font"
|
||||
'attribute (list "color" "#0000ff"))
|
||||
(gnc:html-document-set-style!
|
||||
doc "income"
|
||||
'tag "font"
|
||||
'attribute (list "color" "#0000ff"))
|
||||
|
||||
(gnc:html-document-set-style!
|
||||
doc "income"
|
||||
'tag "font"
|
||||
'attribute (list "color" "#0000ff"))
|
||||
(gnc:html-document-set-style!
|
||||
doc "expense"
|
||||
'tag "font"
|
||||
'attribute (list "color" "#ff0000"))
|
||||
|
||||
(gnc:html-document-set-style!
|
||||
doc "expense"
|
||||
'tag "font"
|
||||
'attribute (list "color" "#ff0000"))
|
||||
(gnc:html-document-set-title! doc report-name)
|
||||
|
||||
(gnc:html-document-set-title! doc report-name)
|
||||
(gnc:html-document-add-object!
|
||||
doc
|
||||
(gnc:make-html-text
|
||||
(gnc:html-markup-p
|
||||
(gnc:html-markup/format
|
||||
(_ "Period from %s to %s") from-date to-date))))
|
||||
|
||||
(gnc:html-document-add-object!
|
||||
doc
|
||||
(gnc:make-html-text
|
||||
(gnc:html-markup-p
|
||||
(gnc:html-markup/format
|
||||
(_ "Period from %s to %s") from-date to-date))))
|
||||
(gnc:html-document-add-object!
|
||||
doc
|
||||
(gnc:make-html-text
|
||||
(gnc:html-markup
|
||||
"blue"
|
||||
(gnc:html-markup-p
|
||||
(_ "Blue items are exportable to a TXF file.")))))
|
||||
|
||||
(gnc:html-document-add-object!
|
||||
doc
|
||||
(gnc:make-html-text
|
||||
(gnc:html-markup
|
||||
"blue"
|
||||
(if tax-mode-in
|
||||
(gnc:html-markup-p
|
||||
(_ "Blue items are exportable to a TXF file."))
|
||||
(gnc:html-markup-p
|
||||
(if file-name
|
||||
(gnc:html-markup/format
|
||||
(_ "Blue items were exported to file %s.")
|
||||
(gnc:html-markup-tt file-name))
|
||||
(_ "Blue items were <em>not</em> exported to \
|
||||
txf file!")))))))
|
||||
(txf-print-dups doc)
|
||||
|
||||
(txf-print-dups doc)
|
||||
(gnc:html-document-add-object! doc table)
|
||||
|
||||
(gnc:html-document-add-object! doc table)
|
||||
(gnc:html-table-append-row!
|
||||
table
|
||||
(append
|
||||
(list
|
||||
(gnc:make-html-table-header-cell
|
||||
(_ "Account Name")))
|
||||
(make-sub-headers max-level)
|
||||
(list
|
||||
(gnc:make-html-table-header-cell/markup
|
||||
"number-header" (_ "Total")))))
|
||||
|
||||
(gnc:html-table-append-row!
|
||||
table
|
||||
(append
|
||||
(list
|
||||
(gnc:make-html-table-header-cell
|
||||
(_ "Account Name")))
|
||||
(make-sub-headers max-level)
|
||||
(list
|
||||
(gnc:make-html-table-header-cell/markup
|
||||
"number-header" (_ "Total")))))
|
||||
(map (lambda (x) (handle-level-x-account 1 x))
|
||||
selected-accounts)
|
||||
|
||||
(map (lambda (x) (handle-level-x-account 1 x))
|
||||
selected-accounts)
|
||||
|
||||
(if (null? selected-accounts)
|
||||
(gnc:html-document-add-object!
|
||||
doc
|
||||
(gnc:make-html-text
|
||||
(gnc:html-markup-p
|
||||
(_ "No Tax Related accounts were found. \
|
||||
(if (null? selected-accounts)
|
||||
(gnc:html-document-add-object!
|
||||
doc
|
||||
(gnc:make-html-text
|
||||
(gnc:html-markup-p
|
||||
(_ "No Tax Related accounts were found. \
|
||||
Go the the Tax Information dialog to set up tax-related accounts.")))))
|
||||
|
||||
doc)))
|
||||
doc)))))
|
||||
|
||||
(gnc:define-report
|
||||
'version 1
|
||||
@ -735,17 +740,16 @@ Go the the Tax Information dialog to set up tax-related accounts.")))))
|
||||
(_ "This report shows your Taxable Income and \
|
||||
Deductable Expenses.")
|
||||
report-obj
|
||||
#t)))
|
||||
|
||||
(gnc:define-report
|
||||
'version 1
|
||||
'name (N_ "Export .TXF")
|
||||
'menu-path (list gnc:menuname-taxes)
|
||||
'options-generator tax-options-generator
|
||||
'renderer (lambda (report-obj)
|
||||
(generate-tax-or-txf
|
||||
(_ "Taxable Income / Deductible Expenses")
|
||||
(_ "This page shows your Taxable Income and \
|
||||
#t))
|
||||
'export-thunk (lambda (report-obj)
|
||||
(let ((choice (choose-export-format)))
|
||||
(case choice
|
||||
((txf)
|
||||
(generate-tax-or-txf
|
||||
(_ "Taxable Income / Deductible Expenses")
|
||||
(_ "This page shows your Taxable Income and \
|
||||
Deductable Expenses.")
|
||||
report-obj
|
||||
#f))))
|
||||
report-obj
|
||||
#f)
|
||||
#f)
|
||||
(else choice))))))
|
||||
|
Loading…
Reference in New Issue
Block a user