r16731 - gnucash/branches/gda-dev2 - Merge trunk revs 16699:16730 (using svn merge)

Phil Longstaff plongstaff at cvs.gnucash.org
Wed Dec 26 14:14:57 EST 2007


Author: plongstaff
Date: 2007-12-26 14:14:54 -0500 (Wed, 26 Dec 2007)
New Revision: 16731
Trac: http://svn.gnucash.org/trac/changeset/16731

Added:
   gnucash/branches/gda-dev2/src/gnome-utils/dialog-book-close.c
   gnucash/branches/gda-dev2/src/gnome-utils/dialog-book-close.h
   gnucash/branches/gda-dev2/src/gnome-utils/glade/dialog-book-close.glade
Modified:
   gnucash/branches/gda-dev2/
   gnucash/branches/gda-dev2/packaging/gnucash.spec.in
   gnucash/branches/gda-dev2/src/business/business-core/gda/gnc-bill-term-gda.c
   gnucash/branches/gda-dev2/src/business/business-core/gncInvoice.c
   gnucash/branches/gda-dev2/src/business/business-core/gncInvoiceP.h
   gnucash/branches/gda-dev2/src/business/business-gnome/dialog-invoice.c
   gnucash/branches/gda-dev2/src/business/business-reports/aging.scm
   gnucash/branches/gda-dev2/src/business/business-reports/owner-report.scm
   gnucash/branches/gda-dev2/src/engine/Account.c
   gnucash/branches/gda-dev2/src/engine/Period.c
   gnucash/branches/gda-dev2/src/engine/cap-gains.c
   gnucash/branches/gda-dev2/src/engine/gnc-commodity.c
   gnucash/branches/gda-dev2/src/engine/gnc-commodity.h
   gnucash/branches/gda-dev2/src/engine/gnc-lot.c
   gnucash/branches/gda-dev2/src/engine/gnc-lot.h
   gnucash/branches/gda-dev2/src/engine/iso-4217-currencies.scm
   gnucash/branches/gda-dev2/src/engine/test-core/test-engine-stuff.c
   gnucash/branches/gda-dev2/src/gnome-utils/Makefile.am
   gnucash/branches/gda-dev2/src/gnome-utils/dialog-commodity.c
   gnucash/branches/gda-dev2/src/gnome-utils/glade/Makefile.am
   gnucash/branches/gda-dev2/src/gnome-utils/gnc-main-window.c
   gnucash/branches/gda-dev2/src/gnome-utils/gnc-tree-view-account.c
   gnucash/branches/gda-dev2/src/gnome/dialog-print-check.c
   gnucash/branches/gda-dev2/src/gnome/druid-merge.c
   gnucash/branches/gda-dev2/src/gnome/glade/budget.glade
   gnucash/branches/gda-dev2/src/gnome/glade/lots.glade
   gnucash/branches/gda-dev2/src/gnome/glade/print.glade
   gnucash/branches/gda-dev2/src/gnome/gnc-plugin-basic-commands.c
   gnucash/branches/gda-dev2/src/gnome/lot-viewer.c
   gnucash/branches/gda-dev2/src/gnome/reconcile-list.c
   gnucash/branches/gda-dev2/src/gnome/reconcile-list.h
   gnucash/branches/gda-dev2/src/gnome/schemas/apps_gnucash_dialog_commodities.schemas.in
   gnucash/branches/gda-dev2/src/gnome/schemas/apps_gnucash_dialog_common.schemas.in
   gnucash/branches/gda-dev2/src/gnome/schemas/apps_gnucash_dialog_prices.schemas.in
   gnucash/branches/gda-dev2/src/gnome/schemas/apps_gnucash_warnings.schemas.in
   gnucash/branches/gda-dev2/src/gnome/ui/gnc-plugin-basic-commands-ui.xml
   gnucash/branches/gda-dev2/src/import-export/generic-import.glade
   gnucash/branches/gda-dev2/src/import-export/hbci/glade/hbci.glade
   gnucash/branches/gda-dev2/src/import-export/qif-import/qif.glade
   gnucash/branches/gda-dev2/src/import-export/schemas/apps_gnucash_import_generic_matcher.schemas.in
   gnucash/branches/gda-dev2/src/register/ledger-core/split-register-load.c
   gnucash/branches/gda-dev2/src/report/locale-specific/us/taxtxf-de_DE.scm
   gnucash/branches/gda-dev2/src/report/locale-specific/us/taxtxf.scm
   gnucash/branches/gda-dev2/src/report/report-gnome/window-report.c
   gnucash/branches/gda-dev2/src/report/report-system/html-acct-table.scm
   gnucash/branches/gda-dev2/src/report/report-system/report.scm
Log:
Merge trunk revs 16699:16730 (using svn merge)




Property changes on: gnucash/branches/gda-dev2
___________________________________________________________________
Name: svk:merge
   - 3889ce50-311e-0410-a464-f059747ec5d1:/local/gnucash/branches/swig-redo:802
3889ce50-311e-0410-a464-f059747ec5d1:/local/gnucash/trunk:1037
57a11ea4-9604-0410-9ed3-97b8803252fd:/gnucash/branches/gobject-engine-dev-warlord:15827
95e783b2-15b2-415a-8f58-462a736813e0:/gnucash/advport:27
d2ab10a8-8a95-4986-baff-8d511d9f15b2:/local/gnucash/branches/gobject-engine-dev-warlord:14369
d2ab10a8-8a95-4986-baff-8d511d9f15b2:/local/gnucash/branches/gobject-engine-dev-warlord1:14446
d2ab10a8-8a95-4986-baff-8d511d9f15b2:/local/gnucash/trunk:14601
d2ab10a8-8a95-4986-baff-8d511d9f15b2:/local/gnucash/trunk2:15116
d2ab10a8-8a95-4986-baff-8d511d9f15b2:/local/gnucash/trunk3:15249
   + 3889ce50-311e-0410-a464-f059747ec5d1:/local/gnucash/branches/swig-redo:802
3889ce50-311e-0410-a464-f059747ec5d1:/local/gnucash/trunk:1037
57a11ea4-9604-0410-9ed3-97b8803252fd:/gnucash/branches/gobject-engine-dev-warlord:15827
95e783b2-15b2-415a-8f58-462a736813e0:/gnucash/advport:27
d2ab10a8-8a95-4986-baff-8d511d9f15b2:/local/gnucash/branches/gobject-engine-dev-warlord:14369
d2ab10a8-8a95-4986-baff-8d511d9f15b2:/local/gnucash/branches/gobject-engine-dev-warlord1:14446
d2ab10a8-8a95-4986-baff-8d511d9f15b2:/local/gnucash/trunk:14601
d2ab10a8-8a95-4986-baff-8d511d9f15b2:/local/gnucash/trunk2:15116
d2ab10a8-8a95-4986-baff-8d511d9f15b2:/local/gnucash/trunk3:15356

Modified: gnucash/branches/gda-dev2/packaging/gnucash.spec.in
===================================================================
--- gnucash/branches/gda-dev2/packaging/gnucash.spec.in	2007-12-26 05:17:37 UTC (rev 16730)
+++ gnucash/branches/gda-dev2/packaging/gnucash.spec.in	2007-12-26 19:14:54 UTC (rev 16731)
@@ -1,5 +1,5 @@
 #
-# Spec file for FC4
+# Spec file for Fedora and other RedHat distros and derivatives
 #
 # Check whether GnuCash should build optional modules.
 # To modify parameters, edit the .spec file, 0 is off, 1 is on
@@ -10,6 +10,10 @@
 # The --whatprovides redhat-release lets us work on RHEL as well as FC
 # Granted, it will look weird, but at least it wont fail outright.
 %define fc_rel %(rpm -q --queryformat='%{VERSION}' --whatprovides redhat-release)
+
+# Edit dist if not a Fedora release
+%define dist FC%{fc_rel}
+
 %define version @-VERSION-@
 %define __libtoolize /bin/true
 
@@ -24,7 +28,7 @@
 Name:      	gnucash
 Summary:   	GnuCash is an application to keep track of your finances.
 Version:   	%{version}
-Release:  	1.FC%{fc_rel}
+Release:  	1.%{dist}
 License:	GPL
 Group:     	Applications/Finance
 URL:            http://www.gnucash.org
@@ -40,6 +44,7 @@
 Requires:	libgnomeprintui22 >= %{libgnomeprintui22_version}
 Requires:	guile >= %{guile_version}
 Requires:	gtkhtml3 >= %{gtkhtml3_version}
+Requires:	slib >= 3a1
 
 BuildRequires: 	libgnomeui-devel >= %{libgnomeui_version}
 BuildRequires: 	libgnomeprintui22-devel >= %{libgnomeprintui22_version}

Modified: gnucash/branches/gda-dev2/src/business/business-core/gda/gnc-bill-term-gda.c
===================================================================
--- gnucash/branches/gda-dev2/src/business/business-core/gda/gnc-bill-term-gda.c	2007-12-26 05:17:37 UTC (rev 16730)
+++ gnucash/branches/gda-dev2/src/business/business-core/gda/gnc-bill-term-gda.c	2007-12-26 19:14:54 UTC (rev 16731)
@@ -52,7 +52,8 @@
 	{ "guid",         CT_GUID,        0,                   COL_NNUL, "guid" },
 	{ "name",         CT_STRING,      MAX_NAME_LEN,        COL_NNUL, NULL, GNC_BILLTERM_NAME },
 	{ "description",  CT_STRING,      MAX_DESCRIPTION_LEN, COL_NNUL, NULL, GNC_BILLTERM_DESC },
-	{ "refcount",     CT_INT,         0,                   COL_NNUL, NULL, GNC_BILLTERM_REFCOUNT },
+	{ "refcount",     CT_INT,         0,                   COL_NNUL, NULL, NULL,
+			(QofAccessFunc)gncBillTermGetRefcount,  (QofSetterFunc)gncBillTermSetRefcount },
 	{ "invisible",    CT_BOOLEAN,     0,                   COL_NNUL, NULL, NULL,
 			(QofAccessFunc)gncBillTermGetInvisible, (QofSetterFunc)set_invisible },
 	{ "parent",       CT_BILLTERMREF, 0,                   0,        NULL, NULL,

Modified: gnucash/branches/gda-dev2/src/business/business-core/gncInvoice.c
===================================================================
--- gnucash/branches/gda-dev2/src/business/business-core/gncInvoice.c	2007-12-26 05:17:37 UTC (rev 16730)
+++ gnucash/branches/gda-dev2/src/business/business-core/gncInvoice.c	2007-12-26 19:14:54 UTC (rev 16731)
@@ -1623,7 +1623,22 @@
   return qof_object_register (&gncInvoiceDesc);
 }
 
-gint64 gncInvoiceNextID (QofBook *book)
+gint64 gncInvoiceNextID (QofBook *book, GncOwner *owner)
 {
-  return qof_book_get_counter (book, _GNC_MOD_NAME);
+  gint64 nextID;
+  switch(gncOwnerGetType(gncOwnerGetEndOwner(owner))) {
+    case GNC_OWNER_CUSTOMER:
+        nextID = qof_book_get_counter (book, "gncInvoice");
+        break;
+    case GNC_OWNER_VENDOR:
+      nextID = qof_book_get_counter (book, "gncBill");
+      break;
+    case GNC_OWNER_EMPLOYEE:
+      nextID = qof_book_get_counter (book, "gncExpVoucher");
+      break;
+    default:
+      nextID = qof_book_get_counter (book, _GNC_MOD_NAME);
+      break;
+  }
+  return nextID;
 }

Modified: gnucash/branches/gda-dev2/src/business/business-core/gncInvoiceP.h
===================================================================
--- gnucash/branches/gda-dev2/src/business/business-core/gncInvoiceP.h	2007-12-26 05:17:37 UTC (rev 16730)
+++ gnucash/branches/gda-dev2/src/business/business-core/gncInvoiceP.h	2007-12-26 19:14:54 UTC (rev 16731)
@@ -32,9 +32,10 @@
 #include "Account.h"
 #include "Transaction.h"
 #include "gnc-lot.h"
+#include "gncOwner.h"
 
 gboolean gncInvoiceRegister (void);
-gint64 gncInvoiceNextID (QofBook *book);
+gint64 gncInvoiceNextID (QofBook *book, GncOwner *owner);
 void gncInvoiceSetPostedAcc (GncInvoice *invoice, Account *acc);
 void gncInvoiceSetPostedTxn (GncInvoice *invoice, Transaction *txn);
 void gncInvoiceSetPostedLot (GncInvoice *invoice, GNCLot *lot);

Modified: gnucash/branches/gda-dev2/src/business/business-gnome/dialog-invoice.c
===================================================================
--- gnucash/branches/gda-dev2/src/business/business-gnome/dialog-invoice.c	2007-12-26 05:17:37 UTC (rev 16730)
+++ gnucash/branches/gda-dev2/src/business/business-gnome/dialog-invoice.c	2007-12-26 19:14:54 UTC (rev 16731)
@@ -344,8 +344,12 @@
   /* Check the ID; set one if necessary */
   res = gtk_entry_get_text (GTK_ENTRY (iw->id_entry));
   if (safe_strcmp (res, "") == 0) {
+    /* Invoices and bills have separate counters.
+       Therefore we pass the GncOwer to gncInvoiceNextID
+       so it knows whether we are creating a bill
+       or an invoice. */
     string = g_strdup_printf ("%.6" G_GINT64_FORMAT,
-			      gncInvoiceNextID(iw->book));
+			      gncInvoiceNextID(iw->book, &(iw->owner)));
     gtk_entry_set_text (GTK_ENTRY (iw->id_entry), string);
     g_free(string);
   }

