From 3109b6f6c3bbfa939bce0e97177f8d654d06c0ce Mon Sep 17 00:00:00 2001 From: John Ralls Date: Thu, 17 Mar 2016 15:41:51 -0700 Subject: [PATCH] Set the transaction currency during auto-completion. When auto-completing a transaction that was originally created in another account with a different currency the balancing code will try to apply conversions in the wrong direction if one edits the transaction. Explicitly setting the transaction currency to the current register's currency prevents the conversions being applied and allows the transaction to balance correctly. --- src/register/ledger-core/split-register-control.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/register/ledger-core/split-register-control.c b/src/register/ledger-core/split-register-control.c index 39565a455f..493a67a041 100644 --- a/src/register/ledger-core/split-register-control.c +++ b/src/register/ledger-core/split-register-control.c @@ -885,11 +885,15 @@ gnc_split_register_auto_completion (SplitRegister *reg, if (gnc_split_register_get_default_account (reg) != NULL) { - Account *default_account; + Account *default_account = + gnc_split_register_get_default_account (reg); + gnc_commodity *trans_cmdty = xaccTransGetCurrency(trans); + gnc_commodity *acct_cmdty = xaccAccountGetCommodity(default_account); Split *s; int i = 0; - - default_account = gnc_split_register_get_default_account (reg); + if (gnc_commodity_is_currency(acct_cmdty) && + !gnc_commodity_equal(trans_cmdty, acct_cmdty)) + xaccTransSetCurrency(trans, acct_cmdty); while ((s = xaccTransGetSplit(trans, i)) != NULL) {