mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
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:
parent
9be6dfbca6
commit
af73f13c53
11
ChangeLog
11
ChangeLog
@ -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>
|
2001-05-01 Robert Graham Merkel <rgmerk@mira.net>
|
||||||
|
|
||||||
* src/engine/Query.{ch}: added date-granularity sorting functionality
|
* src/engine/Query.{ch}: added date-granularity sorting functionality
|
||||||
|
@ -75,7 +75,7 @@
|
|||||||
"Finance::Quote" and "old-file-import".
|
"Finance::Quote" and "old-file-import".
|
||||||
|
|
||||||
type: the type of quote - types possible right now are bid, ask,
|
type: the type of quote - types possible right now are bid, ask,
|
||||||
last, and unknown.
|
last, nav, and unknown.
|
||||||
|
|
||||||
Implementation Details:
|
Implementation Details:
|
||||||
|
|
||||||
|
@ -258,7 +258,10 @@ type_string_to_index (const char *type)
|
|||||||
if (safe_strcmp (type, "last") == 0)
|
if (safe_strcmp (type, "last") == 0)
|
||||||
return 2;
|
return 2;
|
||||||
|
|
||||||
return 3;
|
if (safe_strcmp (type, "nav") == 0)
|
||||||
|
return 3;
|
||||||
|
|
||||||
|
return 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *
|
static const char *
|
||||||
@ -269,6 +272,7 @@ type_index_to_string (int index)
|
|||||||
case 0: return "bid";
|
case 0: return "bid";
|
||||||
case 1: return "ask";
|
case 1: return "ask";
|
||||||
case 2: return "last";
|
case 2: return "last";
|
||||||
|
case 3: return "nav";
|
||||||
default: return "unknown";
|
default: return "unknown";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7653,6 +7653,9 @@ create_Price_Dialog (void)
|
|||||||
glade_menuitem = gtk_menu_item_new_with_label (_("Last"));
|
glade_menuitem = gtk_menu_item_new_with_label (_("Last"));
|
||||||
gtk_widget_show (glade_menuitem);
|
gtk_widget_show (glade_menuitem);
|
||||||
gtk_menu_append (GTK_MENU (type_option_menu), 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"));
|
glade_menuitem = gtk_menu_item_new_with_label (_("Unknown"));
|
||||||
gtk_widget_show (glade_menuitem);
|
gtk_widget_show (glade_menuitem);
|
||||||
gtk_menu_append (GTK_MENU (type_option_menu), glade_menuitem);
|
gtk_menu_append (GTK_MENU (type_option_menu), glade_menuitem);
|
||||||
|
@ -11374,6 +11374,7 @@ quit without making any changes.</text>
|
|||||||
<items>Bid
|
<items>Bid
|
||||||
Ask
|
Ask
|
||||||
Last
|
Last
|
||||||
|
Net Asset Value
|
||||||
Unknown
|
Unknown
|
||||||
</items>
|
</items>
|
||||||
<initial_choice>0</initial_choice>
|
<initial_choice>0</initial_choice>
|
||||||
|
@ -50,12 +50,13 @@ use FileHandle;
|
|||||||
# this script knows about (and knows how to convert to scheme) are
|
# this script knows about (and knows how to convert to scheme) are
|
||||||
# returned, so the conversion function will have to be updated
|
# returned, so the conversion function will have to be updated
|
||||||
# whenever Finance::Quote changes. Currently you'll get symbol,
|
# whenever Finance::Quote changes. Currently you'll get symbol,
|
||||||
# gnc:time-no-zone, last, and currency. Fields with gnc: prefixes are
|
# gnc:time-no-zone, and currency, and either last, nav, or price.
|
||||||
# non-Finance::Quote fields. gnc:time-no-zone is returned as a string
|
# Fields with gnc: prefixes are non-Finance::Quote fields.
|
||||||
# of the form "YYYY-MM-DD HH:MM:SS", basically the unmolested (and
|
# gnc:time-no-zone is returned as a string of the form "YYYY-MM-DD
|
||||||
# underspecified) output of the quote source. It's up to you to know
|
# HH:MM:SS", basically the unmolested (and underspecified) output of
|
||||||
# what it's proper timezone really is. i.e. if you know the time was
|
# the quote source. It's up to you to know what it's proper timezone
|
||||||
# in America/Chicago, you'll need to convert it to that.
|
# really is. i.e. if you know the time was in America/Chicago, you'll
|
||||||
|
# need to convert it to that.
|
||||||
|
|
||||||
# For example:
|
# For example:
|
||||||
|
|
||||||
@ -224,6 +225,13 @@ sub schemify_quote {
|
|||||||
$quotedata .= " ($field . $data)";
|
$quotedata .= " ($field . $data)";
|
||||||
|
|
||||||
$field = 'last';
|
$field = 'last';
|
||||||
|
if (!($$quotehash{$itemname, $field})) {
|
||||||
|
$field = 'nav';
|
||||||
|
}
|
||||||
|
if (!($$quotehash{$itemname, $field})) {
|
||||||
|
$field = 'price';
|
||||||
|
}
|
||||||
|
|
||||||
$data = schemify_num($$quotehash{$itemname, $field});
|
$data = schemify_num($$quotehash{$itemname, $field});
|
||||||
$quotedata .= " ($field . $data)";
|
$quotedata .= " ($field . $data)";
|
||||||
|
|
||||||
|
@ -388,8 +388,7 @@
|
|||||||
(cons (car fq-call-data)
|
(cons (car fq-call-data)
|
||||||
(map
|
(map
|
||||||
(lambda (quote-item-info)
|
(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))))
|
(cdr fq-call-data))))
|
||||||
|
|
||||||
(define (fq-results->commod-tz-quote-triples fq-call-data fq-results)
|
(define (fq-results->commod-tz-quote-triples fq-call-data fq-results)
|
||||||
@ -473,7 +472,8 @@
|
|||||||
(time-zone (second c-tz-quote-triple))
|
(time-zone (second c-tz-quote-triple))
|
||||||
(quote-data (third c-tz-quote-triple))
|
(quote-data (third c-tz-quote-triple))
|
||||||
(gnc-time (assq-ref quote-data 'gnc:time-no-zone))
|
(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))
|
(currency-str (assq-ref quote-data 'currency))
|
||||||
(commodity-table (gnc:book-get-commodity-table book))
|
(commodity-table (gnc:book-get-commodity-table book))
|
||||||
(currency
|
(currency
|
||||||
@ -483,10 +483,26 @@
|
|||||||
"ISO4217"
|
"ISO4217"
|
||||||
(string-upcase currency-str)))))
|
(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...
|
;; FIXME: SIGFIGS is not what we want here...
|
||||||
(if last-price
|
(if price
|
||||||
(set! last-price
|
(set! price
|
||||||
(gnc:double-to-gnc-numeric last-price
|
(gnc:double-to-gnc-numeric price
|
||||||
GNC-DENOM-AUTO
|
GNC-DENOM-AUTO
|
||||||
(logior (GNC-DENOM-SIGFIGS 9)
|
(logior (GNC-DENOM-SIGFIGS 9)
|
||||||
GNC-RND-ROUND))))
|
GNC-RND-ROUND))))
|
||||||
@ -494,22 +510,21 @@
|
|||||||
(if gnc-time
|
(if gnc-time
|
||||||
(set! gnc-time (timestr->time-pair gnc-time time-zone)))
|
(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
|
(string-append
|
||||||
currency-str ":" (gnc:commodity-get-mnemonic commodity))
|
currency-str ":" (gnc:commodity-get-mnemonic commodity))
|
||||||
(let ((price (gnc:price-create)))
|
(let ((gnc-price (gnc:price-create)))
|
||||||
(if (not price)
|
(if (not gnc-price)
|
||||||
(string-append
|
(string-append
|
||||||
currency-str ":" (gnc:commodity-get-mnemonic commodity))
|
currency-str ":" (gnc:commodity-get-mnemonic commodity))
|
||||||
(begin
|
(begin
|
||||||
(gnc:price-set-commodity price commodity)
|
(gnc:price-set-commodity gnc-price commodity)
|
||||||
(gnc:price-set-currency price currency)
|
(gnc:price-set-currency gnc-price currency)
|
||||||
(gnc:price-set-time price gnc-time)
|
(gnc:price-set-time gnc-price gnc-time)
|
||||||
(gnc:price-set-source price "Finance::Quote")
|
(gnc:price-set-source gnc-price "Finance::Quote")
|
||||||
(gnc:price-set-type price "last")
|
(gnc:price-set-type gnc-price price-type)
|
||||||
(gnc:price-set-value price last-price)
|
(gnc:price-set-value gnc-price price)
|
||||||
;;(gnc:price-print-stdout price 2)
|
gnc-price))))))
|
||||||
price))))))
|
|
||||||
|
|
||||||
(define (book-add-prices! book prices)
|
(define (book-add-prices! book prices)
|
||||||
(let ((pricedb (gnc:book-get-pricedb book)))
|
(let ((pricedb (gnc:book-get-pricedb book)))
|
||||||
|
@ -54,10 +54,10 @@
|
|||||||
(define (op-value section name)
|
(define (op-value section name)
|
||||||
(gnc:option-value (get-op 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 table accounts to-date
|
||||||
|
|
||||||
(define (table-add-stock-rows-internal table accounts to-date odd-row?
|
|
||||||
currency pricedb collector)
|
currency pricedb collector)
|
||||||
|
|
||||||
|
(define (table-add-stock-rows-internal accounts odd-row?)
|
||||||
(if (null? accounts) collector
|
(if (null? accounts) collector
|
||||||
(let* ((row-style (if odd-row? "normal-row" "alternate-row"))
|
(let* ((row-style (if odd-row? "normal-row" "alternate-row"))
|
||||||
(current (car accounts))
|
(current (car accounts))
|
||||||
@ -69,7 +69,7 @@
|
|||||||
(unit-collector (gnc:account-get-comm-balance-at-date
|
(unit-collector (gnc:account-get-comm-balance-at-date
|
||||||
current to-date #f))
|
current to-date #f))
|
||||||
(units (cadr (unit-collector 'getpair commodity #f)))
|
(units (cadr (unit-collector 'getpair commodity #f)))
|
||||||
|
|
||||||
(price (gnc:pricedb-lookup-nearest-in-time pricedb
|
(price (gnc:pricedb-lookup-nearest-in-time pricedb
|
||||||
commodity
|
commodity
|
||||||
currency
|
currency
|
||||||
@ -78,13 +78,13 @@
|
|||||||
(price-value (if price
|
(price-value (if price
|
||||||
(gnc:price-get-value price)
|
(gnc:price-get-value price)
|
||||||
(gnc:numeric-zero)))
|
(gnc:numeric-zero)))
|
||||||
|
|
||||||
(value-num (gnc:numeric-mul
|
(value-num (gnc:numeric-mul
|
||||||
units
|
units
|
||||||
price-value
|
price-value
|
||||||
(gnc:commodity-get-fraction currency)
|
(gnc:commodity-get-fraction currency)
|
||||||
GNC-RND-ROUND))
|
GNC-RND-ROUND))
|
||||||
|
|
||||||
(value (gnc:make-gnc-monetary currency value-num)))
|
(value (gnc:make-gnc-monetary currency value-num)))
|
||||||
(collector 'add currency value-num)
|
(collector 'add currency value-num)
|
||||||
(gnc:html-table-append-row/markup!
|
(gnc:html-table-append-row/markup!
|
||||||
@ -96,14 +96,14 @@
|
|||||||
(gnc:make-html-table-header-cell/markup
|
(gnc:make-html-table-header-cell/markup
|
||||||
"number-cell" (gnc:numeric-to-double units))
|
"number-cell" (gnc:numeric-to-double units))
|
||||||
(gnc:make-html-table-header-cell/markup
|
(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
|
(gnc:make-html-table-header-cell/markup
|
||||||
"number-cell" value)))
|
"number-cell" value)))
|
||||||
(gnc:price-unref price)
|
(gnc:price-unref price)
|
||||||
(table-add-stock-rows-internal
|
(table-add-stock-rows-internal rest (not odd-row?)))))
|
||||||
table rest to-date currency (not odd-row?) pricedb collector))))
|
|
||||||
(table-add-stock-rows-internal table accounts to-date
|
(table-add-stock-rows-internal accounts #t))
|
||||||
currency #t pricedb collector))
|
|
||||||
|
|
||||||
;; The first thing we do is make local variables for all the specific
|
;; 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
|
;; options in the set of options given to the function. This set will
|
||||||
|
Loading…
Reference in New Issue
Block a user