Modified: gnucash/branches/gda-dev2/src/business/business-reports/aging.scm
===================================================================
--- gnucash/branches/gda-dev2/src/business/business-reports/aging.scm	2007-12-26 05:17:37 UTC (rev 16730)
+++ gnucash/branches/gda-dev2/src/business/business-reports/aging.scm	2007-12-26 19:14:54 UTC (rev 16731)
@@ -196,20 +196,27 @@
 	     ;; if it's an existing company, destroy the temp owner and
 	     ;; then make sure the currencies match
 	     (begin
-	       (gncOwnerDestroy temp-owner)
 	       (if (not (gnc-commodity-equiv
 			 this-currency
 			 (company-get-currency company-info)))
-		   (cons #f (sprintf
-			     (_ "Transactions relating to '%s' contain \
-more than one currency.  This report is not designed to cope with this possibility.")  (gncOwnerGetName owner)))
+		   (let ((error-str
+			  (string-append "IGNORING TRANSACTION!\n" "Invoice Owner: " (gncOwnerGetName owner)
+					 "\nTransaction GUID:" (gncTransGetGuid transaction)
+					 "\nTransaction Currency" (gnc-commodity-get-mnemonic this-currency)
+					 "\nClient Currency" (gnc-ommodity-get-mnemonic(company-get-currency company-info)))))
+		     (gnc-error-dialog '() error-str)
+		     (gnc:error error-str)
+		     (cons #f (sprintf
+			       (_ "Transactions relating to '%s' contain \
++more than one currency.  This report is not designed to cope with this possibility.")  (gncOwnerGetName owner))))
 		   (begin
 		     (gnc:debug "it's an old company")
 		     (if (gnc-numeric-negative-p value)
 			 (process-invoice company-info (gnc-numeric-neg value) bucket-intervals this-date)
 			 (process-payment company-info value))
 		     (hash-set! hash guid company-info)
-		     (cons #t guid))))
+		     (cons #t guid)))
+	       (gncOwnerDestroy temp-owner))
 		 
 	     ;; if it's a new company
 	     (begin
@@ -294,12 +301,8 @@
 (define (setup-query query account date)
   (define (date-copy date)
     (cons (car date) (cdr date)))
-  (let ((begindate (date-copy date)))
+  (let ((begindate (make-zdate))) ;Set begindate to the start of the Epoch
 ;    (gnc:debug "Account: " account)
-    (set! begindate (decdate begindate NinetyDayDelta))
-    (set! begindate (decdate begindate NinetyDayDelta))
-    (set! begindate (decdate begindate NinetyDayDelta))
-    (set! begindate (decdate begindate NinetyDayDelta))	;XXX - 360 days!?!
     (gnc:debug "begindate" begindate)
     (gnc:debug "date" date)
     (qof-query-set-book query (gnc-get-current-book))
@@ -335,7 +338,7 @@
       gnc:pagename-general
       optname-sort-by
       "i"
-      (N_ "Sort companys by")
+      (N_ "Sort companies by")
       'name
       (list 
        (vector 'name (N_ "Name") (N_ "Name of the company"))

Modified: gnucash/branches/gda-dev2/src/business/business-reports/owner-report.scm
===================================================================
--- gnucash/branches/gda-dev2/src/business/business-reports/owner-report.scm	2007-12-26 05:17:37 UTC (rev 16730)
+++ gnucash/branches/gda-dev2/src/business/business-reports/owner-report.scm	2007-12-26 19:14:54 UTC (rev 16731)
@@ -185,6 +185,27 @@
     table))
 		 
 ;;
+;; Adds the 'Balance' row to the table if it has not been printed and
+;; total is not zero
+;;
+;; Returns printed? 
+;;
+(define (add-balance-row table txn odd-row? printed? start-date total)
+  (if (not printed?)
+      (begin
+	(set! printed? #t)
+	(if (not (gnc-numeric-zero-p total))
+	    (let ((row (list (gnc-print-date start-date) "" "" "Balance" ""
+			(gnc:make-html-table-cell/markup "number-cell" 
+				(gnc:make-gnc-monetary (xaccTransGetCurrency txn) total))))
+		  (row-style (if odd-row? "normal-row" "alternate-row")))
+	      (gnc:html-table-append-row/markup! table row-style row)
+	      (set! odd-row? (not odd-row?))
+	      (set! row-style (if odd-row? "normal-row" "alternate-row")))
+	    )))
+	printed?)
+
+;;
 ;; Make sure the caller checks the type first and only calls us with
 ;; invoice and payment transactions.  we don't verify it here.
 ;;
@@ -240,20 +261,10 @@
 
     (if (gnc:timepair-later start-date date)
 	(begin
-
-	  ; Maybe print out the 'balance' row
-	  (if (not printed?)
-	      (begin
-		(set! printed? #t)
-		(if (not (gnc-numeric-zero-p total))
-		    (let ((row (make-row start-date #f "" (_ "Balance") "" total))
-			  (row-style (if odd-row? "normal-row" "alternate-row")))
-		      (gnc:html-table-append-row/markup! table row-style
-							 (reverse row))
-		      (set! odd-row? (not odd-row?))
-		      (set! row-style (if odd-row? "normal-row" "alternate-row")))
-		    )))
 	  
+	  ; Adds 'balance' row if needed
+	  (set! printed? (add-balance-row table txn odd-row? printed? start-date total))
+	  
 	  ; Now print out the invoice row
 	  (if (not (null? invoice))
 	      (set! due-date (gncInvoiceGetDateDue invoice)))
@@ -305,7 +316,12 @@
 	      (set! total (gnc-numeric-add-fixed total (cadr result)))
 	      (set! odd-row? (caddr result))
 	      ))))
-       txns))
+       txns)
+	  ;Balance row may not have been added if all transactions were before
+	  ;start-date (and no other rows would be added either) so add it now
+      (if (not (null? txns))
+	  (add-balance-row table (car txns) odd-row? printed? start-date total)
+		))
 
     (gnc:html-table-append-row/markup! 
      table

Modified: gnucash/branches/gda-dev2/src/engine/Account.c
===================================================================
--- gnucash/branches/gda-dev2/src/engine/Account.c	2007-12-26 05:17:37 UTC (rev 16730)
+++ gnucash/branches/gda-dev2/src/engine/Account.c	2007-12-26 19:14:54 UTC (rev 16731)
@@ -896,6 +896,7 @@
     /* The new book should contain a commodity that matches
      * the one in the old book. Find it, use it. */
     priv->commodity = gnc_commodity_obtain_twin(from_priv->commodity, book);
+    gnc_commodity_increment_usage_count(priv->commodity);
 
     priv->commodity_scu = from_priv->commodity_scu;
     priv->non_standard_scu = from_priv->non_standard_scu;
@@ -1029,6 +1030,7 @@
   priv->reconciled_balance = gnc_numeric_zero();
 
   priv->type = ACCT_TYPE_NONE;
+  gnc_commodity_decrement_usage_count(priv->commodity);
   priv->commodity = NULL;
 
   priv->balance_dirty = FALSE;
@@ -1675,6 +1677,8 @@
 
     ENTER ("(acc=%p, lot=%p)", acc, lot);
     priv->lots = g_list_remove(priv->lots, lot);
+    qof_event_gen (&lot->inst, QOF_EVENT_REMOVE, NULL);
+    qof_event_gen (&acc->inst, QOF_EVENT_MODIFY, NULL);
     LEAVE ("(acc=%p, lot=%p)", acc, lot);
 }
 
@@ -1710,6 +1714,9 @@
     * called from gnc_book_close_period since xaccAccountInsertSplit
     * will try to balance capital gains and things aren't ready for that. */
 
+   qof_event_gen (&lot->inst, QOF_EVENT_ADD, NULL);
+   qof_event_gen (&acc->inst, QOF_EVENT_MODIFY, NULL);
+
    LEAVE ("(acc=%p, lot=%p)", acc, lot);
 }
 
@@ -2086,7 +2093,9 @@
       return;
 
   xaccAccountBeginEdit(acc);
+  gnc_commodity_decrement_usage_count(priv->commodity);
   priv->commodity = com;
+  gnc_commodity_increment_usage_count(com);
   priv->commodity_scu = gnc_commodity_get_fraction(com);
   priv->non_standard_scu = FALSE;
 
@@ -2105,15 +2114,6 @@
   priv->balance_dirty = TRUE;
   mark_account (acc);
 
-  if (gnc_commodity_is_iso(com)) {
-    /* compatability hack - Gnucash 1.8 gets currency quotes when a
-       non-default currency is assigned to an account.  */
-	gnc_commodity_begin_edit(com);
-    gnc_commodity_set_quote_flag(com, TRUE);
-    gnc_commodity_set_quote_source(com, 
-        gnc_commodity_get_default_quote_source(com));
-	gnc_commodity_commit_edit(com);
-  }
   xaccAccountCommitEdit(acc);
 }
 

Modified: gnucash/branches/gda-dev2/src/engine/Period.c
===================================================================
--- gnucash/branches/gda-dev2/src/engine/Period.c	2007-12-26 05:17:37 UTC (rev 16730)
+++ gnucash/branches/gda-dev2/src/engine/Period.c	2007-12-26 19:14:54 UTC (rev 16731)
@@ -538,7 +538,7 @@
    /* Next, copy the commodity tables */
    src_tbl = gnc_commodity_table_get_table (src_book);
    dst_tbl = gnc_commodity_table_get_table (dest_book);
-   gnc_commodity_table_copy (dst_tbl, src_tbl);
+   gnc_commodity_table_copy (dst_tbl, src_tbl, dest_book);
 
    /* Next, copy all of the accounts */
    /* hack alert -- FIXME -- this should really be a merge, not a

Modified: gnucash/branches/gda-dev2/src/engine/cap-gains.c
===================================================================
--- gnucash/branches/gda-dev2/src/engine/cap-gains.c	2007-12-26 05:17:37 UTC (rev 16730)
+++ gnucash/branches/gda-dev2/src/engine/cap-gains.c	2007-12-26 19:14:54 UTC (rev 16731)
@@ -571,25 +571,6 @@
 
 /* ============================================================== */
 
-static GNCLot *
-MakeDefaultLot (Account *acc)
-{
-   GNCLot * lot;
-   gint64 id;
-   char buff[200];
-
-   lot = gnc_lot_new (qof_instance_get_book(acc));
-
-   /* Provide a reasonable title for the new lot */
-   id = kvp_frame_get_gint64 (xaccAccountGetSlots (acc), "/lot-mgmt/next-id");
-   snprintf (buff, 200, ("%s %" G_GINT64_FORMAT), _("Lot"), id);
-   kvp_frame_set_str (gnc_lot_get_slots (lot), "/title", buff);
-   id ++;
-   kvp_frame_set_gint64 (xaccAccountGetSlots (acc), "/lot-mgmt/next-id", id);
-
-   return lot;
-}
-
 /* Accounting-policy callback.  Given an account and an amount, 
  * this routine should return a lot.  By implementing this as 
  * a callback, we can 'easily' add other accounting policies.
@@ -632,7 +613,7 @@
      lot = pcy->PolicyGetLot (pcy, split);
      if (!lot)
      {
-        lot = MakeDefaultLot (acc);
+        lot = gnc_lot_make_default (acc);
         PINFO ("start new lot (%s)", gnc_lot_get_title(lot));
      }
      split = xaccSplitAssignToLot (split, lot);

Modified: gnucash/branches/gda-dev2/src/engine/gnc-commodity.c
===================================================================
--- gnucash/branches/gda-dev2/src/engine/gnc-commodity.c	2007-12-26 05:17:37 UTC (rev 16730)
+++ gnucash/branches/gda-dev2/src/engine/gnc-commodity.c	2007-12-26 19:14:54 UTC (rev 16731)
@@ -61,6 +61,10 @@
   gboolean  quote_flag;	    /* user wants price quotes */
   gnc_quote_source * quote_source;   /* current/old source of quotes */
   char    * quote_tz;
+
+  /* the number of accounts using this commodity - this field is not
+   * persisted */
+  int       usage_count;
 };
 
 struct _GncCommodityClass
@@ -624,6 +628,17 @@
 
   cm->mark = 0;
 
+#if !ACCOUNTS_CLEANED_UP
+  /* Account objects are not actually cleaned up when a book is closed (in fact
+   * a memory leak), but commodities are, so in currently this warning gets hit
+   * quite frequently.  Disable the check until cleaning up of accounts objects
+   * on close is implemented.  */
+  if(cm->usage_count != 0) {
+      PWARN("Destroying commodity (%p) with non-zero usage_count (%d).", cm,
+              cm->usage_count);
+  }
+#endif
+
   /* qof_instance_release (&cm->inst); */
   g_object_unref(cm);
 }
@@ -638,13 +653,15 @@
   gnc_commodity_set_quote_flag (dest, src->quote_flag);
   gnc_commodity_set_quote_source (dest, gnc_commodity_get_quote_source (src));
   gnc_commodity_set_quote_tz (dest, src->quote_tz);
+  kvp_frame_delete (dest->inst.kvp_data);
+  dest->inst.kvp_data = kvp_frame_copy (src->inst.kvp_data);
 }
 
 gnc_commodity *
