Bug 744858 - Update exchange rate on bill only possible once per session (after unpost/repost)

New behaviour is that each time a bill is (re)posted
all the needed exchange rates will be asked.
If an exchange rate was already known, it is suggested
to the user, so s/he can simply confirm it if still ok.
This commit is contained in:
Geert Janssens 2015-06-15 22:28:36 +02:00
parent f0079e8b4d
commit aa8af8a196

View File

@ -831,15 +831,10 @@ gnc_invoice_post(InvoiceWindow *iw, struct post_invoice_params *post_params)
gnc_commodity *account_currency = (gnc_commodity*)key;
gnc_numeric *amount = (gnc_numeric*)value;
Timespec pricedate;
convprice = gncInvoiceGetPrice (invoice, account_currency);
if (convprice)
pricedate = gnc_price_get_time (convprice);
if (!convprice || !timespec_equal (&postdate, &pricedate))
{
XferDialog *xfer;
gnc_numeric exch_rate;
/* Explain to the user we're about to ask for an exchange rate.
* Only show this dialog once, right before the first xfer dialog pops up.
*/
@ -872,6 +867,20 @@ gnc_invoice_post(InvoiceWindow *iw, struct post_invoice_params *post_params)
* rate for 0. */
gnc_xfer_dialog_set_amount(xfer, gnc_numeric_zero_p (*amount) ?
(gnc_numeric){1, 1} : *amount);
/* If we already had an exchange rate from a previous post operation,
* set it here */
convprice = gncInvoiceGetPrice (invoice, account_currency);
if (convprice)
{
exch_rate = gnc_price_get_value (convprice);
/* Invert the exchange rate as explained above */
if (!gnc_numeric_zero_p (exch_rate))
{
exch_rate = gnc_numeric_div ((gnc_numeric){1, 1}, exch_rate,
GNC_DENOM_AUTO, GNC_HOW_RND_ROUND_HALF_UP);
gnc_xfer_dialog_set_exchange_rate (xfer, exch_rate);
}
}
/* All we want is the exchange rate so prevent the user from thinking
it makes sense to mess with other stuff */
@ -908,7 +917,6 @@ gnc_invoice_post(InvoiceWindow *iw, struct post_invoice_params *post_params)
goto cleanup;
}
}
}
/* Save account as last used account in the kvp frame of the invoice owner */