r20788 - gnucash/branches/2.4/src - [20783] Bug #651889 - Using trading accounts, new non-expanded trading transaction shows inverted rates in exchange dialog
Christian Stimming
cstim at code.gnucash.org
Tue Jun 21 06:04:42 EDT 2011
Author: cstim
Date: 2011-06-21 06:04:42 -0400 (Tue, 21 Jun 2011)
New Revision: 20788
Trac: http://svn.gnucash.org/trac/changeset/20788
Modified:
gnucash/branches/2.4/src/gnome-utils/dialog-transfer.c
gnucash/branches/2.4/src/gnome-utils/dialog-transfer.h
gnucash/branches/2.4/src/register/ledger-core/split-register-control.c
Log:
[20783] Bug #651889 - Using trading accounts, new non-expanded trading transaction shows inverted rates in exchange dialog
When using trading accounts, the exchange rate dialog has a slightly
different behavior. This patch fixes the behavior for transactions
that are created in-line and are not expanded (single-line).
It does not affect the expanded transactions or transactions created
in the new transaction dialog.
Patch by Mathieu De Zutter
Original commit by gjanssens.
Modified: gnucash/branches/2.4/src/gnome-utils/dialog-transfer.c
===================================================================
--- gnucash/branches/2.4/src/gnome-utils/dialog-transfer.c 2011-06-21 10:04:31 UTC (rev 20787)
+++ gnucash/branches/2.4/src/gnome-utils/dialog-transfer.c 2011-06-21 10:04:42 UTC (rev 20788)
@@ -2220,7 +2220,8 @@
gboolean gnc_xfer_dialog_run_exchange_dialog(
XferDialog *xfer, gnc_numeric *exch_rate, gnc_numeric amount,
- Account *reg_acc, Transaction *txn, gnc_commodity *xfer_com)
+ Account *reg_acc, Transaction *txn, gnc_commodity *xfer_com,
+ gboolean expanded)
{
gboolean swap_amounts = FALSE;
gnc_commodity *txn_cur = xaccTransGetCurrency(txn);
@@ -2241,7 +2242,7 @@
*exch_rate = gnc_numeric_create(1, 1);
return FALSE;
}
- swap_amounts = TRUE;
+ swap_amounts = expanded;
/* We know that "amount" is always in the reg_com currency.
* Unfortunately it is possible that neither xfer_com or txn_cur are
@@ -2294,6 +2295,9 @@
{
gnc_xfer_dialog_select_to_currency(xfer, xfer_com);
gnc_xfer_dialog_select_from_currency(xfer, txn_cur);
+
+ if (xaccTransUseTradingAccounts ( txn ))
+ amount = gnc_numeric_neg(amount);
}
gnc_xfer_dialog_hide_to_account_tree(xfer);
gnc_xfer_dialog_hide_from_account_tree(xfer);
Modified: gnucash/branches/2.4/src/gnome-utils/dialog-transfer.h
===================================================================
--- gnucash/branches/2.4/src/gnome-utils/dialog-transfer.h 2011-06-21 10:04:31 UTC (rev 20787)
+++ gnucash/branches/2.4/src/gnome-utils/dialog-transfer.h 2011-06-21 10:04:42 UTC (rev 20788)
@@ -213,6 +213,7 @@
*/
gboolean gnc_xfer_dialog_run_exchange_dialog(
XferDialog *xfer, gnc_numeric *exch_rate, gnc_numeric amount,
- Account *reg_acc, Transaction *txn, gnc_commodity *xfer_com);
+ Account *reg_acc, Transaction *txn, gnc_commodity *xfer_com,
+ gboolean expanded);
#endif
Modified: gnucash/branches/2.4/src/register/ledger-core/split-register-control.c
===================================================================
--- gnucash/branches/2.4/src/register/ledger-core/split-register-control.c 2011-06-21 10:04:31 UTC (rev 20787)
+++ gnucash/branches/2.4/src/register/ledger-core/split-register-control.c 2011-06-21 10:04:42 UTC (rev 20788)
@@ -1462,7 +1462,7 @@
xfer = gnc_split_register_xfer_dialog(reg, txn, split);
gnc_xfer_dialog_is_exchange_dialog(xfer, &exch_rate);
if (gnc_xfer_dialog_run_exchange_dialog(
- xfer, &exch_rate, amount, reg_acc, txn, xfer_com))
+ xfer, &exch_rate, amount, reg_acc, txn, xfer_com, expanded))
{
/* FIXME: How should the dialog be destroyed? */
LEAVE("leaving rate unchanged");
More information about the gnucash-changes
mailing list