-gnc_commodity_clone(gnc_commodity *src)
+gnc_commodity_clone(gnc_commodity *src, QofBook *dest_book)
 {
   gnc_commodity * dest = g_object_new(GNC_TYPE_COMMODITY, NULL);
-  /* qof_instance_init_data (&dest->inst, GNC_ID_COMMODITY, src->inst.book); */
+  qof_instance_init_data (&dest->inst, GNC_ID_COMMODITY, dest_book);
 
   dest->fullname = CACHE_INSERT(src->fullname);
   dest->mnemonic = CACHE_INSERT(src->mnemonic);
@@ -659,6 +676,9 @@
 
   gnc_commodity_set_quote_source (dest, gnc_commodity_get_quote_source (src));
 
+  kvp_frame_delete (dest->inst.kvp_data);
+  dest->inst.kvp_data = kvp_frame_copy (src->inst.kvp_data);
+
   reset_printname(dest);
   reset_unique_name(dest);
 
@@ -775,6 +795,21 @@
 }
 
 /********************************************************************
+ * gnc_commodity_get_auto_quote_control_flag
+ ********************************************************************/
+
+static gboolean
+gnc_commodity_get_auto_quote_control_flag(const gnc_commodity *cm)
+{
+  const char *str;
+
+  if(!cm) return FALSE;
+
+  str = kvp_frame_get_string(cm->inst.kvp_data, "auto_quote_control");
+  return !str || (strcmp(str, "false") != 0);
+}
+
+/********************************************************************
  * gnc_commodity_get_quote_flag
  ********************************************************************/
 
@@ -929,6 +964,60 @@
 }
 
 /********************************************************************
+ * gnc_commodity_set_auto_quote_control_flag
+ ********************************************************************/
+
+static void
+gnc_commodity_set_auto_quote_control_flag(gnc_commodity *cm,
+                                          const gboolean flag)
+{
+  ENTER ("(cm=%p, flag=%d)", cm, flag);
+
+  if(!cm) {
+    LEAVE("");
+    return;
+  }
+
+  gnc_commodity_begin_edit(cm);
+  kvp_frame_set_string(cm->inst.kvp_data,
+                       "auto_quote_control", flag ? NULL : "false");
+  mark_commodity_dirty(cm);
+  gnc_commodity_commit_edit(cm);
+  LEAVE("");
+}
+
+/********************************************************************
+ * gnc_commodity_user_set_quote_flag
+ ********************************************************************/
+
+void
+gnc_commodity_user_set_quote_flag(gnc_commodity *cm, const gboolean flag)
+{
+  ENTER ("(cm=%p, flag=%d)", cm, flag);
+
+  if(!cm) {
+    LEAVE("");
+    return;
+  }
+
+  gnc_commodity_begin_edit(cm);
+  gnc_commodity_set_quote_flag(cm, flag);
+  if(gnc_commodity_is_iso(cm)) {
+    /* For currencies, disable auto quote control if the quote flag is being
+     * changed from its default value and enable it if the quote flag is being
+     * reset to its default value.  The defaults for the quote flag are
+     * disabled if no accounts are using the currency, and true otherwise.
+     * Thus enable auto quote control if flag is FALSE and there are not any
+     * accounts using this currency OR flag is TRUE and there are accounts
+     * using this currency; otherwise disable auto quote control */
+    gnc_commodity_set_auto_quote_control_flag(cm,
+        (!flag && (cm->usage_count == 0)) || (flag && (cm->usage_count != 0)));
+  }
+  gnc_commodity_commit_edit(cm);
+  LEAVE("");
+}
+
+/********************************************************************
  * gnc_commodity_set_quote_flag
  ********************************************************************/
 
@@ -981,6 +1070,70 @@
   LEAVE(" ");
 }
 
+/********************************************************************
+ * gnc_commodity_increment_usage_count
+ ********************************************************************/
+
+void
+gnc_commodity_increment_usage_count(gnc_commodity *cm)
+{
+  const char *str;
+
+  ENTER("(cm=%p)", cm);
+
+  if(!cm) {
+    LEAVE("");
+    return;
+  }
+
+  if((cm->usage_count == 0) && !cm->quote_flag
+      && gnc_commodity_get_auto_quote_control_flag(cm)
+      && gnc_commodity_is_iso(cm)) {
+    /* compatability hack - Gnucash 1.8 gets currency quotes when a
+       non-default currency is assigned to an account.  */
+    gnc_commodity_begin_edit(cm);
+    gnc_commodity_set_quote_flag(cm, TRUE);
+    gnc_commodity_set_quote_source(cm,
+        gnc_commodity_get_default_quote_source(cm));
+    gnc_commodity_commit_edit(cm);
+  }
+  cm->usage_count++;
+  LEAVE("(usage_count=%d)", cm->usage_count);
+}
+
+/********************************************************************
+ * gnc_commodity_decrement_usage_count
+ ********************************************************************/
+
+void
+gnc_commodity_decrement_usage_count(gnc_commodity *cm)
+{
+  const char *str;
+
+  ENTER("(cm=%p)", cm);
+
+  if(!cm) {
+    LEAVE("");
+    return;
+  }
+
+  if(cm->usage_count == 0) {
+    PWARN("usage_count already zero");
+    LEAVE("");
+    return;
+  }
+
+  cm->usage_count--;
+  if((cm->usage_count == 0) && cm->quote_flag
+      && gnc_commodity_get_auto_quote_control_flag(cm)
+      && gnc_commodity_is_iso(cm)) {
+    /* if this is a currency with auto quote control enabled and no more
+     * accounts reference this currency, disable quote retrieval */
+    gnc_commodity_set_quote_flag(cm, FALSE);
+  }
+  LEAVE("(usage_count=%d)", cm->usage_count);
+}
+
 /********************************************************************\
 \********************************************************************/
 
@@ -1122,7 +1275,7 @@
   twin = gnc_commodity_table_lookup_unique (comtbl, ucom);
   if (!twin)
   {
-    twin = gnc_commodity_clone (from);
+    twin = gnc_commodity_clone (from, book);
     twin = gnc_commodity_table_insert (comtbl, twin);
   }
   return twin;
@@ -1779,19 +1932,27 @@
 
 /* =========================================================== */
 
+typedef struct {
+  gnc_commodity_table *dest;
+  QofBook *dest_book;
+} table_copy_helper_data;
+
 static gboolean 
 table_copy_helper (gnc_commodity *src_cm, gpointer user_data)
 {
-  gnc_commodity_table *dest = user_data;
-  gnc_commodity_table_insert (dest, gnc_commodity_clone (src_cm));
+  table_copy_helper_data *data = user_data;
+  gnc_commodity_table_insert (data->dest,
+      gnc_commodity_clone (src_cm, data->dest_book));
   return TRUE;
 }
 
 void
 gnc_commodity_table_copy(gnc_commodity_table *dest,
-                          gnc_commodity_table *src)
+                          gnc_commodity_table *src,
+                          QofBook *dest_book)
 {
-  gnc_commodity_table_foreach_commodity (src, table_copy_helper, dest);
+  table_copy_helper_data data = {dest, dest_book};
+  gnc_commodity_table_foreach_commodity (src, table_copy_helper, &data);
 }
 
 /********************************************************************

Modified: gnucash/branches/gda-dev2/src/engine/gnc-commodity.h
===================================================================
--- gnucash/branches/gda-dev2/src/engine/gnc-commodity.h	2007-12-26 05:17:37 UTC (rev 16730)
+++ gnucash/branches/gda-dev2/src/engine/gnc-commodity.h	2007-12-26 19:14:54 UTC (rev 16731)
@@ -312,7 +312,7 @@
 void  gnc_commodity_copy(gnc_commodity * dest, gnc_commodity *src);
 
 /** allocate and copy */
-gnc_commodity * gnc_commodity_clone(gnc_commodity *src);
+gnc_commodity * gnc_commodity_clone(gnc_commodity *src, QofBook *dest_book);
 /** @} */
 
 
@@ -547,6 +547,23 @@
  */
 void  gnc_commodity_set_fraction(gnc_commodity * cm, int smallest_fraction);
 
+/** Set the automatic price quote flag for the specified commodity,
+ *  based on user input. This flag indicates whether stock quotes
+ *  should be retrieved for the specified stock.
+ *
+ *  It is necessary to have a separate function to distinguish when
+ *  this setting is being modified by a user so that the
+ *  auto-enabling/auto-disabling of currencies can be handled
+ *  properly.
+ *
+ *  @param cm A pointer to a commodity data structure.
+ *
+ *  @param flag TRUE if quotes should be pulled for this commodity, FALSE
+ *  otherwise.
+ */
+void  gnc_commodity_user_set_quote_flag(gnc_commodity *cm,
+                                        const gboolean flag);
+
 /** Set the automatic price quote flag for the specified commodity.
  *  This flag indicates whether stock quotes should be retrieved for
  *  the specified stock.
@@ -584,7 +601,30 @@
 /** @} */
 
 
+/** @name Commodity Usage Count Adjustment Routines
+@{
+*/
 
+/** Increment a commodity's internal counter that tracks how many
+ *  accounts are using that commodity.  For currencies, this may have
+ *  the side effect of enabling the commodity's quote flag.
+ *
+ *  @param cm A pointer to a commodity data structure.
+ */
+void
+gnc_commodity_increment_usage_count(gnc_commodity *cm);
+
+/** Decrement a commodity's internal counter that tracks how many
+ *  accounts are using that commodity.  For currencies, this may have
+ *  the side effect of disabling the commodity's quote flag.
+ *
+ *  @param cm A pointer to a commodity data structure.
+ */
+void
+gnc_commodity_decrement_usage_count(gnc_commodity *cm);
+/** @} */
+
+
 /** @name Commodity Comparison 
  @{
 */
@@ -653,7 +693,8 @@
 
 /** copy all commodities from src table to dest table */
 void gnc_commodity_table_copy(gnc_commodity_table *dest,
-                              gnc_commodity_table *src);
+                              gnc_commodity_table *src,
+                              QofBook *dest_book);
 /** @} */
 /* ---------------------------------------------------------- */
 /** @name Commodity Table Lookup functions

Modified: gnucash/branches/gda-dev2/src/engine/gnc-lot.c
===================================================================
--- gnucash/branches/gda-dev2/src/engine/gnc-lot.c	2007-12-26 05:17:37 UTC (rev 16730)
+++ gnucash/branches/gda-dev2/src/engine/gnc-lot.c	2007-12-26 19:14:54 UTC (rev 16731)
@@ -39,8 +39,12 @@
  * Copyright (c) 2002,2003 Linas Vepstas <linas at linas.org>
  */
 
+#include <glib.h>
+#include <glib/gi18n.h>
+
 #include "config.h"
 #include "Account.h"
+#include "AccountP.h"
 #include "gnc-lot.h"
 #include "gnc-lot-p.h"
 #include "cap-gains.h"
@@ -454,4 +458,22 @@
     return qof_object_register(&gncLotDesc);
 }
 
+GNCLot * gnc_lot_make_default (Account *acc)
+{
+   GNCLot * lot;
+   gint64 id;
+   char buff[200];
+
+   lot = gnc_lot_new (qof_instance_get_book(acc));
+
+   /* Provide a reasonable title for the new lot */
+   id = kvp_frame_get_gint64 (xaccAccountGetSlots (acc), "/lot-mgmt/next-id");
+   snprintf (buff, 200, ("%s %" G_GINT64_FORMAT), _("Lot"), id);
+   kvp_frame_set_str (gnc_lot_get_slots (lot), "/title", buff);
+   id ++;
+   kvp_frame_set_gint64 (xaccAccountGetSlots (acc), "/lot-mgmt/next-id", id);
+
+   return lot;
+}
+
 /* ========================== END OF FILE ========================= */

Modified: gnucash/branches/gda-dev2/src/engine/gnc-lot.h
===================================================================
--- gnucash/branches/gda-dev2/src/engine/gnc-lot.h	2007-12-26 05:17:37 UTC (rev 16730)
+++ gnucash/branches/gda-dev2/src/engine/gnc-lot.h	2007-12-26 19:14:54 UTC (rev 16731)
@@ -156,6 +156,9 @@
  * */
 KvpFrame * gnc_lot_get_slots (const GNCLot *);
 
+/** XXX: Document? */
+GNCLot * gnc_lot_make_default (Account * acc);
+
 #define gnc_lot_get_guid(X)  qof_entity_get_guid(QOF_INSTANCE(X))
 
 #define LOT_IS_CLOSED	"is-closed?"

Modified: gnucash/branches/gda-dev2/src/engine/iso-4217-currencies.scm
===================================================================
--- gnucash/branches/gda-dev2/src/engine/iso-4217-currencies.scm	2007-12-26 05:17:37 UTC (rev 16730)
+++ gnucash/branches/gda-dev2/src/engine/iso-4217-currencies.scm	2007-12-26 19:14:54 UTC (rev 16731)
@@ -205,6 +205,9 @@
 ( "Zambian Kwacha" "kwacha" "ngwee"  "ISO4217" "ZMK" "894" 100 100 )
 ( "Zimbabwe Dollar" "dollar" "cent" "ISO4217" "ZWD" "716" 100 100 )
 
+( "Special Drawing Rights" "SDR" "SDR" "ISO4217" "XDR" "960" 1 1 ) ;; International Monetary Fund
+( "No currency" "" "" "ISO4217" "XXX" "999" 1 1000000 )
+
 ( "Gold" "ounce" "ounce" "ISO4217" "XAU" "959" 1 1000000 )
 ( "Palladium" "ounce" "ounce" "ISO4217" "XPD" "964" 1 1000000 )
 ( "Platinum" "ounce" "ounce" "ISO4217" "XPT" "962" 1 1000000 )

