daily diff

Dave Peticolas dave@krondo.com
Wed, 09 May 2001 12:56:35 -0700


This is a diff of gnucash development in the last 25 hours.
The diff is being posted for code review.


Index: gnucash/ChangeLog
diff -u gnucash/ChangeLog:1.432 gnucash/ChangeLog:1.436
--- gnucash/ChangeLog:1.432	Tue May  8 04:36:29 2001
+++ gnucash/ChangeLog	Wed May  9 03:55:25 2001
@@ -1,3 +1,45 @@
+2001-05-09  Dave Peticolas  <dave@krondo.com>
+
+	* src/doc/design/user-preferences.texinfo: update docs
+
+	* src/doc/design/reports.texinfo: update docs
+
+	* src/doc/design/top-level.texinfo: update docs
+
+	* src/doc/design/register.texinfo: update docs
+
+	* src/doc/design/component-manager.texinfo: update docs
+
+2001-05-09  Christian Stimming  <stimming@tuhh.de>
+
+	* src/scm/report/price-scatter.scm: Added new option: get weighted
+	average prices from the past, not only the instant prices.
+
+	* src/scm/commodity-utilities.scm
+	(gnc:get-commodity-totalaverage-prices): Added
+	function. Eventually this could be an extension/alternative to
+	prices from the pricedb.
+
+2001-05-09  Robert Graham Merkel  <rgmerk@mira.net>
+
+	* src/scm/report/net-barchart.scm: check for empty data
+	and empty account lists.
+
+	* src/scm/report/category-barchart.scm: check for empty
+	data, print a nice error message.
+
+	* src/scm/html-piechart.scm: now produces a warning if an
+	empty piechart is sent to it.
+
+	* src/scm/html-barchart.scm: now checks for and warns
+	against empty barcharts
+
+2001-05-08  Christian Stimming  <stimming@tuhh.de>
+
+	* src/scm/options-utilities.scm, src/scm/report/price-scatter.scm:
+	moved gnc:options-add-marker-choice! from price-scatter.scm to
+	options-utilities.scm.
+
 2001-05-08  Dave Peticolas  <dave@krondo.com>
 
 	* src/scm/price-quotes.scm: add currency quote support
Index: gnucash/README.cvs
diff -u gnucash/README.cvs:1.3 gnucash/README.cvs:1.7
--- gnucash/README.cvs:1.3	Mon May  7 15:23:41 2001
+++ gnucash/README.cvs	Wed May  9 03:55:29 2001
@@ -64,5 +64,3 @@
 
 Dave Peticolas
 May 2, 2001
-
-i
Index: gnucash/configure.in
diff -u gnucash/configure.in:1.182 gnucash/configure.in:1.183
--- gnucash/configure.in:1.182	Mon Apr 23 02:41:10 2001
+++ gnucash/configure.in	Tue May  8 21:42:46 2001
@@ -56,12 +56,15 @@
 
 DL_LIB=
 AC_CHECK_FUNCS(dlopen,,[
-AC_CHECK_LIB(dl, dlopen, DL_LIB="-ldl",[
-AC_CHECK_LIB(dld, shl_load, DL_LIB="-ldld",[
-AC_CHECK_FUNCS(dlopen, DL_LIB="",
-AC_MSG_ERROR(Dynamic linking is not available on this platform.  Some apps,
+  AC_CHECK_LIB(dl, dlopen, DL_LIB="-ldl",[
+    AC_CHECK_LIB(dld, shl_load, DL_LIB="-ldld",[
+      AC_CHECK_FUNCS(dlopen, DL_LIB="",
+      AC_MSG_ERROR(Dynamic linking is not available on this platform.  Some apps,
 like panel, will not run properly.))
-])])])
+    ])
+  ])
+])
+
 oLIBS="$LIBS"
 LIBS="$LIBS $DL_LIB"
 AC_CHECK_FUNCS(dlerror,,)
@@ -158,13 +161,48 @@
 
 ### --------------------------------------------------------------------------
 ### SQL
