mirror of
https://github.com/Gnucash/gnucash.git
synced 2026-09-03 20:53:02 -05:00
Another but in r22646, still getting the existing price check wrong.
It's a long-standing rule that I don't do numbers well. Third time's a charm, I hope. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@22664 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
@@ -1542,6 +1542,7 @@ gnc_xfer_dialog_response_cb (GtkDialog *dialog, gint response, gpointer data)
|
||||
!(gnc_is_euro_currency (from) && gnc_is_euro_currency (to)))
|
||||
{
|
||||
GNCPrice *price;
|
||||
gnc_numeric price_value;
|
||||
gnc_numeric value;
|
||||
gnc_commodity *tmp;
|
||||
gnc_numeric from_amt, to_amt;
|
||||
@@ -1575,40 +1576,38 @@ gnc_xfer_dialog_response_cb (GtkDialog *dialog, gint response, gpointer data)
|
||||
price = gnc_pricedb_lookup_day (xferData->pricedb, from, to, ts);
|
||||
if (price)
|
||||
{
|
||||
gnc_numeric price_value = gnc_price_get_value(price);
|
||||
if (!gnc_numeric_equal (gnc_numeric_mul (from_amt, price_value,
|
||||
GNC_DENOM_AUTO, GNC_HOW_DENOM_REDUCE),
|
||||
to_amt))
|
||||
{
|
||||
gnc_price_unref (price);
|
||||
price = NULL;
|
||||
}
|
||||
if (price)
|
||||
PINFO("Found price for %s in %s", gnc_commodity_get_mnemonic(from),
|
||||
gnc_commodity_get_mnemonic(to));
|
||||
price_value = gnc_price_get_value(price);
|
||||
}
|
||||
else
|
||||
{
|
||||
price = gnc_pricedb_lookup_day (xferData->pricedb, to, from, ts);
|
||||
if (price)
|
||||
{
|
||||
gnc_numeric price_value = gnc_numeric_div (gnc_numeric_create(1, 1),
|
||||
gnc_price_get_value(price),
|
||||
GNC_DENOM_AUTO, GNC_HOW_DENOM_REDUCE);
|
||||
if (!gnc_numeric_equal (gnc_numeric_mul (from_amt, price_value,
|
||||
GNC_DENOM_AUTO, GNC_HOW_DENOM_REDUCE),
|
||||
to_amt))
|
||||
{
|
||||
gnc_price_unref (price);
|
||||
price = NULL;
|
||||
}
|
||||
if (price)
|
||||
PINFO("Found reverse price for %s in %s", gnc_commodity_get_mnemonic(to),
|
||||
gnc_commodity_get_mnemonic(from));
|
||||
price_value = gnc_numeric_div (gnc_numeric_create(1, 1),
|
||||
gnc_price_get_value(price),
|
||||
GNC_DENOM_AUTO, GNC_HOW_DENOM_REDUCE);
|
||||
}
|
||||
}
|
||||
|
||||
/* See if we found a good enough price */
|
||||
if (price)
|
||||
{
|
||||
int scu = gnc_commodity_get_fraction (to);
|
||||
if (!gnc_numeric_equal (gnc_numeric_mul (from_amt, price_value,
|
||||
scu, GNC_HOW_RND_ROUND_HALF_UP),
|
||||
to_amt))
|
||||
{
|
||||
gnc_price_unref (price);
|
||||
price = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (!price)
|
||||
if (price)
|
||||
{
|
||||
PINFO("Found price for %s in %s", gnc_commodity_get_mnemonic(from),
|
||||
gnc_commodity_get_mnemonic(to));
|
||||
}
|
||||
else
|
||||
{
|
||||
price = gnc_price_create (xferData->book);
|
||||
gnc_price_begin_edit (price);
|
||||
|
||||
Reference in New Issue
Block a user