Modified: gnucash/branches/gda-dev2/src/engine/test-core/test-engine-stuff.c
===================================================================
--- gnucash/branches/gda-dev2/src/engine/test-core/test-engine-stuff.c	2007-12-26 05:17:37 UTC (rev 16730)
+++ gnucash/branches/gda-dev2/src/engine/test-core/test-engine-stuff.c	2007-12-26 19:14:54 UTC (rev 16731)
@@ -447,9 +447,9 @@
     }
     else
     {
-       gint64 norm = RAND_IN_RANGE (8ULL);
+       gint64 norm = RAND_IN_RANGE (7ULL);
 
-       /* multiple of 10, between 1 and 10 million */
+       /* multiple of 10, between 1 and 1 million */
        deno = 1;
        while (norm) 
        {
@@ -460,8 +460,14 @@
 
     /* Arbitrary random numbers can cause pointless overflow 
      * during calculations.  Limit dynamic range in hopes 
-     * of avoiding overflow. */
-    numer = get_random_gint64()/1000000;
+     * of avoiding overflow. Right now limit it to approx 2^48.
+     * The initial division is to help us down towards the range.
+     * The loop is to "make sure" we get there.  We might
+     * want to make this dependent on "deno" in the future.
+     */
+    do {
+      numer = get_random_gint64()/1000000;
+    } while ((numer >> 31) > 0x1FFFF);
     if (0 == numer) numer = 1;
     /* Make sure we have a non-zero denominator */
     if (0 == deno) deno = 1;

Modified: gnucash/branches/gda-dev2/src/gnome/dialog-print-check.c
===================================================================
--- gnucash/branches/gda-dev2/src/gnome/dialog-print-check.c	2007-12-26 05:17:37 UTC (rev 16730)
+++ gnucash/branches/gda-dev2/src/gnome/dialog-print-check.c	2007-12-26 19:14:54 UTC (rev 16731)
@@ -1088,7 +1088,7 @@
 		  * is the filename of that format; %3$s the type of
 		  * the other check format; and %4$s the filename of
 		  * that other format. */
-                 _("The guids in the %s check format file '%s' and "
+                 _("The GUIDs in the %s check format file '%s' and "
                    "the %s check format file '%s' match."),
                  existing->group, existing->filename,
                  format->group, format->filename);

Modified: gnucash/branches/gda-dev2/src/gnome/druid-merge.c
===================================================================
--- gnucash/branches/gda-dev2/src/gnome/druid-merge.c	2007-12-26 05:17:37 UTC (rev 16730)
+++ gnucash/branches/gda-dev2/src/gnome/druid-merge.c	2007-12-26 19:14:54 UTC (rev 16731)
@@ -352,7 +352,7 @@
 		   will allocate a new string; all of these need to be
 		   freed later. Currently this causes a lot of memory
 		   leaks. */
-		buffer = g_strconcat(buffer, g_strdup_printf(_("%i:Parameter name: %s "), 
+		buffer = g_strconcat(buffer, g_strdup_printf(_("%i: Parameter name: %s "), 
 			count, one_param->param_name), NULL);
 		importstring = qof_book_merge_param_as_string(one_param, rule->importEnt);
 		buffer = g_strconcat(buffer, 

Modified: gnucash/branches/gda-dev2/src/gnome/glade/budget.glade
===================================================================
--- gnucash/branches/gda-dev2/src/gnome/glade/budget.glade	2007-12-26 05:17:37 UTC (rev 16730)
+++ gnucash/branches/gda-dev2/src/gnome/glade/budget.glade	2007-12-26 19:14:54 UTC (rev 16731)
@@ -824,7 +824,7 @@
 	<widget class="GtkButton" id="SampleButton">
 	  <property name="visible">True</property>
 	  <property name="can_focus">True</property>
-	  <property name="label" translatable="yes">button1</property>
+	  <property name="label" translatable="no">button1</property>
 	  <property name="use_underline">True</property>
 	  <property name="relief">GTK_RELIEF_NORMAL</property>
 	  <property name="focus_on_click">True</property>
@@ -840,7 +840,7 @@
 	<widget class="GtkToggleButton" id="SampleToggleButton">
 	  <property name="visible">True</property>
 	  <property name="can_focus">True</property>
-	  <property name="label" translatable="yes">togglebutton1</property>
+	  <property name="label" translatable="no">togglebutton1</property>
 	  <property name="use_underline">True</property>
 	  <property name="relief">GTK_RELIEF_NORMAL</property>
 	  <property name="focus_on_click">True</property>
@@ -858,7 +858,7 @@
 	<widget class="GtkCheckButton" id="SampleCheckButton">
 	  <property name="visible">True</property>
 	  <property name="can_focus">True</property>
-	  <property name="label" translatable="yes">checkbutton1</property>
+	  <property name="label" translatable="no">checkbutton1</property>
 	  <property name="use_underline">True</property>
 	  <property name="relief">GTK_RELIEF_NORMAL</property>
 	  <property name="focus_on_click">True</property>
@@ -877,7 +877,7 @@
 	<widget class="GtkRadioButton" id="SampleRadioButton">
 	  <property name="visible">True</property>
 	  <property name="can_focus">True</property>
-	  <property name="label" translatable="yes">radiobutton1</property>
+	  <property name="label" translatable="no">radiobutton1</property>
 	  <property name="use_underline">True</property>
 	  <property name="relief">GTK_RELIEF_NORMAL</property>
 	  <property name="focus_on_click">True</property>

Modified: gnucash/branches/gda-dev2/src/gnome/glade/lots.glade
===================================================================
--- gnucash/branches/gda-dev2/src/gnome/glade/lots.glade	2007-12-26 05:17:37 UTC (rev 16730)
+++ gnucash/branches/gda-dev2/src/gnome/glade/lots.glade	2007-12-26 19:14:54 UTC (rev 16731)
@@ -35,6 +35,81 @@
 	  <property name="layout_style">GTK_BUTTONBOX_END</property>
 
 	  <child>
+	    <widget class="GtkButton" id="new lot button">
+	      <property name="visible">True</property>
+	      <property name="can_default">True</property>
+	      <property name="can_focus">True</property>
+	      <property name="relief">GTK_RELIEF_NORMAL</property>
+	      <property name="focus_on_click">True</property>
+	      <property name="response_id">5</property>
+
+	      <child>
+		<widget class="GtkAlignment" id="alignment3">
+		  <property name="visible">True</property>
+		  <property name="xalign">0.5</property>
+		  <property name="yalign">0.5</property>
+		  <property name="xscale">0</property>
+		  <property name="yscale">0</property>
+		  <property name="top_padding">0</property>
+		  <property name="bottom_padding">0</property>
+		  <property name="left_padding">0</property>
+		  <property name="right_padding">0</property>
+
+		  <child>
+		    <widget class="GtkHBox" id="hbox4">
+		      <property name="visible">True</property>
+		      <property name="homogeneous">False</property>
+		      <property name="spacing">2</property>
+
+		      <child>
+			<widget class="GtkImage" id="image3">
+			  <property name="visible">True</property>
+			  <property name="stock">gtk-new</property>
+			  <property name="icon_size">4</property>
+			  <property name="xalign">0.5</property>
+			  <property name="yalign">0.5</property>
+			  <property name="xpad">0</property>
+			  <property name="ypad">0</property>
+			</widget>
+			<packing>
+			  <property name="padding">0</property>
+			  <property name="expand">False</property>
+			  <property name="fill">False</property>
+			</packing>
+		      </child>
+
+		      <child>
+			<widget class="GtkLabel" id="label21">
+			  <property name="visible">True</property>
+			  <property name="label" translatable="yes">_New Lot</property>
+			  <property name="use_underline">True</property>
+			  <property name="use_markup">False</property>
+			  <property name="justify">GTK_JUSTIFY_LEFT</property>
+			  <property name="wrap">False</property>
+			  <property name="selectable">False</property>
+			  <property name="xalign">0.5</property>
+			  <property name="yalign">0.5</property>
+			  <property name="xpad">0</property>
+			  <property name="ypad">0</property>
+			  <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+			  <property name="width_chars">-1</property>
+			  <property name="single_line_mode">False</property>
+			  <property name="angle">0</property>
+			</widget>
+			<packing>
+			  <property name="padding">0</property>
+			  <property name="expand">False</property>
+			  <property name="fill">False</property>
+			</packing>
+		      </child>
+		    </widget>
+		  </child>
+		</widget>
+	      </child>
+	    </widget>
+	  </child>
+
+	  <child>
 	    <widget class="GtkButton" id="scrub account button">
 	      <property name="visible">True</property>
 	      <property name="can_default">True</property>

Modified: gnucash/branches/gda-dev2/src/gnome/glade/print.glade
===================================================================
--- gnucash/branches/gda-dev2/src/gnome/glade/print.glade	2007-12-26 05:17:37 UTC (rev 16730)
+++ gnucash/branches/gda-dev2/src/gnome/glade/print.glade	2007-12-26 19:14:54 UTC (rev 16731)
@@ -1153,7 +1153,7 @@
 	<widget class="GtkLabel" id="label847683">
 	  <property name="visible">True</property>
 	  <property name="can_focus">True</property>
-	  <property name="label" translatable="yes">Enter a title for this custom format.  This title will appear in the &quot;Check format&quot; selector of the Print Check dialog.  Using the title of an exiting custom format will cause that format to be overwritten.</property>
+	  <property name="label" translatable="yes">Enter a title for this custom format.  This title will appear in the &quot;Check format&quot; selector of the Print Check dialog.  Using the title of an existing custom format will cause that format to be overwritten.</property>
 	  <property name="use_underline">False</property>
 	  <property name="use_markup">False</property>
 	  <property name="justify">GTK_JUSTIFY_LEFT</property>

Modified: gnucash/branches/gda-dev2/src/gnome/gnc-plugin-basic-commands.c
===================================================================
--- gnucash/branches/gda-dev2/src/gnome/gnc-plugin-basic-commands.c	2007-12-26 05:17:37 UTC (rev 16730)
+++ gnucash/branches/gda-dev2/src/gnome/gnc-plugin-basic-commands.c	2007-12-26 19:14:54 UTC (rev 16731)
@@ -37,7 +37,9 @@
 #include <string.h>
 
 #include "gnc-plugin-basic-commands.h"
+#include "gnc-ui-util.h"
 
+#include "dialog-book-close.h"
 #include "dialog-chart-export.h"
 #include "dialog-fincalc.h"
 #include "dialog-find-transactions.h"
@@ -76,6 +78,7 @@
 static void gnc_main_window_cmd_actions_since_last_run (GtkAction *action, GncMainWindowActionData *data);
 static void gnc_main_window_cmd_actions_close_books (GtkAction *action, GncMainWindowActionData *data);
 static void gnc_main_window_cmd_tools_financial_calculator (GtkAction *action, GncMainWindowActionData *data);
+static void gnc_main_window_cmd_tools_close_book (GtkAction *action, GncMainWindowActionData *data);
 static void gnc_main_window_cmd_tools_find_transactions (GtkAction *action, GncMainWindowActionData *data);
 static void gnc_main_window_cmd_tools_price_editor (GtkAction *action, GncMainWindowActionData *data);
 static void gnc_main_window_cmd_tools_commodity_editor (GtkAction *action, GncMainWindowActionData *data);
@@ -157,6 +160,9 @@
   { "ToolsFinancialCalculatorAction", NULL, N_("_Financial Calculator"), NULL,
     N_("Use the financial calculator"),
     G_CALLBACK (gnc_main_window_cmd_tools_financial_calculator) },
+  { "ToolsBookCloseAction", NULL, N_("_Close Book"), NULL,
+    N_("Close the Book at the end of the Period"),
+    G_CALLBACK (gnc_main_window_cmd_tools_close_book) },
 
   /* Help menu */
 
@@ -528,6 +534,12 @@
 }
 
 static void
+gnc_main_window_cmd_tools_close_book (GtkAction *action, GncMainWindowActionData *data)
+{
+  gnc_ui_close_book(gnc_get_current_book());
+}
+
+static void
 gnc_main_window_cmd_tools_find_transactions (GtkAction *action, GncMainWindowActionData *data)
 {
   gnc_ui_find_transactions_dialog_create (NULL);

Modified: gnucash/branches/gda-dev2/src/gnome/lot-viewer.c
===================================================================
--- gnucash/branches/gda-dev2/src/gnome/lot-viewer.c	2007-12-26 05:17:37 UTC (rev 16730)
+++ gnucash/branches/gda-dev2/src/gnome/lot-viewer.c	2007-12-26 19:14:54 UTC (rev 16731)
@@ -64,6 +64,7 @@
 #define RESPONSE_DELETE        2
 #define RESPONSE_SCRUB_LOT     3
 #define RESPONSE_SCRUB_ACCOUNT 4
+#define RESPONSE_NEW_LOT       5
 
 #define GCONF_SECTION "dialogs/lot_viewer"
 #define GCONF_KEY_HPOSITION "hpane_position"
@@ -77,6 +78,7 @@
 #endif
    GtkButton     * delete_button;
    GtkButton     * scrub_lot_button;
+   GtkButton     * new_lot_button;
    GtkPaned      * lot_hpaned;
    GtkPaned      * lot_vpaned;
    GtkTreeView   * lot_view;
@@ -210,6 +212,26 @@
    gtk_clist_clear (lv->mini_clist);
 }
 
+static void 
+lv_save_current_row (GNCLotViewer *lv)
+{
+   GNCLot *lot = lv->selected_lot;
+   const char * str;
+   char * notes;
+
+   if (lot)
+   {
+      /* Get the title, save_the_title */
+      str = gtk_entry_get_text (lv->title_entry);
+      gnc_lot_set_title (lot, str);
+
+      /* Get the notes, save the notes */
+      notes = xxxgtk_textview_get_text (lv->lot_notes);
+      gnc_lot_set_notes (lot, notes);
+      g_free(notes);
+   }
+}
+
 /* ======================================================================== */
 /* Callback for selecting a row the the list-of-list clist */
 
@@ -219,6 +241,8 @@
 {
    const char * str;
 
+   lv_save_current_row (lv);
+
    str = gnc_lot_get_title (lot);
    if (!str) str = "";
    gtk_entry_set_text (lv->title_entry, str);
@@ -273,22 +297,8 @@
 static void 
 lv_unselect_row (GNCLotViewer *lv)
 {
-   GNCLot *lot = lv->selected_lot;
-   const char * str;
-   char * notes;
+   lv_save_current_row (lv);
 
-   if (lot)
-   {
-      /* Get the title, save_the_title */
-      str = gtk_entry_get_text (lv->title_entry);
-      gnc_lot_set_title (lot, str);
-
-      /* Get the notes, save the notes */
-      notes = xxxgtk_textview_get_text (lv->lot_notes);
-      gnc_lot_set_notes (lot, notes);
-      g_free(notes);
-   }
-
    lv_unset_lot (lv);
 }
 
@@ -488,21 +498,8 @@
    GNCLotViewer *lv = user_data;
    GNCLot *lot = lv->selected_lot;
 
-   if (lot)
-   {
-      const char * str;
-      char *notes;
+   lv_save_current_row (lv);
 
-      /* Get the title, save the title */
-      str = gtk_entry_get_text (lv->title_entry);
-      gnc_lot_set_title (lot, str);
-
-      /* Get the notes, save the notes */
-      notes = xxxgtk_textview_get_text (lv->lot_notes);
-      gnc_lot_set_notes (lot, notes);
-      g_free(notes);
-   }
-
    gnc_save_window_size(GCONF_SECTION, GTK_WINDOW(lv->window));
    gtk_widget_destroy (lv->window);
 }
@@ -582,6 +579,12 @@
      gnc_lot_viewer_fill (lv);
      lv_show_splits (lv);
      break;
+
+   case RESPONSE_NEW_LOT:
+     lv_save_current_row (lv);
+     lot = gnc_lot_make_default (lv->account);
+     xaccAccountInsertLot (lv->account, lot);
+     break;
    }
 }
 
@@ -659,6 +662,7 @@
 #endif
    lv->delete_button = GTK_BUTTON(glade_xml_get_widget (xml, "delete button"));
    lv->scrub_lot_button = GTK_BUTTON(glade_xml_get_widget (xml, "scrub lot button"));
+   lv->new_lot_button = GTK_BUTTON(glade_xml_get_widget (xml, "new lot button"));
 
    lv->lot_view = GTK_TREE_VIEW(glade_xml_get_widget (xml, "lot view"));
    lv_init_lot_view(lv);
@@ -709,7 +713,7 @@
 
    gnc_gui_component_watch_entity_type (component_id,
                GNC_ID_LOT,
-               QOF_EVENT_CREATE | QOF_EVENT_MODIFY | QOF_EVENT_DESTROY);
+               QOF_EVENT_CREATE | QOF_EVENT_ADD | QOF_EVENT_REMOVE | QOF_EVENT_MODIFY | QOF_EVENT_DESTROY);
 
    gtk_widget_show_all (lv->window);
    gnc_window_adjust_for_screen (GTK_WINDOW(lv->window));

Modified: gnucash/branches/gda-dev2/src/gnome/reconcile-list.c
===================================================================
--- gnucash/branches/gda-dev2/src/gnome/reconcile-list.c	2007-12-26 05:17:37 UTC (rev 16730)
+++ gnucash/branches/gda-dev2/src/gnome/reconcile-list.c	2007-12-26 19:14:54 UTC (rev 16731)
@@ -138,6 +138,7 @@
 
   list->account = account;
   list->list_type = type;
+  list->statement_date = statement_date;
 
   query = xaccMallocQuery();
   xaccQuerySetBook(query, gnc_get_current_book ());
@@ -577,9 +578,16 @@
 
     split = gtk_clist_get_row_data (clist, i);
 
-    recn = g_hash_table_lookup (list->reconciled, split) ? CREC : NREC;
+    // Don't change splits past reconciliation date that haven't been
+    // set to be reconciled
+    if ( difftime(list->statement_date,
+		  xaccTransGetDate(xaccSplitGetParent(split))) >= 0 ||
+	 g_hash_table_lookup(list->reconciled, split))
+    {
+      recn = g_hash_table_lookup (list->reconciled, split) ? CREC : NREC;
 
-    xaccSplitSetReconcile (split, recn);
+      xaccSplitSetReconcile (split, recn);
+    }
   }
   gnc_resume_gui_refresh();
 }