+# Check to see if the user wants to have Postgres support
+
 AC_ARG_ENABLE( sql,
   [  --enable-sql                 compile with sql support],
-       SQL_DIR=sql)
+  [
+    if test "x$enableval" != "xno" ; then
+      AC_CHECK_HEADERS(pgsql/libpq-fe.h postgresql/libpq-fe.h)
+      if test "x$ac_cv_header_pgsql_libpq_fe_h$ac_cv_header_postgresql_libpq_fe_h" == xnono; then
+         AC_MSG_ERROR([Cannot find PosgreSQL headers; won't build sql backend]) 
+      else 
+        if test "x$ac_cv_header_pgsql_libpq_fe_h" != xno; then
+          CFLAGS="${CFLAGS} -I/usr/include/pgsql"
+	fi
+        if test "x$ac_cv_header_postgresql_libpq_fe_h" != xno; then
+          CFLAGS="${CFLAGS} -I/usr/include/postgresql"
+	fi
+        
+        saved_LIBS="$LIBS"
+        LIBS="-lpq $LIBS"
+        AC_MSG_CHECKING(for libpq)
+        AC_TRY_LINK(
+          [
+	    #include <libpq-fe.h>
+	  ],
+          [
+             PQconnectdb("asdf");
+          ],
+          [
+            AC_MSG_RESULT(yes)
+            SQL_DIR=sql
+          ],
+          [
+            AC_MSG_ERROR([Cannot find PosgreSQL libraries; won't build sql backend]) 
+          ]
+        )
+      fi
+    fi
+  ]
+)
 
 AC_SUBST(SQL_DIR)
 
-
 ### --------------------------------------------------------------------------
 ### RPC
 AC_ARG_ENABLE( rpc,
@@ -355,7 +393,7 @@
 
 AC_CHECK_LIB(ghttp, ghttp_enable_ssl,
              AC_DEFINE(HAVE_OPENSSL),
-	     AC_MSG_WARN([ghttp does not have SSL support.]),
+	     AC_MSG_WARN([****** ghttp does not have SSL support.]),
 	     $GHTTP_LIBS)
 
 AC_SUBST(GTKHTML_LIBS)
Index: gnucash/src/doc/design/component-manager.texinfo
diff -u gnucash/src/doc/design/component-manager.texinfo:1.3 gnucash/src/doc/design/component-manager.texinfo:1.4
--- gnucash/src/doc/design/component-manager.texinfo:1.3	Mon Jan 15 05:09:28 2001
+++ gnucash/src/doc/design/component-manager.texinfo	Wed May  9 03:55:33 2001
@@ -336,6 +336,10 @@
 should never be mixed with the suspend/resume refresh routines.
 @end deftypefun
 
+@deftypefun gboolean gnc_gui_refresh_suspended (void)
+Returns TRUE if GUI refreshing is currently suspended.
+@end deftypefun
+
 
 @node Finding Components, Iterating over Components, Controlling Refreshes, Component Manager
 @section Finding Components
Index: gnucash/src/doc/design/engine.texinfo
diff -u gnucash/src/doc/design/engine.texinfo:1.28 gnucash/src/doc/design/engine.texinfo:1.29
--- gnucash/src/doc/design/engine.texinfo:1.28	Thu Feb 22 00:07:24 2001
+++ gnucash/src/doc/design/engine.texinfo	Wed May  9 03:55:34 2001
@@ -39,24 +39,24 @@
 
 Splits (@pxref{Splits}), or "Ledger Entries" are the fundamental
 accounting units. Each Split consists of a quantity (number of dollar
-bills, number of shares, etc.), the price of that quantity (the price of
-one dollar is 1.00 dollars, etc.), a Memo, a pointer to the parent
-Transaction, a pointer to the debited Account, a reconciled flag and
-timestamp, an "Action" field, and a key-value frame which can store
-arbitrary data (@pxref{Key-Value Pair Frames}).
+bills, number of shares, etc.), the value of that quantity expressed in
+a (possibly) different currency than the quantity, a Memo, a pointer to
+the parent Transaction, a pointer to the debited Account, a reconciled
+flag and timestamp, an "Action" field, and a key-value frame which can
+store arbitrary data (@pxref{Key-Value Pair Frames}).
 
 Transactions (@pxref{Transactions}) embody the notion of "double entry"
 accounting. A Transaction consists of a date, a description, a number, a
 list of one or more Splits, and a key-value frame. When double-entry
-rules are enforced, the total value of the splits is zero.  Note that if
+rules are enforced, the total value of the splits is zero. Note that if
 there is just one split, its value must be zero for double-entry
 accounting; this used to be used for storing prices, but with the advent
-of the pricedb, zero-valued splits are probably best avoided. If there
-are two splits, then the value of one must be positive, the other
-negative: this denotes that one account is credited, and another is
-debited by an equal amount. Positive Split values are 'debits' and
-negative Split values are 'credits'.  Ensuring the Splits to 'add up' to
-zero causes a double-entry accounting system to always balance.
+of the Price DB, this is no longer the case. If there are two splits,
+then the value of one must be positive, the other negative: this denotes
+that one account is debited, and another is credited by an equal
+amount. Positive Split values are 'debits' and negative Split values are
+'credits'. Ensuring the Splits to 'add up' to zero causes a double-entry
+accounting system to always balance.
 
 The engine does not enforce double-entry accounting, but provides an API
 to enable user-code to find unbalanced transactions and 'repair' them so
@@ -65,20 +65,19 @@
 Note the sum of the values of Splits in a Transaction is always computed
 with respect to a currency; thus splits can be balanced even when they
 are in different currencies, as long as they share a common currency.
-The conversion price is simply the price stored in the Split. This
-feature allows currency-trading accounts to be established.
+This feature allows currency-trading accounts to be established.
 
-Every Split must point at its parent Transaction, and that Transaction
+Every Split must point to its parent Transaction, and that Transaction
 must in turn include that Split in the Transaction's list of Splits. A
 Split can belong to at most one Transaction. These relationships are
-forced by the engine. The engine user cannnot accidentally destroy this
-relationship as long as they stick to using the API and never access
-internal structures directly.
+enforced by the engine. The engine user cannnot accidentally destroy
+this relationship as long as they stick to using the API and never
+access internal structures directly.
 
 Splits are grouped into Accounts (@pxref{Accounts}) which are also known
-as "Ledgers" in accouting practice. Each Account consists of a list of
+as "Ledgers" in accounting practice. Each Account consists of a list of
 Splits that debit that Account. To ensure consistency, if a Split points
-at an Account, then the Account must point at the Split, and vice-versa.
+to an Account, then the Account must point to the Split, and vice-versa.
 A Split can belong to at most one Account. Besides merely containing a
 list of Splits, the Account structure also give the Account a name, a
 code number, description and notes fields, a key-value frame, a pointer
@@ -1138,14 +1137,13 @@
 This is the number of 'shares' which have been debited to the parent
 Account. This quantity may be negative, in which case the Split
 represents a 'credit'. Shares are given in units of the security of the
-Account, unless the security field is blank, in which case shares are
+Account, unless the security field is NULL, in which case shares are
 given in units of the Account currency. @xref{Accounts}.
 
-@item A 'price'
-This represents the price of the shares. The price is a ratio of the
-parent Account currency to the parent Account security. For most Accounts,
-the security is blank, and thus the price is @code{1.0}, since the currency
-effectively is the security. @xref{Accounts}.
+@item A 'value'
+This represents the value of the shares in units of the currency of
+the Account. If the currency and the security are the same, or the
+security field is NULL, the value and share quantity must be equal.
 
 @item A 'reconciled' flag
 This flag represents the reconciled status of the Split. Possible
@@ -1231,12 +1229,12 @@
 @end deftypefun
 
 @deftypefun gnc_numeric xaccSplitGetSharePrice (Split * @var{split})
-Return the 'share price' of @var{split}.
+Return the 'share price' of @var{split}, which is the value
+divided by the share quantity.
 @end deftypefun
 
 @deftypefun gnc_numeric xaccSplitGetValue (Split * @var{split})
-Return the value of @var{split}, which is equal to the share quantity
-multiplied by the share price.
+Return the value of @var{split}.
 @end deftypefun
 
 @deftypefun gnc_numeric xaccSplitGetBaseValue (Split * @var{split}, const char * @var{base_currency})
@@ -1617,7 +1615,7 @@
 @tindex GNCBook
 
 The @dfn{GNCBook} interface encapsulate all the information about a
-gnucash dataset, including the methods used to read and write the
+GnuCash dataset, including the methods used to read and write the
 dataset to datastores.  This class provides several important services:
 
 @itemize
@@ -1663,7 +1661,7 @@
 implementation, only one type of URI is supported, and that is the file
 URI: anything of the form @url{file:/home/somewhere/somedir/file.xac}
 The path part must be a valid path.  The file-part must be a valid
-gnucash data file. Paths may be relative or absolute. If the path is
+GnuCash data file. Paths may be relative or absolute. If the path is
 relative; that is, if the argument is @url{file:somefile.xac} then a
 sequence of search paths are checked for a file of this name.
 
Index: gnucash/src/doc/design/gnucash-design.texinfo
diff -u gnucash/src/doc/design/gnucash-design.texinfo:1.25 gnucash/src/doc/design/gnucash-design.texinfo:1.26
--- gnucash/src/doc/design/gnucash-design.texinfo:1.25	Thu Jan 11 04:38:55 2001
+++ gnucash/src/doc/design/gnucash-design.texinfo	Wed May  9 03:55:37 2001
@@ -155,6 +155,10 @@
 
 * BasicCell::                   
 
+Reports
+
+* Creating a Report::
+
 User Preferences
 
 * Option Databases::            
Index: gnucash/src/doc/design/register.texinfo
diff -u gnucash/src/doc/design/register.texinfo:1.6 gnucash/src/doc/design/register.texinfo:1.7
--- gnucash/src/doc/design/register.texinfo:1.6	Thu Jan 11 04:38:55 2001
+++ gnucash/src/doc/design/register.texinfo	Wed May  9 03:55:37 2001
@@ -4,7 +4,7 @@
 
 The register is an infrastructure for building a modular matrix of cells
 in which each cell may be specialized to perform a particular function,
-e.g., to read dates, numerical amounts, or text.  The register has been
+e.g., to read dates, numerical amounts, or text. The register has been
 designed to be easy to extend, modular, easy to maintain, and memory
 efficient. It is intended to be used for building financial apps and
 spread-sheets.
@@ -63,47 +63,27 @@
 @item char *value
 The 'value' of the cell stored as a character string.
 
-@item guint8 input_output
-This is a bit field used for storing flag values. The following flag
-values are defined.
-
-  @table @code
-
-  @item XACC_CELL_ALLOW_INPUT
-  If set, the cell will may accept keyboard and mouse input from the
-  user. Otherwise, the cell is for display only.
-
-  @item XACC_CELL_ALLOW_SHADOW
-  If set, the cell will 'shadow' the contents of the register which it
-  is contained in. In other words, as the cell is moved to new locations,
-  the value of the register at that location will be copied into the cell.
-
-  @item XACC_CELL_ALLOW_EXACT_ONLY
-  If set, the cell may only be entered by 'exact' indication of the
-  user. Currently, this means the user must click on the cell with the
-  mouse. This flag will prevent the cell from being tabbed into.
+@item GdkWChar *w_value
+The 'value' of the cell stores as a wide character string.
 
-  @end table
+@item gint value_len
+The length of w_value.
 
 @item guint32 changed
 This member is set to have all 1-bits (2^32 - 1) to indicate the
 cell contents have been changed from the register value.
 
+@item guint32 conditionally_changed
+This member is set to have all 1-bits (2^32 - 1) to indicate the
+cell contents have been changed from the register value, but that
+the register should not be considered to be changed unless other
+cells have been changed (not conditionally).
+
 @item char * blank_help
 This member is a text string which may be used by a GUI implementation
 to display an informative help string when the value of a cell is empty
 (perhaps prompting the user to enter a particular kind of value).
 
-@item guint32 bg_color
-@itemx guint32 fg_color
-An RGB value indicating the background (foreground) color to render the
-cell with.
-
-@item gboolean use_bg_color
-@itemx gboolean use_fg_color
-A boolean value indicating whether to use the @code{bg_color}
-(@code{fg_color}) member.
-
 @end table
 
 
@@ -112,9 +92,7 @@
 
 A @dfn{Cellblock} is an array of active cells. The cells are laid out in
 rows and columns. The cellblock serves as a convenient container for
-organizing active cells in an array. It provides several functions.
-First, it defines a tab-group (group of cells that can be traversed by
-hitting the tab-key). More importantly, through the mechanism of Cursors
+organizing active cells in an array. Through the mechanism of Cursors
 (defined below), it allows a group of cells to be treated as a single
 transactional entity. That is, the cursor/cellblock allows all edits to
 a groups of cells to be simultaneously committed or rejected by
@@ -126,16 +104,16 @@
 @section Table
 
 The @dfn{Table} is a displayed matrix. The table is a complex object;
-it is NOT merely a cellblock.  The table provides all of the GUI
+it is @emph{not} merely a cellblock. The table provides all of the GUI
 infrastructure for displaying a row-column matrix of strings.
 
 The table provides one very important function for minimizing memory
-usage for large matrixes. It defines the notion of a @dfn{Cursor}. The
-cursor is a cellblock (an array of active cells) that is moved to the
-location that the user is currently editing. The cursor "virtualizes"
-cell functions; that is, it makes it seem to the user as if all cells in
-the table are active, when in fact the only cell that actually needs to
-be active is the one that the user is currently editing.
+usage for large matrixes -- the notion of a @dfn{Cursor}. The cursor is
+a cellblock (an array of active cells) that is moved to the location
+that the user is currently editing. The cursor "virtualizes" cell
+functions; that is, it makes it seem to the user as if all cells in the
+table are active, when in fact the only cell that actually needs to be
+active is the one that the user is currently editing.
 
 The table design allows multiple cursors to be defined. When a user
 enters a cell, the appropriate cursor is positioned within the table.
@@ -148,13 +126,18 @@
 transaction. This is very different from a checkbook register, where all
 entries are uniform, and can be handled with a single repeated cursor.
 
+Users of the table must provide a TableView object which provides an API
+the table uses to obtain information about the data it is displaying
+such as strings, colors, etc. Thus, the table represents the non-GUI
+portion of the View object in the Model-View-Controller paradigm.
+
 
 @node Split Register,  , Table, Register
 @section Split Register
 
 The split register is a special-purpose object aimed at the display
 of financial transactions. It includes cells for the date, prices,
-balances, transfer accounts, etc.  The register is where the cells,
+balances, transfer accounts, etc. The register is where the cells,
 cursor and table get put together into a unified whole. The register
 defines specific, actual layouts and widths of the date, price, etc.
 cells in a table. It includes a table header, and defines more than
@@ -168,7 +151,7 @@
 mind.
 
 The second component (src/SplitLedger.[ch]) implements the full register
-behavior and makes full use of the Engine API. This component is
-responsible for loading transactions and splits into the register,
-modifying transactions and splits according to user input, and
-accomplishing tasks such as performing automatic completion.
+behavior (the Controller in MVC) and makes full use of the Engine
+API. This component is responsible for loading transactions and splits
+into the register, modifying transactions and splits according to user
+input, and accomplishing tasks such as performing automatic completion.
Index: gnucash/src/doc/design/reports.texinfo
diff -u gnucash/src/doc/design/reports.texinfo:1.6 gnucash/src/doc/design/reports.texinfo:1.7
--- gnucash/src/doc/design/reports.texinfo:1.6	Fri Nov 17 20:27:08 2000
+++ gnucash/src/doc/design/reports.texinfo	Wed May  9 03:55:38 2001
@@ -1,6 +1,39 @@
 @node Reports, User Preferences, Register, Top
 @chapter Reports
+@cindex Reports
 
+The reporting infrastructure is designed facilitate the creation
+of sophisticated reports including tables, graphs, and hyperlinks.
+The infrastructure includes functionality to support the following:
+
+@itemize
+
+@item
+Creation of tables, with headings, subheadings, totals, and subtotals.
+
+@item
+Formatting of dates & numbers.
+
+@item
+Currency conversions.
+
+@item
+Create of graphs such as pie and bar charts.
+
+@item
+Creation of hyperlinks to other reports and to other GnuCash
+objects such as registers.
+
+@end itemize
+
+@menu
+* Creating a Report::           
+@end menu
+
+
+@node Creating a Report,  , Reports, Reports
+@section Creating a Report
+
 To define a report, your report must have 
 
 @code{(gnc:support <your_report_name>)}
@@ -11,9 +44,10 @@
 
 as well as
 
-@code{(gnc:depend "html-generator.scm")}
+@code{(gnc:depend "report-html.scm")}
  
-if you wish to use the html table generation facilities.
+if you wish to use the html generation facilities. You should
+avoid creating HTML directly wherever possible.
 
 To autoload your report, you should add the line @code{(gnc:depend
 <your_report_name>)} to the file @file{src/scm/report/report-list.scm}.
@@ -24,51 +58,33 @@
 
 To define a report, you call @code{(gnc:define-report)}. This function
 can accept a variable number of arguments, but at the moment four
-distinct arguments are recognised, as in like the following from
+distinct arguments are recognised, as in the following from
 the transaction report:
 
 @example
   (gnc:define-report
    'version 1
-   'name (string-db 'lookup 'title)
+   'name (N_ "Transaction Report")
    'options-generator trep-options-generator
-   'renderer gnc:trep-renderer)
+   'renderer trep-renderer)
 @end example
 
 @table @code
 
-@item 'version
+@item version
 This is the version number of the report, which is currently ignored.
 
-@item 'name
-This is self-explanatory.
+@item name
+This is the name of the report. It should be marked as translatable,
+but the name should be given in untranslated form, hence the use of
+@code{(N_ )}.
 
-@item 'options-generator
+@item options-generator
 This should be a function that takes no arguments and returns an options
-structure with the options for the report.  The options interface is
+structure with the options for the report. The options interface is
 currently not fully documented, but should be.
 
-@item 'renderer
-This is a function that takes one argument - a set of options that use
-the options API. It returns a list, which either contains strings, or
-lists which only contain strings or lists of the same type.  When
-flattened and concatenated these strings should form the HTML of the
-report.
+@item renderer
+This is the function which renders the HTML.
 
 @end table
-
-To generate the HTML, you can write your own HTML generation code, or
-use the functions in html-generator.scm. These are already quite well
-documented in the source code itself. To use the HTML generation code,
-you build a structure containing a list of report columns, and for each
-column write functions that, given a report entry, generate the text for
-the cell, as well as column headers and column totals. This interface
-is quite likely to change.
-
-At the moment, the only tools for collecting summary information are
-@code{gnc:account-get-balance-interval} and
-@code{gnc:group-get-balance-interval}. As we start to calculate more
-sophisticated summary statistics (particularly for stock and investment
-tracking), we will add to these. Extracting data from accounts is also
-done directly ATM, but we shall soon use the Query API to do this. The
-Query API therefore needs some user-level documentation as well.
Index: gnucash/src/doc/design/top-level.texinfo
diff -u gnucash/src/doc/design/top-level.texinfo:1.4 gnucash/src/doc/design/top-level.texinfo:1.5
--- gnucash/src/doc/design/top-level.texinfo:1.4	Tue Sep 19 19:33:40 2000
+++ gnucash/src/doc/design/top-level.texinfo	Wed May  9 03:55:38 2001
@@ -1,24 +1,24 @@
 @node Top Level, Engine, Introduction, Top
 @chapter Architectural Overview
 
-GnuCash is written primarily in two languages: C and Scheme.
-The engine/server is written in C primarily for speed,
-portability, stability and historical purposes.  Much of the
-day-to-day workhorse code is written in Scheme, primarily
-for its power, expressiveness and ease of development.
-The user interface is gtk/gnome, some of it done up in C,
-some in scheme, and some with the
-GUI designer tool glade @uref{glade.pn.org}.
+GnuCash is written primarily in two languages: C and Scheme. The
+engine/server is written in C primarily for speed, portability,
+stability and historical purposes. Much of the day-to-day workhorse code
+is written in Scheme, primarily for its power, expressiveness and ease
+of development.  The user interface is Gtk/Gnome, some of it written in
+C, some in scheme, and some with the GUI designer tool Glade
+@uref{glade.pn.org}.
 
 GnuCash is modular, thereby allowing separate individuals
 to maintain, develop and enhance certain modules without
-disturbing the overall development.  (Never mind that 
+disturbing the overall development. (Never mind that 
 modules help avoid spaghetti code and nasty, ugly hacks).
 The interfaces between modules are documented, and, for the
 most part, stable and unchanging.
 
 GnuCash currently consists of the following modules:
 
+
 @section The Engine
 
 The @dfn{Engine} (located under the @file{src/engine} directory in the
@@ -41,9 +41,21 @@
 
 The @dfn{File I/O} module (@file{src/engine/FileIO.*}) provides an
 interface for reading and writing a set of Accounts, Transactions, and
-Splits to a binary file. This module is being deprecated. A text-based
-format using scheme forms is being developed as a replacement. This new
-module will be separate from the Engine.
+Splits to a binary file. This module is deprecated.
+
+@subsection XML I/O
+
+The @dfn{XML I/O} module (@file{src/engine/*xml*.*} and
+@file{src/engine/*sixtp*.*}) provides an interface for reading and
+writing the engine information to an XML format.
+
+@subsection Backend
+
+The @dfn{Backend} module (@file{src/engine/Backend*.*}) provides
+hooks to allow different modules to be used for storing and retrieving
+Engine data. There are two backends currently under development, a
+Postgresql backend (@file{src/engine/sql/*}) and an RPC backend
+(@file{src/engine/rpc/*}).
 
 
 @section The Register
@@ -75,23 +87,23 @@
 balance sheets, profit & loss statements, etc. by using the engine
 API to fetch and display data formatted in HTML.
 
-This module is being redesigned to use the Query API to fetch the engine
-information instead of using the raw engine interface. The new reporting
-design will use Queries to extract the data and assemble it into a
-view-independent format. This data will then be converted to HTML
-reports and/or graphs such as bar and pie charts.
+For the most part, this module uses the Query API to fetch the engine
+information instead of using the raw engine interface. This design uses
+Queries to extract the data and assemble it into a view-independent
+format. This data is then be converted to HTML reports and/or graphs
+such as bar and pie charts.
 
 
 @section Graphs
 
-The @dfn{Graphs} module will be a future module implementing GUI graphs
-such as bar and pie charts. These graphs will be interactive in that the
-user can, for example, move pie wedges, and 'live' in that the user will
-be able to click on graph subsections to see a detail graph or report of
-that particular subsection.
+The @dfn{Graphs} module implements GUI graphs such as bar and pie
+charts. These graphs can be interactive in that the user can, for
+example, move pie wedges, and 'live' in that the user can click on graph
+subsections to see a detail graph or report of that particular
+subsection.
 
-This module will be implemented using the GUPPI library being developed
-by Jon Trowbridge (@url{http://www.gnome.org/guppi}).
+This module is implemented using the GUPPI library being developed by
+Jon Trowbridge (@url{http://www.gnome.org/guppi}).
 
 
 @section Price Quotes
@@ -146,5 +158,6 @@
 and the ease of use for the beginner.
 
 Currently, the Gnome interface is the only operational interface. There
-is an obsolete Motif interface which is not maintained. The Qt code
-won't compile, and most/all functions are missing.
+is an obsolete Motif interface which is not maintained and which is
+removed in current CVS. There is also old Qt code (removed in current
+CVS) which won't compile, and most/all functions are missing.
Index: gnucash/src/doc/design/user-preferences.texinfo
diff -u gnucash/src/doc/design/user-preferences.texinfo:1.2 gnucash/src/doc/design/user-preferences.texinfo:1.3
--- gnucash/src/doc/design/user-preferences.texinfo:1.2	Tue Sep  5 02:09:19 2000
+++ gnucash/src/doc/design/user-preferences.texinfo	Wed May  9 03:55:39 2001
@@ -3,17 +3,17 @@
 @cindex User Preferences
 
 The options system is used to obtain user preferences, both globally,
-and when displaying a report.  A wide variety of option types are
+and when displaying a report. A wide variety of option types are
 supported, so it should be possible to create an option for just about
 any property the user might wish to specify.  New option types can be
 added if necessary, but as the process requires detailed knowledge of
-gnucash internals and GTK+/GNOME, it is not documented here.
+GnuCash internals and GTK+/GNOME, it is not documented here.
 
 At present, users are most likely to come across the options system when
 designing custom reports, and are consequently mostly going to use the
-Scheme interface.  There is also a C interface to much of the options
+Scheme interface. There is also a C interface to much of the options
 system which is used to access preferences for the UI, but it is not yet
-documented..
+documented.
 
 @menu
 * Option Databases::            
@@ -47,7 +47,7 @@
 Sometimes, GnuCash requires the user to specify true/false properties.
 Others properties most easily specified by selections from a list,
 others from a number, others still by selecting dates, or one or more
-accounts in the account hierachy, or even colors.  Gnucash supports all
+accounts in the account hierachy, or even colors.  GnuCash supports all
 of these and more:
 
 @table @code
@@ -96,6 +96,14 @@
 For specifying a numeric quantity.  The programmer can bound the range
 and precision of the quantity.
 
+@item pixmap
+
+For selecting a pixmap located on the filesystem.
+
+@item color
+
+For selecting a color value.
+
 @item internal
 
 An option that isn't specified through an options dialog box.  For
@@ -256,7 +264,7 @@
 Create an option that isn't controlled through the options GUI.  This is
 used mainly by the GUI to store state that should be preserved from 
 session to session but isn't really configurable from a dialog box, 
-such as the size of the gnucash main window.  
+such as the size of the GnuCash main window.  
 @end deffn
 
 @deffn Function gnc:make-number-range-option section name sort-tag documentation-string default-value lower-bound upper-bound num-decimals step-size
@@ -291,4 +299,3 @@
 which needs to be fixed).
 
 @end deffn
-
Index: gnucash/src/engine/sql/PostgresBackend.c
diff -u gnucash/src/engine/sql/PostgresBackend.c:1.35 gnucash/src/engine/sql/PostgresBackend.c:1.36
--- gnucash/src/engine/sql/PostgresBackend.c:1.35	Tue Apr 17 04:32:06 2001
+++ gnucash/src/engine/sql/PostgresBackend.c	Tue May  8 21:42:47 2001
@@ -25,7 +25,7 @@
 #include <sys/types.h>  
 #include <unistd.h>  
 
-#include <pgsql/libpq-fe.h>  
+#include <libpq-fe.h>  
 
 #include "AccountP.h"
 #include "Backend.h"
Index: gnucash/src/engine/sql/PostgresBackend.h
diff -u gnucash/src/engine/sql/PostgresBackend.h:1.9 gnucash/src/engine/sql/PostgresBackend.h:1.10
--- gnucash/src/engine/sql/PostgresBackend.h:1.9	Wed Feb 21 01:49:57 2001
+++ gnucash/src/engine/sql/PostgresBackend.h	Tue May  8 21:42:47 2001
@@ -13,7 +13,7 @@
 #ifndef __POSTGRES_BACKEND_H__
 #define __POSTGRES_BACKEND_H__
 
-#include <pgsql/libpq-fe.h>
+#include <libpq-fe.h>
 
 #include "Group.h"
 #include "guid.h"
Index: gnucash/src/engine/sql/README
diff -u gnucash/src/engine/sql/README:1.22 gnucash/src/engine/sql/README:1.23
--- gnucash/src/engine/sql/README:1.22	Tue May  8 13:24:07 2001
+++ gnucash/src/engine/sql/README	Tue May  8 21:42:48 2001
@@ -17,9 +17,11 @@
     have a GUI to ask for your password yet)
 
 5) (optional) enable TCPIP connections to remote hosts. To do this:
-   edit the file /var/lib/pgsql/pg_hba.conf on the remote host to
-   configure and allow access from other hosts.  See 'man pg_hba.conf'
-   for details.  Also create users.  Be sure to set a password.
+   edit the file pg_hba.conf on the remote host to configure and allow 
+   access from other hosts.  See 'man pg_hba.conf' for details.  
+        RedHat:   /var/lib/pgsql/pg_hba.conf  
+	Debian:   /etc/postgresql/pg_hba.conf 
+   Also create users.  Be sure to set a password.
    (there appears to be no way to pass an empty password to postgres)
    Note also the user must have 'createuser' permissions in order to 
    lock tables (this is a bug in postgres 6.5 and maybe later ???)
@@ -54,7 +56,9 @@
 
 GnuCash Build Instructions
 --------------------------
-Same as usual, but you want to specify the flag '--enable-sql' i.e. 
+Same as usual, but you must specify the flag '--enable-sql' in order
+to build in Postrges support.  
+i.e. 
 ./configure --enable-sql
 and then 'make'.
 
Index: gnucash/src/engine/sql/checkpoint.c
diff -u gnucash/src/engine/sql/checkpoint.c:1.4 gnucash/src/engine/sql/checkpoint.c:1.5
--- gnucash/src/engine/sql/checkpoint.c:1.4	Sun Feb 25 22:30:33 2001
+++ gnucash/src/engine/sql/checkpoint.c	Tue May  8 21:42:48 2001
@@ -17,7 +17,7 @@
 #include <string.h>  
 #include <sys/types.h>  
 
-#include <pgsql/libpq-fe.h>  
+#include <libpq-fe.h>  
 
 #include "Account.h"
 #include "AccountP.h"
Index: gnucash/src/engine/sql/putil.h
diff -u gnucash/src/engine/sql/putil.h:1.3 gnucash/src/engine/sql/putil.h:1.4
--- gnucash/src/engine/sql/putil.h:1.3	Mon Feb 19 02:38:54 2001
+++ gnucash/src/engine/sql/putil.h	Tue May  8 21:42:48 2001
@@ -17,7 +17,7 @@
 #include <string.h>  
 #include <sys/types.h>  
 
-#include <pgsql/libpq-fe.h>  
+#include <libpq-fe.h>  
 
 #include "Backend.h"
 #include "BackendP.h"
Index: gnucash/src/gnome/gnc-html-guppi.c
diff -u gnucash/src/gnome/gnc-html-guppi.c:1.13 gnucash/src/gnome/gnc-html-guppi.c:1.14
--- gnucash/src/gnome/gnc-html-guppi.c:1.13	Thu May  3 02:56:46 2001
+++ gnucash/src/gnome/gnc-html-guppi.c	Wed May  9 03:27:03 2001
@@ -38,6 +38,7 @@
 #include "gnc-html-guppi.h"
 #include "gnc-ui-util.h"
 
+static short module = MOD_GUI;
 
 static int handle_piechart(gnc_html * html, GtkHTMLEmbedded * eb, gpointer d);
 static int handle_barchart(gnc_html * html, GtkHTMLEmbedded * eb, gpointer d);
@@ -193,6 +194,31 @@
     strings[count] = NULL;
   }
   g_free(strings);
+}
+
+
+/* 
+ * if at least one is non-zero, return TRUE
+ * ie TRUE==good
+ */
+
+static gboolean
+check_doubles(double *numbers, int size)
+{
+  int count;
+
+  for(count = 0;count < size; count++)
+  {
+    /* FIXME: floating point equalities are strictly evil but 
+     * it shouldn't catch us here
+     */
+    if(numbers[count] != 0.0)
+    {
+      return TRUE;
+    }
+  }
+
+  return FALSE;
 }
 
 
Index: gnucash/src/scm/commodity-utilities.scm
diff -u gnucash/src/scm/commodity-utilities.scm:1.12 gnucash/src/scm/commodity-utilities.scm:1.13
--- gnucash/src/scm/commodity-utilities.scm:1.12	Tue May  8 03:02:54 2001
+++ gnucash/src/scm/commodity-utilities.scm	Wed May  9 03:52:08 2001
@@ -83,6 +83,82 @@
   (gnc:get-match-commodity-splits currency-accounts end-date-tp #f))
 
 
+;; Create a list of all prices of 'price-commodity' measured in the
+;; currency 'report-currency'. The prices are taken from all splits in
+;; 'currency-accounts' up until the date 'end-date-tp'. Returns a list
+;; of lists. Each element-list looks like (time price), where 'time'
+;; is the timepair when the 'price' was valid.
+(define (gnc:get-commodity-totalaverage-prices
+	 currency-accounts end-date-tp price-commodity report-currency)
+  (let ((total-foreign (gnc:numeric-zero))
+	(total-domestic (gnc:numeric-zero)))
+    (map-in-order
+     (lambda (a)
+       (let* ((transaction-comm (gnc:transaction-get-commodity 
+				 (gnc:split-get-parent a)))
+	      (account-comm (gnc:account-get-commodity 
+			     (gnc:split-get-account a)))
+	      (share-amount (gnc:numeric-abs
+			     (gnc:split-get-share-amount a)))
+	      (value-amount (gnc:numeric-abs
+			     (gnc:split-get-value a)))
+	      (transaction-date (gnc:transaction-get-date-posted
+				 (gnc:split-get-parent a)))
+	      (foreignlist
+	       (if (gnc:commodity-equiv? transaction-comm 
+					 price-commodity)
+		   (list account-comm
+			 share-amount value-amount)
+		   (list transaction-comm
+			 value-amount share-amount))))
+	 
+;	 (warn "render-scatterplot: value " 
+;	       (commodity-numeric->string
+;		(first foreignlist) (second foreignlist))
+;	       " bought shares "
+;	       (commodity-numeric->string
+;		price-commodity (third foreignlist)))
+	 
+	 (list
+	  transaction-date
+	  (if (not (gnc:commodity-equiv? (first foreignlist) 
+					 report-currency))
+	      (begin
+		(warn "totalaverage-prices: " 
+		      "Sorry, currency exchange not yet implemented:"
+		      (commodity-numeric->string
+		       (first foreignlist) (second foreignlist))
+		      " (buying "
+		      (commodity-numeric->string
+		       price-commodity (third foreignlist))
+		      ") =? "
+		      (commodity-numeric->string
+		       report-currency (gnc:numeric-zero)))
+		(gnc:numeric-zero))
+	      (begin
+		(set! total-foreign (gnc:numeric-add-fixed 
+				     total-foreign (third foreignlist)))
+		(set! total-domestic (gnc:numeric-add-fixed 
+				      total-domestic (second foreignlist)))
+		(gnc:numeric-div 
+		 total-domestic
+		 total-foreign
+		 GNC-DENOM-AUTO 
+		 (logior (GNC-DENOM-SIGFIGS 8) GNC-RND-ROUND)))))))
+     ;; Get all the interesting splits, and sort them according to the
+     ;; date.
+     (sort 
+      (gnc:get-match-commodity-splits 
+       currency-accounts 
+       end-date-tp price-commodity)
+      (lambda (a b)
+	(gnc:timepair-lt
+	 (gnc:transaction-get-date-posted
+	  (gnc:split-get-parent a))
+	 (gnc:transaction-get-date-posted
+	  (gnc:split-get-parent b)))))
+     )))
+  
 ;; Go through all toplevel non-report-commodity balances in sumlist
 ;; and add them to report-commodity, if possible. This function takes
 ;; a sumlist (described below) and returns an alist similar to one
Index: gnucash/src/scm/html-barchart.scm
diff -u gnucash/src/scm/html-barchart.scm:1.8 gnucash/src/scm/html-barchart.scm:1.9
--- gnucash/src/scm/html-barchart.scm:1.8	Sun Apr 15 03:34:07 2001
+++ gnucash/src/scm/html-barchart.scm	Wed May  9 03:27:05 2001
@@ -228,6 +228,17 @@
        (set! rownum (+ 1 rownum)))
      newcol)))
 
+(define (gnc:not-all-zeros data)
+  (define (myor list)
+    (begin 
+      (gnc:debug "list" list)
+      (if (null? list) #f
+	  (or (car list) (myor (cdr list))))))
+
+  (cond ((number? data) (not (= 0 data)))
+	((list? data) (myor (map gnc:not-all-zeros data)))
+	(else #f)))
+
 (define (gnc:html-barchart-prepend-column! barchart newcol)
   (let ((rows (gnc:html-barchart-data barchart))
         (this-row #f)
@@ -309,6 +320,7 @@
          (x-label (gnc:html-barchart-x-axis-label barchart))
          (y-label (gnc:html-barchart-y-axis-label barchart))
          (data (gnc:html-barchart-data barchart))
+	 (dummy1 (gnc:debug "data " data))
          (row-labels (catenate-escaped-strings 
                       (gnc:html-barchart-row-labels barchart)))
          (col-labels (catenate-escaped-strings 
@@ -316,7 +328,8 @@
          (col-colors (catenate-escaped-strings 
                       (gnc:html-barchart-col-colors barchart))))
     (if (and (list? data)
-             (not (null? data)))
+             (not (null? data))
+	     (gnc:not-all-zeros data))
         (begin 
           (push "<object classid=\"gnc-guppi-bar\" width=")
           (push (gnc:html-barchart-width barchart))
@@ -421,5 +434,7 @@
 		    "0\">\n"))
           (push "Unable to push bar chart\n")
           (push "</object> &nbsp;\n"))
-        " ")
+        (begin 
+	  (gnc:warn "barchart has no non-zero data.")
+	  " "))
     retval))
Index: gnucash/src/scm/html-piechart.scm
diff -u gnucash/src/scm/html-piechart.scm:1.6 gnucash/src/scm/html-piechart.scm:1.7
--- gnucash/src/scm/html-piechart.scm:1.6	Wed Mar 28 17:02:19 2001
+++ gnucash/src/scm/html-piechart.scm	Wed May  9 03:27:05 2001
@@ -259,7 +259,8 @@
                 (push "\">\n")))
           (push "Unable to display pie chart\n")
           (push "</object> &nbsp;\n"))
-        " ")
+	(begin (gnc:warn "null-data, not rendering piechart")
+	       " "))
     retval))
 
 
