2001-04-30 Dave Peticolas <dave@krondo.com>

* src/scm/report/portfolio.scm: fix bug

	* src/scm/price-quotes.scm: handle 'nav' and 'price' types

	* src/gnome/dialog-price-editor.c: update for nav price type

	* src/quotes/finance-quote-helper.in: try 'nav' and 'price' if
	'last' fails.


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@4094 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Dave Peticolas 2001-05-01 06:52:35 +00:00
parent 9be6dfbca6
commit af73f13c53
8 changed files with 78 additions and 36 deletions

View File

@ -1,3 +1,14 @@
2001-04-30 Dave Peticolas <dave@krondo.com>
* src/scm/report/portfolio.scm: fix bug
* src/scm/price-quotes.scm: handle 'nav' and 'price' types
* src/gnome/dialog-price-editor.c: update for nav price type
* src/quotes/finance-quote-helper.in: try 'nav' and 'price' if
'last' fails.
2001-05-01 Robert Graham Merkel <rgmerk@mira.net>
* src/engine/Query.{ch}: added date-granularity sorting functionality

View File

@ -75,7 +75,7 @@
"Finance::Quote" and "old-file-import".
type: the type of quote - types possible right now are bid, ask,
last, and unknown.
last, nav, and unknown.
Implementation Details:

View File

@ -258,7 +258,10 @@ type_string_to_index (const char *type)
if (safe_strcmp (type, "last") == 0)
return 2;
return 3;
if (safe_strcmp (type, "nav") == 0)
return 3;
return 4;
}
static const char *
@ -269,6 +272,7 @@ type_index_to_string (int index)
case 0: return "bid";
case 1: return "ask";
case 2: return "last";
case 3: return "nav";
default: return "unknown";
}
}

View File

@ -7653,6 +7653,9 @@ create_Price_Dialog (void)
glade_menuitem = gtk_menu_item_new_with_label (_("Last"));
gtk_widget_show (glade_menuitem);
gtk_menu_append (GTK_MENU (type_option_menu), glade_menuitem);
glade_menuitem = gtk_menu_item_new_with_label (_("Net Asset Value"));
gtk_widget_show (glade_menuitem);
gtk_menu_append (GTK_MENU (type_option_menu), glade_menuitem);
glade_menuitem = gtk_menu_item_new_with_label (_("Unknown"));
gtk_widget_show (glade_menuitem);
gtk_menu_append (GTK_MENU (type_option_menu), glade_menuitem);

View File

@ -11374,6 +11374,7 @@ quit without making any changes.</text>
<items>Bid
Ask
Last
Net Asset Value
Unknown
</items>
<initial_choice>0</initial_choice>

View File

