* src/gnome/dialog-tax-info.c: more work

* src/engine/Transaction.c (DxaccSplitSetSharePriceAndAmount):
	do the double->numeric conversion directly.

	* src/guile/gnc.gwp: remove unused deprecated functions

	* src/engine/Transaction.c (xaccSplitsComputeValue): convert
	imbalance to base_currency fraction if possible

	* src/SplitLedger.c (LedgerDestroy): commit pending instead
	of rolling back.


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@3847 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Dave Peticolas 2001-03-28 11:06:12 +00:00
parent 42252a5e77
commit 2c984b5993
6 changed files with 155 additions and 79 deletions

View File

@ -1,3 +1,18 @@
2001-03-28 Dave Peticolas <dave@krondo.com>
* src/gnome/dialog-tax-info.c: more work
* src/engine/Transaction.c (DxaccSplitSetSharePriceAndAmount):
do the double->numeric conversion directly.
* src/guile/gnc.gwp: remove unused deprecated functions
* src/engine/Transaction.c (xaccSplitsComputeValue): convert
imbalance to base_currency fraction if possible
* src/SplitLedger.c (LedgerDestroy): commit pending instead
of rolling back.
2001-03-27 Christian Stimming <stimming@tuhh.de>
* src/scm/report/average-balance.scm: Major rework: Uses

View File

@ -1643,7 +1643,7 @@ LedgerDestroy (SplitRegister *reg)
/* Make sure we don't commit this below */
if (trans == pending_trans)
{
info->pending_trans_guid = *xaccGUIDNULL();
info->pending_trans_guid = *xaccGUIDNULL ();
pending_trans = NULL;
}
@ -1651,21 +1651,21 @@ LedgerDestroy (SplitRegister *reg)
xaccTransDestroy (trans);
xaccTransCommitEdit (trans);
info->blank_split_guid = *xaccGUIDNULL();
info->blank_split_guid = *xaccGUIDNULL ();
blank_split = NULL;
}
/* be sure to take care of any open transactions */
if (pending_trans != NULL)
{
if (xaccTransIsOpen(pending_trans))
xaccTransRollbackEdit (pending_trans);
if (xaccTransIsOpen (pending_trans))
xaccTransCommitEdit (pending_trans);
info->pending_trans_guid = *xaccGUIDNULL();
info->pending_trans_guid = *xaccGUIDNULL ();
pending_trans = NULL;
}
xaccSRDestroyRegisterData(reg);
xaccSRDestroyRegisterData (reg);
gnc_resume_gui_refresh ();
}

View File

@ -442,11 +442,15 @@ get_security_denom(Split * s)
void
DxaccSplitSetSharePriceAndAmount (Split *s, double price, double amt)
{
xaccSplitSetSharePriceAndAmount
(s,
double_to_gnc_numeric(price, GNC_DENOM_AUTO,
GNC_DENOM_SIGFIGS(PRICE_SIGFIGS) | GNC_RND_ROUND),
double_to_gnc_numeric(amt, get_security_denom(s), GNC_RND_ROUND));
if (!s) return;
check_open (s->parent);
s->damount = double_to_gnc_numeric(amt, get_security_denom(s),
GNC_RND_ROUND);
s->value = double_to_gnc_numeric(price * amt, get_currency_denom(s),
GNC_RND_ROUND);
mark_split (s);
}
void
@ -456,7 +460,7 @@ xaccSplitSetSharePriceAndAmount (Split *s, gnc_numeric price,
if (!s) return;
check_open (s->parent);
s->damount = gnc_numeric_convert(amt, get_security_denom(s), GNC_RND_ROUND);;
s->damount = gnc_numeric_convert(amt, get_security_denom(s), GNC_RND_ROUND);
s->value = gnc_numeric_mul(s->damount, price,
get_currency_denom(s), GNC_RND_ROUND);
@ -1091,7 +1095,12 @@ xaccSplitsComputeValue (GList *splits, Split * skip_me,
}
}
return gnc_numeric_convert (value, GNC_DENOM_AUTO, GNC_DENOM_REDUCE);
if (base_currency)
return gnc_numeric_convert (value,
gnc_commodity_get_fraction (base_currency),
GNC_RND_ROUND);
else
return gnc_numeric_convert (value, GNC_DENOM_AUTO, GNC_DENOM_REDUCE);
}
gnc_numeric

View File

