Bug 746792 - process payment in foreign currency leads to broken equation

The payment dialog was inconsistent in interpreting amounts and values.
By clicking on documents the document's amount is added to the Payment field
suggesting it's in the owner's currency. However the post-processing code
took that amount as being the amount in the transfer accounts currency
and calculated the rest backwards.
This will now become: the amount fields are interpreted in the owner's currency
and the exchange rate asked will be from owner's currenty to transfer
account's currency.
This commit is contained in:
Geert Janssens
2015-06-13 17:43:54 +02:00
parent 240e36f73b
commit ec8ed38860
2 changed files with 12 additions and 7 deletions

View File

@@ -691,10 +691,10 @@ gnc_payment_ok_cb (GtkWidget *widget, gpointer data)
text = _("The transfer and post accounts are associated with different currencies. Please specify the conversion rate.");
xfer = gnc_xfer_dialog(pw->dialog, pw->xfer_acct);
xfer = gnc_xfer_dialog(pw->dialog, pw->post_acct);
gnc_info_dialog(pw->dialog, "%s", text);
gnc_xfer_dialog_select_to_account(xfer, pw->post_acct);
gnc_xfer_dialog_select_to_account(xfer, pw->xfer_acct);
gnc_xfer_dialog_set_amount(xfer, pw->amount_tot);
/* All we want is the exchange rate so prevent the user from thinking

View File

@@ -809,12 +809,17 @@ gncOwnerCreatePaymentLot (const GncOwner *owner, Transaction *txn,
}
else
{
/* Need to value the payment in terms of the owner commodity */
gnc_numeric payment_value = gnc_numeric_mul(amount,
exch, GNC_DENOM_AUTO, GNC_HOW_RND_ROUND_HALF_UP);
/* This will be a multi-currency transaction. The amount passed to this
* function is in the owner commodity (also used by the post account).
* For the xfer split we also need to value the payment in the xfer account's
* commodity.
* exch is from post account to xfer account so that can be used directly
* to calculate the equivalent amount in the xfer account's commodity. */
gnc_numeric xfer_amount = gnc_numeric_mul (amount, exch, GNC_DENOM_AUTO,
GNC_HOW_RND_ROUND_HALF_UP);
xaccSplitSetAmount(split, amount);
xaccSplitSetValue(split, payment_value);
xaccSplitSetAmount(split, xfer_amount); /* Payment in xfer account currency */
xaccSplitSetValue(split, amount); /* Payment in transaction currency */
}
}