Modified: gnucash/branches/gda-dev2/src/gnome/reconcile-list.h
===================================================================
--- gnucash/branches/gda-dev2/src/gnome/reconcile-list.h	2007-12-26 05:17:37 UTC (rev 16730)
+++ gnucash/branches/gda-dev2/src/gnome/reconcile-list.h	2007-12-26 19:14:54 UTC (rev 16731)
@@ -49,6 +49,8 @@
   Account *account;
   GList *column_list;
 
+  time_t statement_date;
+
   GNCReconcileList *sibling;
   GNCReconcileListType list_type;
   gboolean no_toggle;

Modified: gnucash/branches/gda-dev2/src/gnome/schemas/apps_gnucash_dialog_commodities.schemas.in
===================================================================
--- gnucash/branches/gda-dev2/src/gnome/schemas/apps_gnucash_dialog_commodities.schemas.in	2007-12-26 05:17:37 UTC (rev 16730)
+++ gnucash/branches/gda-dev2/src/gnome/schemas/apps_gnucash_dialog_commodities.schemas.in	2007-12-26 19:14:54 UTC (rev 16731)
@@ -10,7 +10,7 @@
       <default>[namespace,symbol,name,printname,uniquename,cusip_code,fraction,quote_flag,quote_source,quote_timezone]</default>
       <locale name="C">
         <short>Order of columns in the dialog</short>
-        <long>This setting contains a list of name which control the order
+        <long>This setting contains a list of names which controls the order
 	in which the columns are listed in the dialog.  Names may be reordered
 	or removed from this list to control which columns appear in the dialog
 	and in what order.</long>

Modified: gnucash/branches/gda-dev2/src/gnome/schemas/apps_gnucash_dialog_common.schemas.in
===================================================================
--- gnucash/branches/gda-dev2/src/gnome/schemas/apps_gnucash_dialog_common.schemas.in	2007-12-26 05:17:37 UTC (rev 16730)
+++ gnucash/branches/gda-dev2/src/gnome/schemas/apps_gnucash_dialog_common.schemas.in	2007-12-26 19:14:54 UTC (rev 16731)
@@ -160,7 +160,7 @@
       <default>1.0</default>
       <locale name="C">
         <short>Default to 'new search' if fewer than this number of items is returned</short>
-        <long>Default to 'new search' if fewer than this number of items is returned.</long>
+        <long>Default to 'new search' if fewer than this number of items is returned</long>
       </locale>
     </schema>
 

Modified: gnucash/branches/gda-dev2/src/gnome/schemas/apps_gnucash_dialog_prices.schemas.in
===================================================================
--- gnucash/branches/gda-dev2/src/gnome/schemas/apps_gnucash_dialog_prices.schemas.in	2007-12-26 05:17:37 UTC (rev 16730)
+++ gnucash/branches/gda-dev2/src/gnome/schemas/apps_gnucash_dialog_prices.schemas.in	2007-12-26 19:14:54 UTC (rev 16731)
@@ -10,7 +10,7 @@
       <default>[commodity,currency,date,source,type,price]</default>
       <locale name="C">
         <short>Order of columns in the dialog</short>
-        <long>This setting contains a list of name which control the order
+        <long>This setting contains a list of names which controls the order
 	in which the columns are listed in the dialog.  Names may be reordered
 	or removed from this list to control which columns appear in the dialog
 	and in what order.</long>

Modified: gnucash/branches/gda-dev2/src/gnome/schemas/apps_gnucash_warnings.schemas.in
===================================================================
--- gnucash/branches/gda-dev2/src/gnome/schemas/apps_gnucash_warnings.schemas.in	2007-12-26 05:17:37 UTC (rev 16730)
+++ gnucash/branches/gda-dev2/src/gnome/schemas/apps_gnucash_warnings.schemas.in	2007-12-26 19:14:54 UTC (rev 16731)
@@ -75,8 +75,8 @@
       <type>int</type>
       <default>0</default>
       <locale name="C">
-        <short>Remove a splits from a transaction</short>
-        <long>This dialog is presented before allowing you to remove a splits from a transaction.</long>
+        <short>Remove a split from a transaction</short>
+        <long>This dialog is presented before allowing you to remove a split from a transaction.</long>
       </locale>
     </schema>
 
@@ -88,7 +88,7 @@
       <type>int</type>
       <default>0</default>
       <locale name="C">
-        <short>Remove a splits from a transaction</short>
+        <short>Remove a reconciled split from a transaction</short>
         <long>This dialog is presented before allowing you to remove a reconciled split from a transaction.  Doing so will throw off the reconciled value of the register and can make it hard to perform future reconciliations.</long>
       </locale>
     </schema>

Modified: gnucash/branches/gda-dev2/src/gnome/ui/gnc-plugin-basic-commands-ui.xml
===================================================================
--- gnucash/branches/gda-dev2/src/gnome/ui/gnc-plugin-basic-commands-ui.xml	2007-12-26 05:17:37 UTC (rev 16730)
+++ gnucash/branches/gda-dev2/src/gnome/ui/gnc-plugin-basic-commands-ui.xml	2007-12-26 19:14:54 UTC (rev 16731)
@@ -59,6 +59,7 @@
         <menuitem name="ToolsPriceEditor" action="ToolsPriceEditorAction"/>
         <menuitem name="ToolsCommodityEditor" action="ToolsCommodityEditorAction"/>
         <menuitem name="ToolsFinancialCalculator" action="ToolsFinancialCalculatorAction"/>
+        <menuitem name="ToolsBookClose" action="ToolsBookCloseAction"/>
       </placeholder>
     </menu>
 

Modified: gnucash/branches/gda-dev2/src/gnome-utils/Makefile.am
===================================================================
--- gnucash/branches/gda-dev2/src/gnome-utils/Makefile.am	2007-12-26 05:17:37 UTC (rev 16730)
+++ gnucash/branches/gda-dev2/src/gnome-utils/Makefile.am	2007-12-26 19:14:54 UTC (rev 16731)
@@ -27,6 +27,7 @@
   account-quickfill.c \
   cursors.c \
   dialog-account.c \
+  dialog-book-close.c \
   dialog-commodity.c \
   dialog-options.c \
   dialog-preferences.c \
@@ -100,6 +101,7 @@
   QuickFill.h \
   account-quickfill.h \
   dialog-account.h \
+  dialog-book-close.h \
   dialog-commodity.h \
   dialog-preferences.h \
   dialog-options.h \

