mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
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:
@@ -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
|
||||
|
||||
@@ -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 */
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user