@ -50,12 +50,13 @@ use FileHandle;
# this script knows about (and knows how to convert to scheme) are
# returned, so the conversion function will have to be updated
# whenever Finance::Quote changes. Currently you'll get symbol,
# gnc:time-no-zone, last, and currency. Fields with gnc: prefixes are
# non-Finance::Quote fields. gnc:time-no-zone is returned as a string
# of the form "YYYY-MM-DD HH:MM:SS", basically the unmolested (and
# underspecified) output of the quote source. It's up to you to know
# what it's proper timezone really is. i.e. if you know the time was
# in America/Chicago, you'll need to convert it to that.
# gnc:time-no-zone, and currency, and either last, nav, or price.
# Fields with gnc: prefixes are non-Finance::Quote fields.
# gnc:time-no-zone is returned as a string of the form "YYYY-MM-DD
# HH:MM:SS", basically the unmolested (and underspecified) output of
# the quote source. It's up to you to know what it's proper timezone
# really is. i.e. if you know the time was in America/Chicago, you'll
# need to convert it to that.
# For example:
@ -224,6 +225,13 @@ sub schemify_quote {
$quotedata .= " ($field . $data)";
$field = 'last';
if (!($$quotehash{$itemname, $field})) {
$field = 'nav';
}
if (!($$quotehash{$itemname, $field})) {
$field = 'price';
}
$data = schemify_num($$quotehash{$itemname, $field});
$quotedata .= " ($field . $data)";

View File

@ -388,8 +388,7 @@
(cons (car fq-call-data)
(map
(lambda (quote-item-info)
(string-upcase
(gnc:commodity-get-mnemonic (car quote-item-info))))
(gnc:commodity-get-mnemonic (car quote-item-info)))
(cdr fq-call-data))))
(define (fq-results->commod-tz-quote-triples fq-call-data fq-results)
@ -473,7 +472,8 @@
(time-zone (second c-tz-quote-triple))
(quote-data (third c-tz-quote-triple))
(gnc-time (assq-ref quote-data 'gnc:time-no-zone))
(last-price (assq-ref quote-data 'last))
(price #f)
(price-type #f)
(currency-str (assq-ref quote-data 'currency))
(commodity-table (gnc:book-get-commodity-table book))
(currency
@ -483,10 +483,26 @@
"ISO4217"
(string-upcase currency-str)))))
(or-map (lambda (price-sym)
(let ((p (assq-ref quote-data price-sym)))
(if p
(begin (set! price p)
(set! price-type price-sym)
#t)
#f)))
'(last nav price))
(set! price-type
(case price-type
((last) "last")
((nav) "nav")
((price) "unknown")
(else #f)))
;; FIXME: SIGFIGS is not what we want here...
(if last-price
(set! last-price
(gnc:double-to-gnc-numeric last-price
(if price
(set! price
(gnc:double-to-gnc-numeric price
GNC-DENOM-AUTO
(logior (GNC-DENOM-SIGFIGS 9)
GNC-RND-ROUND))))
@ -494,22 +510,21 @@
(if gnc-time
(set! gnc-time (timestr->time-pair gnc-time time-zone)))
(if (not (and commodity currency gnc-time last-price))
(if (not (and commodity currency gnc-time price price-type))
(string-append
currency-str ":" (gnc:commodity-get-mnemonic commodity))
(let ((price (gnc:price-create)))
(if (not price)
(let ((gnc-price (gnc:price-create)))
(if (not gnc-price)
(string-append
currency-str ":" (gnc:commodity-get-mnemonic commodity))
(begin
(gnc:price-set-commodity price commodity)
(gnc:price-set-currency price currency)
(gnc:price-set-time price gnc-time)
(gnc:price-set-source price "Finance::Quote")
(gnc:price-set-type price "last")
(gnc:price-set-value price last-price)
;;(gnc:price-print-stdout price 2)
price))))))
(gnc:price-set-commodity gnc-price commodity)
(gnc:price-set-currency gnc-price currency)
(gnc:price-set-time gnc-price gnc-time)
(gnc:price-set-source gnc-price "Finance::Quote")
(gnc:price-set-type gnc-price price-type)
(gnc:price-set-value gnc-price price)
gnc-price))))))
(define (book-add-prices! book prices)
(let ((pricedb (gnc:book-get-pricedb book)))

View File

@ -54,10 +54,10 @@
(define (op-value section name)
(gnc:option-value (get-op section name)))
(define (table-add-stock-rows table accounts to-date currency pricedb collector)
(define (table-add-stock-rows-internal table accounts to-date odd-row?
(define (table-add-stock-rows table accounts to-date
currency pricedb collector)
(define (table-add-stock-rows-internal accounts odd-row?)
(if (null? accounts) collector
(let* ((row-style (if odd-row? "normal-row" "alternate-row"))
(current (car accounts))
@ -69,7 +69,7 @@
(unit-collector (gnc:account-get-comm-balance-at-date
current to-date #f))
(units (cadr (unit-collector 'getpair commodity #f)))
(price (gnc:pricedb-lookup-nearest-in-time pricedb
commodity
currency
@ -78,13 +78,13 @@
(price-value (if price
(gnc:price-get-value price)
(gnc:numeric-zero)))
(value-num (gnc:numeric-mul
units
price-value
(gnc:commodity-get-fraction currency)
GNC-RND-ROUND))
(value (gnc:make-gnc-monetary currency value-num)))
(collector 'add currency value-num)
(gnc:html-table-append-row/markup!
@ -96,14 +96,14 @@
(gnc:make-html-table-header-cell/markup
"number-cell" (gnc:numeric-to-double units))
(gnc:make-html-table-header-cell/markup
"number-cell" (gnc:make-gnc-monetary currency price-value))
"number-cell" (gnc:make-gnc-monetary currency
price-value))
(gnc:make-html-table-header-cell/markup
"number-cell" value)))
(gnc:price-unref price)
(table-add-stock-rows-internal
table rest to-date currency (not odd-row?) pricedb collector))))
(table-add-stock-rows-internal table accounts to-date
currency #t pricedb collector))
(table-add-stock-rows-internal rest (not odd-row?)))))
(table-add-stock-rows-internal accounts #t))
;; The first thing we do is make local variables for all the specific
;; options in the set of options given to the function. This set will