Copied: gnucash/branches/gda-dev2/src/gnome-utils/dialog-book-close.c (from rev 16730, gnucash/trunk/src/gnome-utils/dialog-book-close.c)
===================================================================
--- gnucash/branches/gda-dev2/src/gnome-utils/dialog-book-close.c	                        (rev 0)
+++ gnucash/branches/gda-dev2/src/gnome-utils/dialog-book-close.c	2007-12-26 19:14:54 UTC (rev 16731)
@@ -0,0 +1,340 @@
+/********************************************************************\
+ * dialog-book-close.c -- dialog for helping the user close the     *
+ *                        book at the end of the year by adding     *
+ *                        zero-izing splits to all Income and       *
+ *                        Expense accounts                          *
+ *                                                                  *
+ * Copyright (C) 2007-8 Derek Atkins <derek at ihtfp.com>              *
+ *                                                                  *
+ * This program is free software; you can redistribute it and/or    *
+ * modify it under the terms of the GNU General Public License as   *
+ * published by the Free Software Foundation; either version 2 of   *
+ * the License, or (at your option) any later version.              *
+ *                                                                  *
+ * This program is distributed in the hope that it will be useful,  *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
+ * GNU General Public License for more details.                     *
+ *                                                                  *
+ * You should have received a copy of the GNU General Public License*
+ * along with this program; if not, contact:                        *
+ *                                                                  *
+ * Free Software Foundation           Voice:  +1-617-542-5942       *
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org                   *
+\********************************************************************/
+
+#include "config.h"
+
+#include <gtk/gtk.h>
+#include <glib/gi18n.h>
+#include <glade/glade.h>
+
+#include "dialog-utils.h"
+#include "gnc-engine.h"
+#include "Transaction.h"
+#include "Split.h"
+#include "Account.h"
+#include "gnc-ui.h"
+#include "gnc-gui-query.h"
+#include "dialog-book-close.h"
+#include "gnc-account-sel.h"
+#include "gnc-date-edit.h"
+
+void gnc_book_close_response_cb(GtkDialog *, gint, GtkDialog *);
+
+struct CloseBookWindow
+{
+  /* Passed in by the creator */
+  QofBook* book;
+
+  /* Parts of the dialog */
+  GtkWidget* dialog;
+  GtkWidget* close_date_widget;
+  GtkWidget* income_acct_widget;
+  GtkWidget* expense_acct_widget;
+  GtkWidget* desc_widget;
+
+  /* The final settings */
+  time_t close_date;
+  const char* desc;
+};
+
+struct CloseAccountsCB
+{
+  struct CloseBookWindow* cbw;
+  Account* base_acct;
+  GNCAccountType acct_type;
+  GHashTable* txns;
+  guint hash_size;
+};
+
+struct CACBTransactionList
+{
+  gnc_commodity* cmdty;
+  Transaction* txn;
+  gnc_numeric total;
+};
+
+static struct CACBTransactionList*
+find_or_create_txn(struct CloseAccountsCB* cacb, gnc_commodity* cmdty)
+{
+  struct CACBTransactionList* txn;
+
+  g_return_val_if_fail(cacb, NULL);
+  g_return_val_if_fail(cmdty, NULL);
+
+  txn = g_hash_table_lookup(cacb->txns, cmdty);
+  if (!txn)
+  {
+    txn = g_new0(struct CACBTransactionList, 1);
+    txn->cmdty = cmdty;
+    txn->total = gnc_numeric_zero();
+    txn->txn = xaccMallocTransaction(cacb->cbw->book);
+    xaccTransBeginEdit(txn->txn);
+    xaccTransSetDateEnteredSecs(txn->txn, time(NULL));
+    xaccTransSetDatePostedSecs(txn->txn, cacb->cbw->close_date);
+    xaccTransSetDescription(txn->txn, cacb->cbw->desc);
+    xaccTransSetCurrency(txn->txn, cmdty);
+
+    g_hash_table_insert(cacb->txns, cmdty, txn);
+  }
+
+  return txn;
+}
+
+/* Make sure that the account is of the correct type.
+ * then make sure the account has a balance as of the closing date.
+ * then get the account commodity and find the appropriate
+ * balancing transaction for that commodity and add this balance
+ * to it.
+ */
+static void close_accounts_cb(Account *a, gpointer data)
+{
+  struct CloseAccountsCB* cacb = data;
+  struct CACBTransactionList* txn;
+  gnc_commodity* acct_commodity;
+  Split* split;
+  gnc_numeric bal;
+
+  g_return_if_fail(a);
+  g_return_if_fail(cacb);
+  g_return_if_fail(cacb->cbw);
+  g_return_if_fail(cacb->txns);
+
+  if (cacb->acct_type != xaccAccountGetType(a))
+    return;
+
+  bal = xaccAccountGetBalanceAsOfDate(a, cacb->cbw->close_date);
+  if (gnc_numeric_zero_p(bal))
+    return;
+
+  acct_commodity = xaccAccountGetCommodity(a);
+  g_assert(acct_commodity);
+
+  txn = find_or_create_txn(cacb, acct_commodity);
+  g_assert(txn);
+  
+  split = xaccMallocSplit(cacb->cbw->book);
+  xaccSplitSetParent(split, txn->txn);
+  xaccAccountBeginEdit(a);
+  xaccAccountInsertSplit(a, split);
+  xaccSplitSetBaseValue(split, gnc_numeric_neg(bal), acct_commodity);
+  xaccAccountCommitEdit(a);
+  txn->total = gnc_numeric_add(txn->total, bal, GNC_DENOM_AUTO,
+			       GNC_HOW_DENOM_FIXED | GNC_HOW_RND_NEVER);
+}
+
+
+static void finish_txn_cb(gnc_commodity* cmdty,
+			  struct CACBTransactionList* txn,
+			  struct CloseAccountsCB* cacb)
+{
+  Account* acc;
+  Split* split;
+
+  g_return_if_fail(cmdty);
+  g_return_if_fail(txn);
+  g_return_if_fail(cacb);
+  g_return_if_fail(cacb->hash_size);
+
+  /* If we only have one currency and the base account uses
+   * that currency, then we can use that account.  Otherwise,
+   * create a subaccount for each currency.
+   */
+  if (cacb->hash_size == 1 &&
+      gnc_commodity_equal(cmdty, xaccAccountGetCommodity(cacb->base_acct)))
+    acc = cacb->base_acct;
+  else
+  {
+    /* See if we already have an account by that name */
+    acc = gnc_account_lookup_by_name(cacb->base_acct,
+				     gnc_commodity_get_mnemonic(cmdty));
+
+    /* If not, then create one */
+    if (!acc)
+    {
+      acc = xaccMallocAccount(cacb->cbw->book);
+      xaccAccountBeginEdit(acc);
+      xaccAccountSetType(acc, ACCT_TYPE_EQUITY);
+      xaccAccountSetName(acc, gnc_commodity_get_mnemonic(cmdty));
+      xaccAccountSetDescription(acc, gnc_commodity_get_mnemonic(cmdty));
+      xaccAccountSetCommodity(acc, cmdty);
+      gnc_account_append_child(cacb->base_acct, acc);
+      xaccAccountCommitEdit(acc);
+    }
+  }
+  /* Make sure the account exists and is of the correct commodity */
+  g_assert(acc);
+  g_assert(gnc_commodity_equal(cmdty, xaccAccountGetCommodity(acc)));
+
+  /* Create the split for the Equity account to balance out
+   * all the accounts of this.  Use the "total".
+   */
+  split = xaccMallocSplit(cacb->cbw->book);
+  xaccSplitSetParent(split, txn->txn);
+  xaccAccountBeginEdit(acc);
+  xaccAccountInsertSplit(acc, split);
+  xaccSplitSetBaseValue(split, txn->total, cmdty);
+  xaccAccountCommitEdit(acc);
+  xaccTransCommitEdit(txn->txn);
+}
+
+static void close_accounts_of_type(struct CloseBookWindow* cbw,
+				   Account* acct,
+				   GNCAccountType acct_type)
+{
+  struct CloseAccountsCB cacb;
+  Account* root_acct;
+
+  g_return_if_fail(cbw);
+  g_return_if_fail(acct);
+
+  cacb.cbw = cbw;
+  cacb.base_acct = acct;
+  cacb.acct_type = acct_type;
+  cacb.txns = g_hash_table_new_full(g_direct_hash,
+				    (GEqualFunc)gnc_commodity_equal,
+				    NULL, g_free);
+
+  /* Iterate through all accounts and set up the balancing splits */
+  root_acct = gnc_book_get_root_account(cbw->book);
+  gnc_account_foreach_descendant(root_acct, close_accounts_cb, &cacb);
+
+  /* now iterate through the transactions and handle each currency */
+  cacb.hash_size = g_hash_table_size(cacb.txns);
+  if (cacb.hash_size)
+    g_hash_table_foreach(cacb.txns, (GHFunc)finish_txn_cb, &cacb);
+
+  /* Destroy the table, freeing the used memory */
+  g_hash_table_destroy(cacb.txns);
+}
+
+
+void
+gnc_book_close_response_cb(GtkDialog *dialog, gint response, GtkDialog *unused)
+{
+  struct CloseBookWindow* cbw;
+  Account* income_acct;
+  Account* expense_acct;
+
+  g_return_if_fail(dialog);
+
+  cbw = g_object_get_data(G_OBJECT(dialog), "CloseBookWindow");
+  g_return_if_fail(cbw);
+
+  switch (response)
+  {
+  case GTK_RESPONSE_HELP:
+     gnc_gnome_help(HF_HELP, HL_GLOBPREFS);
+     break;
+  case GTK_RESPONSE_OK:
+    cbw->close_date = gnc_date_edit_get_date(GNC_DATE_EDIT(cbw->close_date_widget));
+    cbw->close_date += (3600 * 12);  /* Add 12 hours to the timestamp */
+    cbw->desc = gtk_entry_get_text(GTK_ENTRY(cbw->desc_widget));
+
+    income_acct = gnc_account_sel_get_account(GNC_ACCOUNT_SEL(cbw->income_acct_widget));
+    expense_acct = gnc_account_sel_get_account(GNC_ACCOUNT_SEL(cbw->expense_acct_widget));
+
+    if (!income_acct)
+    {
+      gnc_error_dialog(cbw->dialog, "%s",
+		       _("Please select an Equity account to hold the total Period Income."));
+      break;
+    }
+
+    if (!expense_acct)
+    {
+      gnc_error_dialog(cbw->dialog, "%s",
+		       _("Please select an Equity account to hold the total Period Expense."));
+      break;
+    }
+
+    close_accounts_of_type(cbw, income_acct, ACCT_TYPE_INCOME);
+    close_accounts_of_type(cbw, expense_acct, ACCT_TYPE_EXPENSE);
+
+    /* FALLTHROUGH */ 
+  default:
+     gtk_widget_destroy(GTK_WIDGET(dialog));
+     break;
+  }
+}
+
+void gnc_ui_close_book (QofBook* book)
+{
+  struct CloseBookWindow *cbw;
+  GladeXML* xml;
+  GtkWidget* box;
+  GList* equity_list = NULL;
+
+  g_return_if_fail(book);
+
+  cbw = g_new0(struct CloseBookWindow, 1);
+  g_return_if_fail(cbw);
+  cbw->book = book;
+
+  /* Open the dialog */
+  xml = gnc_glade_xml_new("dialog-book-close.glade", "Close Book");
+  cbw->dialog = glade_xml_get_widget(xml, "Close Book");
+
+  /* close date */
+  box = glade_xml_get_widget(xml, "date_box");
+  cbw->close_date_widget = gnc_date_edit_new(time(NULL), FALSE, FALSE);
+  gtk_box_pack_start(GTK_BOX(box), cbw->close_date_widget, TRUE, TRUE, 0);
+
+  /* income acct */
+  equity_list = g_list_prepend(equity_list, GINT_TO_POINTER(ACCT_TYPE_EQUITY));
+  box = glade_xml_get_widget(xml, "income_acct_box");
+  cbw->income_acct_widget = gnc_account_sel_new();
+  gnc_account_sel_set_acct_filters(GNC_ACCOUNT_SEL(cbw->income_acct_widget),
+				   equity_list);
+  gnc_account_sel_set_new_account_ability(GNC_ACCOUNT_SEL(cbw->income_acct_widget), TRUE);
+  gtk_box_pack_start(GTK_BOX(box), cbw->income_acct_widget, TRUE, TRUE, 0);
+
+  /* expense acct */
+  box = glade_xml_get_widget(xml, "expense_acct_box");
+  cbw->expense_acct_widget = gnc_account_sel_new();
+  gnc_account_sel_set_acct_filters(GNC_ACCOUNT_SEL(cbw->expense_acct_widget),
+				   equity_list);
+  gnc_account_sel_set_new_account_ability(GNC_ACCOUNT_SEL(cbw->expense_acct_widget), TRUE);
+  gtk_box_pack_start(GTK_BOX(box), cbw->expense_acct_widget, TRUE, TRUE, 0);
+
+  /* desc */
+  cbw->desc_widget = glade_xml_get_widget(xml, "desc_entry");
+
+  /* Autoconnect signals */
+  glade_xml_signal_autoconnect_full(xml, gnc_glade_autoconnect_full_func,
+				    cbw->dialog);
+
+  /* Clean up the xml data structure when the dialog is destroyed */
+  g_object_set_data_full(G_OBJECT(cbw->dialog), "dialog-book-close.glade",
+			 xml, g_object_unref);
+  g_object_set_data_full(G_OBJECT(cbw->dialog), "CloseBookWindow", cbw,
+			 g_free);
+
+  /* Run the dialog */
+  gtk_widget_show_all(cbw->dialog);
+
+  g_list_free(equity_list);
+}
+

Copied: gnucash/branches/gda-dev2/src/gnome-utils/dialog-book-close.h (from rev 16730, gnucash/trunk/src/gnome-utils/dialog-book-close.h)
===================================================================
--- gnucash/branches/gda-dev2/src/gnome-utils/dialog-book-close.h	                        (rev 0)
+++ gnucash/branches/gda-dev2/src/gnome-utils/dialog-book-close.h	2007-12-26 19:14:54 UTC (rev 16731)
@@ -0,0 +1,49 @@
+/********************************************************************\
+ * dialog-book-close.h -- dialog for helping the user close the     *
+ *                        book at the end of the year by adding     *
+ *                        zero-izing splits to all Income and       *
+ *                        Expense accounts                          *
+ *                                                                  *
+ * Copyright (C) 2007-8 Derek Atkins <derek at ihtfp.com>              *
+ *                                                                  *
+ * This program is free software; you can redistribute it and/or    *
+ * modify it under the terms of the GNU General Public License as   *
+ * published by the Free Software Foundation; either version 2 of   *
+ * the License, or (at your option) any later version.              *
+ *                                                                  *
+ * This program is distributed in the hope that it will be useful,  *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
+ * GNU General Public License for more details.                     *
+ *                                                                  *
+ * You should have received a copy of the GNU General Public License*
+ * along with this program; if not, contact:                        *
+ *                                                                  *
+ * Free Software Foundation           Voice:  +1-617-542-5942       *
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org                   *
+\********************************************************************/
+
+#ifndef DIALOG_BOOK_CLOSE_H
+#define DIALOG_BOOK_CLOSE_H
+
+/** @addtogroup GUI
+    @{ */
+/** @file dialog-book-close.h
+ *
+ *  This file contains the functions to present a GUI to select
+ *  a book closing date and accounts into which to close the
+ *  Income and Expense accounts.
+ */
+
+/** Create and run the dialog to close the book.
+ *
+ *  @param book This parameter specifies the book whose data
+ *  will be closed.
+ */
+void gnc_ui_close_book (QofBook* book);
+
+
+/** @} */
+
+#endif /* DIALOG_BOOK_CLOSE_H */

