portfolio.scm (gnucash-5.0.tar.bz2) | : | portfolio.scm (gnucash-5.1.tar.bz2) | ||
---|---|---|---|---|
skipping to change at line 98 | skipping to change at line 98 | |||
;; These are some helper functions for looking up option values. | ;; These are some helper functions for looking up option values. | |||
(define (get-option section name) | (define (get-option section name) | |||
(gnc-optiondb-lookup-value (gnc:report-options report-obj) section name)) | (gnc-optiondb-lookup-value (gnc:report-options report-obj) section name)) | |||
(define (table-add-stock-rows table accounts to-date currency | (define (table-add-stock-rows table accounts to-date currency | |||
exchange-fn price-fn include-empty collector) | exchange-fn price-fn include-empty collector) | |||
(let ((share-print-info | (let ((share-print-info | |||
(gnc-share-print-info-places | (gnc-share-print-info-places | |||
(inexact->exact (get-option gnc:pagename-general | (inexact->exact (get-option gnc:pagename-general | |||
optname-shares-digits))))) | optname-shares-digits))))) | |||
(define (table-add-stock-rows-internal accounts odd-row?) | (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)) | |||
(rest (cdr accounts)) | (rest (cdr accounts)) | |||
(commodity (xaccAccountGetCommodity current)) | (commodity (xaccAccountGetCommodity current)) | |||
(ticker-symbol (gnc-commodity-get-mnemonic commodity)) | (ticker-symbol (gnc-commodity-get-mnemonic commodity)) | |||
(listing (gnc-commodity-get-namespace commodity)) | (listing (gnc-commodity-get-namespace commodity)) | |||
(unit-collector (gnc:account-get-comm-balance-at-date | (unit-collector (gnc:account-get-comm-balance-at-date | |||
skipping to change at line 126 | skipping to change at line 126 | |||
(price-monetary (if price | (price-monetary (if price | |||
(gnc:make-gnc-monetary | (gnc:make-gnc-monetary | |||
(gnc-price-get-currency price) | (gnc-price-get-currency price) | |||
(gnc-price-get-value price)) | (gnc-price-get-value price)) | |||
(gnc:make-gnc-monetary | (gnc:make-gnc-monetary | |||
currency | currency | |||
(cdr price-info)))) | (cdr price-info)))) | |||
(value (exchange-fn (gnc:make-gnc-monetary commodity units) | (value (exchange-fn (gnc:make-gnc-monetary commodity units) | |||
currency))) | currency))) | |||
(set! work-done (+ 1 work-done)) | (set! work-done (+ 1 work-done)) | |||
(gnc:report-percent-done (* 100 (/ work-done work-to-do))) | (gnc:report-percent-done (* 100 (/ work-done work-to-do))) | |||
(if (or include-empty (not (gnc-numeric-zero-p units))) | (if (or include-empty (not (gnc-numeric-zero-p units))) | |||
(begin (collector 'add currency (gnc:gnc-monetary-amount value)) | (begin (collector 'add currency (gnc:gnc-monetary-amount value)) | |||
(gnc:html-table-append-row/markup! | (gnc:html-table-append-row/markup! | |||
table | table | |||
row-style | row-style | |||
(list (gnc:html-account-anchor current) | (list (gnc:html-account-anchor current) | |||
(gnc:make-html-table-header-cell/markup "text-cell" | (gnc:make-html-table-header-cell/markup "text-cell | |||
ticker-symbol) | " ticker-symbol) | |||
(gnc:make-html-table-header-cell/markup "text-cell" | (gnc:make-html-table-header-cell/markup "text-cell | |||
listing) | " listing) | |||
(gnc:make-html-table-header-cell/markup | (gnc:make-html-table-header-cell/markup | |||
"number-cell" | "number-cell" | |||
(xaccPrintAmount units share-print-info)) | (xaccPrintAmount units share-print-info)) | |||
(gnc:make-html-table-header-cell/markup | (gnc:make-html-table-header-cell/markup | |||
"number-cell" | "number-cell" | |||
(gnc:html-price-anchor price price-monetary)) | (gnc:html-price-anchor price price-monetary)) | |||
(gnc:make-html-table-header-cell/markup | (gnc:make-html-table-header-cell/markup | |||
"number-cell" value))) | "number-cell" value))) | |||
;;(display (format #f "Shares: ~6d " (gnc-numeric-to-doub | ;;(display (format #f "Shares: ~6d " (gnc-numeric-to-dou | |||
le units))) | ble units))) | |||
;;(display units) (newline) | ;;(display units) (newline) | |||
(if price (gnc-price-unref price)) | (if price (gnc-price-unref price)) | |||
(table-add-stock-rows-internal rest (not odd-row?))) | (table-add-stock-rows-internal rest (not odd-row?))) | |||
(begin (if price (gnc-price-unref price)) | (begin (if price (gnc-price-unref price)) | |||
(table-add-stock-rows-internal rest odd-row?)))))) | (table-add-stock-rows-internal rest odd-row?)))))) | |||
(set! work-to-do (length accounts)) | (set! work-to-do (length accounts)) | |||
(table-add-stock-rows-internal accounts #t))) | (table-add-stock-rows-internal accounts #t))) | |||
;; Tell the user that we're starting. | ;; Tell the user that we're starting. | |||
(gnc:report-starting reportname) | (gnc:report-starting reportname) | |||
;; 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 | |||
;; be generated by the options generator above. | ;; be generated by the options generator above. | |||
skipping to change at line 188 | skipping to change at line 188 | |||
document (string-append | document (string-append | |||
report-title | report-title | |||
(format #f " ~a" (qof-print-date to-date)))) | (format #f " ~a" (qof-print-date to-date)))) | |||
;(gnc:debug "accounts" accounts) | ;(gnc:debug "accounts" accounts) | |||
(if (not (null? accounts)) | (if (not (null? accounts)) | |||
(let* ((commodity-list (gnc:accounts-get-commodities | (let* ((commodity-list (gnc:accounts-get-commodities | |||
(gnc-accounts-and-all-descendants accounts) | (gnc-accounts-and-all-descendants accounts) | |||
currency)) | currency)) | |||
(pricedb (gnc-pricedb-get-db (gnc-get-current-book))) | (pricedb (gnc-pricedb-get-db (gnc-get-current-book))) | |||
(exchange-fn (gnc:case-exchange-fn price-source currency to-date)) | (exchange-fn (gnc:case-exchange-fn price-source currency to-date) ) | |||
(price-fn | (price-fn | |||
(case price-source | (case price-source | |||
((weighted-average average-cost) | ((weighted-average average-cost) | |||
(lambda (foreign date) | (lambda (foreign date) | |||
(cons #f (gnc-numeric-div | (cons #f (gnc-numeric-div | |||
(gnc:gnc-monetary-amount | (gnc:gnc-monetary-amount | |||
(exchange-fn (gnc:make-gnc-monetary foreign | (exchange-fn (gnc:make-gnc-monetary foreign | |||
(gnc-numeric-create 10000 1)) | (gnc-numeric-create 10000 1)) | |||
currency)) | currency)) | |||
(gnc-numeric-create 10000 1) | (gnc-numeric-create 10000 1) | |||
skipping to change at line 280 | skipping to change at line 280 | |||
(gnc:make-html-table-cell/size/markup | (gnc:make-html-table-cell/size/markup | |||
1 5 "total-number-cell" | 1 5 "total-number-cell" | |||
(gnc:make-gnc-monetary currency amount))))) | (gnc:make-gnc-monetary currency amount))))) | |||
#f) | #f) | |||
(gnc:html-document-add-object! document table)) | (gnc:html-document-add-object! document table)) | |||
;if no accounts selected. | ;if no accounts selected. | |||
(gnc:html-document-add-object! | (gnc:html-document-add-object! | |||
document | document | |||
(gnc:html-make-no-account-warning | (gnc:html-make-no-account-warning | |||
report-title (gnc:report-id report-obj)))) | report-title (gnc:report-id report-obj)))) | |||
(gnc:report-finished) | (gnc:report-finished) | |||
document))) | document))) | |||
(gnc:define-report | (gnc:define-report | |||
'version 1 | 'version 1 | |||
'name reportname | 'name reportname | |||
'report-guid "4a6b82e8678c4f3d9e85d9f09634ca89" | 'report-guid "4a6b82e8678c4f3d9e85d9f09634ca89" | |||
'menu-path (list gnc:menuname-asset-liability) | 'menu-path (list gnc:menuname-asset-liability) | |||
'options-generator options-generator | 'options-generator options-generator | |||
End of changes. 5 change blocks. | ||||
32 lines changed or deleted | 32 lines changed or added |