GnuCash Daily Diff

Dave Peticolas peticolas@linas.org
Sun, 13 May 2001 08:02:27 -0500 (CDT)


Index: gnucash/ChangeLog
diff -u gnucash/ChangeLog:1.455 gnucash/ChangeLog:1.459
--- gnucash/ChangeLog:1.455	Sat May 12 06:50:23 2001
+++ gnucash/ChangeLog	Sun May 13 05:18:31 2001
@@ -1,3 +1,43 @@
+2001-05-13  Dave Peticolas  <dave@krondo.com>
+
+	* src/gnome/window-main.c: write commodities with accounts
+
+	* src/engine/io-gncxml-v2.c (write_commodities): make public
+
+	* src/gnome/new-user.glade: tweak gui
+
+	* src/gnome/window-main.c: the "destroy" handler does not
+	return a result. add menu item & functionality for account
+	hierarchy export.
+
+	* src/scm/report/welcome-to-gnucash.scm: take out the ugly :)
+
+2001-05-12  Christian Stimming  <stimming@tuhh.de>
+
+	* src/scm/report/category-barchart.scm, net-barchart.scm,
+	average-balance.scm: Added price-source option. Uses new function
+	gnc:make-exchange-nearest-function to offer time-varying exchange
+	rates.
+
+	* src/scm/report-utilities.scm
+	(gnc:acccounts-get-all-subaccounts): added.
+
+	* src/scm/commodity-utilities.scm
+	(gnc:make-exchange-nearest-function): Added this and many more
+	functions to enable time-variant currency exchange.
+
+	* src/scm/report/price-scatter.scm: Add warnings if data is empty.
+
+2001-05-12  Bill Gribble  <grib@billgribble.com>
+
+	* src/gnome/dialog-options.c: fix destructor bug 
+
+	* src/gnome/window-report.c: add options dialog to edited list
+	even if opened by a URL click. 
+	
+	* src/gnome/window-main.c: handle close of last window safely.
+	Still don't save MDI info correctly with WM close, though.
+
 2001-05-12  Dave Peticolas  <dave@krondo.com>
 
 	* src/FileDialog.c (gncFileSaveAs): don't use a default filename
Index: gnucash/src/engine/io-gncxml-v2.c
diff -u gnucash/src/engine/io-gncxml-v2.c:1.12 gnucash/src/engine/io-gncxml-v2.c:1.13
--- gnucash/src/engine/io-gncxml-v2.c:1.12	Tue Apr 17 04:32:03 2001
+++ gnucash/src/engine/io-gncxml-v2.c	Sun May 13 05:18:32 2001
@@ -394,7 +394,7 @@
                      gnc_commodity_get_mnemonic(cb)));
 }
 
-static void
+void
 write_commodities(FILE *out, GNCBook *book)
 {
     gnc_commodity_table *tbl;
@@ -436,7 +436,6 @@
     }
 
     g_list_free (namespaces);
-
 }
 
 static void
Index: gnucash/src/engine/io-utils.h
diff -u gnucash/src/engine/io-utils.h:1.2 gnucash/src/engine/io-utils.h:1.3
--- gnucash/src/engine/io-utils.h:1.2	Wed May  9 18:03:36 2001
+++ gnucash/src/engine/io-utils.h	Sun May 13 05:18:32 2001
@@ -32,6 +32,7 @@
 
 void write_account_group(FILE *out, AccountGroup *grp);
 void write_accounts(FILE *out, GNCBook *book);
+void write_commodities(FILE *out, GNCBook *book);
 
 void write_emacs_trailer(FILE *out);
 
Index: gnucash/src/gnome/dialog-options.c
diff -u gnucash/src/gnome/dialog-options.c:1.48 gnucash/src/gnome/dialog-options.c:1.49
--- gnucash/src/gnome/dialog-options.c:1.48	Tue Apr 24 04:12:34 2001
+++ gnucash/src/gnome/dialog-options.c	Sat May 12 07:47:30 2001
@@ -1919,7 +1919,6 @@
     gtk_widget_hide(container);
 
   /* at this point, window may point to freed data */