Index: gnucash/src/scm/html-utilities.scm
diff -u gnucash/src/scm/html-utilities.scm:1.34 gnucash/src/scm/html-utilities.scm:1.35
--- gnucash/src/scm/html-utilities.scm:1.34	Mon Apr 30 21:14:17 2001
+++ gnucash/src/scm/html-utilities.scm	Wed May  9 03:27:05 2001
@@ -661,4 +661,13 @@
      (gnc:html-markup-h2 (_ "No accounts selected"))
      (gnc:html-markup-p
       (_ "This report requires accounts to be selected.")))
+    p))
+
+(define (gnc:html-make-empty-data-warning)
+  (let ((p (gnc:make-html-text)))
+    (gnc:html-text-append! 
+     p 
+     (gnc:html-markup-h2 (_ "No data"))
+     (gnc:html-markup-p
+      (_ "The selected accounts contain no data for the selected time period")))
     p))
Index: gnucash/src/scm/options-utilities.scm
diff -u gnucash/src/scm/options-utilities.scm:1.10 gnucash/src/scm/options-utilities.scm:1.11
--- gnucash/src/scm/options-utilities.scm:1.10	Sun Apr 29 20:23:17 2001
+++ gnucash/src/scm/options-utilities.scm	Tue May  8 21:21:05 2001
@@ -243,3 +243,21 @@
     (N_ "Height of plot in pixels.") default-height
     100 1000 0 1)))
 
