Yes, this bug has been reported many times. For example the following bug id's: 335101, 340438, 410604. The bug has been present in all GnuCash versions since at least the 1.8 series, probably longer.
Mike Alexander has submitted a one-line patch that partially fixes this bug. See http://bugzilla.gnome.org/show_bug.cgi?id=335101, comment #5. Unfortunately, the bug and patch have been ignored so far. It is quite a critical bug for anybody doing multi-currency accounting. Here is the information I have collected about this bug. The bug actually consists of two separate problems. The first is that it is possible, in several different ways, to enter into the engine an exchange rate of 0.0 for a transaction (the engine should really forbid this). The second problem is that, once an exchange rate of 0.0 has been committed, the "edit exchange rate" dialog no longer works and therefore the problem is (almost) impossible to fix. More details: (1) when entering a multiple currency transaction, in certain situations, GnuCash fails to prompt for an exchange rate. This happens in the situations you describe and some others. Here are five situations where the exchange rate dialog should pop up but does not: (a) when entering a different-currency split in a split transaction view. (b) when splitting a transaction after selecting the correspondent foreign currency account, but before entering the amount. (c) if the user enters an exchange rate of 0.0 in the exchange rate dialog, then the dialog will pop up a second time; however, if the user enters 0.0 again, it will not pop up a third time and an exchange rate of 0.0 will be used. (d) when changing the account for a previously entered split, from a same-currency account to a different-currency account (whether or not the transaction view is split or basic), (e) when changing the account for a previously entered split, from one different-currency account to another different-currency account (whether or not the transaction view is split or basic), In cases (a)-(c), an exchange rate of 0.0 will be committed to the engine. In case (d), and exchange rate of 1.0 will be committed, and in case (e), whichever exchange rate one had previously entered will be kept, even if the currency of the new account is different from the currency for which the rate was originally entered. The debugger shows that for cases (a)-(b), the culprit is a clause in line 1127 of src/register/ledger-core/split-register-control.c, which was entered by "warlord" in revision 8979. The clause carries the following commentary by warlord: /* If the exch_rate is zero, we're not forcing the dialog, and this is _not_ the blank split, then return FALSE -- this is a "special" gain/loss stock transaction. */ Here is part of the SVN log message of that revision: Support "gain/loss" balancing splits on stocks: * src/register/ledger-core/split-register-control.c: if the exchange rate cell is 0 but this is NOT the blank split, then don't run the exchange-rate dialog unless specifically requested. There is apparently something wrong with this reasoning, because the clause reproducibly catches in the above situations (a) and (b), which have nothing to do with stock transactions. But since I don't know what the intention of that clause was, it is hard to suggest a fix. Mike Alexander's patch fixes (a) but not (b). The debugger also shows that for cases (d)-(e), the culprit is line 1026 of the same file, which prevents an exchange dialog if the transaction already has an exchange rate, regardless whether that rate was for an entirely different currency. This clause was also originally created by warlord, in revision 7599. (2) The second bug is that, once an exchange rate of 0.0 (i.e., a split with "quantity" 0 but "value" non-zero) has been entered into the engine, it is almost impossible to edit the exchange rate to correct the transaction. Going to Actions -> Edit Exchange Rate usually fails silently, probably due to a "division by zero" error that prevents the dialog from popping up. The only remedy is to find some account view from which the split shows a non-zero value (usually the account whose currency is the same as the base currency of the transaction, although it can be difficult to find out which one this was). From there, Actions -> Edit Exchange Rate works (presumably because it calculates the exchange rate as A/B rather than B/A, thereby avoiding the division by 0). The logic in split-register-control.c is so complicated that I do not dare trying to fix this bug myself, but I hope that the above information, which is consistently reproducible, helps someone else to do it. I don't think these bugs are very complicated. Probably the best remedy would be to simply disallow exchange rates of 0.0 in the engine (negative exchange rates are already prohibited anyway). This would solve problem (2), and would force the UI to deal with (1). The other part of the fix is to rewrite the function gnc_split_register_handle_exchange() in src/register/ledger-core/split-register-control.c so that it will always prompt for an exchange rate, unless provably (1) the currency of the split is the same as the transaction currency, (2) the amount is zero, or (3) an exchange rate has already been provided for this split and the currency has not changed. The remainder of the logic in that function is too complicated and probably wrong. Also, the pop-up dialog should disallow exchange rates of <= 0.0, i.e., not allow the user to press "OK" until a valid rate has been entered. -- Peter [EMAIL PROTECTED] wrote: > > Hello. I am having a problem when entering a split transaction, when I > enter one of the splits which is to a different currency account it will > not let me edit the exchange rate and sets the number "unexchanged" on > the other account. > > The process is: open account A, go to the bottom, find the last row, > enter a date, enter a transaction , enter one of the other accounts (B > same currency as A), enter the amount 100, click on Split in toolbar, > the amount entered is set on the A split, th B split has no amount, so I > enter 80 on B, I then go the next split select account C (different > currency) and enter amount 20. Now I wish to set the exchange rate for > this amount on split C so I right click on the 20 or elsewhere in that > row and select Edit Exchange rate but nothing happens. I have found no > way to get the exchange rate dialog. If I save and then jump to > account C the transaction has a value of 20 which is not correct when > viewed in C ledger. > > I was using 2.0.2, I just downloaded and compiled 2.0.5 and it is the > same thing. > > This also happens in non-split transactions, when I enter the amount > before entering the account. Say I go to account A, add new transaction, > enter date, enter description, skip acount, enter amount, go back to > account and select C (different currency), then I try to get the Edit > Exchange Rate but it is not possible. > > I expected the Edit Exchange Rate dialog to be accessible always > regardless of the exact order in which one enters items. > > Does anyone know what is the problem here? > > Thanks > > Alonso > _______________________________________________ > gnucash-devel mailing list > [EMAIL PROTECTED] > https://lists.gnucash.org/mailman/listinfo/gnucash-devel > _______________________________________________ gnucash-devel mailing list [EMAIL PROTECTED] https://lists.gnucash.org/mailman/listinfo/gnucash-devel
