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.
This commit is contained in:
John Ralls 2016-03-17 15:41:51 -07:00
parent d0e103be08
commit 3109b6f6c3

View File

@ -885,11 +885,15 @@ gnc_split_register_auto_completion (SplitRegister *reg,
if (gnc_split_register_get_default_account (reg) != NULL) 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; Split *s;
int i = 0; int i = 0;
if (gnc_commodity_is_currency(acct_cmdty) &&
default_account = gnc_split_register_get_default_account (reg); !gnc_commodity_equal(trans_cmdty, acct_cmdty))
xaccTransSetCurrency(trans, acct_cmdty);
while ((s = xaccTransGetSplit(trans, i)) != NULL) while ((s = xaccTransGetSplit(trans, i)) != NULL)
{ {