+;; A multicoice option for the marker of a scatter plot.
+(define (gnc:options-add-marker-choice!
+	 options pagename optname sort-tag default)
+  (gnc:register-option
+   options
+   (gnc:make-multichoice-option
+    pagename optname 
+    sort-tag
+    (N_ "Choose the marker for each data point.")
+    default
+    (list
+     (vector 'circle "circle" "circle")
+     (vector 'cross "cross" "cross")
+     (vector 'square "square" "square")
+     (vector 'asterisk "asterisk" "asterisk")
+     (vector 'filledcircle "filled circle" "filled circle")
+     (vector 'filledsquare "filled square" "filled square")))))
+
Index: gnucash/src/scm/report/category-barchart.scm
diff -u gnucash/src/scm/report/category-barchart.scm:1.22 gnucash/src/scm/report/category-barchart.scm:1.23
--- gnucash/src/scm/report/category-barchart.scm:1.22	Wed May  2 15:14:19 2001
+++ gnucash/src/scm/report/category-barchart.scm	Wed May  9 03:27:07 2001
@@ -314,67 +314,72 @@
 	    ;; choose sorting.
 	    
 	    
-	    ;;(warn "all-data" all-data)
+	    (gnc:warn "all-data" all-data)
 	    
-	    ;; Set chart title, subtitle etc.
-	    (gnc:html-barchart-set-title! chart report-title)
-	    (gnc:html-barchart-set-subtitle!
-	     chart (sprintf #f
-			    (if do-intervals?
-				(_ "%s to %s")
-				(_ "Balances %s to %s"))
-			    (gnc:timepair-to-datestring from-date-tp) 
-			    (gnc:timepair-to-datestring to-date-tp)))
-	    (gnc:html-barchart-set-width! chart width)
-	    (gnc:html-barchart-set-height! chart height)
+	    (let ((all-data-amounts (map cadr all-data)))
+	      (if 
+	       (and (not (null? all-data-amounts))
+		    (gnc:not-all-zeros all-data-amounts))
+		  ;; Set chart title, subtitle etc.
+	       (begin 
+		 (gnc:html-barchart-set-title! chart report-title)
+		 (gnc:html-barchart-set-subtitle!
+		  chart (sprintf #f
+				 (if do-intervals?
+				     (_ "%s to %s")
+				     (_ "Balances %s to %s"))
+				 (gnc:timepair-to-datestring from-date-tp) 
+				 (gnc:timepair-to-datestring to-date-tp)))
+		 (gnc:html-barchart-set-width! chart width)
+		 (gnc:html-barchart-set-height! chart height)
+		 
+		 ;; row labels etc.
+		 (gnc:html-barchart-set-row-labels! chart date-string-list)
+		 ;; FIXME: why doesn't the y-axis label get printed?!?
+		 (gnc:html-barchart-set-y-axis-label!
+		  chart (gnc:commodity-get-mnemonic report-currency))
+		 (gnc:html-barchart-set-row-labels-rotated?! chart #t)
+		 (gnc:html-barchart-set-stacked?! chart stacked?)
+		 ;; If this is a stacked barchart, then reverse the legend.
+		 (gnc:html-barchart-set-legend-reversed?! chart stacked?)
+		 
+		 ;; If we have too many categories, we sum them into a new
+		 ;; 'other' category and add a link to a new report with just
+		 ;; those accounts.
+		 (if (> (length all-data) max-slices)
+		     (let* ((start (take all-data (- max-slices 1)))
+			    (finish (drop all-data (- max-slices 1)))
+			    (other-sum (map 
+					(lambda (l) (apply + l))
+					(apply zip (map cadr finish)))))
+		       (set! all-data
+			     (append start
+				     (list (list (_ "Other") other-sum))))
+		       (let* ((options (gnc:make-report-options reportname))
+			      (id #f))
+			 ;; now copy all the options
+			 (gnc:options-copy-values 
+			  (gnc:report-options report-obj) options)
+			 ;; and set the destination accounts
+			 (gnc:option-set-value
+			  (gnc:lookup-option options gnc:pagename-accounts 
+					     optname-accounts)
+			  (map car finish))
+			 ;; Set the URL to point to this report.
+			 (set! id (gnc:make-report reportname options))
+			 (gnc:report-add-child-by-id! report-obj id)
+			 (gnc:report-set-parent! (gnc:find-report id) report-obj)
+			 (set! other-anchor (gnc:report-anchor-text id)))))
+		 
+		 
+		 ;; This adds the data. Note the apply-zip stuff: This
+		 ;; transposes the data, i.e. swaps rows and columns. Pretty
+		 ;; cool, eh? Courtesy of dave_p.
+		 (if (not (null? all-data))
+		     (gnc:html-barchart-set-data! chart 
+						  (apply zip all-data-amounts)))
 	    
-	    ;; row labels etc.
-	    (gnc:html-barchart-set-row-labels! chart date-string-list)
-	    ;; FIXME: why doesn't the y-axis label get printed?!?
-	    (gnc:html-barchart-set-y-axis-label!
-	     chart (gnc:commodity-get-mnemonic report-currency))
-	    (gnc:html-barchart-set-row-labels-rotated?! chart #t)
-	    (gnc:html-barchart-set-stacked?! chart stacked?)
-	    ;; If this is a stacked barchart, then reverse the legend.
-	    (gnc:html-barchart-set-legend-reversed?! chart stacked?)
-	    
-	    ;; If we have too many categories, we sum them into a new
-	    ;; 'other' category and add a link to a new report with just
-	    ;; those accounts.
-	    (if (> (length all-data) max-slices)
-		(let* ((start (take all-data (- max-slices 1)))
-		       (finish (drop all-data (- max-slices 1)))
-		       (other-sum (map 
-				   (lambda (l) (apply + l))
-				   (apply zip (map cadr finish)))))
-		  (set! all-data
-			(append start
-				(list (list (_ "Other") other-sum))))
-		  (let* ((options (gnc:make-report-options reportname))
-			 (id #f))
-		    ;; now copy all the options
-		    (gnc:options-copy-values 
-		     (gnc:report-options report-obj) options)
-		    ;; and set the destination accounts
-		    (gnc:option-set-value
-		     (gnc:lookup-option options gnc:pagename-accounts 
-					optname-accounts)
-		     (map car finish))
-		    ;; Set the URL to point to this report.
-		    (set! id (gnc:make-report reportname options))
-		    (gnc:report-add-child-by-id! report-obj id)
-		    (gnc:report-set-parent! (gnc:find-report id) report-obj)
-		    (set! other-anchor (gnc:report-anchor-text id)))))
-	    
-	    
-	    ;; This adds the data. Note the apply-zip stuff: This
-	    ;; transposes the data, i.e. swaps rows and columns. Pretty
-	    ;; cool, eh? Courtesy of dave_p.
-	    (if (not (null? all-data))
-		(gnc:html-barchart-set-data! chart 
-					     (apply zip (map cadr all-data))))
-	    
-	    ;; Labels and colors
+		 ;; Labels and colors
 	    (gnc:html-barchart-set-col-labels!
 	     chart (map (lambda (pair)
 			  (if (string? (car pair))
@@ -443,14 +448,19 @@
 		  (gnc:html-markup-p "Remove this text by disabling \
 the global Preference \"Display Tip of the Day\".")))))
 
+	       ;; else if empty data
+	       (gnc:html-document-add-object!
+		document
+		(gnc:html-make-empty-data-warning)))))
+	  
 	  ;; else if no accounts selected
 	  (gnc:html-document-add-object! 
 	   document 
 	   (gnc:html-make-no-account-warning)))
-					 
-	    
-	    document))
-
+      
+	      
+	      document))
+	  
   (for-each 
    (lambda (l)
      (gnc:define-report
Index: gnucash/src/scm/report/net-barchart.scm
diff -u gnucash/src/scm/report/net-barchart.scm:1.4 gnucash/src/scm/report/net-barchart.scm:1.5
--- gnucash/src/scm/report/net-barchart.scm:1.4	Wed May  2 15:42:56 2001
+++ gnucash/src/scm/report/net-barchart.scm	Wed May  9 03:27:07 2001
@@ -236,103 +236,122 @@
 				    (gnc:timepair-to-datestring
 				     (car date-list-item)))
 				  gnc:timepair-to-datestring)
-			      dates-list)))
+			      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))
       
-      (gnc:html-barchart-set-title! 
-       chart (if inc-exp? (_ "Income/Expense Chart") 
-		 (_ "Net Worth Chart")))
-      (gnc:html-barchart-set-subtitle!
-       chart (sprintf #f
-                      (_ "%s to %s")
-                      (gnc:timepair-to-datestring from-date-tp) 
-                      (gnc:timepair-to-datestring to-date-tp)))
-      (gnc:html-barchart-set-width! chart width)
-      (gnc:html-barchart-set-height! chart height)
-      (gnc:html-barchart-set-row-labels! chart date-string-list)
-      (gnc:html-barchart-set-y-axis-label!
-       chart (gnc:commodity-get-mnemonic report-currency))
-      ;; Determine whether we have enough space for horizontal labels
-      ;; -- kind of a hack. Assumptions: y-axis labels and legend
-      ;; require 200 pixels, and each x-axes label needs 60 pixels.
-      (gnc:html-barchart-set-row-labels-rotated?! 
-       chart (< (/ (- width 200) 
-		   (length date-string-list)) 60))
+      (if 
+       (not (null? accounts))
+       (begin
 
-      (if show-sep?
-          (begin
-            (gnc:html-barchart-append-column! chart assets-list)
-            (gnc:html-barchart-append-column! chart 
-					      ;;(if inc-exp?
-					      (map - liability-list)
-					      ;;liability-list)
-					      )))
-      (if show-net?
-	  (gnc:html-barchart-append-column! 
-	   chart net-list))
-      (gnc:html-barchart-set-col-labels! 
-       chart (append
-	      (if show-sep?
-		  (if inc-exp?
-		      (list (_ "Income") (_ "Expense"))
-		      (list (_ "Assets") (_ "Liabilities")))
-		  '())
-	      (if show-net?
-		  (if inc-exp?
-		      (list (_ "Net Profit"))
-		      (list (_ "Net Worth")))
-		  '())))
-      (gnc:html-barchart-set-col-colors! 
-       chart (append
-	      (if show-sep?
-		  '("blue" "red") '())
-	      (if show-net?
-		  '("green") '())))
-      
-      (if show-sep?
-	  (let ((urls
-		 (list
-		  (gnc:make-report-anchor
-		   (if inc-exp?
-		       "Income Over Time"
-		       "Assets Over Time")
-		   report-obj
-		   (list 
-		    (list gnc:pagename-display
-			  "Use Stacked Bars" #t)
-		    (list gnc:pagename-general
-			  gnc:optname-reportname
-			  (if inc-exp?
-			  (_ "Income Chart")
-			  (_ "Asset Chart")))))
-		  (gnc:make-report-anchor
-		   (if inc-exp?
-		       "Expense Over Time"
-		       "Liabilities Over Time")
-		   report-obj
-		   (list 
-		    (list gnc:pagename-display
-			  "Use Stacked Bars" #t)
-		    (list gnc:pagename-general
-			  gnc:optname-reportname
-			  (if inc-exp?
-			      (_ "Expense Chart")
-			      (_ "Liability Chart"))))))))
-	    (gnc:html-barchart-set-button-1-bar-urls! 
-	     chart urls)
-	    (gnc:html-barchart-set-button-1-legend-urls! 
-	     chart urls)))
-
-      (gnc:html-document-add-object! document chart) 
+	 (gnc:html-barchart-set-title! 
+	  chart (if inc-exp? (_ "Income/Expense Chart") 
+		    (_ "Net Worth Chart")))
+	 (gnc:html-barchart-set-subtitle!
+	  chart (sprintf #f
+			 (_ "%s to %s")
+			 (gnc:timepair-to-datestring from-date-tp) 
+			 (gnc:timepair-to-datestring to-date-tp)))
+	 (gnc:html-barchart-set-width! chart width)
+	 (gnc:html-barchart-set-height! chart height)
+	 (gnc:html-barchart-set-row-labels! chart date-string-list)
+	 (gnc:html-barchart-set-y-axis-label!
+	  chart (gnc:commodity-get-mnemonic report-currency))
+	 ;; Determine whether we have enough space for horizontal labels
+	 ;; -- kind of a hack. Assumptions: y-axis labels and legend
+	 ;; require 200 pixels, and each x-axes label needs 60 pixels.
+	 (gnc:html-barchart-set-row-labels-rotated?! 
+	  chart (< (/ (- width 200) 
+		      (length date-string-list)) 60))
+	 
+	 (if show-sep?
+	     (begin
+	       (add-column! assets-list)
+	       (add-column!		      ;;(if inc-exp?
+		(map - liability-list)
+		;;liability-list)
+		)))
+	 (if show-net?
+	     (add-column! net-list))
+	 (gnc:html-barchart-set-col-labels! 
+	  chart (append
+		 (if show-sep?
+		     (if inc-exp?
+			 (list (_ "Income") (_ "Expense"))
+			 (list (_ "Assets") (_ "Liabilities")))
+		     '())
+		 (if show-net?
+		     (if inc-exp?
+			 (list (_ "Net Profit"))
+			 (list (_ "Net Worth")))
+		     '())))
+	 (gnc:html-barchart-set-col-colors! 
+	  chart (append
+		 (if show-sep?
+		     '("blue" "red") '())
+		 (if show-net?
+		     '("green") '())))
+	 
+	 (if show-sep?
+	     (let ((urls
+		    (list
+		     (gnc:make-report-anchor
+		      (if inc-exp?
+			  "Income Over Time"
+			  "Assets Over Time")
+		      report-obj
+		      (list 
+		       (list gnc:pagename-display
+			     "Use Stacked Bars" #t)
+		       (list gnc:pagename-general
+			     gnc:optname-reportname
+			     (if inc-exp?
+				 (_ "Income Chart")
+				 (_ "Asset Chart")))))
+		     (gnc:make-report-anchor
+		      (if inc-exp?
+			  "Expense Over Time"
+			  "Liabilities Over Time")
+		      report-obj
+		      (list 
+		       (list gnc:pagename-display
+			     "Use Stacked Bars" #t)
+		       (list gnc:pagename-general
+			     gnc:optname-reportname
+			     (if inc-exp?
+				 (_ "Expense Chart")
+				 (_ "Liability Chart"))))))))
+	       (gnc:html-barchart-set-button-1-bar-urls! 
+		chart urls)
+	       (gnc:html-barchart-set-button-1-legend-urls! 
+		chart urls)))
+	 
+	 (if non-zeros
+	     (gnc:html-document-add-object! document chart) 
+	     (gnc:html-document-add-object!
+	      document
+	      (gnc:html-make-empty-data-warning))))
+       
+       ;; else no accounts selected
 
-      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: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)))
 
   (gnc:define-report
    'version 1
Index: gnucash/src/scm/report/price-scatter.scm
diff -u gnucash/src/scm/report/price-scatter.scm:1.3 gnucash/src/scm/report/price-scatter.scm:1.5
--- gnucash/src/scm/report/price-scatter.scm:1.3	Sun May  6 23:22:55 2001
+++ gnucash/src/scm/report/price-scatter.scm	Wed May  9 03:52:12 2001
@@ -31,6 +31,7 @@
       (optname-report-currency (N_ "Report's currency"))
 
       (optname-price-commodity (N_ "Price of Commodity"))
+      (optname-price-source (N_ "Price Source"))
 
       ;;      (optname-accounts (N_ "Accounts"))
 
@@ -59,17 +60,17 @@
       (gnc:options-add-interval-choice! 
        options gnc:pagename-general optname-stepsize "b" 'MonthDelta)
 
-;      (add-option
-;       (gnc:make-account-list-option
-;	gnc:pagename-accounts optname-accounts
-;	"c"
-;	(N_ "Report on these accounts, if chosen account level allows.")
-;	(lambda ()
-;	  (gnc:group-get-subaccounts (gnc:get-current-group)))
-;	(lambda (accounts)
-;	  (list #t
-;		accounts))
-;	#t))
+					;      (add-option
+					;       (gnc:make-account-list-option
+					;	gnc:pagename-accounts optname-accounts
+					;	"c"
+					;	(N_ "Report on these accounts, if chosen account level allows.")
+					;	(lambda ()
+					;	  (gnc:group-get-subaccounts (gnc:get-current-group)))
+					;	(lambda (accounts)
+					;	  (list #t
+					;		accounts))
+					;	#t))
 
       (gnc:options-add-currency! 
        options gnc:pagename-general optname-report-currency "d")
@@ -81,24 +82,30 @@
 	(N_ "Calculate the price of this commodity.")
 	(gnc:locale-default-currency)))
       
+      (add-option
+       (gnc:make-multichoice-option
+	gnc:pagename-general optname-price-source
+	"f" (N_ "The source of price information") 
+	'actual-transactions
+	(list (vector 'weighted-average 
+		      (N_ "Weighted Average")
+		      (N_ "The weighted average all currency transactions of the past"))
+	      (vector 'actual-transactions
+		      (N_ "Actual Transactions")
+		      (N_ "The actual price of currency transactions in the past"))
+	      ;;(vector 'pricedb-nearest
+	      ;;      (N_ "Pricedb: Nearest in time")
+	      ;;    (N_ "The price recorded nearest in time to the report date"))
+	      )))
+
       
       (gnc:options-add-plot-size! 
        options gnc:pagename-display 
        optname-plot-width optname-plot-height "c" 500 400)
-
-      (add-option
-       (gnc:make-multichoice-option
-	gnc:pagename-display optname-marker
-	"a"
-	(N_ "Choose a marker")
-	'filledsquare
-	(list
-	 (vector 'circle "circle" "circle")
-	 (vector 'cross "cross" "cross")
-	 (vector 'square "square" "square")
-	 (vector 'asterisk "asterisk" "asterisk")
-	 (vector 'filledcircle "filled circle" "filled circle")
-	 (vector 'filledsquare "filled square" "filled square"))))
+      
+      (gnc:options-add-marker-choice!
+       options gnc:pagename-display 
+       optname-marker "a" 'filledsquare)
 
       (add-option
        (gnc:make-color-option
@@ -136,7 +143,7 @@
                            (op-value gnc:pagename-general 
 				     optname-from-date))))
 	   (interval (op-value gnc:pagename-general optname-stepsize))
-;	   (accounts (op-value gnc:pagename-accounts optname-accounts))
+	   ;; (accounts (op-value gnc:pagename-accounts optname-accounts))
 
 	   (height (op-value gnc:pagename-display optname-plot-height))
 	   (width (op-value gnc:pagename-display optname-plot-width))
@@ -150,6 +157,8 @@
                                       optname-report-currency))
 	   (price-commodity (op-value gnc:pagename-general 
 				      optname-price-commodity))
+	   (price-source (op-value gnc:pagename-general
+				   optname-price-source))
 
 	   (dates-list (gnc:make-date-list
 			(gnc:timepair-end-day-time from-date-tp) 
@@ -161,6 +170,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))))
       
@@ -203,70 +213,78 @@
 	     ;; go into commodity-utilities.scm or even start a new file.
 	     (set!
 	      data
-	      ;; go through all splits; convert all splits into a
-	      ;; price. 
-	      (map
-	       (lambda (a)
-		 (let* ((transaction-comm (gnc:transaction-get-commodity 
-					   (gnc:split-get-parent a)))
-			(account-comm (gnc:account-get-commodity 
-				       (gnc:split-get-account a)))
-			(share-amount (gnc:split-get-share-amount a))
-			(value-amount (gnc:split-get-value a))
-			(transaction-date (gnc:transaction-get-date-posted
-					   (gnc:split-get-parent a)))
-			(foreignlist
-			 (if (gnc:commodity-equiv? transaction-comm 
-						   price-commodity)
-			     (list account-comm
-				   (gnc:numeric-neg share-amount)
-				   (gnc:numeric-neg value-amount))
-			     (list transaction-comm
-				   value-amount
-				   share-amount))))
-		   
-;		   (warn "render-scatterplot: value " 
-;			 (commodity-numeric->string
-;			  (first foreignlist) (second foreignlist))
-;			 " bought shares "
-;			 (commodity-numeric->string
-;			  price-commodity (third foreignlist)))
-		   
-		   (list
-		    transaction-date
-		    (if (not (gnc:commodity-equiv? (first foreignlist) 
-						   report-currency))
-			(begin
-			  (warn "render-scatterplot: " 
-				"Sorry, currency exchange not yet implemented:"
-				(commodity-numeric->string
-				 (first foreignlist) (second foreignlist))
-				" (buying "
-				(commodity-numeric->string
-				 price-commodity (third foreignlist))
-				") =? "
-				(commodity-numeric->string
-				 report-currency (gnc:numeric-zero)))
-			  (gnc:numeric-zero))
-			(gnc:numeric-div 
-			 (second foreignlist)
-			 (third foreignlist)
-			 GNC-DENOM-AUTO 
-			 (logior (GNC-DENOM-SIGFIGS 8) GNC-RND-ROUND))))))
-	       ;; Get all the interesting splits
-	       (gnc:get-match-commodity-splits 
-		currency-accounts 
-		to-date-tp price-commodity))))
+	      (case price-source
+		('actual-transactions
+		 ;; go through all splits; convert all splits into a
+		 ;; price. 
+		 (map
+		  (lambda (a)
+		    (let* ((transaction-comm (gnc:transaction-get-commodity 
+					      (gnc:split-get-parent a)))
+			   (account-comm (gnc:account-get-commodity 
+					  (gnc:split-get-account a)))
+			   (share-amount (gnc:split-get-share-amount a))
+			   (value-amount (gnc:split-get-value a))
+			   (transaction-date (gnc:transaction-get-date-posted
+					      (gnc:split-get-parent a)))
+			   (foreignlist
+			    (if (gnc:commodity-equiv? transaction-comm 
+						      price-commodity)
+				(list account-comm
+				      (gnc:numeric-neg share-amount)
+				      (gnc:numeric-neg value-amount))
+				(list transaction-comm
+				      value-amount
+				      share-amount))))
+		      
+		      ;;(warn "render-scatterplot: value " 
+		      ;;    (commodity-numeric->string
+		      ;;   (first foreignlist) (second foreignlist))
+		      ;; " bought shares "
+		      ;;(commodity-numeric->string
+		      ;; price-commodity (third foreignlist)))
+		      
+		      (list
+		       transaction-date
+		       (if (not (gnc:commodity-equiv? (first foreignlist) 
+						      report-currency))
+			   (begin
+			     (warn "render-scatterplot: " 
+				   "Sorry, currency exchange not yet implemented:"
+				   (commodity-numeric->string
+				    (first foreignlist) (second foreignlist))
+				   " (buying "
+				   (commodity-numeric->string
+				    price-commodity (third foreignlist))
+				   ") =? "
+				   (commodity-numeric->string
+				    report-currency (gnc:numeric-zero)))
+			     (gnc:numeric-zero))
+			   (gnc:numeric-div 
+			    (second foreignlist)
+			    (third foreignlist)
+			    GNC-DENOM-AUTO 
+			    (logior (GNC-DENOM-SIGFIGS 8) GNC-RND-ROUND))))))
+		  ;; Get all the interesting splits
+		  (gnc:get-match-commodity-splits 
+		   currency-accounts 
+		   to-date-tp price-commodity)))
+		('weighted-average
+		 (gnc:get-commodity-totalaverage-prices
+		  currency-accounts to-date-tp 
+		  price-commodity report-currency))
+		)))
 
 	 (set! data (filter
-		     (lambda (x) (gnc:timepair-lt from-date-tp (first x)))
+		     (lambda (x) 
+		       (gnc:timepair-lt from-date-tp (first x)))
 		     data))
-
+	 
 	 ;; some output
-;	 (warn (map (lambda (x) (list
-;				 (gnc:timepair-to-datestring (car x))
-;				 (gnc:numeric-to-double (second x))))
-;		    data))
+	 ;;(warn (map (lambda (x) (list
+	 ;;		     (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) 
@@ -297,7 +315,7 @@
       
       (gnc:html-scatter-set-data! 
        chart data)
-
+      
       (gnc:html-document-add-object! document chart) 
       
       (gnc:html-document-add-object! 
@@ -306,11 +324,8 @@
 	(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.) The prices shown are the actual values, \
-i.e. there is no averaging at all. This scaling of the x-axis looks so \
-weird that \
-we should rather throw it out before 1.6 is released, I guess (cstim).")))
-
+commodity involved in between.) cstim.")))
+      
       document))
 
   ;; Here we define the actual report
@@ -320,4 +335,3 @@
    ;;'menu-path (list gnc:menuname-asset-liability)
    'options-generator options-generator
    'renderer renderer))
-