Modified: gnucash/branches/gda-dev2/src/gnome-utils/dialog-commodity.c
===================================================================
--- gnucash/branches/gda-dev2/src/gnome-utils/dialog-commodity.c	2007-12-26 05:17:37 UTC (rev 16730)
+++ gnucash/branches/gda-dev2/src/gnome-utils/dialog-commodity.c	2007-12-26 19:14:54 UTC (rev 16731)
@@ -1194,7 +1194,7 @@
     if (w->edit_commodity) {
       c = w->edit_commodity;
       gnc_commodity_begin_edit(c);
-      gnc_commodity_set_quote_flag (c, gtk_toggle_button_get_active
+      gnc_commodity_user_set_quote_flag (c, gtk_toggle_button_get_active
 				    (GTK_TOGGLE_BUTTON (w->get_quote_check)));
       selection = gtk_combo_box_get_active(GTK_COMBO_BOX(w->quote_tz_menu));
       string = gnc_timezone_menu_position_to_string(selection);
@@ -1237,7 +1237,7 @@
       gnc_commodity_set_fraction (c, fraction);
     }
 
-    gnc_commodity_set_quote_flag (c, gtk_toggle_button_get_active
+    gnc_commodity_user_set_quote_flag (c, gtk_toggle_button_get_active
 				  (GTK_TOGGLE_BUTTON (w->get_quote_check)));
 
     for (type = SOURCE_SINGLE; type < SOURCE_MAX; type++) {

Modified: gnucash/branches/gda-dev2/src/gnome-utils/glade/Makefile.am
===================================================================
--- gnucash/branches/gda-dev2/src/gnome-utils/glade/Makefile.am	2007-12-26 05:17:37 UTC (rev 16730)
+++ gnucash/branches/gda-dev2/src/gnome-utils/glade/Makefile.am	2007-12-26 19:14:54 UTC (rev 16731)
@@ -1,6 +1,7 @@
 gladedir = $(GNC_GLADE_DIR)
 glade_DATA = \
   commodity.glade \
+  dialog-book-close.glade \
   dialog-query-list.glade \
   dialog-reset-warnings.glade \
   druid-provider-multifile.glade \

Copied: gnucash/branches/gda-dev2/src/gnome-utils/glade/dialog-book-close.glade (from rev 16730, gnucash/trunk/src/gnome-utils/glade/dialog-book-close.glade)
===================================================================
--- gnucash/branches/gda-dev2/src/gnome-utils/glade/dialog-book-close.glade	                        (rev 0)
+++ gnucash/branches/gda-dev2/src/gnome-utils/glade/dialog-book-close.glade	2007-12-26 19:14:54 UTC (rev 16731)
@@ -0,0 +1,293 @@
+<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
+<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
+
+<glade-interface>
+
+<widget class="GtkDialog" id="Close Book">
+  <property name="visible">True</property>
+  <property name="title" translatable="yes">Close Book</property>
+  <property name="type">GTK_WINDOW_TOPLEVEL</property>
+  <property name="window_position">GTK_WIN_POS_NONE</property>
+  <property name="modal">False</property>
+  <property name="resizable">True</property>
+  <property name="destroy_with_parent">False</property>
+  <property name="decorated">True</property>
+  <property name="skip_taskbar_hint">False</property>
+  <property name="skip_pager_hint">False</property>
+  <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
+  <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
+  <property name="focus_on_map">True</property>
+  <property name="urgency_hint">False</property>
+  <property name="has_separator">True</property>
+  <signal name="response" handler="gnc_book_close_response_cb" last_modification_time="Mon, 24 Dec 2007 03:23:33 GMT"/>
+
+  <child internal-child="vbox">
+    <widget class="GtkVBox" id="dialog-vbox1">
+      <property name="visible">True</property>
+      <property name="homogeneous">False</property>
+      <property name="spacing">0</property>
+
+      <child internal-child="action_area">
+	<widget class="GtkHButtonBox" id="dialog-action_area1">
+	  <property name="visible">True</property>
+	  <property name="layout_style">GTK_BUTTONBOX_END</property>
+
+	  <child>
+	    <widget class="GtkButton" id="helpbutton1">
+	      <property name="visible">True</property>
+	      <property name="can_default">True</property>
+	      <property name="can_focus">True</property>
+	      <property name="label">gtk-help</property>
+	      <property name="use_stock">True</property>
+	      <property name="relief">GTK_RELIEF_NORMAL</property>
+	      <property name="focus_on_click">True</property>
+	      <property name="response_id">-11</property>
+	    </widget>
+	  </child>
+
+	  <child>
+	    <widget class="GtkButton" id="cancelbutton1">
+	      <property name="visible">True</property>
+	      <property name="can_default">True</property>
+	      <property name="can_focus">True</property>
+	      <property name="label">gtk-cancel</property>
+	      <property name="use_stock">True</property>
+	      <property name="relief">GTK_RELIEF_NORMAL</property>
+	      <property name="focus_on_click">True</property>
+	      <property name="response_id">-6</property>
+	    </widget>
+	  </child>
+
+	  <child>
+	    <widget class="GtkButton" id="okbutton1">
+	      <property name="visible">True</property>
+	      <property name="can_default">True</property>
+	      <property name="can_focus">True</property>
+	      <property name="label">gtk-ok</property>
+	      <property name="use_stock">True</property>
+	      <property name="relief">GTK_RELIEF_NORMAL</property>
+	      <property name="focus_on_click">True</property>
+	      <property name="response_id">-5</property>
+	    </widget>
+	  </child>
+	</widget>
+	<packing>
+	  <property name="padding">0</property>
+	  <property name="expand">False</property>
+	  <property name="fill">True</property>
+	  <property name="pack_type">GTK_PACK_END</property>
+	</packing>
+      </child>
+
+      <child>
+	<widget class="GtkTable" id="table2">
+	  <property name="visible">True</property>
+	  <property name="n_rows">4</property>
+	  <property name="n_columns">2</property>
+	  <property name="homogeneous">False</property>
+	  <property name="row_spacing">0</property>
+	  <property name="column_spacing">0</property>
+
+	  <child>
+	    <widget class="GtkLabel" id="label1">
+	      <property name="visible">True</property>
+	      <property name="label" translatable="yes">Closing Date:</property>
+	      <property name="use_underline">False</property>
+	      <property name="use_markup">False</property>
+	      <property name="justify">GTK_JUSTIFY_LEFT</property>
+	      <property name="wrap">False</property>
+	      <property name="selectable">False</property>
+	      <property name="xalign">0</property>
+	      <property name="yalign">0.5</property>
+	      <property name="xpad">0</property>
+	      <property name="ypad">0</property>
+	      <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+	      <property name="width_chars">-1</property>
+	      <property name="single_line_mode">False</property>
+	      <property name="angle">0</property>
+	    </widget>
+	    <packing>
+	      <property name="left_attach">0</property>
+	      <property name="right_attach">1</property>
+	      <property name="top_attach">0</property>
+	      <property name="bottom_attach">1</property>
+	      <property name="x_options">fill</property>
+	      <property name="y_options"></property>
+	    </packing>
+	  </child>
+
+	  <child>
+	    <widget class="GtkLabel" id="label2">
+	      <property name="visible">True</property>
+	      <property name="label" translatable="yes">Income Total:</property>
+	      <property name="use_underline">False</property>
+	      <property name="use_markup">False</property>
+	      <property name="justify">GTK_JUSTIFY_LEFT</property>
+	      <property name="wrap">False</property>
+	      <property name="selectable">False</property>
+	      <property name="xalign">0</property>
+	      <property name="yalign">0.5</property>
+	      <property name="xpad">0</property>
+	      <property name="ypad">0</property>
+	      <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+	      <property name="width_chars">-1</property>
+	      <property name="single_line_mode">False</property>
+	      <property name="angle">0</property>
+	    </widget>
+	    <packing>
+	      <property name="left_attach">0</property>
+	      <property name="right_attach">1</property>
+	      <property name="top_attach">1</property>
+	      <property name="bottom_attach">2</property>
+	      <property name="x_options">fill</property>
+	      <property name="y_options"></property>
+	    </packing>
+	  </child>
+
+	  <child>
+	    <widget class="GtkLabel" id="label3">
+	      <property name="visible">True</property>
+	      <property name="label" translatable="yes">Expense Total:</property>
+	      <property name="use_underline">False</property>
+	      <property name="use_markup">False</property>
+	      <property name="justify">GTK_JUSTIFY_LEFT</property>
+	      <property name="wrap">False</property>
+	      <property name="selectable">False</property>
+	      <property name="xalign">0</property>
+	      <property name="yalign">0.5</property>
+	      <property name="xpad">0</property>
+	      <property name="ypad">0</property>
+	      <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+	      <property name="width_chars">-1</property>
+	      <property name="single_line_mode">False</property>
+	      <property name="angle">0</property>
+	    </widget>
+	    <packing>
+	      <property name="left_attach">0</property>
+	      <property name="right_attach">1</property>
+	      <property name="top_attach">2</property>
+	      <property name="bottom_attach">3</property>
+	      <property name="x_options">fill</property>
+	      <property name="y_options"></property>
+	    </packing>
+	  </child>
+
+	  <child>
+	    <widget class="GtkHBox" id="date_box">
+	      <property name="visible">True</property>
+	      <property name="homogeneous">False</property>
+	      <property name="spacing">0</property>
+
+	      <child>
+		<placeholder/>
+	      </child>
+	    </widget>
+	    <packing>
+	      <property name="left_attach">1</property>
+	      <property name="right_attach">2</property>
+	      <property name="top_attach">0</property>
+	      <property name="bottom_attach">1</property>
+	      <property name="y_options">fill</property>
+	    </packing>
+	  </child>
+
+	  <child>
+	    <widget class="GtkHBox" id="income_acct_box">
+	      <property name="visible">True</property>
+	      <property name="homogeneous">False</property>
+	      <property name="spacing">0</property>
+
+	      <child>
+		<placeholder/>
+	      </child>
+	    </widget>
+	    <packing>
+	      <property name="left_attach">1</property>
+	      <property name="right_attach">2</property>
+	      <property name="top_attach">1</property>
+	      <property name="bottom_attach">2</property>
+	      <property name="x_options">fill</property>
+	      <property name="y_options">fill</property>
+	    </packing>
+	  </child>
+
+	  <child>
+	    <widget class="GtkHBox" id="expense_acct_box">
+	      <property name="visible">True</property>
+	      <property name="homogeneous">False</property>
+	      <property name="spacing">0</property>
+
+	      <child>
+		<placeholder/>
+	      </child>
+	    </widget>
+	    <packing>
+	      <property name="left_attach">1</property>
+	      <property name="right_attach">2</property>
+	      <property name="top_attach">2</property>
+	      <property name="bottom_attach">3</property>
+	      <property name="x_options">fill</property>
+	      <property name="y_options">fill</property>
+	    </packing>
+	  </child>
+
+	  <child>
+	    <widget class="GtkLabel" id="label4">
+	      <property name="visible">True</property>
+	      <property name="label" translatable="yes">Description:</property>
+	      <property name="use_underline">False</property>
+	      <property name="use_markup">False</property>
+	      <property name="justify">GTK_JUSTIFY_LEFT</property>
+	      <property name="wrap">False</property>
+	      <property name="selectable">False</property>
+	      <property name="xalign">0</property>
+	      <property name="yalign">0.5</property>
+	      <property name="xpad">0</property>
+	      <property name="ypad">0</property>
+	      <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+	      <property name="width_chars">-1</property>
+	      <property name="single_line_mode">False</property>
+	      <property name="angle">0</property>
+	    </widget>
+	    <packing>
+	      <property name="left_attach">0</property>
+	      <property name="right_attach">1</property>
+	      <property name="top_attach">3</property>
+	      <property name="bottom_attach">4</property>
+	      <property name="x_options">fill</property>
+	      <property name="y_options"></property>
+	    </packing>
+	  </child>
+
+	  <child>
+	    <widget class="GtkEntry" id="desc_entry">
+	      <property name="visible">True</property>
+	      <property name="can_focus">True</property>
+	      <property name="editable">True</property>
+	      <property name="visibility">True</property>
+	      <property name="max_length">0</property>
+	      <property name="text" translatable="yes"></property>
+	      <property name="has_frame">True</property>
+	      <property name="invisible_char">•</property>
+	      <property name="activates_default">False</property>
+	    </widget>
+	    <packing>
+	      <property name="left_attach">1</property>
+	      <property name="right_attach">2</property>
+	      <property name="top_attach">3</property>
+	      <property name="bottom_attach">4</property>
+	      <property name="y_options"></property>
+	    </packing>
+	  </child>
+	</widget>
+	<packing>
+	  <property name="padding">0</property>
+	  <property name="expand">True</property>
+	  <property name="fill">True</property>
+	</packing>
+      </child>
+    </widget>
+  </child>
+</widget>
+
+</glade-interface>

Modified: gnucash/branches/gda-dev2/src/gnome-utils/gnc-main-window.c
===================================================================
--- gnucash/branches/gda-dev2/src/gnome-utils/gnc-main-window.c	2007-12-26 05:17:37 UTC (rev 16730)
+++ gnucash/branches/gda-dev2/src/gnome-utils/gnc-main-window.c	2007-12-26 19:14:54 UTC (rev 16731)
@@ -275,7 +275,7 @@
 
 	{ "ScrubMenuAction", NULL, N_("_Check & Repair"), NULL, NULL, NULL },
 	{ "ActionsForgetWarningsAction", NULL, N_("Reset _Warnings..."), NULL,
-	  N_("Reset the state of all warning message so they will be shown again."),
+	  N_("Reset the state of all warning messages so they will be shown again."),
 	  G_CALLBACK (gnc_main_window_cmd_actions_reset_warnings) },
 	{ "ActionsRenamePageAction", NULL, N_("Re_name Page"), NULL,
 	  N_("Rename this page."),

Modified: gnucash/branches/gda-dev2/src/gnome-utils/gnc-tree-view-account.c
===================================================================
--- gnucash/branches/gda-dev2/src/gnome-utils/gnc-tree-view-account.c	2007-12-26 05:17:37 UTC (rev 16730)
+++ gnucash/branches/gda-dev2/src/gnome-utils/gnc-tree-view-account.c	2007-12-26 19:14:54 UTC (rev 16731)
@@ -1119,6 +1119,11 @@
   gtk_tree_path_free(parent_path);
 
   gtk_tree_selection_select_path (selection, s_path);
+
+  /* give gtk+ a chance to resize the tree view first by handling pending
+   * configure events */
+  while (gtk_events_pending ())
+    gtk_main_iteration ();
   gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW(view), s_path, NULL, FALSE, 0.0, 0.0);
   debug_path(LEAVE, s_path);
   gtk_tree_path_free(s_path);

Modified: gnucash/branches/gda-dev2/src/import-export/generic-import.glade
===================================================================
--- gnucash/branches/gda-dev2/src/import-export/generic-import.glade	2007-12-26 05:17:37 UTC (rev 16730)
+++ gnucash/branches/gda-dev2/src/import-export/generic-import.glade	2007-12-26 19:14:54 UTC (rev 16731)
@@ -576,7 +576,7 @@
 check whether GnuCash chose the right existing transaction.
 To switch transactions between both states, click on the checkmark in the &quot;New&quot; column.
 When all new transactions have the correct destination account and all duplicates are matched with the right existing transaction, 
-click &quot;Ok&quot;.</property>
+click &quot;OK&quot;.</property>
 	      <property name="use_underline">False</property>
 	      <property name="use_markup">False</property>
 	      <property name="justify">GTK_JUSTIFY_LEFT</property>
@@ -1073,7 +1073,7 @@
       <child>
 	<widget class="GtkSpinButton" id="gconf/dialogs/import/generic_matcher/atm_fee_threshold">
 	  <property name="visible">True</property>
-	  <property name="tooltip" translatable="yes">In some places commercial ATMs (not belonging to a financial institution) are installed in places like convienience store.  These ATM add its fee directly to the amount instead of showing up as a separate transaction or in your monthly banking fees.  For example, you withdraw 100$, and you are charged 101,50$ plus Interac fees.  If you manually entered that 100$, the amounts won't match.  You should set this to whatever is the maximum such fee in your area (in units of your local currency), so the transaction will be recognised as a match.</property>
+	  <property name="tooltip" translatable="yes">In some places commercial ATMs (not belonging to a financial institution) are installed in places like convenience stores.  These ATMs add their fee directly to the amount instead of showing up as a separate transaction or in your monthly banking fees.  For example, you withdraw $100, and you are charged $101,50 plus Interac fees.  If you manually entered that $100, the amounts won't match.  You should set this to whatever is the maximum such fee in your area (in units of your local currency), so the transaction will be recognised as a match.</property>
 	  <property name="can_focus">True</property>
 	  <property name="climb_rate">1</property>
 	  <property name="digits">2</property>

Modified: gnucash/branches/gda-dev2/src/import-export/hbci/glade/hbci.glade
===================================================================
--- gnucash/branches/gda-dev2/src/import-export/hbci/glade/hbci.glade	2007-12-26 05:17:37 UTC (rev 16730)
+++ gnucash/branches/gda-dev2/src/import-export/hbci/glade/hbci.glade	2007-12-26 19:14:54 UTC (rev 16731)
@@ -86,7 +86,7 @@
 		      <child>
 			<widget class="GtkLabel" id="label8877441">
 			  <property name="visible">True</property>
-			  <property name="label" translatable="yes">The Setup of your Online Banking connection is handled by the external program &quot;AqBanking Setup Wizard&quot;. Please press the button below to start this program.	</property>
+			  <property name="label" translatable="yes">The Setup of your Online Banking connection is handled by the external program &quot;AqBanking Setup Wizard&quot;. Please press the button below to start this program.</property>
 			  <property name="use_underline">False</property>
 			  <property name="use_markup">False</property>
 			  <property name="justify">GTK_JUSTIFY_LEFT</property>

Modified: gnucash/branches/gda-dev2/src/import-export/qif-import/qif.glade
===================================================================
--- gnucash/branches/gda-dev2/src/import-export/qif-import/qif.glade	2007-12-26 05:17:37 UTC (rev 16730)
+++ gnucash/branches/gda-dev2/src/import-export/qif-import/qif.glade	2007-12-26 19:14:54 UTC (rev 16731)
@@ -1119,7 +1119,7 @@
 		  <property name="visible">True</property>
 		  <property name="label" translatable="yes">If you are importing a QIF file downloaded from a bank or other financial institution, some of the information in the QIF file may duplicate information already in your GnuCash accounts.  GnuCash will try to detect duplicates of existing transactions.  
 
-On the next page, you will be asked to confirm that an existing transaction matches an imported transaction.  Imported transactions are shown on the left side of the page, and possible  matches for the selected left-hand transaction are shown  to the right.  There may be several old transactions that could match an imported transaction; you will be able to select the correct one by double-clicking in the &quot;Dup?&quot; column of the correct transaction.
+On the next page, you will be asked to confirm that an existing transaction matches an imported transaction.  Imported transactions are shown on the left side of the page, and possible matches for the selected left-hand transaction are shown to the right.  There may be several old transactions that could match an imported transaction; you will be able to select the correct one by double-clicking in the &quot;Dup?&quot; column of the correct transaction.
 
 You can control the rules used by GnuCash to find duplicate transactions in the &quot;QIF Import&quot; section of the GnuCash Preferences dialog.
 

Modified: gnucash/branches/gda-dev2/src/import-export/schemas/apps_gnucash_import_generic_matcher.schemas.in
===================================================================
--- gnucash/branches/gda-dev2/src/import-export/schemas/apps_gnucash_import_generic_matcher.schemas.in	2007-12-26 05:17:37 UTC (rev 16730)
+++ gnucash/branches/gda-dev2/src/import-export/schemas/apps_gnucash_import_generic_matcher.schemas.in	2007-12-26 19:14:54 UTC (rev 16731)
@@ -143,11 +143,11 @@
           This field specifies the extra fee that is taken into
           account when matching imported transactions. In some places
           commercial ATMs (not belonging to a financial institution)
-          are installed in places like convienience store.  These ATM
-          add its fee directly to the amount instead of showing up as
+          are installed in places like convenience stores.  These ATMs
+          add their fee directly to the amount instead of showing up as
           a separate transaction or in your monthly banking fees.  For
-          example, you withdraw 100$, and you are charged 101,50$ plus
-          Interac fees.  If you manually entered that 100$, the
+          example, you withdraw $100, and you are charged $101,50 plus
+          Interac fees.  If you manually entered that $100, the
           amounts won't match.  You should set this to whatever is the
           maximum such fee in your area (in units of your local
           currency), so the transaction will be recognised as a match.

Modified: gnucash/branches/gda-dev2/src/register/ledger-core/split-register-load.c
===================================================================
--- gnucash/branches/gda-dev2/src/register/ledger-core/split-register-load.c	2007-12-26 05:17:37 UTC (rev 16730)
+++ gnucash/branches/gda-dev2/src/register/ledger-core/split-register-load.c	2007-12-26 19:14:54 UTC (rev 16731)
@@ -24,11 +24,14 @@
 
 #include "config.h"
 
+#include <glib/gi18n.h>
+
 #include "account-quickfill.h"
 #include "combocell.h"
 #include "gnc-component-manager.h"
 #include "qof.h"
 #include "gnc-ui-util.h"
+#include "gnc-gui-query.h"
 #include "numcell.h"
 #include "quickfillcell.h"
 #include "recncell.h"
@@ -221,7 +224,34 @@
     if (default_account != NULL) {
       gnc_commodity * commodity = xaccAccountGetCommodity (default_account);
       if (gnc_commodity_is_currency(commodity))
-          currency = commodity;
+	currency = commodity;
+      else {
+	Account *parent_account = default_account;
+	/* Account commodity is not a currency, walk up the tree until
+	 * we find a parent account that is a currency account and use
+	 * it's currency.
+	 */
+	do {
+	  parent_account = gnc_account_get_parent ( parent_account );
+	  if (parent_account)
+	  {
+	    commodity = xaccAccountGetCommodity (parent_account);
+	    if (gnc_commodity_is_currency(commodity))
+	    {
+	      currency = commodity;
+	      break;
+	    }
+	  }
+	} while (parent_account && !currency);
+      }
+
+      /* If we don't have a currency then pop up a warning dialog */
+      if (!currency)
+      {
+	gnc_info_dialog(NULL, "%s",
+			_("Could not compute the currency for this register.  "
+			  "Using the locale currency."));
+      }
     }
 
     gnc_suspend_gui_refresh ();

Modified: gnucash/branches/gda-dev2/src/report/locale-specific/us/taxtxf-de_DE.scm
===================================================================
--- gnucash/branches/gda-dev2/src/report/locale-specific/us/taxtxf-de_DE.scm	2007-12-26 05:17:37 UTC (rev 16730)
+++ gnucash/branches/gda-dev2/src/report/locale-specific/us/taxtxf-de_DE.scm	2007-12-26 19:14:54 UTC (rev 16731)
@@ -137,6 +137,9 @@
           (list->vector
            (list '2nd-est (N_ "2nd Est Tax Quarter") (N_ "Apr 1 - May 31")))
           (list->vector
+	   ;; Translators: The US tax quarters are different from
+	   ;; actual year's quarters! See the definition of
+	   ;; tax-qtr-real-qtr-year variable above.
            (list '3rd-est (N_ "3rd Est Tax Quarter") (N_ "Jun 1 - Aug 31")))
           (list->vector
            (list '4th-est (N_ "4th Est Tax Quarter") (N_ "Sep 1 - Dec 31")))
@@ -283,7 +286,7 @@
       '()
       (cons (gnc:make-html-table-header-cell/markup
              "number-header"
-             (_ "Sub-")
+             "Sub-"
              (number->string (- max-level 1)))
             (make-sub-headers (- max-level 1)))))
 

Modified: gnucash/branches/gda-dev2/src/report/locale-specific/us/taxtxf.scm
===================================================================
--- gnucash/branches/gda-dev2/src/report/locale-specific/us/taxtxf.scm	2007-12-26 05:17:37 UTC (rev 16730)
+++ gnucash/branches/gda-dev2/src/report/locale-specific/us/taxtxf.scm	2007-12-26 19:14:54 UTC (rev 16731)
@@ -121,6 +121,9 @@
           (list->vector
            (list '2nd-est (N_ "2nd Est Tax Quarter") (N_ "Apr 1 - May 31")))
           (list->vector
+	   ;; Translators: The US tax quarters are different from
+	   ;; actual year's quarters! See the definition of
+	   ;; tax-qtr-real-qtr-year variable above.
            (list '3rd-est (N_ "3rd Est Tax Quarter") (N_ "Jun 1 - Aug 31")))
           (list->vector
            (list '4th-est (N_ "4th Est Tax Quarter") (N_ "Sep 1 - Dec 31")))
@@ -134,6 +137,9 @@
                  (N_ "Apr 1 - May 31, Last year")))
           (list->vector
            (list '3rd-last (N_ "Last Yr 3rd Est Tax Qtr")
+		 ;; Translators: The US tax quarters are different from
+		 ;; actual year's quarters! See the definition of
+		 ;; tax-qtr-real-qtr-year variable above.
                  (N_ "Jun 1 - Aug 31, Last year")))
           (list->vector
            (list '4th-last (N_ "Last Yr 4th Est Tax Qtr")
@@ -267,7 +273,7 @@
       '()
       (cons (gnc:make-html-table-header-cell/markup
              "number-header"
-             (_ "Sub-")
+             "Sub-"
              (number->string (- max-level 1)))
             (make-sub-headers (- max-level 1)))))
 

Modified: gnucash/branches/gda-dev2/src/report/report-gnome/window-report.c
===================================================================
--- gnucash/branches/gda-dev2/src/report/report-gnome/window-report.c	2007-12-26 05:17:37 UTC (rev 16730)
+++ gnucash/branches/gda-dev2/src/report/report-gnome/window-report.c	2007-12-26 19:14:54 UTC (rev 16731)
@@ -243,7 +243,7 @@
         report == SCM_BOOL_F)
     {
       result->error_message =
-        g_strdup_printf (_("Badly report id: %s"), location);
+        g_strdup_printf (_("Badly-formed report id: %s"), location);
 
       return FALSE;
     }

Modified: gnucash/branches/gda-dev2/src/report/report-system/html-acct-table.scm
===================================================================
--- gnucash/branches/gda-dev2/src/report/report-system/html-acct-table.scm	2007-12-26 05:17:37 UTC (rev 16730)
+++ gnucash/branches/gda-dev2/src/report/report-system/html-acct-table.scm	2007-12-26 19:14:54 UTC (rev 16731)
@@ -1029,6 +1029,11 @@
 ;; Here are some standard functions to help process gnc:html-acct-tables.
 ;; 
 
+(define (gnc:html-make-nbsps n)
+  (if (> n 0)
+      (string-append "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" (gnc:html-make-nbsps (- n 1)))
+      ""))
+
 ;; Stylesheets define the following cell styles which these functions
 ;; use: "text-cell" "total-label-cell" "number-cell"
 ;; "total-number-cell".  Row styles include "normal-row",
@@ -1065,16 +1070,15 @@
 	 (tbl-width (or table-width (+ amt-depth amt-colspan)))
 	 (row
 	  (append
-	   (gnc:html-make-empty-cells lbl-depth)  ;; padding before label
 	   (list
 	    (if label-markup                      ;; the actual label
 		(gnc:make-html-table-cell/size/markup
-		 1 lbl-colspan label-markup label)
+		 1 1 label-markup (gnc:make-html-text (gnc:html-make-nbsps lbl-depth)) label)
 		(gnc:make-html-table-cell/size
-		 1 lbl-colspan label))
+		 1 1 (gnc:make-html-text (gnc:html-make-nbsps lbl-depth)) label))
 	    )
 	   (gnc:html-make-empty-cells             ;; padding after label
-            (+ (- amt-depth (+ lbl-depth lbl-colspan))
+            (+ (- amt-depth (/ tbl-width 2))
                (if total-rule? -1 0)
                )
             )

Modified: gnucash/branches/gda-dev2/src/report/report-system/report.scm
===================================================================
--- gnucash/branches/gda-dev2/src/report/report-system/report.scm	2007-12-26 05:17:37 UTC (rev 16730)
+++ gnucash/branches/gda-dev2/src/report/report-system/report.scm	2007-12-26 19:14:54 UTC (rev 16731)
@@ -169,7 +169,7 @@
               (string->symbol (gnc:html-style-sheet-name ss))
               (gnc:html-style-sheet-name ss)
               (string-append (gnc:html-style-sheet-name ss) 
-                             (_ " Stylesheet"))))
+                             " " (_ "Stylesheet"))))
            (gnc:get-html-style-sheets)))))
 
     (if (procedure? generator)



More information about the gnucash-changes mailing list