[advanced-portfolio] fix report warnings flags

the flags warn-no-price and warn-price-dirty are report-specific
warnings to flag price difficulties. these warnings must now be
recorded in table-add-stock-rows because they are not accessible
globally.
This commit is contained in:
Christopher Lam
2020-06-29 21:09:33 +08:00
parent 8d47622ab6
commit 2610b5f57f

View File

@@ -282,7 +282,7 @@ by preventing negative stock balances.<br/>")
basis-method prefer-pricelist handle-brokerage-fees basis-method prefer-pricelist handle-brokerage-fees
total-basis total-value total-basis total-value
total-moneyin total-moneyout total-income total-gain total-moneyin total-moneyout total-income total-gain
total-ugain total-brokerage share-print-info) total-ugain total-brokerage share-print-info warnings)
(define work-to-do 0) (define work-to-do 0)
@@ -790,8 +790,8 @@ by preventing negative stock balances.<br/>")
;; If we're using the txn, warn the user ;; If we're using the txn, warn the user
(if use-txn (if use-txn
(if pricing-txn (if pricing-txn
(set! warn-price-dirty #t) (hashq-set! warnings 'warn-price-dirty #t)
(set! warn-no-price #t) (hashq-set! warnings 'warn-no-price #t)
)) ))
(total-value 'add (gnc:gnc-monetary-commodity value) (gnc:gnc-monetary-amount value)) (total-value 'add (gnc:gnc-monetary-commodity value) (gnc:gnc-monetary-amount value))
@@ -881,8 +881,8 @@ by preventing negative stock balances.<br/>")
(define (advanced-portfolio-renderer report-obj) (define (advanced-portfolio-renderer report-obj)
(let ((warn-no-price #f) ;; report-warnings hash-table.
(warn-price-dirty #f)) (define warnings (make-hash-table))
;; These are some helper functions for looking up option values. ;; These are some helper functions for looking up option values.
(define (get-op section name) (define (get-op section name)
@@ -1062,7 +1062,7 @@ by preventing negative stock balances.<br/>")
prefer-pricelist handle-brokerage-fees prefer-pricelist handle-brokerage-fees
total-basis total-value total-moneyin total-moneyout total-basis total-value total-moneyin total-moneyout
total-income total-gain total-ugain total-brokerage total-income total-gain total-ugain total-brokerage
share-print-info)) share-print-info warnings))
(lambda (k reason) (lambda (k reason)
(gnc:html-document-add-object! (gnc:html-document-add-object!
document (format #f OVERFLOW-ERROR reason)))) document (format #f OVERFLOW-ERROR reason))))
@@ -1142,15 +1142,15 @@ by preventing negative stock balances.<br/>")
) )
(gnc:html-document-add-object! document table) (gnc:html-document-add-object! document table)
(if warn-price-dirty (if (hashq-ref warnings 'warn-price-dirty)
(gnc:html-document-append-objects! document (gnc:html-document-append-objects! document
(list (gnc:make-html-text (_ "* this commodity data was built using transaction pricing instead of the price list.")) (list (gnc:make-html-text (_ "* this commodity data was built using transaction pricing instead of the price list."))
(gnc:make-html-text (gnc:html-markup-br)) (gnc:make-html-text (gnc:html-markup-br))
(gnc:make-html-text (_ "If you are in a multi-currency situation, the exchanges may not be correct."))))) (gnc:make-html-text (_ "If you are in a multi-currency situation, the exchanges may not be correct.")))))
(if warn-no-price (if (hashq-ref warnings 'warn-no-price)
(gnc:html-document-append-objects! document (gnc:html-document-append-objects! document
(list (gnc:make-html-text (if warn-price-dirty (gnc:html-markup-br) "")) (list (gnc:make-html-text (if (hashq-ref warnings 'warn-price-dirty) (gnc:html-markup-br) ""))
(gnc:make-html-text (_ "** this commodity has no price and a price of 1 has been used."))))) (gnc:make-html-text (_ "** this commodity has no price and a price of 1 has been used.")))))
) )
@@ -1161,7 +1161,7 @@ by preventing negative stock balances.<br/>")
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