mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
2001-05-10 Christian Stimming <stimming@tuhh.de>
* src/engine/gnc-pricedb.c (gnc_pricedb_lookup_nearest_in_time): Fixed this function so that it works properly now. * src/scm/commodity-utilities.scm (gnc:get-match-commodity-splits): fix bug. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@4145 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
@@ -1,3 +1,11 @@
|
||||
2001-05-10 Christian Stimming <stimming@tuhh.de>
|
||||
|
||||
* src/engine/gnc-pricedb.c (gnc_pricedb_lookup_nearest_in_time):
|
||||
Fixed this function so that it works properly now.
|
||||
|
||||
* src/scm/commodity-utilities.scm
|
||||
(gnc:get-match-commodity-splits): fix bug.
|
||||
|
||||
2001-05-09 Dave Peticolas <dave@krondo.com>
|
||||
|
||||
* src/doc/design/engine.texinfo: update docs
|
||||
|
||||
@@ -653,8 +653,8 @@ gnc_pricedb_lookup_nearest_in_time(GNCPriceDB *db,
|
||||
Timespec t)
|
||||
{
|
||||
GList *price_list;
|
||||
GNCPrice *before_price = NULL;
|
||||
GNCPrice *after_price = NULL;
|
||||
GNCPrice *current_price = NULL;
|
||||
GNCPrice *next_price = NULL;
|
||||
GNCPrice *result = NULL;
|
||||
GList *item = NULL;
|
||||
GHashTable *currency_hash;
|
||||
@@ -670,34 +670,37 @@ gnc_pricedb_lookup_nearest_in_time(GNCPriceDB *db,
|
||||
item = price_list;
|
||||
|
||||
/* default answer */
|
||||
before_price = item->data;
|
||||
current_price = item->data;
|
||||
|
||||
/* find the first candidate past the one we want. Remember that
|
||||
prices are in most-recent-first order. */
|
||||
while(!after_price && item) {
|
||||
while (!next_price && item) {
|
||||
GNCPrice *p = item->data;
|
||||
Timespec price_time = gnc_price_get_time(p);
|
||||
if(timespec_cmp(&price_time, &t) > 0) {
|
||||
before_price = after_price;
|
||||
after_price = item->data;
|
||||
if (timespec_cmp(&price_time, &t) <= 0) {
|
||||
next_price = item->data;
|
||||
break;
|
||||
}
|
||||
current_price = item->data;
|
||||
item = item->next;
|
||||
}
|
||||
|
||||
if(before_price && !after_price) result = before_price;
|
||||
|
||||
{
|
||||
Timespec before_t = gnc_price_get_time(before_price);
|
||||
Timespec after_t = gnc_price_get_time(after_price);
|
||||
Timespec diff_before = timespec_diff(&before_t, &t);
|
||||
Timespec diff_after = timespec_diff(&after_t, &t);
|
||||
Timespec abs_before = timespec_abs(&diff_before);
|
||||
Timespec abs_after = timespec_abs(&diff_after);
|
||||
|
||||
if(timespec_cmp(&abs_before, &abs_after) < 0) {
|
||||
result = before_price;
|
||||
if (current_price) {
|
||||
if (!next_price) {
|
||||
result = current_price;
|
||||
} else {
|
||||
result = after_price;
|
||||
Timespec current_t = gnc_price_get_time(current_price);
|
||||
Timespec next_t = gnc_price_get_time(next_price);
|
||||
Timespec diff_current = timespec_diff(¤t_t, &t);
|
||||
Timespec diff_next = timespec_diff(&next_t, &t);
|
||||
Timespec abs_current = timespec_abs(&diff_current);
|
||||
Timespec abs_next = timespec_abs(&diff_next);
|
||||
|
||||
if (timespec_cmp(&abs_current, &abs_next) <= 0) {
|
||||
result = current_price;
|
||||
} else {
|
||||
result = next_price;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@
|
||||
(not (gnc:commodity-equiv?
|
||||
trans-comm acc-comm))
|
||||
(or
|
||||
commodity
|
||||
(not commodity)
|
||||
(gnc:commodity-equiv?
|
||||
commodity trans-comm)
|
||||
(gnc:commodity-equiv?
|
||||
|
||||
Reference in New Issue
Block a user