-
   if (!GTK_OBJECT_DESTROYED (container))
     gtk_signal_handler_unblock_by_func(GTK_OBJECT(container),
                                        GTK_SIGNAL_FUNC
@@ -2047,15 +2046,22 @@
 gnc_options_dialog_destroy(GNCOptionWin * win) {
 
   if (!win) return;
-
-  gtk_widget_destroy(win->container);
 
+  gtk_signal_disconnect_by_func(GTK_OBJECT(win->container), 
+                                GTK_SIGNAL_FUNC
+                                (gnc_options_dialog_destroy_stub_cb),
+                                win);
   if(!win->toplevel) {
     gtk_widget_unref(win->container);
   }
-
-  gtk_object_unref (GTK_OBJECT(win->tips));
+  else {
+    gtk_widget_destroy(win->container);
+  }
 
+  if(win->tips) {
+    gtk_object_unref (GTK_OBJECT(win->tips));
+  }
+  
   win->container = NULL;
   win->notebook = NULL;
   win->apply_cb = NULL;
Index: gnucash/src/gnome/gnc-html-guppi.c
diff -u gnucash/src/gnome/gnc-html-guppi.c:1.15 gnucash/src/gnome/gnc-html-guppi.c:1.16
--- gnucash/src/gnome/gnc-html-guppi.c:1.15	Thu May 10 17:30:38 2001
+++ gnucash/src/gnome/gnc-html-guppi.c	Sat May 12 18:03:10 2001
@@ -621,6 +621,7 @@
     argind++;    
   }
 
+  /* Those are not yet implemented in libguppitank :( */
 #if 0
   if((param = g_hash_table_lookup(params, "x_axis_label")) != NULL) {
     arglist[argind].name   = "x_axis_label";
Index: gnucash/src/gnome/new-user-interface.c
diff -u gnucash/src/gnome/new-user-interface.c:1.10 gnucash/src/gnome/new-user-interface.c:1.11
--- gnucash/src/gnome/new-user-interface.c:1.10	Sat May 12 06:50:33 2001
+++ gnucash/src/gnome/new-user-interface.c	Sun May 13 05:05:35 2001
@@ -215,7 +215,7 @@
   gtk_widget_show (hbox1);
   gtk_box_pack_start (GTK_BOX (druid_vbox1), hbox1, TRUE, TRUE, 0);
 
-  frame1 = gtk_frame_new (_("Long Description"));
+  frame1 = gtk_frame_new (_("Detailed Description"));
   gtk_widget_set_name (frame1, "frame1");
   gtk_widget_ref (frame1);
   gtk_object_set_data_full (GTK_OBJECT (newUserDialog), "frame1", frame1,
Index: gnucash/src/gnome/new-user.glade
diff -u gnucash/src/gnome/new-user.glade:1.10 gnucash/src/gnome/new-user.glade:1.11
--- gnucash/src/gnome/new-user.glade:1.10	Sat May 12 06:50:33 2001
+++ gnucash/src/gnome/new-user.glade	Sun May 13 05:05:35 2001
@@ -252,7 +252,7 @@
 	  <widget>
 	    <class>GtkFrame</class>
 	    <name>frame1</name>
-	    <label>Long Description</label>
+	    <label>Detailed Description</label>
 	    <label_xalign>0</label_xalign>
 	    <shadow_type>GTK_SHADOW_ETCHED_IN</shadow_type>
 	    <child>
Index: gnucash/src/gnome/window-main.c
diff -u gnucash/src/gnome/window-main.c:1.122 gnucash/src/gnome/window-main.c:1.125
--- gnucash/src/gnome/window-main.c:1.122	Thu May 10 17:30:39 2001
+++ gnucash/src/gnome/window-main.c	Sun May 13 05:18:34 2001
@@ -24,14 +24,20 @@
 
 #include "config.h"
 
+#include <errno.h>
 #include <gnome.h>
 #include <guile/gh.h>
+#include <stdio.h>
 #include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
 
 #include "gfec.h"
 #include "gnc-engine.h"
 #include "gnc-ui.h"
 #include "gnucash.h"
+#include "io-utils.h"
 #include "top-level.h"
 #include "extensions.h"
 
@@ -54,12 +60,12 @@
 #include "window-register.h"
 #include "window-report.h"
 
-#include "mainwindow-account-tree.h"
+#include "file-history.h"
+#include "global-options.h"
 #include "gnc-component-manager.h"
+#include "mainwindow-account-tree.h"
 #include "option-util.h"
-#include "global-options.h"
 #include "query-user.h"
-#include "file-history.h"
 
 #define WINDOW_MAIN_CM_CLASS "window-main"
 
@@ -89,22 +95,28 @@
   GtkWidget *toolbar;
   GList * child; 
 
-  toolbar = gtk_object_get_user_data (GTK_OBJECT (app));
-  if (toolbar)
-    gtk_widget_unref (toolbar);
-  gtk_object_set_user_data (GTK_OBJECT (app), NULL);
-
-  for(child = mainwin->children; child; child = child->next) {
-    mc = child->data;
-    if(mc && mc->toolbar && mc->app && (mc->app == app)) {
-      /* we need to pull the toolbar out to prevent its being
-       * destroyed */
-      gtk_widget_ref(mc->toolbar);
-      gtk_container_remove(GTK_CONTAINER(mc->toolbar->parent), mc->toolbar);
+  if(g_list_length(mdi->windows) == 0) {
+    gnc_shutdown(0);
+  }
+  else {
+    toolbar = gtk_object_get_user_data (GTK_OBJECT (app));
+    if (toolbar)
+      gtk_widget_unref (toolbar);
+    gtk_object_set_user_data (GTK_OBJECT (app), NULL);
+    
+    for(child = mainwin->children; child; child = child->next) {
+      mc = child->data;
+      if(mc && mc->toolbar && mc->app && (mc->app == app)) {
+        /* we need to pull the toolbar out to prevent its being
+         * destroyed */
+        gtk_widget_ref(mc->toolbar);
+        gtk_container_remove(GTK_CONTAINER(mc->toolbar->parent), mc->toolbar);
+      }
     }
   }
 }
 
+
 /********************************************************************
  * gnc_main_window_app_created_cb()
  * called when a new top-level GnomeApp is created.  
@@ -141,15 +153,13 @@
     item = gnome_dock_item_new("Summary Bar", behavior);
     gtk_container_add( GTK_CONTAINER (item), summarybar );
 
-    if (app->layout)
-    {
+    if (app->layout) {
       gnome_dock_layout_add_item( app->layout,
                                   GNOME_DOCK_ITEM(item),
                                   GNOME_DOCK_TOP,
                                   2, 0, 0 );
     }
-    else
-    {
+    else {
       gnome_dock_add_item( GNOME_DOCK(app->dock),
                            GNOME_DOCK_ITEM(item),
                            GNOME_DOCK_TOP,
@@ -690,6 +700,113 @@
 }
 
 static void
+gnc_main_window_file_export_cb(GtkWidget * widget) {
+  const char *filename;
+  struct stat statbuf;
+  gboolean ok;
+  FILE *file;
+  int rc;
+
+  filename =  fileBox (_("Export"), NULL, NULL);
+  if (!filename)
+    return;
+
+  rc = stat (filename, &statbuf);
+
+  /* Check for an error that isn't a non-existant file. */
+  if (rc != 0 && errno != ENOENT)
+  {
+    const char *message = _("You cannot save to that filename.");
+    char *string;
+
+    string = g_strconcat (message, "\n\n", strerror (errno), NULL);
+    gnc_error_dialog_parented (GTK_WINDOW (gtk_widget_get_toplevel (widget)),
+                               string);
+    g_free (string);
+    return;
+  }
+
+  /* Check for a file that isn't a regular file. */
+  if (rc == 0 && !S_ISREG (statbuf.st_mode))
+  {
+    const char *message = _("You cannot save to that file.");
+
+    gnc_error_dialog_parented (GTK_WINDOW (gtk_widget_get_toplevel (widget)),
+                               message);
+    return;
+  }
+
+  if (rc == 0)
+  {
+    const char *format = _("The file \n    %s\n already exists.\n"
+                           "Are you sure you want to overwrite it?");
+    char *string;
+    gboolean result;
+
+    string = g_strdup_printf (format, filename);
+    result = gnc_verify_dialog_parented (gtk_widget_get_toplevel (widget),
+                                         string, FALSE);
+    g_free (string);
+
+    if (!result)
+      return;
+  }
+
+  file = fopen (filename, "w");
+  if (!file)
+  {
+    const char *message = _("You cannot save to that file.");
+    char *string;
+
+    string = g_strconcat (message, "\n\n", strerror (errno), NULL);
+    gnc_error_dialog_parented (GTK_WINDOW (gtk_widget_get_toplevel (widget)),
+                               string);
+    g_free (string);
+    return;
+  }
+
+  ok = FALSE;
+
+  do
+  {
+    rc = fputs ("<?xml version=\"1.0\"?>\n", file);
+    if (rc == EOF)
+      break;
+
+    rc = fputs ("<gnc-v2>\n", file);
+    if (rc == EOF)
+      break;
+
+    write_commodities (file, gncGetCurrentBook ());
+    write_accounts (file, gncGetCurrentBook ());
+
+    rc = fputs ("<\\gnc-v2>\n", file);
+    if (rc == EOF)
+      break;
+
+    write_emacs_trailer (file);
+
+    rc = fclose (file);
+    if (rc != 0)
+      break;
+
+    ok = TRUE;
+  } while (FALSE);
+
+  if (!ok)
+  {
+    const char *message = _("There was an error saving the file.");
+    char *string;
+
+    string = g_strconcat (message, "\n\n", strerror (errno), NULL);
+    gnc_error_dialog_parented (GTK_WINDOW (gtk_widget_get_toplevel (widget)),
+                               string);
+    g_free (string);
+    return;
+  }
+}
+
+static void
 gnc_main_window_file_shutdown_cb(GtkWidget * widget) {
   gnc_shutdown(0);
 }
@@ -805,6 +922,14 @@
     GNOMEUIINFO_MENU_OPEN_ITEM(gnc_main_window_file_open_cb, NULL),
     GNOMEUIINFO_MENU_SAVE_ITEM(gnc_main_window_file_save_cb, NULL),
     GNOMEUIINFO_MENU_SAVE_AS_ITEM(gnc_main_window_file_save_as_cb, NULL),
+    {
+      GNOME_APP_UI_ITEM,
+      N_("Export Accounts..."),
+      N_("Export the account hierarchy to a new file"),
+      gnc_main_window_file_export_cb, NULL, NULL,
+      GNOME_APP_PIXMAP_NONE, NULL,
+      0, 0, NULL
+    },
     GNOMEUIINFO_SEPARATOR,
     {
       GNOME_APP_UI_ITEM,
Index: gnucash/src/gnome/window-report.c
diff -u gnucash/src/gnome/window-report.c:1.44 gnucash/src/gnome/window-report.c:1.45
--- gnucash/src/gnome/window-report.c:1.44	Thu May 10 17:30:40 2001
+++ gnucash/src/gnome/window-report.c	Sat May 12 07:47:31 2001
@@ -353,6 +353,9 @@
     if(gh_call1(start_editor, report->cur_report) == SCM_BOOL_F) {
       gnc_warning_dialog("There are no options for this report.");
     }
+    else {
+      gnc_report_window_add_edited_report(report, report->cur_report);
+    }
   }
   return TRUE;
 }
@@ -433,10 +436,22 @@
   SCM  inst_options;
   SCM  inst_options_ed;
   
+  /* we get this callback if a new report is requested to be loaded OR
+   * if any URL is clicked.  If an options URL is clicked, we want to
+   * know about it */
   if((type == URL_TYPE_REPORT) && location && (strlen(location) > 3) && 
      !strncmp("id=", location, 3)) {
     sscanf(location+3, "%d", &report_id);
   }
+  else if((type == URL_TYPE_OPTIONS) && location && (strlen(location) > 10) &&
+          !strncmp("report-id=", location, 10)) {
+    sscanf(location+10, "%d", &report_id);
+    inst_report = gh_call1(find_report, gh_int2scm(report_id));
+    if(inst_report != SCM_BOOL_F) {
+      gnc_report_window_add_edited_report(win, inst_report);      
+    }
+    return;
+  }
   else {
     return;
   }
@@ -768,8 +783,7 @@
 }
 
 void
-gnc_print_report (int report_id)
-{
+gnc_print_report (int report_id) {
   gnc_html *html;
   char * location;
 
@@ -833,7 +847,6 @@
 GtkWidget * 
 gnc_report_window_default_params_editor(SCM options, SCM report) {
   SCM get_editor = gh_eval_str("gnc:report-editor-widget");
-  SCM set_editor = gh_eval_str("gnc:report-set-editor-widget!");
   SCM ptr;
   SCM new_edited;
   
@@ -867,7 +880,6 @@
     gnc_options_dialog_set_close_cb(prm->win, 
                                     gnc_options_dialog_close_cb,
                                     (gpointer)prm);
-
     return gnc_options_dialog_widget(prm->win);
   }
 }
Index: gnucash/src/scm/commodity-utilities.scm
diff -u gnucash/src/scm/commodity-utilities.scm:1.16 gnucash/src/scm/commodity-utilities.scm:1.17
--- gnucash/src/scm/commodity-utilities.scm:1.16	Sat May 12 03:40:57 2001
+++ gnucash/src/scm/commodity-utilities.scm	Sat May 12 18:03:11 2001
@@ -170,13 +170,16 @@
 ;; of the foreign-currency and the appropriate list from
 ;; gnc:get-commodity-totalavg-prices, see there.
 (define (gnc:get-commoditylist-totalavg-prices
-	 currency-accounts end-date-tp commodity-list report-currency)
-  (map
-   (lambda (c)
-     (cons c
-	   (gnc:get-commodity-totalavg-prices
-	    currency-accounts end-date-tp c report-currency)))
-   commodity-list))
+	 commodity-list report-currency end-date-tp)
+  (let ((currency-accounts 
+	 (filter gnc:account-has-shares? (gnc:group-get-subaccounts
+					  (gnc:get-current-group)))))
+    (map
+     (lambda (c)
+       (cons c
+	     (gnc:get-commodity-totalavg-prices
+	      currency-accounts end-date-tp c report-currency)))
+     commodity-list)))
 
 ;; Get the instantaneous prices for the 'price-commodity', measured in
 ;; amounts of the 'report-currency'. The prices are taken from all