@ -69,6 +69,7 @@ typedef struct
GtkWidget * txf_category_clist;
GtkWidget * txf_help_text;
GtkWidget * current_account_button;
GtkWidget * parent_account_button;
GList * income_txf_infos;
GList * expense_txf_infos;
@ -173,20 +174,26 @@ load_txf_info (gboolean income)
code_scm = gh_car (codes);
codes = gh_cdr (codes);
txf_info = g_new0 (TXFInfo, 1);
str = gh_symbol2newstr (code_scm, NULL);
txf_info->code = g_strdup (str);
free (str);
scm = gh_call2 (getters.payer_name_source, category, code_scm);
str = gh_symbol2newstr (scm, NULL);
if (safe_strcmp (str, "not-impl") == 0)
{
free (str);
continue;
}
txf_info = g_new0 (TXFInfo, 1);
if (safe_strcmp (str, "none") == 0)
txf_info->payer_name_source = NULL;
else
txf_info->payer_name_source = g_strdup (str);
free (str);
str = gh_symbol2newstr (code_scm, NULL);
txf_info->code = g_strdup (str);
free (str);
scm = gh_call2 (getters.form, category, code_scm);
str = gh_scm2newstr (scm, NULL);
txf_info->form = g_strdup (str);
@ -240,6 +247,34 @@ load_category_list (TaxInfoDialog *ti_dialog)
gtk_clist_thaw (clist);
}
static void
clear_gui (TaxInfoDialog *ti_dialog)
{
gtk_toggle_button_set_active
(GTK_TOGGLE_BUTTON (ti_dialog->tax_related_button), FALSE);
gtk_clist_select_row (GTK_CLIST (ti_dialog->txf_category_clist), 0, 0);
gtk_toggle_button_set_active
(GTK_TOGGLE_BUTTON (ti_dialog->current_account_button), TRUE);
}
static void
account_to_gui (TaxInfoDialog *ti_dialog, Account *account)
{
gboolean tax_related;
if (!account)
{
clear_gui (ti_dialog);
return;
}
tax_related = xaccAccountGetTaxRelated (account);
gtk_toggle_button_set_active
(GTK_TOGGLE_BUTTON (ti_dialog->tax_related_button), tax_related);
}
static void
window_destroy_cb (GtkObject *object, gpointer data)
{
@ -274,24 +309,6 @@ select_subaccounts_clicked (GtkWidget *widget, gpointer data)
gtk_widget_grab_focus (ti_dialog->account_tree);
}
static void
unselect_subaccounts_clicked (GtkWidget *widget, gpointer data)
{
TaxInfoDialog *ti_dialog = data;
GNCAccountTree *tree;
Account *account;
tree = GNC_ACCOUNT_TREE (ti_dialog->account_tree);
account = gnc_account_tree_get_focus_account (tree);
if (!account)
return;
gnc_account_tree_unselect_subaccounts (tree, account, FALSE);
gtk_widget_grab_focus (ti_dialog->account_tree);
}
static void
tax_info_ok_clicked (GtkWidget *widget, gpointer data)
{
@ -339,7 +356,7 @@ tax_info_show_income_accounts (TaxInfoDialog *ti_dialog, gboolean show_income)
load_category_list (ti_dialog);
}
static void
static int
gnc_tax_info_update_accounts (TaxInfoDialog *ti_dialog)
{
GNCAccountTree *tree;
@ -363,6 +380,8 @@ gnc_tax_info_update_accounts (TaxInfoDialog *ti_dialog)
g_free (string);
gtk_widget_set_sensitive (frame, num_accounts > 0);
return num_accounts;
}
static void
@ -379,6 +398,8 @@ gnc_tax_info_income_cb (GtkWidget *w, gpointer data)
gnc_account_tree_expand_all (GNC_ACCOUNT_TREE (ti_dialog->account_tree));
gnc_tax_info_update_accounts (ti_dialog);
clear_gui (ti_dialog);
}
static void
@ -387,7 +408,10 @@ gnc_tax_info_select_account_cb (GNCAccountTree *tree,
{
TaxInfoDialog *ti_dialog = data;
gnc_tax_info_update_accounts (ti_dialog);
if (gnc_tax_info_update_accounts (ti_dialog) != 1)
return;
account_to_gui (ti_dialog, account);
}
static void
@ -411,6 +435,7 @@ txf_code_select_row_cb (GtkCList *clist,
{
TaxInfoDialog *ti_dialog = user_data;
TXFInfo *txf_info;
GtkWidget *frame;
GtkEditable *ge;
const char *text;
gint pos = 0;
@ -424,6 +449,30 @@ txf_code_select_row_cb (GtkCList *clist,
gtk_editable_delete_text (ge, 0, -1);
gtk_editable_insert_text (ge, text, strlen (text), &pos);
frame = lookup_widget (GTK_WIDGET (clist), "payer_name_source_frame");
if (txf_info->payer_name_source)
{
gboolean current;
gtk_widget_set_sensitive (frame, TRUE);
current = (strcmp ("current", txf_info->payer_name_source) == 0);
if (current)
gtk_toggle_button_set_active
(GTK_TOGGLE_BUTTON (ti_dialog->current_account_button), TRUE);
else
gtk_toggle_button_set_active
(GTK_TOGGLE_BUTTON (ti_dialog->parent_account_button), TRUE);
}
else
{
gtk_widget_set_sensitive (frame, FALSE);
gtk_toggle_button_set_active
(GTK_TOGGLE_BUTTON (ti_dialog->current_account_button), TRUE);
}
gnc_tax_info_set_changed (ti_dialog, TRUE);
}
@ -432,6 +481,13 @@ tax_related_toggled_cb (GtkToggleButton *togglebutton,
gpointer user_data)
{
TaxInfoDialog *ti_dialog = user_data;
GtkWidget *frame;
gboolean on;
on = gtk_toggle_button_get_active (togglebutton);
frame = lookup_widget (GTK_WIDGET (togglebutton), "txf_categories_frame");
gtk_widget_set_sensitive (frame, on);
gnc_tax_info_set_changed (ti_dialog, TRUE);
}
@ -505,6 +561,9 @@ gnc_tax_info_dialog_create (GtkWidget * parent, TaxInfoDialog *ti_dialog)
button = lookup_widget (dialog, "current_account_button");
ti_dialog->current_account_button = button;
button = lookup_widget (dialog, "parent_account_button");
ti_dialog->parent_account_button = button;
gtk_signal_connect (GTK_OBJECT (button), "toggled",
GTK_SIGNAL_FUNC (current_account_toggled_cb),
ti_dialog);
@ -521,7 +580,7 @@ gnc_tax_info_dialog_create (GtkWidget * parent, TaxInfoDialog *ti_dialog)
gtk_clist_column_titles_hide (GTK_CLIST (ti_dialog->account_tree));
gtk_clist_set_selection_mode (GTK_CLIST (ti_dialog->account_tree),
GTK_SELECTION_MULTIPLE);
GTK_SELECTION_EXTENDED);
gnc_account_tree_hide_all_but_name (tree);
tax_info_show_income_accounts (ti_dialog, FALSE);
@ -548,7 +607,7 @@ gnc_tax_info_dialog_create (GtkWidget * parent, TaxInfoDialog *ti_dialog)
ti_dialog);
}
/* account buttons */
/* select subaccounts button */
{
GtkWidget *button;
@ -556,15 +615,11 @@ gnc_tax_info_dialog_create (GtkWidget * parent, TaxInfoDialog *ti_dialog)
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (select_subaccounts_clicked),
ti_dialog);
button = lookup_widget (dialog, "unselect_subaccounts_button");
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (unselect_subaccounts_clicked),
ti_dialog);
}
gnc_tax_info_update_accounts (ti_dialog);
gnc_tax_info_set_changed (ti_dialog, FALSE);
clear_gui (ti_dialog);
}
static void
@ -575,6 +630,16 @@ close_handler (gpointer user_data)
gnome_dialog_close (GNOME_DIALOG (ti_dialog->dialog));
}
static void
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);
}
/********************************************************************\
* gnc_tax_info_dialog *
* opens up a window to set account tax information *
@ -586,13 +651,19 @@ void
gnc_tax_info_dialog (GtkWidget * parent)
{
TaxInfoDialog *ti_dialog;
gint component_id;
ti_dialog = g_new0 (TaxInfoDialog, 1);
gnc_tax_info_dialog_create (parent, ti_dialog);
gnc_register_gui_component (DIALOG_TAX_INFO_CM_CLASS,
NULL, close_handler, ti_dialog);
component_id = gnc_register_gui_component (DIALOG_TAX_INFO_CM_CLASS,
refresh_handler, close_handler,
ti_dialog);
gnc_gui_component_watch_entity_type (component_id,
GNC_ID_ACCOUNT,
GNC_EVENT_MODIFY | GNC_EVENT_DESTROY);
gtk_widget_grab_focus (ti_dialog->account_tree);

View File

@ -5710,12 +5710,11 @@ create_Tax_Information_Dialog (void)
GtkWidget *label847733;
GtkWidget *num_accounts_label;
GtkWidget *select_subaccounts_button;
GtkWidget *unselect_subaccounts_button;
GtkWidget *tax_info_frame;
GtkWidget *vbox92;
GtkWidget *tax_related_button;
GtkWidget *hseparator1;
GtkWidget *frame42;
GtkWidget *txf_categories_frame;
GtkWidget *hbox85;
GtkWidget *scrolledwindow18;
GtkWidget *txf_category_clist;
@ -5826,20 +5825,13 @@ create_Tax_Information_Dialog (void)
gtk_box_pack_start (GTK_BOX (vbox96), select_subaccounts_button, FALSE, FALSE, 0);
gtk_container_set_border_width (GTK_CONTAINER (select_subaccounts_button), 3);
unselect_subaccounts_button = gtk_button_new_with_label (_("Unselect Subaccounts"));
gtk_widget_ref (unselect_subaccounts_button);
gtk_object_set_data_full (GTK_OBJECT (Tax_Information_Dialog), "unselect_subaccounts_button", unselect_subaccounts_button,
(GtkDestroyNotify) gtk_widget_unref);
gtk_widget_show (unselect_subaccounts_button);
gtk_box_pack_start (GTK_BOX (vbox96), unselect_subaccounts_button, FALSE, FALSE, 0);
gtk_container_set_border_width (GTK_CONTAINER (unselect_subaccounts_button), 3);
tax_info_frame = gtk_frame_new (_("Tax Information"));
gtk_widget_ref (tax_info_frame);
gtk_object_set_data_full (GTK_OBJECT (Tax_Information_Dialog), "tax_info_frame", tax_info_frame,
(GtkDestroyNotify) gtk_widget_unref);
gtk_widget_show (tax_info_frame);
gtk_box_pack_start (GTK_BOX (hbox81), tax_info_frame, TRUE, TRUE, 0);
gtk_widget_set_sensitive (tax_info_frame, FALSE);
vbox92 = gtk_vbox_new (FALSE, 3);
gtk_widget_ref (vbox92);
@ -5863,19 +5855,20 @@ create_Tax_Information_Dialog (void)
gtk_widget_show (hseparator1);
gtk_box_pack_start (GTK_BOX (vbox92), hseparator1, FALSE, FALSE, 6);
frame42 = gtk_frame_new (_("TXF Categories"));
gtk_widget_ref (frame42);
gtk_object_set_data_full (GTK_OBJECT (Tax_Information_Dialog), "frame42", frame42,
txf_categories_frame = gtk_frame_new (_("TXF Categories"));
gtk_widget_ref (txf_categories_frame);
gtk_object_set_data_full (GTK_OBJECT (Tax_Information_Dialog), "txf_categories_frame", txf_categories_frame,
(GtkDestroyNotify) gtk_widget_unref);
gtk_widget_show (frame42);
gtk_box_pack_start (GTK_BOX (vbox92), frame42, TRUE, TRUE, 0);
gtk_widget_show (txf_categories_frame);
gtk_box_pack_start (GTK_BOX (vbox92), txf_categories_frame, TRUE, TRUE, 0);
gtk_widget_set_sensitive (txf_categories_frame, FALSE);
hbox85 = gtk_hbox_new (FALSE, 0);
gtk_widget_ref (hbox85);
gtk_object_set_data_full (GTK_OBJECT (Tax_Information_Dialog), "hbox85", hbox85,
(GtkDestroyNotify) gtk_widget_unref);
gtk_widget_show (hbox85);
gtk_container_add (GTK_CONTAINER (frame42), hbox85);
gtk_container_add (GTK_CONTAINER (txf_categories_frame), hbox85);
gtk_container_set_border_width (GTK_CONTAINER (hbox85), 3);
scrolledwindow18 = gtk_scrolled_window_new (NULL, NULL);

View File

@ -8647,26 +8647,13 @@ words.
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkButton</class>
<name>unselect_subaccounts_button</name>
<border_width>3</border_width>
<can_focus>True</can_focus>
<label>Unselect Subaccounts</label>
<relief>GTK_RELIEF_NORMAL</relief>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
</widget>
</widget>
<widget>
<class>GtkFrame</class>
<name>tax_info_frame</name>
<sensitive>False</sensitive>
<label>Tax Information</label>
<label_xalign>0</label_xalign>
<shadow_type>GTK_SHADOW_ETCHED_IN</shadow_type>
@ -8709,7 +8696,8 @@ words.
<widget>
<class>GtkFrame</class>
<name>frame42</name>
<name>txf_categories_frame</name>
<sensitive>False</sensitive>
<label>TXF Categories</label>
<label_xalign>0</label_xalign>
<shadow_type>GTK_SHADOW_ETCHED_IN</shadow_type>