gnucash maint: Bug - 761172 Importing invoices posts incorrect values.
Mike Evans
mikee at code.gnucash.org
Wed Mar 2 04:30:45 EST 2016
Updated via https://github.com/Gnucash/gnucash/commit/e4e19a4c (commit)
from https://github.com/Gnucash/gnucash/commit/cb88fe8f (commit)
commit e4e19a4caa2b9a5673ab227022cb193026a5c301
Author: Mike Evans <mikee at saxicola.co.uk>
Date: Wed Mar 2 09:23:10 2016 +0000
Bug - 761172 Importing invoices posts incorrect values.
This looks a rounding error caused by not setting the denominator to an
appropirate value. I've set it to 100x the currency fraction.
For some reason I removed the call to gnc_numeric_convert() in commit
564b9874575 I shouldn't have done that. I should have adjusted the denom.
diff --git a/src/plugins/bi_import/dialog-bi-import.c b/src/plugins/bi_import/dialog-bi-import.c
index f9eb832..c872f30 100644
--- a/src/plugins/bi_import/dialog-bi-import.c
+++ b/src/plugins/bi_import/dialog-bi-import.c
@@ -716,8 +716,11 @@ gnc_bi_import_create_bis (GtkListStore * store, QofBook * book,
notes = un_escape(notes);
gncEntrySetDescription (entry, desc);
gncEntrySetAction (entry, action);
- value = gnc_numeric_zero();
+ value = gnc_numeric_zero();
gnc_exp_parser_parse (quantity, &value, NULL);
+ // Need to set the denom appropriately else we get stupid rounding errors.
+ value = gnc_numeric_convert (value, denom * 100, GNC_HOW_RND_NEVER);
+ //DEBUG("qty = %s",gnc_num_dbg_to_string(value));
gncEntrySetQuantity (entry, value);
acc = gnc_account_lookup_for_register (gnc_get_current_root_account (),
account);
@@ -727,6 +730,7 @@ gnc_bi_import_create_bis (GtkListStore * store, QofBook * book,
gncEntrySetBillAccount (entry, acc);
value = gnc_numeric_zero();
gnc_exp_parser_parse (price, &value, NULL);
+ value = gnc_numeric_convert (value, denom * 100, GNC_HOW_RND_NEVER);
gncEntrySetBillPrice (entry, value);
gncEntrySetBillTaxable (entry, text2bool (taxable));
gncEntrySetBillTaxIncluded (entry, text2bool (taxincluded));
@@ -740,12 +744,15 @@ gnc_bi_import_create_bis (GtkListStore * store, QofBook * book,
gncEntrySetInvAccount (entry, acc);
value = gnc_numeric_zero();
gnc_exp_parser_parse (price, &value, NULL);
+ value = gnc_numeric_convert (value, denom * 100, GNC_HOW_RND_NEVER);
+ //DEBUG("price = %s",gnc_num_dbg_to_string(value));
gncEntrySetInvPrice (entry, value);
gncEntrySetInvTaxable (entry, text2bool (taxable));
gncEntrySetInvTaxIncluded (entry, text2bool (taxincluded));
gncEntrySetInvTaxTable (entry, gncTaxTableLookupByName (book, tax_table));
value = gnc_numeric_zero();
gnc_exp_parser_parse (discount, &value, NULL);
+ value = gnc_numeric_convert (value, denom * 100, GNC_HOW_RND_NEVER);
gncEntrySetInvDiscount (entry, value);
gncEntrySetInvDiscountType (entry, text2disc_type (disc_type));
gncEntrySetInvDiscountHow (entry, text2disc_how (disc_how));
Summary of changes:
src/plugins/bi_import/dialog-bi-import.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
More information about the gnucash-changes
mailing list