Skip to content

Commit

Permalink
Bug 798036 - Transaction Report should offer price source
Browse files Browse the repository at this point in the history
  • Loading branch information
christopherlam committed Dec 1, 2020
1 parent cc64f19 commit a8bed43
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions gnucash/report/trep-engine.scm
Expand Up @@ -76,6 +76,7 @@
;;General
(define optname-startdate (N_ "Start Date"))
(define optname-enddate (N_ "End Date"))
(define optname-price-source (N_ "Price Source"))
(define optname-table-export (N_ "Table for Exporting"))
(define optname-common-currency (N_ "Common Currency"))
(define optname-orig-currency (N_ "Show original currency amount"))
Expand Down Expand Up @@ -545,6 +546,9 @@ Credit Card, and Income accounts."))
(gnc-option-db-set-option-selectable-by-name
options gnc:pagename-general optname-orig-currency x))))

(gnc:options-add-price-source!
options gnc:pagename-general optname-price-source "e5" 'pricedb-nearest)

(gnc:options-add-currency!
options gnc:pagename-general optname-currency "f")

Expand Down Expand Up @@ -1051,7 +1055,7 @@ be excluded from periodic reporting.")
;; Here comes the big function that builds the whole table.

(define (make-split-table splits options custom-calculated-cells
begindate)
begindate enddate c_account_1)

(define (opt-val section name)
(let ((option (gnc:lookup-option options section name)))
Expand Down Expand Up @@ -1145,7 +1149,15 @@ be excluded from periodic reporting.")
(gnc-reverse-balance acc)))

(define (column-uses? param)
(cdr (assq param used-columns)))
(assq-ref used-columns param))

(define exchange-fn
(if (column-uses? 'common-currency)
(gnc:case-exchange-time-fn
(opt-val gnc:pagename-general optname-price-source)
(opt-val gnc:pagename-general optname-currency)
(gnc:accounts-get-commodities c_account_1 #f) enddate #f #f)
gnc:exchange-by-pricedb-nearest))

(define left-columns
(let* ((add-if (lambda (pred? . items) (if pred? items '())))
Expand Down Expand Up @@ -1306,7 +1318,7 @@ be excluded from periodic reporting.")
;; Otherwise it uses midnight which will likely match a
;; price on the previous day
(converted-amount (lambda (s)
(gnc:exchange-by-pricedb-nearest
(exchange-fn
(gnc:make-gnc-monetary (split-currency s)
(split-amount s))
(row-currency s)
Expand Down Expand Up @@ -2223,7 +2235,7 @@ warning will be removed in GnuCash 5.0"))
(else
(let-values (((table grid csvlist)
(make-split-table splits options custom-calculated-cells
begindate)))
begindate enddate c_account_1)))

(gnc:html-document-set-title! document report-title)

Expand Down

0 comments on commit a8bed43

Please sign in to comment.