AUDIT: r20783 - gnucash/trunk/src - Bug #651889 - Using trading accounts, new non-expanded trading transaction shows inverted rates in exchange dialog
Geert Janssens
gjanssens at code.gnucash.org
Tue Jun 21 05:51:04 EDT 2011
Author: gjanssens
Date: 2011-06-21 05:51:04 -0400 (Tue, 21 Jun 2011)
New Revision: 20783
Trac: http://svn.gnucash.org/trac/changeset/20783
Modified:
gnucash/trunk/src/gnome-utils/dialog-transfer.c
gnucash/trunk/src/gnome-utils/dialog-transfer.h
gnucash/trunk/src/register/ledger-core/split-register-control.c
Log:
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
BP
Modified: gnucash/trunk/src/gnome-utils/dialog-transfer.c
===================================================================
--- gnucash/trunk/src/gnome-utils/dialog-transfer.c 2011-06-21 09:50:54 UTC (rev 20782)
+++ gnucash/trunk/src/gnome-utils/dialog-transfer.c 2011-06-21 09:51:04 UTC (rev 20783)
@@ -2222,7 +2222,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);
@@ -2243,7 +2244,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
@@ -2296,6 +2297,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/trunk/src/gnome-utils/dialog-transfer.h
===================================================================
--- gnucash/trunk/src/gnome-utils/dialog-transfer.h 2011-06-21 09:50:54 UTC (rev 20782)
+++ gnucash/trunk/src/gnome-utils/dialog-transfer.h 2011-06-21 09:51:04 UTC (rev 20783)
@@ -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/trunk/src/register/ledger-core/split-register-control.c
===================================================================
--- gnucash/trunk/src/register/ledger-core/split-register-control.c 2011-06-21 09:50:54 UTC (rev 20782)
+++ gnucash/trunk/src/register/ledger-core/split-register-control.c 2011-06-21 09:51:04 UTC (rev 20783)
@@ -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