Commit Graph

16896 Commits

Author SHA1 Message Date
John Ralls
f82717496a Merge branch 'big-prices' 2015-10-29 15:37:18 -07:00
John Ralls
e391cce1af Replace unnecessary indirection in calling gnc_pricedb_convert_balance... 2015-10-29 15:35:35 -07:00
John Ralls
8877f862d3 Replace tortured attempt to implement indirect amount-value conversion. 2015-10-29 15:01:26 -07:00
John Ralls
7adc5e4451 Handle reversed prices from gnc_pricedb_lookup*.
In several cases replaces attempting to check both directions directly. This
had produced incorrect results because an older forward price would be preferred
over a reverse price.
2015-10-29 14:13:37 -07:00
John Ralls
edefc9e57c Provide new function gnc_price_invert.
To invert a price when it's currency is what we want to use as a commodity.
Generalizes the source-type PRICE_SOURCE_INVOICE to PRICE_SOURCE_TEMPORARY
for all cases like this where we don't want to save the price.
2015-10-27 17:30:23 -07:00
John Ralls
62c7693860 Rewrite GNCPriceDB queries to check for prices in both directions.
Currency exchange rates can be recorded in either direction depending upon
which one provides the larger fraction. Queries therefore need to check
both directions when creating the date-ordered list for selecting latest,
nearest in time, or latest before.
2015-10-27 17:30:23 -07:00
John Ralls
dde310bf71 Tests for GNCPriceDB. They fail until the next commit. 2015-10-27 17:30:23 -07:00
John Ralls
6525db7639 Doxygenate GncPriceDB and document explicitly which functions are bidirectional.
Meaning which functions check prices in both commodities for the rate
with the other.
2015-10-27 17:30:23 -07:00
John Ralls
4644f28403 Remove the preference for storing prices relative to the base currency.
It interferes with the preference for storing the price in the direction
in which the price is >1 for preserving sigfigs.
2015-10-27 17:30:23 -07:00
John Ralls
8d856843c3 Recognize and handle reversed price quotes from gnc-fq-helper.
Gnc-fq-helper will flip currency price quotes if the one requested is < 1
or not available, which might mean that it's not representable in 4 digits
to the right of the decimal.
2015-10-27 17:30:23 -07:00
John Ralls
ac09496c73 Invert the F::Q price if there's already one in the other direction.
We don't want to create prices in both directions on the same day.
2015-10-27 17:30:22 -07:00
John Ralls
923b01e269 Handle currencies with one-directional quotes and quotes < 1 in F::Q.
Some currencies quotes are one-directional, so check both directions if
necessary. Quotes with values < 1 often have too few significant digits,
so in that case use the other direction if available.
2015-10-27 17:30:22 -07:00
John Ralls
ac34d316a5 Merge branch 'maint' 2015-10-27 17:28:45 -07:00
John Ralls
ce838d3cfc Rename GNOME_COMPILE_WARNINGS to just COMPILE_WARNINGS.
Poaching someone else's macro name is a really dumb idea, because aclocal
looks in our macros directory only if it can't find the macro in the system
directories. Our config code doesn't work with Gnome's macro, it exports
WARN_CFLAGS rather than modifying CFLAGS directly the way ours does.
2015-10-27 17:25:48 -07:00
John Ralls
f3de156e65 Revert "Use gnc_pricedb_has_prices instead of testing the return value of get_prices."
This reverts commit ae35dbb464.
because the return value was actually used later on.
2015-10-27 14:08:59 -07:00
John Ralls
5537a7ed35 Implement gnc_numeric_invert via GncRational::invert. 2015-10-24 15:58:16 -07:00
John Ralls
50e3bf21db Merge branch 'maint' 2015-10-24 14:55:56 -07:00
John Ralls
f5cf2ba542 Merge branch 'single-price' into maint 2015-10-24 14:52:49 -07:00
John Ralls
362b9e3d7c Fix leaking QofBook in most of the engine unit tests.
The problem is that QofBook is not a well-formed GObject and doesn't clean
itself up properly when its ref count goes to zero. qof_book_destroy() must
be explicitly called on it. An interesting side effect is that QofObject
keeps a list of all of the books ever opened and not properly destroyed and
registering a class (in this case GNCPriceDB) tries to create that class's
instance in all of those leaked books. Since they already have one, the
instantiation code raises a critical error and the test program fails.
2015-10-24 14:15:23 -07:00
John Ralls
ae35dbb464 Use gnc_pricedb_has_prices instead of testing the return value of get_prices. 2015-10-24 13:24:13 -07:00
John Ralls
dfc0b28bed Remove be->price_lookup conditional clauses.
No backend implements price_lookup, and the struct member is removed from
master. Even if it had existed these clauses wouldn't actually do anything.
2015-10-24 13:24:13 -07:00
John Ralls
4bfe29aca3 Prevent F::Q from updating PRICE_SOURCE_EDIT_DLG prices. 2015-10-24 13:24:12 -07:00
John Ralls
9a53cc8f58 Remove unnecessary and harmful price rounding. 2015-10-24 13:24:10 -07:00
John Ralls
7298a46999 Implement user-entered-price preference.
Add user:price as a source and prefer values with lower PriceSource enum
values over higher ones: In other words a price with a lower PriceSource
value (e.g. user:price-editor) will overwrite one with a higher value (e.g.
user:split-register) and not the other way around.
2015-10-24 13:22:51 -07:00
John Ralls
811a30db4a Fold separate call of gnc_pricedb_lookup_latest() into lookup_price.
Requires a 3-state enum instead of a boolean for the second arg to lookup_price.
2015-10-24 13:22:46 -07:00
John Ralls
70493537e9 Use an enum for internal representation of Price Sources.
Strings are still used for storage and display.
Purpose is to make multiple comparisons and conditional setting more
convenient.
2015-10-24 13:20:29 -07:00
John Ralls
ab15ca8f84 Extract function lookup_price in dialog_transfer.c 2015-10-24 13:20:28 -07:00
John Ralls
76c1259f1b Adjust split_register to match transfer dialog checking inverted prices. 2015-10-24 13:20:28 -07:00
John Ralls
348fe45b76 Fix missing initialization of price_value. 2015-10-24 13:20:28 -07:00
John Ralls
a40bc92d34 Change CURRENCY_DENOM to 10000, matching what F::Q returns. 2015-10-24 13:20:27 -07:00
John Ralls
6e14137710 Extract function round_price(), consistently apply it. 2015-10-24 13:20:23 -07:00
John Ralls
f30b38b5c3 Create a rounding policy for prices in the pricedb.
Currency-currency prices will be priced in the smaller currency so that
the price > 1 and will be rounded to 3 digits after the decimal.
Commodity-currency prices will be priced in the currency and rounded to
the currency's scu * 10000.
This affects only prices stored in the pricedb. Prices in splits will
continue to be computed from value/amount.
2015-10-24 13:19:05 -07:00
John Ralls
a8d4eaae5e Rename _gnc_xfer_dialog_set_exchange_rate and use it consistently.
gnc_xfer_dialog_set_price_edit says what we're actually setting.
2015-10-24 13:18:39 -07:00
John Ralls
f79a3af4a2 Provide gnc_numeric_invert() convenience function.
Clearer and faster than dividing into 1/1.
2015-10-24 13:15:05 -07:00
John Ralls
be5b9f2b84 Use price_value when referring to a gnc_numeric.
Price and prc are for gnc_price*.
For clarity.
2015-10-24 13:15:05 -07:00
John Ralls
9c2813acb6 Price-quotes: Modify quotes on same day instead of creating new ones.
We can use only one per day so no point in keeping a bunch of them.
Finance::Quote prices always overwrite user prices.
2015-10-24 13:15:04 -07:00
John Ralls
966789374d Edit split-based prices instead of adding.
For split-register and xfer-dialog generated prices if there's an existing
non-FQ price for the day, change it. If there's an F::Q quote for the day,
do nothing. Only add a price if there isn't one for the from/to
combination.
2015-10-24 13:15:04 -07:00
John Ralls
5e609dac0d Check for an existing price before adding one in split_reg.
To make the behavior the same as in xfer_dialog.
2015-10-24 13:15:04 -07:00
John Ralls
c4082524cb In the transfer dialog use the price_edit value for the saved price.
Instead of computing it separately and differently from to_amt and from_amt.
2015-10-24 13:15:04 -07:00
John Ralls
ca447fc047 Fix up whitespace in dialog-transfer.c. 2015-10-24 13:14:49 -07:00
John Ralls
85148cd23b Refactor gnc_xfer_dialog_response_cb with several extract-functions. 2015-10-24 13:12:39 -07:00
John Ralls
e94622c9e3 Don't store prices of source invoice.
They're intended to be temporary, for creating splits. They're also already
stored from the transfer dialog.
2015-10-24 13:12:38 -07:00
John Ralls
ab535fb100 Replace the price source and type strings with defines. 2015-10-24 13:12:38 -07:00
John Ralls
de264c5832 Merge branch 'maint' 2015-10-23 12:14:25 -07:00
John Ralls
e3da1c4247 Revert "Merge branch 'single-price' into maint"
This reverts commit bc9285bbfb, reversing
changes made to e921de8b6f.
Final step of reverting the single-price changes.
2015-10-23 12:11:51 -07:00
John Ralls
b723578c82 Revert "Fix rename failure for gnc_xfer_dialog_set_exchange_rate."
This reverts commit 766cf48f45, and
is step 3 of reverting the single-price changes from maint.
2015-10-23 11:49:11 -07:00
John Ralls
39d43a31fa Revert "Fix price-reading crash if the price needs to be inverted."
This reverts commit 027080a830,
and is step 2 in reverting the single-price changes.
2015-10-23 11:44:57 -07:00
John Ralls
9fc0c4667c Revert "Bug 756339 - Prices table not updated"
This reverts commit 0baf078b6f,
and is step 1 in reverting out the single-price changes and
moving them to master.
2015-10-23 11:43:03 -07:00
Mike Alexander
49cd682665 Merge branch 'maint' 2015-10-21 15:18:34 -04:00
John Ralls
9d43a616e1 Fix typo. 2015-10-16 10:28:41 -07:00