mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Remove price-direction code for to default currency and alphabetic order.
It's much more important to have currency exchange rates > 1 to preserve significant digits.
This commit is contained in:
parent
56cb0327e1
commit
afe7dacb85
@ -1567,20 +1567,6 @@ create_transaction(XferDialog *xferData, Timespec *ts,
|
||||
xferData->transaction_cb(trans, xferData->transaction_user_data);
|
||||
}
|
||||
|
||||
static void
|
||||
swap_amount (gnc_commodity **from, gnc_commodity **to, gnc_numeric *value,
|
||||
gnc_numeric *from_amt, gnc_numeric *to_amt)
|
||||
{
|
||||
gnc_commodity *tmp = *from;
|
||||
gnc_numeric *tmp_amt = from_amt;
|
||||
*from = *to;
|
||||
*to = tmp;
|
||||
from_amt = to_amt;
|
||||
to_amt = tmp_amt;
|
||||
*value = gnc_numeric_invert (*value);
|
||||
*value = round_price(*from, *to, *value);
|
||||
}
|
||||
|
||||
static gnc_numeric
|
||||
swap_commodities(gnc_commodity **from, gnc_commodity **to, gnc_numeric value)
|
||||
{
|
||||
@ -1637,37 +1623,19 @@ new_price(XferDialog *xferData, Timespec ts)
|
||||
gnc_commodity *from = xferData->from_commodity;
|
||||
gnc_commodity *to = xferData->to_commodity;
|
||||
gnc_numeric value = gnc_amount_edit_get_amount(GNC_AMOUNT_EDIT(xferData->price_edit));
|
||||
gnc_numeric from_amt, to_amt;
|
||||
|
||||
/* Normally we want to store currency rates such that the rate > 1 and commodity
|
||||
* prices in terms of a currency regardless of value, but we also try to be
|
||||
* consistent about how quotes are installed.
|
||||
/* We want to store currency rates such that the rate > 1 and commodity
|
||||
* prices in terms of a currency regardless of value.
|
||||
*/
|
||||
if (from == gnc_default_currency() ||
|
||||
((to != gnc_default_currency()) &&
|
||||
(strcmp (gnc_commodity_get_mnemonic(from),
|
||||
gnc_commodity_get_mnemonic(to)) < 0)))
|
||||
swap_amount (&from, &to, &value, &from_amt, &to_amt);
|
||||
|
||||
if (gnc_commodity_is_currency(from) && gnc_commodity_is_currency(to))
|
||||
{
|
||||
if (value.num < value.denom)
|
||||
{
|
||||
value = swap_commodities(&from, &to, value);
|
||||
}
|
||||
value = gnc_numeric_convert(value, CURRENCY_DENOM,
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
}
|
||||
else if (gnc_commodity_is_currency(from) || gnc_commodity_is_currency(to))
|
||||
{
|
||||
int scu;
|
||||
if (gnc_commodity_is_currency(from))
|
||||
else if (gnc_commodity_is_currency(from))
|
||||
value = swap_commodities(&from, &to, value);
|
||||
scu = gnc_commodity_get_fraction (to);
|
||||
value = gnc_numeric_convert(value, scu * COMMODITY_DENOM_MULT,
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
}
|
||||
|
||||
value = round_price (from, to, value);
|
||||
price = gnc_price_create (xferData->book);
|
||||
gnc_price_begin_edit (price);
|
||||
gnc_price_set_commodity (price, from);
|
||||
|
Loading…
Reference in New Issue
Block a user