Bug 787813 - Price change from editing a transaction not reflected...

in pricedb.

Allow PRICE_SOURCE_SPLIT_REG to overwrite PRICE_SOURCE_XFER_DLG_VAL.
This commit is contained in:
John Ralls 2021-06-10 11:27:58 -07:00
parent 9546c0587f
commit 80d6749989
2 changed files with 4 additions and 3 deletions

View File

@ -2223,7 +2223,6 @@ gnc_split_register_auto_calc (SplitRegister* reg, Split* split)
Account* account; Account* account;
int denom; int denom;
int choice; int choice;
PriceSource source = PRICE_SOURCE_USER_PRICE;
if (STOCK_REGISTER != reg->type && if (STOCK_REGISTER != reg->type &&
CURRENCY_REGISTER != reg->type && CURRENCY_REGISTER != reg->type &&
@ -2372,7 +2371,6 @@ gnc_split_register_auto_calc (SplitRegister* reg, Split* split)
{ {
recalculate_price (split, reg, value, amount); recalculate_price (split, reg, value, amount);
price_changed = TRUE; price_changed = TRUE;
source = PRICE_SOURCE_SPLIT_REG;
} }
if (recalc_value) if (recalc_value)
recalculate_value (split, reg, price, amount, shares_changed); recalculate_value (split, reg, price, amount, shares_changed);

View File

@ -3009,6 +3009,7 @@ record_price (Split *split,
if (price) if (price)
{ {
PriceSource oldsource = gnc_price_get_source (price);
price_value = gnc_price_get_value (price); price_value = gnc_price_get_value (price);
if (gnc_numeric_equal (swap ? gnc_numeric_invert (value) : value, if (gnc_numeric_equal (swap ? gnc_numeric_invert (value) : value,
price_value)) price_value))
@ -3016,7 +3017,9 @@ record_price (Split *split,
gnc_price_unref (price); gnc_price_unref (price);
return; return;
} }
if (gnc_price_get_source (price) < source) if (oldsource < source &&
!(oldsource == PRICE_SOURCE_XFER_DLG_VAL &&
source == PRICE_SOURCE_SPLIT_REG))
{ {
/* Existing price is preferred over this one. */ /* Existing price is preferred over this one. */
gnc_price_unref (price); gnc_price_unref (price);