@@ -245,13 +248,16 @@
 ;; consists of the foreign-currency and the appropriate list from
 ;; gnc:get-commodity-inst-prices, see there.
 (define (gnc:get-commoditylist-inst-prices
-	 currency-accounts end-date-tp commodity-list report-currency)
-  (map
-   (lambda (c)
-     (cons c
-	   (gnc:get-commodity-inst-prices
-	    currency-accounts end-date-tp c report-currency)))
-   commodity-list))
+	 commodity-list report-currency end-date-tp)
+  (let ((currency-accounts 
+	 (filter gnc:account-has-shares? (gnc:group-get-subaccounts
+					  (gnc:get-current-group)))))
+    (map
+     (lambda (c)
+       (cons c
+	     (gnc:get-commodity-inst-prices
+	      currency-accounts end-date-tp c report-currency)))
+     commodity-list)))
 
 
 ;; Go through all toplevel non-'report-commodity' balances in
@@ -359,10 +365,10 @@
 
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; In progress: A suggested function to calculate the weighted average
-;; exchange rate between all commodities and the
-;; report-commodity. Uses all currency transactions up until the
-;; end-date. Returns an alist, see sumlist.
+;; Calculate the weighted average exchange rate between all
+;; commodities and the 'report-commodity'. Uses all currency
+;; transactions up until the 'end-date'. Returns an alist, see
+;; sumlist.
 (define (gnc:get-exchange-totals report-commodity end-date)
   (let ((curr-accounts 
 	 (filter gnc:account-has-shares? (gnc:group-get-subaccounts
@@ -543,8 +549,89 @@
 	domestic date))
       #f))
 
-;; Return a ready-to-use function. Which one is determined by the
-;; value of 'source-option', whose possible values are set in
+;; Find the price in 'pricelist' that's nearest to 'date'. The
+;; pricelist comes from
+;; e.g. gnc:get-commodity-totalavg-prices. Returns a <gnc-numeric> or,
+;; if pricelist was empty, #f.
+(define (gnc:pricelist-price-find-nearest
+	 pricelist date)
+  (let* ((later (find (lambda (p) 
+			(gnc:timepair-lt date (first p)))
+		      pricelist))
+	 (earlierlist (take-while 
+		       (lambda (p) 
+			 (gnc:timepair-ge date (first p)))
+		       pricelist))
+	 (earlier (and (not (null? earlierlist))
+		       (last earlierlist))))
+    ;;		(if earlier
+    ;;		    (warn "earlier" 
+    ;;			  (gnc:timepair-to-datestring (first earlier))
+    ;;			  (gnc:numeric-to-double (second earlier))))
+    ;;		(if later
+    ;;		    (warn "later" 
+    ;;			  (gnc:timepair-to-datestring (first later))
+    ;;			  (gnc:numeric-to-double (second later))))
+    
+    (if (and earlier later)
+	(if (< (abs (gnc:timepair-delta date (first earlier)))
+	       (abs (gnc:timepair-delta date (first later))))
+	    (second earlier)
+	    (second later))
+	(or
+	 (and earlier (second earlier))
+	 (and later (second later))))))
+
+;; Exchange by the nearest price from pricelist. This function takes
+;; the <gnc-monetary> 'foreign' amount, the <gnc:commodity*>
+;; 'domestic' commodity, a <gnc:time-pair> 'date' and the
+;; 'pricelist'. It exchanges the amount into the domestic currency,
+;; using the price nearest to 'data' found in the pricelist. The
+;; function returns a <gnc-monetary>.
+(define (gnc:exchange-by-pricelist-nearest
+	 pricelist foreign domestic date)
+  (if (and (record? foreign) (gnc:gnc-monetary? foreign)
+	   date (not (null? pricelist)))
+      (gnc:make-gnc-monetary 
+       domestic
+       (let ((price (gnc:pricelist-price-find-nearest pricelist date)))
+	 (if price
+	     (gnc:numeric-mul (gnc:gnc-monetary-amount foreign) 
+			      price
+			      (gnc:commodity-get-fraction domestic)
+			      GNC-RND-ROUND)
+	     (begin
+	       (warn "gnc:exchange-by-pricelist-nearest: No price found for "
+		     (gnc:monetary->string foreign) " into "
+		     (gnc:monetary->string
+		      (gnc:make-gnc-monetary domestic (gnc:numeric-zero)))
+		     " at date " (gnc:timepair-to-datestring date))
+	       (gnc:numeric-zero)))))
+      #f))
+
+;; Create a ready-to-use function for calculation of the exchange
+;; rates at different times. (This is the glorious generalization of
+;; gnc:make-exchange-function, woohoo!) The prices over time are
+;; stored in 'pricealist' which comes from
+;; e.g. gnc:get-commoditylist-totalavg-prices. The returned function
+;; takes the <gnc-monetary> 'foreign' amount, the <gnc:commodity*>
+;; 'domestic', and the <gnc:timepair> 'date'. It exchanges the amount
+;; into the domestic currency according to the nearest price found in
+;; the 'pricealist'. It will return a <gnc-monetary>.
+(define (gnc:make-exchange-nearest-function pricealist)
+  (lambda (foreign domestic date)
+    (let ((plist (assoc-ref pricealist 
+			    (gnc:gnc-monetary-commodity foreign))))
+      (if (and plist (not (null? plist)))
+	  (gnc:exchange-by-pricelist-nearest
+	   plist foreign domestic date)
+	  (warn "gnc:make-exchange-nearest-fn: No pricelist found for "
+		(gnc:monetary->string foreign) " into "
+		(gnc:monetary->string
+		 (gnc:make-gnc-monetary domestic (gnc:numeric-zero))))))))
+
+;; 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!.
 (define (gnc:case-exchange-fn 
 	 source-option report-currency to-date-tp)
@@ -556,9 +643,21 @@
     ('pricedb-nearest (lambda (foreign domestic)
 			(gnc:exchange-by-pricedb-nearest
 			 foreign domestic to-date-tp)))
-    (else (gnc:warn "gnc:case-exchange-gn: bad price-source value"))))
+    (else (gnc:warn "gnc:case-exchange-fn: bad price-source value"))))
 
-
+;; 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!.
+(define (gnc:case-exchange-time-fn 
+	 source-option report-currency commodity-list to-date-tp)
+  (case source-option
+    ('weighted-average (gnc:make-exchange-nearest-function 
+			(gnc:get-commoditylist-totalavg-prices
+			 commodity-list report-currency to-date-tp)))
+    ('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"))))
 
 ;; Adds all different commodities in the commodity-collector <foreign>
 ;; by using the exchange rates of <exchange-fn> to calculate the
Index: gnucash/src/scm/report-utilities.scm
diff -u gnucash/src/scm/report-utilities.scm:1.65 gnucash/src/scm/report-utilities.scm:1.66
--- gnucash/src/scm/report-utilities.scm:1.65	Sat May 12 02:44:21 2001
+++ gnucash/src/scm/report-utilities.scm	Sat May 12 18:03:11 2001
@@ -202,6 +202,15 @@
   (let ((group (gnc:account-get-children acct)))
     (gnc:group-get-subaccounts group)))
 
+;; Get all children of this list of accounts.
+(define (gnc:acccounts-get-all-subaccounts accountlist)
+  (append-map 
+   (lambda (a)
+     (gnc:group-get-subaccounts
+      (gnc:account-get-children a)))
+   accountlist))
+
+
 (define (gnc:transaction-map-splits thunk transaction)
   (let loop ((num-splits (gnc:transaction-get-split-count transaction))
              (i 0))
Index: gnucash/src/scm/report/average-balance.scm
diff -u gnucash/src/scm/report/average-balance.scm:1.56 gnucash/src/scm/report/average-balance.scm:1.57
--- gnucash/src/scm/report/average-balance.scm:1.56	Wed May  2 15:14:19 2001
+++ gnucash/src/scm/report/average-balance.scm	Sat May 12 18:03:12 2001
@@ -13,8 +13,13 @@
 (gnc:depend "report-utilities.scm")
 (gnc:depend "date-utilities.scm")
 
-(let ((optname-subacct (N_ "Include Sub-Accounts"))
-      (optname-report-currency (N_ "Report Currency")))
+(let ((optname-from-date (N_ "From"))
+      (optname-to-date (N_ "To"))
+      (optname-stepsize (N_ "Step Size"))
+      (optname-report-currency (N_ "Report's currency"))
+      (optname-price-source (N_ "Price Source"))
+      (optname-subacct (N_ "Include Sub-Accounts")))
+
   ;;;;;;;;;;;;;;;;;;;;;;;;;
   ;; Options
   ;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -26,14 +31,32 @@
             (lambda (new-option)
               (gnc:register-option options new-option))))      
 
+      ;; General tab
       (gnc:options-add-date-interval!
-       options gnc:pagename-general (N_ "From") (N_ "To") "a")
+       options gnc:pagename-general optname-from-date optname-to-date "a")
+
+      (gnc:options-add-interval-choice! 
+       options gnc:pagename-general optname-stepsize "b" 'TwoWeekDelta)
+
+      ;; Report currency
+      (gnc:options-add-currency! 
+       options gnc:pagename-general optname-report-currency "c")
+      
+      (gnc:options-add-price-source! 
+       options gnc:pagename-general
+       optname-price-source "d" 'pricedb-latest)
 
+      ;; Account tab
+      (register-option
+       (gnc:make-simple-boolean-option
+        gnc:pagename-accounts optname-subacct
+        "a" (N_ "Include sub-accounts of all selected accounts") #t))
+
       ;; account(s) to do report on
       (register-option
        (gnc:make-account-list-option
         gnc:pagename-accounts (N_ "Accounts")
-        "d" (N_ "Do transaction report on this account")
+        "b" (N_ "Do transaction report on this account")
         (lambda ()
           ;; FIXME : gnc:get-current-accounts disappeared
           (let ((current-accounts '()))
@@ -49,19 +72,8 @@
 		    ;; mutual-fund money-market)
 		    (gnc:group-get-account-list (gnc:get-current-group)))))))
         #f #t))
-
-      (gnc:options-add-interval-choice! 
-       options gnc:pagename-general (N_ "Step Size") "b" 'TwoWeekDelta)
-
-      (register-option
-       (gnc:make-simple-boolean-option
-        gnc:pagename-accounts optname-subacct
-        "e" (N_ "Include sub-accounts of all selected accounts") #t))
 
-      ;; Report currency
-      (gnc:options-add-currency! 
-       options gnc:pagename-general optname-report-currency "f")
-      
+      ;; Display tab
       (register-option
        (gnc:make-simple-boolean-option
         gnc:pagename-display (N_ "Show table")
@@ -106,19 +118,12 @@
   ;; avg-bal max-bal min-bal total-in total-out net) if multiple
   ;; accounts are selected the balance is the sum for all.  Each
   ;; balance in a foreign currency will be converted to a double in
-  ;; the report-currency by means of the collector->double
+  ;; the report-currency by means of the monetary->double
   ;; function. 
-
-  ;; FIXME: the exchange rate should change every time interval, of
-  ;; course, but right now we assume the very last exchange rate to be
-  ;; constant over the whole report period. Note that this might get
-  ;; *really* complicated.
-
-  (define (analyze-splits splits start-bal 
-			  start-date end-date interval collector->double)
+  (define (analyze-splits splits start-bal-double 
+			  start-date end-date interval monetary->double)
     (let ((interval-list 
 	   (gnc:make-date-interval-list start-date end-date interval))
-	  (start-bal-double (collector->double start-bal))
 	  (data-rows '()))
       
       (define (output-row interval-start 
@@ -142,14 +147,14 @@
                data-rows)))
       
       ;; Returns a double which is the split value, correctly
-      ;; exchanged to the current report-currency.
-      (define (get-split-value split)
-	(let ((coll (gnc:make-commodity-collector)))
-	  (coll 'add (gnc:account-get-commodity (gnc:split-get-account split))
-		(gnc:split-get-amount split))
-	  ;; FIXME: not as efficient as it would be possible because I
-	  ;; only have the collector->double conversion at hand.
-	  (collector->double coll)))
+      ;; exchanged to the current report-currency. We use the exchange
+      ;; rate at the 'date'.
+      (define (get-split-value split date)
+	(monetary->double
+	 (gnc:make-gnc-monetary
+	  (gnc:account-get-commodity (gnc:split-get-account split))
+	  (gnc:split-get-amount split))
+	 date))
       
       ;; calculate the statistics for one interval - returns a list 
       ;;  containing the following: 
@@ -189,9 +194,11 @@
 		#f
 		(let* 
 		    ((split (car splits))
-		     (split-amt (get-split-value split))
 		     (split-time (gnc:transaction-get-date-posted 
-				  (gnc:split-get-parent split))))
+				  (gnc:split-get-parent split)))
+		     ;; FIXME: Which date should we use here? The 'to'
+		     ;; date? the 'split-time'?
+		     (split-amt (get-split-value split split-time)))
 		  
 		  
 		  (gnc:debug "split " split)
@@ -247,42 +254,55 @@
   ;;;;;;;;;;;;;;;;;;;;;;;;;
 
   (define (renderer report-obj)
-    (let* ((opt-val 
-            (lambda (sec value)
-              (gnc:option-value 
-               (gnc:lookup-option (gnc:report-options report-obj) sec value))))
-	   (report-title (opt-val gnc:pagename-general gnc:optname-reportname))
-           (begindate  (gnc:timepair-start-day-time
-			(gnc:date-option-absolute-time 
-			 (opt-val gnc:pagename-general (N_ "From")))))
-           (enddate    (gnc:timepair-end-day-time 
-			(gnc:date-option-absolute-time 
-			 (opt-val gnc:pagename-general (N_ "To")))))
-           (stepsize   (eval (opt-val gnc:pagename-general (N_ "Step Size"))))
-           (accounts   (opt-val gnc:pagename-accounts (N_ "Accounts")))
-           (dosubs?    (opt-val gnc:pagename-accounts optname-subacct))
-	   (report-currency (opt-val gnc:pagename-general 
+
+    (define (get-option section name)
+      (gnc:option-value 
+       (gnc:lookup-option (gnc:report-options report-obj) section name)))
+
+    (let* ((report-title (get-option gnc:pagename-general 
+				     gnc:optname-reportname))
+           (begindate (gnc:timepair-start-day-time
+		       (gnc:date-option-absolute-time 
+			(get-option gnc:pagename-general optname-from-date))))
+           (enddate (gnc:timepair-end-day-time 
+		     (gnc:date-option-absolute-time 
+		      (get-option gnc:pagename-general optname-to-date))))
+           (stepsize (eval (get-option gnc:pagename-general optname-stepsize)))
+	   (report-currency (get-option gnc:pagename-general 
 				     optname-report-currency))
-           (plot-type  (opt-val gnc:pagename-display (N_ "Plot Type")))
-           (show-plot? (opt-val gnc:pagename-display (N_ "Show plot")))
-           (show-table? (opt-val gnc:pagename-display (N_ "Show table")))
+	   (price-source (get-option gnc:pagename-general
+				     optname-price-source))
+
+           (accounts   (get-option gnc:pagename-accounts (N_ "Accounts")))
+           (dosubs?    (get-option gnc:pagename-accounts optname-subacct))
+
+           (plot-type  (get-option gnc:pagename-display (N_ "Plot Type")))
+           (show-plot? (get-option gnc:pagename-display (N_ "Show plot")))
+           (show-table? (get-option gnc:pagename-display (N_ "Show table")))
+
            (document   (gnc:make-html-document))
-	   (exchange-alist (gnc:make-exchange-alist
-			    report-currency enddate))
-	   (exchange-fn (gnc:make-exchange-function exchange-alist))
+
+	   (commodity-list (gnc:accounts-get-commodities 
+			    (append 
+			     (gnc:acccounts-get-all-subaccounts accounts)
+			     accounts)
+			    report-currency))
+	   (exchange-fn (gnc:case-exchange-time-fn 
+			 price-source report-currency 
+			 commodity-list enddate))
+
 	   (beforebegindate (gnc:timepair-end-day-time 
 			     (gnc:timepair-previous-day begindate)))
 	   ;; startbal will be a commodity-collector
            (startbal  '()))
 
-      (define (collector->double commodity-collector)
+      (define (monetary->double foreign-monetary date)
 	(gnc:numeric-to-double
 	 (gnc:gnc-monetary-amount
-	  (gnc:sum-collector-commodity commodity-collector
-				       report-currency 
-				       exchange-fn))))
+	  (exchange-fn foreign-monetary report-currency date))))
 
       (gnc:html-document-set-title! document report-title)
+      (warn commodity-list)
 
       (if (not (null? accounts))
           (let ((query (gnc:malloc-query))
@@ -332,18 +352,28 @@
 		   (lambda (acct) (gnc:account-get-comm-balance-at-date 
 				   acct beforebegindate #f))
 		   gnc:account-reverse-balance?))
+
+	    (set! startbal 
+		  (gnc:numeric-to-double
+		   (gnc:gnc-monetary-amount
+		    (gnc:sum-collector-commodity 
+		     startbal
+		     report-currency 
+		     (lambda (a b) 
+		       (exchange-fn a b beforebegindate))))))
             
             ;; and analyze the data 
-            (set! data (analyze-splits splits startbal begindate enddate 
-                                       stepsize collector->double))
+            (set! data (analyze-splits splits startbal
+				       begindate enddate 
+                                       stepsize monetary->double))
             
             ;; make a plot (optionally)... if both plot and table, 
             ;; plot comes first. 
             (if show-plot?
                 (let ((barchart (gnc:make-html-barchart))
-                      (width (opt-val gnc:pagename-display 
+                      (width (get-option gnc:pagename-display 
 				      (N_ "Plot Width")))
-                      (height (opt-val gnc:pagename-display 
+                      (height (get-option gnc:pagename-display 
 				       (N_ "Plot Height")))
                       (col-labels '())
                       (col-colors '()))
Index: gnucash/src/scm/report/category-barchart.scm
diff -u gnucash/src/scm/report/category-barchart.scm:1.24 gnucash/src/scm/report/category-barchart.scm:1.25
--- gnucash/src/scm/report/category-barchart.scm:1.24	Thu May 10 17:30:44 2001
+++ gnucash/src/scm/report/category-barchart.scm	Sat May 12 18:03:13 2001
@@ -62,6 +62,7 @@
       (optname-to-date (N_ "To"))
       (optname-stepsize (N_ "Step Size"))
       (optname-report-currency (N_ "Report's currency"))
+      (optname-price-source (N_ "Price Source"))
 
       (optname-accounts (N_ "Accounts"))
       (optname-levels (N_ "Show Accounts until level"))
@@ -89,6 +90,10 @@
       (gnc:options-add-currency! 
        options gnc:pagename-general optname-report-currency "c")
 
+      (gnc:options-add-price-source! 
+       options gnc:pagename-general
+       optname-price-source "d" 'pricedb-latest)
+
       ;; Accounts tab
       (add-option
        (gnc:make-account-list-option
@@ -167,6 +172,8 @@
 	  (interval (get-option gnc:pagename-general optname-stepsize))
 	  (report-currency (get-option gnc:pagename-general
 				       optname-report-currency))
+	  (price-source (get-option gnc:pagename-general
+				    optname-price-source))
 	  (report-title (get-option gnc:pagename-general 
 				    gnc:optname-reportname))
 
@@ -196,9 +203,14 @@
 	  
 	  ;; Define more helper variables.
 	  
-	  (let* ((exchange-alist (gnc:make-exchange-alist
-				  report-currency to-date-tp))
-		 (exchange-fn (gnc:make-exchange-function exchange-alist))
+	  (let* ((commodity-list (gnc:accounts-get-commodities 
+				  (append 
+				   (gnc:acccounts-get-all-subaccounts accounts)
+				   accounts)
+				  report-currency))
+		 (exchange-fn (gnc:case-exchange-time-fn 
+			       price-source report-currency 
+			       commodity-list to-date-tp))
 		 (tree-depth (if (equal? account-levels 'all)
 				 (gnc:get-current-group-depth)
 				 account-levels))
@@ -226,15 +238,15 @@
 	    
 	    ;; Converts a commodity-collector into one single double
 	    ;; number, depending on the report currency and the
-	    ;; exchange-alist calculated above. Returns a double.
-	    (define (collector->double c)
+	    ;; exchange-fn calculated above. Returns a double.
+	    (define (collector->double c date)
 	      ;; Future improvement: Let the user choose which kind of
 	      ;; currency combining she want to be done. 
 	      (gnc:numeric-to-double 
 	       (gnc:gnc-monetary-amount
 		(gnc:sum-collector-commodity 
 		 c report-currency 
-		 exchange-fn))))
+		 (lambda (a b) (exchange-fn a b date))))))
 	    
 	    ;; Calculates the net balance (profit or loss) of an account in
 	    ;; the given time interval. date-list-entry is a pair containing
@@ -245,14 +257,17 @@
 	    (define (get-balance account date-list-entry subacct?)
 	      ((if (gnc:account-reverse-balance? account)
 		   - +)
-	       (collector->double
 		(if do-intervals?
-		    (gnc:account-get-comm-balance-interval 
-		     account 
-		     (car date-list-entry) 
-		     (cadr date-list-entry) subacct?)
-		    (gnc:account-get-comm-balance-at-date
-		     account date-list-entry subacct?)))))
+		    (collector->double
+		     (gnc:account-get-comm-balance-interval 
+		      account 
+		      (first date-list-entry) 
+		      (second date-list-entry) subacct?)
+		     (second date-list-entry))
+		    (collector->double
+		     (gnc:account-get-comm-balance-at-date
+		      account date-list-entry subacct?)
+		     date-list-entry))))
 	    
 	    ;; Creates the <balance-list> to be used in the function
 	    ;; below. 
@@ -314,7 +329,7 @@
 	    ;; choose sorting.
 	    
 	    
-	    (gnc:warn "all-data" all-data)
+	    ;;(gnc:warn "all-data" all-data)
 	    
 	    (let ((all-data-amounts (map cadr all-data)))
 	      (if 
@@ -437,8 +452,7 @@
 		  (gnc:html-markup-p 
 		   "If you don't see a stacked barchart i.e. you only see \
 lots of thin bars next to each other for each date, then you \
-should upgrade Guppi to version 0.35.4 or, \
-if that isn't out yet, use the Guppi CVS version.")
+should upgrade Guppi to version 0.35.5.")
 		  (gnc:html-markup-p
 		   "Double-click on any legend box or any bar opens \
 another barchart report with the subaccounts of that account or, \
Index: gnucash/src/scm/report/net-barchart.scm
diff -u gnucash/src/scm/report/net-barchart.scm:1.5 gnucash/src/scm/report/net-barchart.scm:1.6
--- gnucash/src/scm/report/net-barchart.scm:1.5	Wed May  9 03:27:07 2001
+++ gnucash/src/scm/report/net-barchart.scm	Sat May 12 18:03:13 2001
@@ -32,6 +32,7 @@
       (optname-to-date (N_ "To"))
       (optname-stepsize (N_ "Step Size"))
       (optname-report-currency (N_ "Report's currency"))
+      (optname-price-source (N_ "Price Source"))
 
       (optname-accounts (N_ "Accounts"))
 
@@ -52,6 +53,7 @@
             (lambda (new-option)
               (gnc:register-option options new-option))))
 
+      ;; General tab
       (gnc:options-add-date-interval!
        options gnc:pagename-general
        optname-from-date optname-to-date "a")
@@ -59,10 +61,18 @@
       (gnc:options-add-interval-choice! 
        options gnc:pagename-general optname-stepsize "b" 'MonthDelta)
 
+      (gnc:options-add-currency! 
+       options gnc:pagename-general optname-report-currency "c")
+      
+      (gnc:options-add-price-source! 
+       options gnc:pagename-general
+       optname-price-source "d" 'pricedb-latest)
+
+      ;; Account tab
       (add-option
        (gnc:make-account-list-option
 	gnc:pagename-accounts optname-accounts
-	"c"
+	"a"
 	(N_ "Report on these accounts, if chosen account level allows.")
 	(lambda ()
 	  (filter
@@ -80,9 +90,7 @@
 		 accounts)))
 	#t))
 
-      (gnc:options-add-currency! 
-       options gnc:pagename-general optname-report-currency "d")
-      
+      ;; Display tab
       (add-option
        (gnc:make-simple-boolean-option
         gnc:pagename-display 
@@ -103,7 +111,6 @@
 	    (N_ "Show a Net Worth bar?")) 
 	#t))
 
-
       (gnc:options-add-plot-size! 
        options gnc:pagename-display 
        optname-plot-width optname-plot-height "c" 500 400)
@@ -121,79 +128,43 @@
   (define (net-renderer report-obj inc-exp?)
 
     ;; This is a helper function for looking up option values.
-    (define (op-value section name)
+    (define (get-option section name)
       (gnc:option-value 
        (gnc:lookup-option (gnc:report-options report-obj) section name)))
 
-    ;; This calculates the balances for all the 'accounts' for each
-    ;; element of the list 'dates'. If income?==#t, the signs get
-    ;; reversed according to income-sign-reverse general option
-    ;; settings. Returns a commodity-collector.
-    (define (collector-fn accounts dates income?)
-      (map 
-       (lambda (date)
-	 ((if inc-exp?
-	      (if income?
-		  gnc:accounts-get-comm-total-income
-		  gnc:accounts-get-comm-total-expense)
-	      gnc:accounts-get-comm-total-assets)
-	  accounts 
-	  (lambda (account)
-	    (if inc-exp?
-		;; for inc-exp, 'date' is a pair of time values, else
-		;; it is a time value.
-		(gnc:account-get-comm-balance-interval 
-		 account (car date) (cadr date) #f)
-		(gnc:account-get-comm-balance-at-date 
-		 account date #f)))))
-       dates))
-
-    ;; This exchanges a commodity-collector to one single
-    ;; 'report-currency' according to the exchange-fn. Returns a
-    ;; double.
-    (define (collector-to-double-fn report-currency exchange-fn)
-      (lambda (commodity-collector)
-        (gnc:numeric-to-double
-         (gnc:gnc-monetary-amount
-          (gnc:sum-collector-commodity commodity-collector
-                                       report-currency 
-                                       exchange-fn)))))
-
-    ;; Helper - Adds two commodity-collectors.
-    (define (collector-combine collector1 collector2)
-      (let ((new-collector (gnc:make-commodity-collector)))
-	(new-collector 'merge collector1 #f)
-	(new-collector 'merge collector2 #f)
-	new-collector))
-
     (let* ((to-date-tp (gnc:timepair-end-day-time 
 			(gnc:date-option-absolute-time
-                         (op-value gnc:pagename-general 
+                         (get-option gnc:pagename-general 
 				   optname-to-date))))
 	   (from-date-tp (gnc:timepair-start-day-time 
 			  (gnc:date-option-absolute-time
-                           (op-value gnc:pagename-general 
+                           (get-option gnc:pagename-general 
 				     optname-from-date))))
-	   (interval (op-value gnc:pagename-general optname-stepsize))
-	   (accounts (op-value gnc:pagename-accounts optname-accounts))
+	   (interval (get-option gnc:pagename-general optname-stepsize))
+           (report-currency (get-option gnc:pagename-general
+                                      optname-report-currency))
+	   (price-source (get-option gnc:pagename-general
+				     optname-price-source))
 
-	   (show-sep? (op-value gnc:pagename-display 
+	   (accounts (get-option gnc:pagename-accounts optname-accounts))
+
+	   (show-sep? (get-option gnc:pagename-display 
 				(if inc-exp? optname-inc-exp 
 				    optname-sep-bars)))
-	   (show-net? (op-value gnc:pagename-display 
+	   (show-net? (get-option gnc:pagename-display 
 				(if inc-exp? optname-show-profit
 				    optname-net-bars)))
-	   (height (op-value gnc:pagename-display optname-plot-height))
-	   (width (op-value gnc:pagename-display optname-plot-width))
-
-           (report-currency (op-value gnc:pagename-general
-                                      optname-report-currency))
+	   (height (get-option gnc:pagename-display optname-plot-height))
+	   (width (get-option gnc:pagename-display optname-plot-width))
 
-	   (exchange-alist (gnc:make-exchange-alist
-			    report-currency to-date-tp))
-	   (exchange-fn-internal (gnc:make-exchange-function exchange-alist))
-	   ;;(exchange-fn (lambda (foreign)
-	   ;;              (exchange-fn-internal foreign report-currency)))
+	   (commodity-list (gnc:accounts-get-commodities 
+			    (append 
+			     (gnc:acccounts-get-all-subaccounts accounts)
+			     accounts)
+			    report-currency))
+	   (exchange-fn (gnc:case-exchange-time-fn 
+			 price-source report-currency 
+			 commodity-list to-date-tp))
 
 	   (dates-list ((if inc-exp? gnc:make-date-interval-list
 			    gnc:make-date-list)
@@ -205,48 +176,73 @@
 	   (classified-accounts (gnc:decompose-accountlist accounts))
 	   (document (gnc:make-html-document))
 	   (chart (gnc:make-html-barchart))
-
-           (assets-collector-list 
-	    (collector-fn 
-	     (if inc-exp? 
-		 accounts
-		 (assoc-ref classified-accounts 'asset))
-	     dates-list #t))
-	   (liab-collector-list 
-	    (collector-fn 
-	     (if inc-exp?
-		 accounts
-                 (assoc-ref classified-accounts 'liability))
-	     dates-list #f))
-	   (net-collector-list
-            (map collector-combine assets-collector-list
-                 liab-collector-list))
-	   (assets-list
-            (map (collector-to-double-fn report-currency exchange-fn-internal)
-                 assets-collector-list))
-           (liability-list
-            (map (collector-to-double-fn report-currency exchange-fn-internal)
-                 liab-collector-list))
-	   (net-list
-	    (map (collector-to-double-fn report-currency exchange-fn-internal)
-		 net-collector-list))
-	   (date-string-list (map 
-			      (if inc-exp?
-				  (lambda (date-list-item)
-				    (gnc:timepair-to-datestring
-				     (car date-list-item)))
-				  gnc:timepair-to-datestring)
-			      dates-list))
 	   (non-zeros #f))
+
       (define (add-column! data-list)
 	(begin
 	  (gnc:html-barchart-append-column! chart data-list)
 	  (if (gnc:not-all-zeros data-list) (set! non-zeros #t))
 	  #f))
-      
+
+      ;; This exchanges the commodity-collector 'c' to one single
+      ;; 'report-currency' according to the exchange-fn. Returns a
+      ;; double.
+      (define (collector->double c date)
+	(gnc:numeric-to-double
+	 (gnc:gnc-monetary-amount
+	  (gnc:sum-collector-commodity 
+	   c report-currency 
+	   (lambda (a b) (exchange-fn a b date))))))
+
+      ;; This calculates the balances for all the 'accounts' for each
+      ;; element of the list 'dates'. If income?==#t, the signs get
+      ;; reversed according to income-sign-reverse general option
+      ;; settings. Uses the collector->double conversion function
+      ;; above. Returns a list of doubles.
+      (define (process-datelist accounts dates income?)
+	(map 
+	 (lambda (date)
+	   (collector->double
+	    ((if inc-exp?
+		 (if income?
+		     gnc:accounts-get-comm-total-income
+		     gnc:accounts-get-comm-total-expense)
+		 gnc:accounts-get-comm-total-assets)
+	     accounts 
+	     (lambda (account)
+	       (if inc-exp?
+		   ;; for inc-exp, 'date' is a pair of time values, else
+		   ;; it is a time value.
+		   (gnc:account-get-comm-balance-interval 
+		    account (first date) (second date) #f)
+		   (gnc:account-get-comm-balance-at-date 
+		    account date #f))))
+	    (if inc-exp? (second date) date)))
+	 dates))
+
       (if 
        (not (null? accounts))
-       (begin
+       (let* ((assets-list
+	       (process-datelist
+		(if inc-exp? 
+		    accounts
+		    (assoc-ref classified-accounts 'asset))
+		dates-list #t))
+	      (liability-list
+	       (process-datelist
+		(if inc-exp?
+		    accounts
+		    (assoc-ref classified-accounts 'liability))
+		dates-list #f))
+	      (net-list
+	       (map + assets-list liability-list))
+	      (date-string-list (map 
+				 (if inc-exp?
+				     (lambda (date-list-item)
+				       (gnc:timepair-to-datestring
+					(car date-list-item)))
+				     gnc:timepair-to-datestring)
+				 dates-list)))
 
 	 (gnc:html-barchart-set-title! 
 	  chart (if inc-exp? (_ "Income/Expense Chart") 
@@ -268,6 +264,7 @@
 	  chart (< (/ (- width 200) 
 		      (length date-string-list)) 60))
 	 
+	 ;; Add the data
 	 (if show-sep?
 	     (begin
 	       (add-column! assets-list)
@@ -277,6 +274,8 @@
 		)))
 	 (if show-net?
 	     (add-column! net-list))
+
+	 ;; Legend labels, colors
 	 (gnc:html-barchart-set-col-labels! 
 	  chart (append
 		 (if show-sep?
@@ -296,6 +295,7 @@
 		 (if show-net?
 		     '("green") '())))
 	 
+	 ;; URLs for income/expense or asset/liabilities bars.
 	 (if show-sep?
 	     (let ((urls
 		    (list
@@ -330,6 +330,7 @@
 	       (gnc:html-barchart-set-button-1-legend-urls! 
 		chart urls)))
 	 
+	 ;; Test for all-zero data here.
 	 (if non-zeros
 	     (gnc:html-document-add-object! document chart) 
 	     (gnc:html-document-add-object!
@@ -337,21 +338,19 @@
 	      (gnc:html-make-empty-data-warning))))
        
        ;; else no accounts selected
-
        (gnc:html-document-add-object!
 	document
 	(gnc:html-make-no-account-warning)))
-       
-	 
-	 document))
       
-      ;; Here we define the actual report
-      (gnc:define-report
-       'version 1
-       'name (N_ "Net Worth Barchart")
-       'menu-path (list gnc:menuname-asset-liability)
-       'options-generator (lambda () (options-generator #f))
-       'renderer (lambda (report-obj) (net-renderer report-obj #f)))
+      document))
+  
+  ;; Here we define the actual report
+  (gnc:define-report
+   'version 1
+   'name (N_ "Net Worth Barchart")
+   'menu-path (list gnc:menuname-asset-liability)
+   'options-generator (lambda () (options-generator #f))
+   'renderer (lambda (report-obj) (net-renderer report-obj #f)))
 
   (gnc:define-report
    'version 1
Index: gnucash/src/scm/report/price-scatter.scm
diff -u gnucash/src/scm/report/price-scatter.scm:1.8 gnucash/src/scm/report/price-scatter.scm:1.9
--- gnucash/src/scm/report/price-scatter.scm:1.8	Sat May 12 03:41:01 2001
+++ gnucash/src/scm/report/price-scatter.scm	Sat May 12 18:03:13 2001
@@ -160,9 +160,7 @@
 	   (currency-accounts 
 	    (filter gnc:account-has-shares? (gnc:group-get-subaccounts
 					     (gnc:get-current-group))))
-	   ;; some bogus data
-	   (data '((1.0 1.0) (1.1 1.2) (1.2 1.4) (1.3 1.6) 
-		   (2.0 1.0) (2.1 1.2) (2.2 1.4) (2.3 1.6))))
+	   (data '()))
       
       (gnc:html-scatter-set-title! 
        chart report-title)
@@ -225,13 +223,13 @@
 			(gnc:timepair-ge to-date-tp (first x))
 			(gnc:timepair-ge (first x) from-date-tp)))
 		     data))
-	 
+
 	 ;; some output
 	 ;;(warn "data" (map (lambda (x) (list
-	 ;;    (gnc:timepair-to-datestring (car x))
-	 ;;    (gnc:numeric-to-double (second x))))
-	 ;;data))
-
+	 ;;			(gnc:timepair-to-datestring (car x))
+	 ;;		(gnc:numeric-to-double (second x))))
+	 ;; data))
+	 
 	 ;; convert the gnc:numeric's to doubles
 	 (set! data (map (lambda (x) 
 			   (list (first x) 
@@ -257,20 +255,25 @@
 			    ('YearDelta 31536000)))
 		       (second x)))
 		    data))
-	 ))
-      
-      (gnc:html-scatter-set-data! 
-       chart data)
-      
-      (gnc:html-document-add-object! document chart) 
-      
-;;      (gnc:html-document-add-object! 
-;;       document 
-;;       (gnc:make-html-text 
-;;	(gnc:html-markup-p 
-;;	 "This report calculates the 'prices of commodity' transactions \
-;;versus the 'report commodity'. (I.e. it won't work if there's another \
-;;commodity involved in between.) cstim.")))
+	 
+	 (gnc:html-scatter-set-data! 
+	  chart data)
+	 
+	 (if (not (null? data))
+	     (gnc:html-document-add-object! document chart) 
+	     (gnc:html-document-add-object!
+	      document
+	      (gnc:html-make-empty-data-warning))))
+
+       ;; 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 \
+are identical. It doesn't make sense to show prices for identical \
+commodities.")))))
       
       document))
 
Index: gnucash/src/scm/report/view-column.scm
diff -u gnucash/src/scm/report/view-column.scm:1.8 gnucash/src/scm/report/view-column.scm:1.9
--- gnucash/src/scm/report/view-column.scm:1.8	Sat May 12 06:50:36 2001
+++ gnucash/src/scm/report/view-column.scm	Sat May 12 07:47:32 2001
@@ -191,7 +191,6 @@
            (reports
             (gnc:option-value
              (gnc:lookup-option options "__general" "report-list"))))
-      (simple-format #t "view options changed cb\n")
       (for-each 
        (lambda (child)
          (gnc:report-set-dirty?! (gnc:find-report (car child)) #t))
Index: gnucash/src/scm/report/welcome-to-gnucash.scm
diff -u gnucash/src/scm/report/welcome-to-gnucash.scm:1.4 gnucash/src/scm/report/welcome-to-gnucash.scm:1.5
--- gnucash/src/scm/report/welcome-to-gnucash.scm:1.4	Sat May 12 06:50:36 2001
+++ gnucash/src/scm/report/welcome-to-gnucash.scm	Sun May 13 05:05:38 2001
@@ -31,11 +31,11 @@
          (sub-income-pie (gnc:make-report "Income Accounts"))
          (sub-bar (gnc:make-report "Income/Expense Chart"))
          (options #f))
-    
+
     (define (set-option! section name value)
       (gnc:option-set-value 
        (gnc:lookup-option options section name) value))
-    
+
     (set! options (gnc:report-options (gnc:find-report view)))
     (set-option! "General" "Report name" "Welcome to GnuCash 1.6")
     (set-option! "General" "Number of columns" 2)
@@ -67,15 +67,13 @@
       (gnc:html-document-add-object! 
        doc
        (gnc:make-html-text 
-        (gnc:html-markup-h2 "Welcome to GnuCash 1.6!")
-        (gnc:html-markup-p 
-         "GnuCash 1.6 has lots of nice features. Here are a few.")
-        (gnc:html-markup-p 
-         "I know this is ugly.")))
+        (gnc:html-markup-h2 (_ "Welcome to GnuCash 1.6!"))
+        (gnc:html-markup-p
+         (_ "GnuCash 1.6 has lots of nice features. Here are a few."))))
       doc))
 
   (gnc:define-report 
-   'name "Welcome to GnuCash 1.6"
+   'name (N_ "Welcome to GnuCash 1.6")
    'in-menu? #f
    'options-generator options
    'renderer renderer))
Index: gnucash/src/test/Makefile.am
diff -u gnucash/src/test/Makefile.am:1.17 gnucash/src/test/Makefile.am:1.18
--- gnucash/src/test/Makefile.am:1.17	Fri Apr 13 01:54:26 2001
+++ gnucash/src/test/Makefile.am	Sun May 13 05:47:15 2001
@@ -44,6 +44,7 @@
 
 EXTRA_DIST = \
   README \
+  grab-types.pl \
   test-real-data.sh
 
 #test_dom_parser1_SOURCES = test-dom-parser1.c test-stuff.c gnc-test-stuff.c