From a12f34c67386bd004878723b0bcda1666d2187ae Mon Sep 17 00:00:00 2001 From: Christian Stimming Date: Wed, 16 May 2001 04:18:32 +0000 Subject: [PATCH] 2001-05-15 Christian Stimming * src/scm/commodity-utilities.scm: added another case to gnc:case-exchange-time-fn. Needs more work. * src/scm/report/price-scatter.scm: Catch all cases that would cause Guppi's scatterplot to barf. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@4225 57a11ea4-9604-0410-9ed3-97b8803252fd --- ChangeLog | 15 +++----- src/scm/commodity-utilities.scm | 23 +++++++++++ src/scm/report/price-scatter.scm | 65 ++++++++++++++++++++++---------- 3 files changed, 74 insertions(+), 29 deletions(-) diff --git a/ChangeLog b/ChangeLog index e6408477a7..e3437242a9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,15 +1,10 @@ -2001-05-16 Robert Graham Merkel +2001-05-15 Christian Stimming - * src/scm/report/transaction-report.scm: use colspan to make - room for long subtotal labels. + * src/scm/commodity-utilities.scm: added another case to + gnc:case-exchange-time-fn. Needs more work. - * src/scm/doc.scm: remove unnecessary debugging output inadvertantly - added. - -2001-05-15 Bill Gribble - - * fix report updating problem. should reload multicolumn reports - correctly when "reload" is hit. + * src/scm/report/price-scatter.scm: Catch all cases that would + cause Guppi's scatterplot to barf. 2001-05-15 Rob Browning diff --git a/src/scm/commodity-utilities.scm b/src/scm/commodity-utilities.scm index 59c4303243..836ca43489 100644 --- a/src/scm/commodity-utilities.scm +++ b/src/scm/commodity-utilities.scm @@ -661,6 +661,14 @@ pricealist (gnc:gnc-monetary-commodity foreign) date)) #f)) + + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Choosing exchange functions made easy -- get the right function by +;; the value of a multichoice option. + + ;; Return a ready-to-use function. Which one to use is determined by ;; the value of 'source-option', whose possible values are set in ;; gnc:options-add-price-source!. @@ -688,11 +696,26 @@ (lambda (foreign domestic date) (gnc:exchange-by-pricealist-nearest pricealist foreign domestic date)))) + ('actual-transactions (let ((pricealist + (gnc:get-commoditylist-inst-prices + commodity-list report-currency to-date-tp))) + (lambda (foreign domestic date) + (gnc:exchange-by-pricealist-nearest + pricealist foreign domestic date)))) ('pricedb-latest (lambda (foreign domestic date) (gnc:exchange-by-pricedb-latest foreign domestic))) ('pricedb-nearest gnc:exchange-by-pricedb-nearest) (else (gnc:warn "gnc:case-exchange-time-fn: bad price-source value")))) + + + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Functions using the exchange-fn's above to get from a +;; commodity-collector to one value. + + ;; Adds all different commodities in the commodity-collector ;; by using the exchange rates of to calculate the ;; exchange rates to the commodity . Returns a diff --git a/src/scm/report/price-scatter.scm b/src/scm/report/price-scatter.scm index a608a66978..d7c4bf5448 100644 --- a/src/scm/report/price-scatter.scm +++ b/src/scm/report/price-scatter.scm @@ -126,14 +126,14 @@ (let* ((to-date-tp (gnc:timepair-end-day-time (gnc:date-option-absolute-time (get-option gnc:pagename-general - optname-to-date)))) + optname-to-date)))) (from-date-tp (gnc:timepair-start-day-time (gnc:date-option-absolute-time (get-option gnc:pagename-general - optname-from-date)))) + optname-from-date)))) (interval (get-option gnc:pagename-general optname-stepsize)) (report-title (get-option gnc:pagename-general - gnc:optname-reportname)) + gnc:optname-reportname)) (height (get-option gnc:pagename-display optname-plot-height)) (width (get-option gnc:pagename-display optname-plot-width)) @@ -144,11 +144,11 @@ gnc:pagename-display optname-markercolor))) (report-currency (get-option pagename-price - optname-report-currency)) + optname-report-currency)) (price-commodity (get-option pagename-price - optname-price-commodity)) + optname-price-commodity)) (price-source (get-option pagename-price - optname-price-source)) + optname-price-source)) (dates-list (gnc:make-date-list (gnc:timepair-end-day-time from-date-tp) @@ -161,7 +161,15 @@ (filter gnc:account-has-shares? (gnc:group-get-subaccounts (gnc:get-current-group)))) (data '())) - + + ;; Short helper for all the warnings below + (define (make-warning title text) + (gnc:html-document-add-object! + document + (gnc:make-html-text + (gnc:html-markup-h2 title) + (gnc:html-markup-p text)))) + (gnc:html-scatter-set-title! chart report-title) (gnc:html-scatter-set-subtitle! @@ -258,22 +266,41 @@ (gnc:html-scatter-set-data! chart data) - + + ;; Make tons of tests so that Guppi won't barf (if (not (null? data)) - (gnc:html-document-add-object! document chart) - (gnc:html-document-add-object! - document - (gnc:html-make-empty-data-warning)))) + (if (> (length data) 1) + (if (apply equal? (map second data)) + (make-warning + (_ "All Prices equal") + (_ "All the prices found are equal. \ +This would result in a plot with one straight line. \ +Unfortunately, the plotting tool can't handle that.")) + (if (apply equal? (map first data)) + (make-warning + (_ "All Prices at the same date") + (_ "All the prices found are from the same date. \ +This would result in a plot with one straight line. \ +Unfortunately, the plotting tool can't handle that.")) + + (gnc:html-document-add-object! document chart))) + + (make-warning + (_ "Only one price") + (_ "There was only one single price found for the \ +selected commodities in the selected time period. This doesn't give \ +a useful plot."))) + (make-warning + (_ "No data") + (_ "There is no price information available for the \ +selected commodities in the selected time period.")))) ;; warning if report-currency == price-commodity - (gnc:html-document-add-object! - document - (gnc:make-html-text - (gnc:html-markup-h2 (_ "Identical commodities")) - (gnc:html-markup-p - (_ "Your selected commodity and the currency of the report \ + (make-warning + (_ "Identical commodities") + (_ "Your selected commodity and the currency of the report \ are identical. It doesn't make sense to show prices for identical \ -commodities."))))) +commodities."))) document))