From 8d66754429e1fda7020ebdd3cc0e756a4f5dfb74 Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Thu, 8 Jul 2021 14:56:48 +0100 Subject: [PATCH] Bug 798219 - Price dialog prices truncated Correct previous commit that truncates decimal places of prices entered in the price dialog to that of the currency, they should not be rounded. --- gnucash/gnome/dialog-price-editor.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gnucash/gnome/dialog-price-editor.c b/gnucash/gnome/dialog-price-editor.c index 94812eb65e..74880aa813 100644 --- a/gnucash/gnome/dialog-price-editor.c +++ b/gnucash/gnome/dialog-price-editor.c @@ -138,6 +138,7 @@ type_index_to_string (int index) static void price_to_gui (PriceEditDialog *pedit_dialog) { + GNCPrintAmountInfo print_info; gnc_commodity *commodity = NULL; gnc_commodity *currency = NULL; const gchar *name_space, *fullname; @@ -189,6 +190,10 @@ price_to_gui (PriceEditDialog *pedit_dialog) gtk_combo_box_set_active (GTK_COMBO_BOX(pedit_dialog->type_combobox), type_string_to_index (type)); + print_info = gnc_commodity_print_info (currency, FALSE); + gnc_amount_edit_set_print_info (GNC_AMOUNT_EDIT (pedit_dialog->price_edit), print_info); + gnc_amount_edit_set_fraction (GNC_AMOUNT_EDIT (pedit_dialog->price_edit), 0); + gnc_amount_edit_set_amount (GNC_AMOUNT_EDIT (pedit_dialog->price_edit), value); } @@ -277,8 +282,7 @@ gui_to_price (PriceEditDialog *pedit_dialog) print_info = gnc_commodity_print_info (currency, FALSE); gnc_amount_edit_set_print_info (GNC_AMOUNT_EDIT (pedit_dialog->price_edit), print_info); - gnc_amount_edit_set_fraction (GNC_AMOUNT_EDIT (pedit_dialog->price_edit), - gnc_commodity_get_fraction (currency)); + gnc_amount_edit_set_fraction (GNC_AMOUNT_EDIT (pedit_dialog->price_edit), 0); if (!gnc_amount_edit_evaluate (GNC_AMOUNT_EDIT (pedit_dialog->price_edit), NULL)) return _("You must enter a valid amount.");