From 74a258393ccfc252c0c9d0b71c47bc259716e2c5 Mon Sep 17 00:00:00 2001 From: Dave Peticolas Date: Tue, 17 Jul 2001 18:48:18 +0000 Subject: [PATCH] 2001-07-17 Dave Peticolas * src/engine/Transaction.c (xaccTransAppendSplit): make sure split's value conforms to the transaction common currency. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@4955 57a11ea4-9604-0410-9ed3-97b8803252fd --- ChangeLog | 5 +++++ src/engine/Transaction.c | 12 ++++++++++++ 2 files changed, 17 insertions(+) diff --git a/ChangeLog b/ChangeLog index 0d113305c0..c4f0995f1c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2001-07-17 Dave Peticolas + + * src/engine/Transaction.c (xaccTransAppendSplit): make sure + split's value conforms to the transaction common currency. + 2001-07-12 Dave Peticolas * src/gnome/window-register.c: same as below diff --git a/src/engine/Transaction.c b/src/engine/Transaction.c index 30ed13c66b..c7aa7145c1 100644 --- a/src/engine/Transaction.c +++ b/src/engine/Transaction.c @@ -1720,6 +1720,18 @@ xaccTransAppendSplit (Transaction *trans, Split *split) /* now, insert the split into the array */ split->parent = trans; trans->splits = g_list_append (trans->splits, split); + + /* convert the split to the new transaction's commodity denominator */ + /* if the denominator can't be exactly converted, it's an error */ + if (trans->common_currency) + { + int fraction = gnc_commodity_get_fraction (trans->common_currency); + gnc_numeric new_value; + + new_value = gnc_numeric_convert(split->value, fraction, GNC_RND_ROUND); + if (gnc_numeric_check (new_value) == GNC_ERROR_OK) + split->value = new_value; + } } /********************************************************************\