gnucash unstable: Multiple changes pushed

Geert Janssens gjanssens at code.gnucash.org
Thu Sep 21 08:29:49 EDT 2017


Updated	 via  https://github.com/Gnucash/gnucash/commit/7448d8b5 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/0b85bbc1 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/5b99835c (commit)
	 via  https://github.com/Gnucash/gnucash/commit/678794c8 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/ff32ddc9 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/40006a3f (commit)
	 via  https://github.com/Gnucash/gnucash/commit/62824e00 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/c6f5118b (commit)
	 via  https://github.com/Gnucash/gnucash/commit/df764626 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/daf1bf35 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/1a84b4a0 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/350dd690 (commit)
	from  https://github.com/Gnucash/gnucash/commit/0004a44f (commit)



commit 7448d8b532e34ae1d4a750b23df065bd39b8db81
Merge: 0b85bbc c6f5118
Author: Geert Janssens <geert at kobaltwit.be>
Date:   Thu Sep 21 14:26:20 2017 +0200

    Merge 'maint' into unstable
    
    Resolved conflicts:
            configure.ac

diff --cc configure.ac
index beafb19,0649065..aec5aaa
--- a/configure.ac
+++ b/configure.ac
@@@ -1604,176 -1412,189 +1604,177 @@@ AC_CONFIG_FILES
    po/Makefile.in
    dnl # Makefiles
    Makefile
 -  accounts/Makefile
 -  accounts/C/Makefile
 -  accounts/ca/Makefile
 -  accounts/cs/Makefile
 -  accounts/da/Makefile
 -  accounts/de_AT/Makefile
 -  accounts/de_CH/Makefile
 -  accounts/de_DE/Makefile
 -  accounts/el_GR/Makefile
 -  accounts/en_GB/Makefile
 -  accounts/es_ES/Makefile
 -  accounts/es_MX/Makefile
 -  accounts/fi_FI/Makefile
 -  accounts/fr_CA/Makefile
 -  accounts/fr_CH/Makefile
 -  accounts/fr_FR/Makefile
 -  accounts/hu_HU/Makefile
 -  accounts/it/Makefile
 -  accounts/ja/Makefile
 -  accounts/ko/Makefile
 -  accounts/lt/Makefile
 -  accounts/lv/Makefile
 -  accounts/nb/Makefile
 -  accounts/nl/Makefile
 -  accounts/pl/Makefile
 -  accounts/pt_BR/Makefile
 -  accounts/pt_PT/Makefile
 -  accounts/ru/Makefile
 -  accounts/sk/Makefile
 -  accounts/sv_AX/Makefile
 -  accounts/sv_FI/Makefile
 -  accounts/sv_SE/Makefile
 -  accounts/tr_TR/Makefile
 -  accounts/zh_CN/Makefile
 -  accounts/zh_HK/Makefile
 -  accounts/zh_TW/Makefile
 -  checks/Makefile
 +  data/Makefile
 +  data/accounts/Makefile
 +  data/accounts/C/Makefile
++  data/accounts/ca/Makefile
 +  data/accounts/cs/Makefile
 +  data/accounts/da/Makefile
 +  data/accounts/de_AT/Makefile
 +  data/accounts/de_CH/Makefile
 +  data/accounts/de_DE/Makefile
 +  data/accounts/el_GR/Makefile
 +  data/accounts/en_GB/Makefile
 +  data/accounts/es_ES/Makefile
 +  data/accounts/es_MX/Makefile
 +  data/accounts/fi_FI/Makefile
 +  data/accounts/fr_CA/Makefile
 +  data/accounts/fr_CH/Makefile
 +  data/accounts/fr_FR/Makefile
 +  data/accounts/hu_HU/Makefile
 +  data/accounts/it/Makefile
 +  data/accounts/ja/Makefile
 +  data/accounts/ko/Makefile
 +  data/accounts/lt/Makefile
 +  data/accounts/lv/Makefile
 +  data/accounts/nb/Makefile
 +  data/accounts/nl/Makefile
 +  data/accounts/pl/Makefile
 +  data/accounts/pt_BR/Makefile
 +  data/accounts/pt_PT/Makefile
 +  data/accounts/ru/Makefile
 +  data/accounts/sk/Makefile
 +  data/accounts/sv_AX/Makefile
 +  data/accounts/sv_FI/Makefile
 +  data/accounts/sv_SE/Makefile
 +  data/accounts/tr_TR/Makefile
 +  data/accounts/zh_CN/Makefile
 +  data/accounts/zh_HK/Makefile
 +  data/accounts/zh_TW/Makefile
 +  data/checks/Makefile
 +  data/pixmaps/Makefile
 +  bindings/Makefile
 +  bindings/python/Makefile
 +  bindings/python/tests/Makefile
 +  borrowed/Makefile
 +  borrowed/goffice/Makefile
 +  borrowed/libc/Makefile
 +  borrowed/gwengui-gtk3/Makefile
 +  common/Makefile
 +  common/debug/Makefile
 +  common/debug/valgrind/Makefile
 +  common/test-core/Makefile
    doc/Makefile
    doc/examples/Makefile
 -  lib/Makefile
 -  lib/libc/Makefile
 -  lib/stf/Makefile
 -  packaging/Makefile
 -  src/Makefile
 -  src/app-utils/Makefile
 -  src/app-utils/test/Makefile
 -  src/backend/Makefile
 -  src/backend/dbi/Makefile
 -  src/backend/dbi/test/Makefile
 -  src/backend/xml/Makefile
 -  src/backend/xml/test/Makefile
 -  src/backend/xml/test/test-files/Makefile
 -  src/backend/xml/test/test-files/xml2/Makefile
 -  src/backend/sql/Makefile
 -  src/backend/sql/test/Makefile
 -  src/bin/Makefile
 -  src/bin/overrides/Makefile
 -  src/bin/test/Makefile
 -  src/core-utils/Makefile
 -  src/core-utils/test/Makefile
 -  src/debug/Makefile
 -  src/debug/valgrind/Makefile
 -  src/doc/Makefile
 -  src/doc/design/Makefile
 -  src/doc/xml/Makefile
 -  src/engine/Makefile
 -  src/engine/test/Makefile
 -  src/engine/test-core/Makefile
 -  src/gnc-module/Makefile
 -  src/gnc-module/test/Makefile
 -  src/gnc-module/test/mod-foo/Makefile
 -  src/gnc-module/test/mod-bar/Makefile
 -  src/gnc-module/test/mod-baz/Makefile
 -  src/gnc-module/test/misc-mods/Makefile
 -  src/gnome/Makefile
 -  src/gnome/gtkbuilder/Makefile
 -  src/gnome/gschemas/Makefile
 -  src/gnome/ui/Makefile
 -  src/gnome-utils/Makefile
 -  src/gnome-utils/gtkbuilder/Makefile
 -  src/gnome-utils/gschemas/Makefile
 -  src/gnome-utils/test/Makefile
 -  src/gnome-utils/ui/Makefile
 -  src/gnome-search/Makefile
 -  src/html/Makefile
 -  src/import-export/Makefile
 -  src/import-export/test/Makefile
 -  src/import-export/ofx/gschemas/Makefile
 -  src/import-export/qif-imp/Makefile
 -  src/import-export/qif/Makefile
 -  src/import-export/qif/test/Makefile
 -  src/import-export/qif-imp/gschemas/Makefile
 -  src/import-export/qif-imp/test/Makefile
 -  src/import-export/gschemas/Makefile
 -  src/import-export/ofx/Makefile
 -  src/import-export/ofx/test/Makefile
 -  src/import-export/csv-imp/Makefile
 -  src/import-export/csv-imp/gschemas/Makefile
 -  src/import-export/csv-imp/test/Makefile
 -  src/import-export/csv-exp/Makefile
 -  src/import-export/csv-exp/gschemas/Makefile
 -  src/import-export/log-replay/Makefile
 -  src/import-export/aqb/Makefile
 -  src/import-export/aqb/gschemas/Makefile
 -  src/libqof/Makefile
 -  src/libqof/qof/Makefile
 -  src/libqof/qof/test/Makefile
 -  src/optional/Makefile
 -  src/optional/gtkmm/Makefile
 -  src/optional/gtkmm/test/Makefile
 -  src/optional/python-bindings/Makefile
 -  src/optional/python-bindings/tests/Makefile
 -  src/pixmaps/Makefile
 -  src/python/Makefile
 -  src/python/pycons/Makefile
 -  src/quotes/Makefile
 -  src/register/Makefile
 -  src/register/ledger-core/Makefile
 -  src/register/ledger-core/test/Makefile
 -  src/register/register-core/Makefile
 -  src/register/register-core/test/Makefile
 -  src/register/register-gnome/Makefile
 -  src/register/register-gnome/test/Makefile
 -  src/report/Makefile
 -  src/report/report-gnome/Makefile
 -  src/report/report-gnome/test/Makefile
 -  src/report/report-system/Makefile
 -  src/report/report-system/test/Makefile
 -  src/report/standard-reports/Makefile
 -  src/report/standard-reports/test/Makefile
 -  src/report/business-reports/Makefile
 -  src/report/locale-specific/Makefile
 -  src/report/locale-specific/us/Makefile
 -  src/report/locale-specific/us/test/Makefile
 -  src/report/stylesheets/Makefile
 -  src/report/stylesheets/test/Makefile
 -  src/report/utility-reports/Makefile
 -  src/report/utility-reports/test/Makefile
 -  src/report/jqplot/Makefile
 -  src/scm/Makefile
 -  src/scm/gnumeric/Makefile
 -  src/tax/Makefile
 -  src/tax/us/Makefile
 -  src/tax/us/test/Makefile
 -  src/test-core/Makefile
 -  src/business/Makefile
 -  src/business/business-gnome/Makefile
 -  src/business/business-gnome/gtkbuilder/Makefile
 -  src/business/business-gnome/gschemas/Makefile
 -  src/business/business-gnome/ui/Makefile
 -  src/business/business-ledger/Makefile
 -  dnl # Stuff for bill/invoice import plugin
 -  src/plugins/Makefile
 -  src/plugins/bi_import/Makefile
 -  src/plugins/bi_import/gtkbuilder/Makefile
 -  src/plugins/bi_import/ui/Makefile
 -  dnl # Stuff for customer import.
 -  src/plugins/customer_import/Makefile
 -  src/plugins/customer_import/gtkbuilder/Makefile
 -  src/plugins/customer_import/ui/Makefile
 +  gnucash/Makefile
 +  gnucash/overrides/Makefile
 +  gnucash/test/Makefile
 +  gnucash/gnome/Makefile
 +  gnucash/gnome/gtkbuilder/Makefile
 +  gnucash/gnome/gschemas/Makefile
 +  gnucash/gnome/ui/Makefile
 +  gnucash/gnome-utils/Makefile
 +  gnucash/gnome-utils/gtkbuilder/Makefile
 +  gnucash/gnome-utils/gschemas/Makefile
 +  gnucash/gnome-utils/test/Makefile
 +  gnucash/gnome-utils/ui/Makefile
 +  gnucash/gnome-search/Makefile
 +  gnucash/html/Makefile
 +  gnucash/import-export/Makefile
 +  gnucash/import-export/test/Makefile
 +  gnucash/import-export/ofx/gschemas/Makefile
 +  gnucash/import-export/qif-imp/Makefile
 +  gnucash/import-export/qif/Makefile
 +  gnucash/import-export/qif/test/Makefile
 +  gnucash/import-export/qif-imp/gschemas/Makefile
 +  gnucash/import-export/qif-imp/test/Makefile
 +  gnucash/import-export/gschemas/Makefile
 +  gnucash/import-export/ofx/Makefile
 +  gnucash/import-export/ofx/test/Makefile
 +  gnucash/import-export/csv-imp/Makefile
 +  gnucash/import-export/csv-imp/gschemas/Makefile
 +  gnucash/import-export/csv-imp/test/Makefile
 +  gnucash/import-export/csv-exp/Makefile
 +  gnucash/import-export/csv-exp/gschemas/Makefile
 +  gnucash/import-export/log-replay/Makefile
 +  gnucash/import-export/aqb/Makefile
 +  gnucash/import-export/aqb/gschemas/Makefile
 +  gnucash/import-export/aqb/test/Makefile
 +  gnucash/import-export/bi-import/Makefile
 +  gnucash/import-export/bi-import/gtkbuilder/Makefile
 +  gnucash/import-export/bi-import/ui/Makefile
 +  gnucash/import-export/customer-import/Makefile
 +  gnucash/import-export/customer-import/gtkbuilder/Makefile
 +  gnucash/import-export/customer-import/ui/Makefile
 +  gnucash/python/Makefile
 +  gnucash/python/pycons/Makefile
 +  gnucash/register/Makefile
 +  gnucash/register/ledger-core/Makefile
 +  gnucash/register/ledger-core/test/Makefile
 +  gnucash/register/register-core/Makefile
 +  gnucash/register/register-core/test/Makefile
 +  gnucash/register/register-gnome/Makefile
 +  gnucash/register/register-gnome/test/Makefile
 +  gnucash/report/Makefile
 +  gnucash/report/report-gnome/Makefile
 +  gnucash/report/report-gnome/test/Makefile
 +  gnucash/report/report-system/Makefile
 +  gnucash/report/report-system/test/Makefile
 +  gnucash/report/standard-reports/Makefile
 +  gnucash/report/standard-reports/test/Makefile
 +  gnucash/report/business-reports/Makefile
 +  gnucash/report/locale-specific/Makefile
 +  gnucash/report/locale-specific/us/Makefile
 +  gnucash/report/locale-specific/us/test/Makefile
 +  gnucash/report/stylesheets/Makefile
 +  gnucash/report/stylesheets/test/Makefile
 +  gnucash/report/utility-reports/Makefile
 +  gnucash/report/jqplot/Makefile
 +  libgnucash/Makefile
 +  libgnucash/app-utils/Makefile
 +  libgnucash/app-utils/test/Makefile
 +  libgnucash/backend/Makefile
 +  libgnucash/backend/dbi/Makefile
 +  libgnucash/backend/dbi/test/Makefile
 +  libgnucash/backend/xml/Makefile
 +  libgnucash/backend/xml/test/Makefile
 +  libgnucash/backend/xml/test/test-files/Makefile
 +  libgnucash/backend/xml/test/test-files/xml2/Makefile
 +  libgnucash/backend/sql/Makefile
 +  libgnucash/backend/sql/test/Makefile
 +  libgnucash/core-utils/Makefile
 +  libgnucash/core-utils/test/Makefile
 +  libgnucash/doc/Makefile
 +  libgnucash/doc/design/Makefile
 +  libgnucash/doc/xml/Makefile
 +  libgnucash/engine/Makefile
 +  libgnucash/engine/test/Makefile
 +  libgnucash/engine/test-core/Makefile
 +  libgnucash/gnc-module/Makefile
 +  libgnucash/gnc-module/test/Makefile
 +  libgnucash/gnc-module/test/mod-foo/Makefile
 +  libgnucash/gnc-module/test/mod-bar/Makefile
 +  libgnucash/gnc-module/test/mod-baz/Makefile
 +  libgnucash/gnc-module/test/misc-mods/Makefile
 +  libgnucash/quotes/Makefile
 +  libgnucash/scm/Makefile
 +  libgnucash/scm/gnumeric/Makefile
 +  libgnucash/tax/Makefile
 +  libgnucash/tax/us/Makefile
 +  libgnucash/tax/us/test/Makefile
    dnl # non-makefiles
 -  src/bin/gnucash.rc
 -  src/app-utils/migratable-prefs.xml
 -  src/gnome/gnucash.desktop.in
 +  gnucash/gnucash.rc
 +  libgnucash/app-utils/migratable-prefs.xml
 +  gnucash/gnome/gnucash.desktop.in
    dnl # GSettings schema files
 -  src/business/business-gnome/gschemas/org.gnucash.dialogs.business.gschema.xml.in
 -  src/gnome/gschemas/org.gnucash.dialogs.checkprinting.gschema.xml.in
 -  src/gnome/gschemas/org.gnucash.dialogs.commodities.gschema.xml.in
 -  src/gnome/gschemas/org.gnucash.dialogs.gschema.xml.in
 -  src/gnome/gschemas/org.gnucash.dialogs.reconcile.gschema.xml.in
 -  src/gnome/gschemas/org.gnucash.dialogs.sxs.gschema.xml.in
 -  src/gnome/gschemas/org.gnucash.dialogs.totd.gschema.xml.in
 -  src/gnome/gschemas/org.gnucash.gschema.xml.in
 -  src/gnome/gschemas/org.gnucash.window.pages.account.tree.gschema.xml.in
 -  src/gnome/gschemas/org.gnucash.window.pages.gschema.xml.in
 -  src/gnome-utils/gschemas/org.gnucash.history.gschema.xml.in
 -  src/gnome-utils/gschemas/org.gnucash.warnings.gschema.xml.in
 -  src/import-export/aqb/gschemas/org.gnucash.dialogs.import.hbci.gschema.xml.in
 -  src/import-export/csv-exp/gschemas/org.gnucash.dialogs.export.csv.gschema.xml.in
 -  src/import-export/csv-imp/gschemas/org.gnucash.dialogs.import.csv.gschema.xml.in
 -  src/import-export/gschemas/org.gnucash.dialogs.import.generic.gschema.xml.in
 -  src/import-export/ofx/gschemas/org.gnucash.dialogs.import.ofx.gschema.xml.in
 -  src/import-export/qif-imp/gschemas/org.gnucash.dialogs.import.qif.gschema.xml.in
 +  gnucash/gnome/gschemas/org.gnucash.dialogs.business.gschema.xml.in
 +  gnucash/gnome/gschemas/org.gnucash.dialogs.checkprinting.gschema.xml.in
 +  gnucash/gnome/gschemas/org.gnucash.dialogs.commodities.gschema.xml.in
 +  gnucash/gnome/gschemas/org.gnucash.dialogs.gschema.xml.in
 +  gnucash/gnome/gschemas/org.gnucash.dialogs.reconcile.gschema.xml.in
 +  gnucash/gnome/gschemas/org.gnucash.dialogs.sxs.gschema.xml.in
 +  gnucash/gnome/gschemas/org.gnucash.dialogs.totd.gschema.xml.in
 +  gnucash/gnome/gschemas/org.gnucash.gschema.xml.in
 +  gnucash/gnome/gschemas/org.gnucash.window.pages.account.tree.gschema.xml.in
 +  gnucash/gnome/gschemas/org.gnucash.window.pages.gschema.xml.in
 +  gnucash/gnome-utils/gschemas/org.gnucash.history.gschema.xml.in
 +  gnucash/gnome-utils/gschemas/org.gnucash.warnings.gschema.xml.in
 +  gnucash/import-export/aqb/gschemas/org.gnucash.dialogs.import.hbci.gschema.xml.in
 +  gnucash/import-export/csv-exp/gschemas/org.gnucash.dialogs.export.csv.gschema.xml.in
 +  gnucash/import-export/csv-imp/gschemas/org.gnucash.dialogs.import.csv.gschema.xml.in
 +  gnucash/import-export/gschemas/org.gnucash.dialogs.import.generic.gschema.xml.in
 +  gnucash/import-export/ofx/gschemas/org.gnucash.dialogs.import.ofx.gschema.xml.in
 +  gnucash/import-export/qif-imp/gschemas/org.gnucash.dialogs.import.qif.gschema.xml.in
    dnl # Please read doc/build-system before adding *anything* here
    ,
    dnl # init-commands go here
diff --cc data/accounts/ca/CMakeLists.txt
index 0000000,768fae4..768fae4
mode 000000,100644..100644
--- a/data/accounts/ca/CMakeLists.txt
+++ b/data/accounts/ca/CMakeLists.txt
diff --cc data/accounts/ca/Makefile.am
index 0000000,5b2b814..5b2b814
mode 000000,100644..100644
--- a/data/accounts/ca/Makefile.am
+++ b/data/accounts/ca/Makefile.am
diff --cc data/accounts/ca/acctchrt_brokerage.gnucash-xea
index 0000000,f7dd0f2..f7dd0f2
mode 000000,100644..100644
--- a/data/accounts/ca/acctchrt_brokerage.gnucash-xea
+++ b/data/accounts/ca/acctchrt_brokerage.gnucash-xea
diff --cc data/accounts/ca/acctchrt_carloan.gnucash-xea
index 0000000,499b172..499b172
mode 000000,100644..100644
--- a/data/accounts/ca/acctchrt_carloan.gnucash-xea
+++ b/data/accounts/ca/acctchrt_carloan.gnucash-xea
diff --cc data/accounts/ca/acctchrt_cdmoneymkt.gnucash-xea
index 0000000,c77b3c8..c77b3c8
mode 000000,100644..100644
--- a/data/accounts/ca/acctchrt_cdmoneymkt.gnucash-xea
+++ b/data/accounts/ca/acctchrt_cdmoneymkt.gnucash-xea
diff --cc data/accounts/ca/acctchrt_childcare.gnucash-xea
index 0000000,3cfea6b..3cfea6b
mode 000000,100644..100644
--- a/data/accounts/ca/acctchrt_childcare.gnucash-xea
+++ b/data/accounts/ca/acctchrt_childcare.gnucash-xea
diff --cc data/accounts/ca/acctchrt_common.gnucash-xea
index 0000000,e61093f..e61093f
mode 000000,100644..100644
--- a/data/accounts/ca/acctchrt_common.gnucash-xea
+++ b/data/accounts/ca/acctchrt_common.gnucash-xea
diff --cc data/accounts/ca/acctchrt_currency.gnucash-xea
index 0000000,4b5acca..4b5acca
mode 000000,100644..100644
--- a/data/accounts/ca/acctchrt_currency.gnucash-xea
+++ b/data/accounts/ca/acctchrt_currency.gnucash-xea
diff --cc data/accounts/ca/acctchrt_eduloan.gnucash-xea
index 0000000,c4f69f0..c4f69f0
mode 000000,100644..100644
--- a/data/accounts/ca/acctchrt_eduloan.gnucash-xea
+++ b/data/accounts/ca/acctchrt_eduloan.gnucash-xea
diff --cc data/accounts/ca/acctchrt_fixedassets.gnucash-xea
index 0000000,d0bbe54..d0bbe54
mode 000000,100644..100644
--- a/data/accounts/ca/acctchrt_fixedassets.gnucash-xea
+++ b/data/accounts/ca/acctchrt_fixedassets.gnucash-xea
diff --cc data/accounts/ca/acctchrt_homeloan.gnucash-xea
index 0000000,c872aef..c872aef
mode 000000,100644..100644
--- a/data/accounts/ca/acctchrt_homeloan.gnucash-xea
+++ b/data/accounts/ca/acctchrt_homeloan.gnucash-xea
diff --cc data/accounts/ca/acctchrt_homeown.gnucash-xea
index 0000000,126c4f1..126c4f1
mode 000000,100644..100644
--- a/data/accounts/ca/acctchrt_homeown.gnucash-xea
+++ b/data/accounts/ca/acctchrt_homeown.gnucash-xea
diff --cc data/accounts/ca/acctchrt_otherloan.gnucash-xea
index 0000000,9959254..9959254
mode 000000,100644..100644
--- a/data/accounts/ca/acctchrt_otherloan.gnucash-xea
+++ b/data/accounts/ca/acctchrt_otherloan.gnucash-xea
diff --cc data/accounts/ca/acctchrt_renter.gnucash-xea
index 0000000,d076ff4..d076ff4
mode 000000,100644..100644
--- a/data/accounts/ca/acctchrt_renter.gnucash-xea
+++ b/data/accounts/ca/acctchrt_renter.gnucash-xea
diff --cc data/accounts/ca/acctchrt_retiremt.gnucash-xea
index 0000000,9e26790..9e26790
mode 000000,100644..100644
--- a/data/accounts/ca/acctchrt_retiremt.gnucash-xea
+++ b/data/accounts/ca/acctchrt_retiremt.gnucash-xea
diff --cc data/accounts/ca/acctchrt_spouseinc.gnucash-xea
index 0000000,a02afd7..a02afd7
mode 000000,100644..100644
--- a/data/accounts/ca/acctchrt_spouseinc.gnucash-xea
+++ b/data/accounts/ca/acctchrt_spouseinc.gnucash-xea
diff --cc data/accounts/ca/acctchrt_spouseretire.gnucash-xea
index 0000000,b5f1393..b5f1393
mode 000000,100644..100644
--- a/data/accounts/ca/acctchrt_spouseretire.gnucash-xea
+++ b/data/accounts/ca/acctchrt_spouseretire.gnucash-xea
diff --cc gnucash/gnome-utils/dialog-options.c
index 356905c,0000000..ff0a51a
mode 100644,000000..100644
--- a/gnucash/gnome-utils/dialog-options.c
+++ b/gnucash/gnome-utils/dialog-options.c
@@@ -1,4329 -1,0 +1,4334 @@@
 +/********************************************************************\
 + * dialog-options.c -- GNOME option handling                        *
 + * Copyright (C) 1998-2000 Linas Vepstas                            *
 + * Copyright (c) 2006 David Hampton <hampton at employees.org>         *
 + * Copyright (c) 2011 Robert Fewell                                 *
 + *                                                                  *
 + * 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 <gdk/gdk.h>
 +#include <glib/gi18n.h>
 +#include "swig-runtime.h"
 +
 +#include "gnc-tree-model-budget.h" //FIXME?
 +#include "gnc-budget.h"
 +
 +#include "dialog-options.h"
 +#include "dialog-utils.h"
 +#include "engine-helpers-guile.h"
 +#include "glib-helpers.h"
 +#include "gnc-account-sel.h"
 +#include "gnc-tree-view-account.h"
 +#include "gnc-tree-model-account.h"
 +#include "gnc-combott.h"
 +#include "gnc-commodity-edit.h"
 +#include "gnc-component-manager.h"
 +#include "gnc-general-select.h"
 +#include "gnc-currency-edit.h"
 +#include "gnc-date-edit.h"
 +#include "gnc-engine.h"
 +#include "gnc-prefs.h"
 +#include "gnc-gui-query.h"
 +#include "gnc-session.h"
 +#include "gnc-ui.h"
 +#include "guile-util.h"
 +#include "gnc-guile-utils.h"
 +#include "option-util.h"
 +#include "guile-mappings.h"
 +#include "gnc-date-format.h"
 +#include "misc-gnome-utils.h"
 +
 +#define GNC_PREF_CLOCK_24H "clock-24h"
 +
 +#define FUNC_NAME G_STRFUNC
 +/* TODO: clean up "register-stocks" junk
 + */
 +
 +
 +/* This static indicates the debugging module that this .o belongs to.  */
 +static QofLogModule log_module = GNC_MOD_GUI;
 +
 +#define DIALOG_OPTIONS_CM_CLASS "dialog-options"
 +#define DIALOG_BOOK_OPTIONS_CM_CLASS "dialog-book-options"
 +
 +/*
 + * Point where preferences switch control method from a set of
 + * notebook tabs to a list.
 + */
 +#define MAX_TAB_COUNT 4
 +
 +/* A pointer to the last selected filename */
 +#define LAST_SELECTION "last-selection"
 +
 +/* A Hash-table of GNCOptionDef_t keyed with option names. */
 +static GHashTable *optionTable = NULL;
 +
 +static int gain_loss_accounts_in_filter = 0;
 +
 +struct gnc_option_win
 +{
 +    GtkWidget  * dialog;
 +    GtkWidget  * notebook;
 +    GtkWidget  * page_list_view;
 +    GtkWidget  * page_list;
 +
 +    gboolean toplevel;
 +
 +    GNCOptionWinCallback apply_cb;
 +    gpointer             apply_cb_data;
 +
 +    GNCOptionWinCallback help_cb;
 +    gpointer             help_cb_data;
 +
 +    GNCOptionWinCallback close_cb;
 +    gpointer             close_cb_data;
 +
 +    /* Hold onto this for a complete reset */
 +    GNCOptionDB *		option_db;
 +
 +    /* Hold on to this to unregister the right class */
 +    const char *component_class;
 +};
 +
 +typedef enum
 +{
 +    GNC_RD_WID_AB_BUTTON_POS = 0,
 +    GNC_RD_WID_AB_WIDGET_POS,
 +    GNC_RD_WID_REL_BUTTON_POS,
 +    GNC_RD_WID_REL_WIDGET_POS
 +} GNCRdPositions;
 +
 +enum page_tree
 +{
 +    PAGE_INDEX = 0,
 +    PAGE_NAME,
 +    NUM_COLUMNS
 +};
 +
 +typedef struct
 +{
 +    GtkWidget *gnc_currency_radiobutton_0;
 +    GtkWidget *gnc_currency_radiobutton_1;
 +    GtkWidget *gnc_currency_radiobutton_2;
 +    GtkWidget *book_currency_widget;
 +    GtkWidget *default_cost_policy_widget;
 +    GtkWidget *default_gain_loss_account_widget;
 +    GtkWidget *book_currency_table;
 +    GtkWidget *book_currency_vbox;
 +    GtkWidget *gain_loss_account_del_button;
 +    GtkWidget *gain_loss_account_table;
 +    GtkWidget *default_gain_loss_account_text;
 +    GNCOption *option;
 +    gnc_commodity *retrieved_book_currency;
 +    SCM retrieved_policy_scm;
 +    SCM retrieved_gain_loss_acct_guid_scm;
 +    Account *prior_gain_loss_account;
 +
 +} currency_accounting_data;
 +
 +static currency_accounting_data *book_currency_data = NULL;
 +
 +static GNCOptionWinCallback global_help_cb = NULL;
 +gpointer global_help_cb_data = NULL;
 +
 +void gnc_options_dialog_response_cb(GtkDialog *dialog, gint response,
 +                                    GNCOptionWin *window);
 +static void gnc_options_dialog_reset_cb(GtkWidget * w, gpointer data);
 +void gnc_options_dialog_list_select_cb (GtkTreeSelection *selection,
 +                                        gpointer data);
 +void gnc_set_default_cost_policy_widget(SCM list_symbol);
 +void gnc_set_default_gain_loss_account_widget(gnc_commodity *commodity);
 +void gnc_option_changed_book_currency_widget_cb(GtkWidget *widget);
 +void gnc_option_changed_gain_loss_account_widget_cb(GtkTreeSelection *selection,
 +                                                    gpointer data);
 +void gnc_option_changed_gain_loss_account_del_button_widget_cb (GtkButton *button,
 +                                                    gpointer data);
 +
 +GtkWidget *
 +gnc_option_get_gtk_widget (GNCOption *option)
 +{
 +    return (GtkWidget *)gnc_option_get_widget(option);
 +}
 +
 +static void
 +gnc_options_dialog_changed_internal (GtkWidget *widget, gboolean sensitive)
 +{
 +    GtkDialog *dialog;
 +
 +    while (widget && !GTK_IS_DIALOG(widget))
 +        widget = gtk_widget_get_parent(widget);
 +    if (widget == NULL)
 +        return;
 +
 +    dialog = GTK_DIALOG(widget);
 +    gtk_dialog_set_response_sensitive (dialog, GTK_RESPONSE_OK, sensitive);
 +    gtk_dialog_set_response_sensitive (dialog, GTK_RESPONSE_APPLY, sensitive);
 +}
 +
 +void
 +gnc_options_dialog_changed (GNCOptionWin *win)
 +{
 +    if (!win) return;
 +
 +    gnc_options_dialog_changed_internal (win->dialog, TRUE);
 +}
 +
 +void
 +gnc_option_changed_widget_cb(GtkWidget *widget, GNCOption *option)
 +{
 +    gnc_option_set_changed (option, TRUE);
 +    gnc_option_call_option_widget_changed_proc(option);
 +    gnc_options_dialog_changed_internal (widget, TRUE);
 +}
 +
 +void
 +gnc_option_changed_option_cb(GtkWidget *dummy, GNCOption *option)
 +{
 +    GtkWidget *widget;
 +
 +    widget = gnc_option_get_gtk_widget (option);
 +    gnc_option_changed_widget_cb(widget, option);
 +}
 +
 +static void
 +gnc_date_option_set_select_method(GNCOption *option, gboolean use_absolute,
 +                                  gboolean set_buttons)
 +{
 +    GList* widget_list;
 +    GtkWidget *ab_button, *rel_button, *rel_widget, *ab_widget;
 +    GtkWidget *widget;
 +
 +    widget = gnc_option_get_gtk_widget (option);
 +
 +    widget_list = gtk_container_get_children(GTK_CONTAINER(widget));
 +    ab_button = g_list_nth_data(widget_list, GNC_RD_WID_AB_BUTTON_POS);
 +    ab_widget = g_list_nth_data(widget_list, GNC_RD_WID_AB_WIDGET_POS);
 +    rel_button = g_list_nth_data(widget_list, GNC_RD_WID_REL_BUTTON_POS);
 +    rel_widget = g_list_nth_data(widget_list, GNC_RD_WID_REL_WIDGET_POS);
 +    g_list_free(widget_list);
 +
 +    if (use_absolute)
 +    {
 +        gtk_widget_set_sensitive(ab_widget, TRUE);
 +        gtk_widget_set_sensitive(rel_widget, FALSE);
 +        if (set_buttons)
 +        {
 +            gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ab_button), TRUE);
 +        }
 +    }
 +    else
 +    {
 +        gtk_widget_set_sensitive(rel_widget, TRUE);
 +        gtk_widget_set_sensitive(ab_widget, FALSE);
 +        if (set_buttons)
 +        {
 +            gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(rel_button), TRUE);
 +        }
 +    }
 +}
 +
 +static void
 +gnc_rd_option_ab_set_cb(GtkWidget *widget, gpointer *raw_option)
 +{
 +    GNCOption *option = (GNCOption *) raw_option;
 +    gnc_date_option_set_select_method(option, TRUE, FALSE);
 +    gnc_option_changed_option_cb(widget, option);
 +}
 +
 +static void
 +gnc_rd_option_rel_set_cb(GtkWidget *widget, gpointer *raw_option)
 +{
 +    GNCOption *option = (GNCOption *) raw_option;
 +    gnc_date_option_set_select_method(option, FALSE, FALSE);
 +    gnc_option_changed_option_cb(widget, option);
 +    return;
 +}
 +
 +static void
 +gnc_image_option_update_preview_cb (GtkFileChooser *chooser,
 +                                    GNCOption *option)
 +{
 +    gchar *filename;
 +    GtkImage *image;
 +    GdkPixbuf *pixbuf;
 +    gboolean have_preview;
 +
 +    g_return_if_fail(chooser != NULL);
 +
 +    ENTER("chooser %p, option %p", chooser, option);
 +    filename = gtk_file_chooser_get_preview_filename(chooser);
 +    DEBUG("chooser preview name is %s.", filename ? filename : "(null)");
 +    if (filename == NULL)
 +    {
 +        filename = g_strdup(g_object_get_data(G_OBJECT(chooser), LAST_SELECTION));
 +        DEBUG("using last selection of %s", filename ? filename : "(null)");
 +        if (filename == NULL)
 +        {
 +            LEAVE("no usable name");
 +            return;
 +        }
 +    }
 +
 +    image = GTK_IMAGE(gtk_file_chooser_get_preview_widget(chooser));
 +    pixbuf = gdk_pixbuf_new_from_file_at_size(filename, 128, 128, NULL);
 +    g_free(filename);
 +    have_preview = (pixbuf != NULL);
 +
 +    gtk_image_set_from_pixbuf(image, pixbuf);
 +    if (pixbuf)
 +        g_object_unref(pixbuf);
 +
 +    gtk_file_chooser_set_preview_widget_active(chooser, have_preview);
 +    LEAVE("preview visible is %d", have_preview);
 +}
 +
 +static void
 +gnc_image_option_selection_changed_cb (GtkFileChooser *chooser,
 +                                       GNCOption *option)
 +{
 +    gchar *filename;
 +
 +    filename = gtk_file_chooser_get_preview_filename(chooser);
 +    if (!filename)
 +        return;
 +    g_object_set_data_full(G_OBJECT(chooser), LAST_SELECTION, filename, g_free);
 +}
 +
 +/********************************************************************\
 + * gnc_option_set_ui_value_internal                                 *
 + *   sets the GUI representation of an option with either its       *
 + *   current guile value, or its default value                      *
 + *                                                                  *
 + * Args: option      - option structure containing option           *
 + *       use_default - if true, use the default value, otherwise    *
 + *                     use the current value                        *
 + * Return: nothing                                                  *
 +\********************************************************************/
 +static void
 +gnc_option_set_ui_value_internal (GNCOption *option, gboolean use_default)
 +{
 +    gboolean bad_value = FALSE;
 +    GtkWidget *widget;
 +    char *type;
 +    SCM getter;
 +    SCM value;
 +    GNCOptionDef_t *option_def;
 +
 +    widget = gnc_option_get_gtk_widget (option);
 +    if (!widget)
 +        return;
 +
 +    type = gnc_option_type(option);
 +
 +    if (use_default)
 +        getter = gnc_option_default_getter(option);
 +    else
 +        getter = gnc_option_getter(option);
 +
 +    value = scm_call_0(getter);
 +
 +    option_def = gnc_options_ui_get_option (type);
 +    if (option_def && option_def->set_value)
 +    {
 +        bad_value = option_def->set_value (option, use_default, widget, value);
 +        if (bad_value)
 +        {
 +            PERR("bad value\n");
 +        }
 +    }
 +    else
 +    {
 +        PERR("Unknown type. Ignoring.\n");
 +    }
 +
 +    free(type);
 +}
 +
 +/********************************************************************\
 + * gnc_option_get_ui_value_internal                                 *
 + *   returns the SCM representation of the GUI option value         *
 + *                                                                  *
 + * Args: option - option structure containing option                *
 + * Return: SCM handle to GUI option value                           *
 +\********************************************************************/
 +static SCM
 +gnc_option_get_ui_value_internal (GNCOption *option)
 +{
 +    SCM result = SCM_UNDEFINED;
 +    GtkWidget *widget;
 +    char *type;
 +    GNCOptionDef_t *option_def;
 +
 +    widget = gnc_option_get_gtk_widget (option);
 +    if (!widget)
 +        return result;
 +
 +    type = gnc_option_type(option);
 +
 +    option_def = gnc_options_ui_get_option (type);
 +    if (option_def && option_def->get_value)
 +    {
 +        result = option_def->get_value (option, widget);
 +    }
 +    else
 +    {
 +        PERR("Unknown type for refresh. Ignoring.\n");
 +    }
 +
 +    free(type);
 +
 +    return result;
 +}
 +
 +/********************************************************************\
 + * gnc_option_set_selectable_internal                               *
 + *   Change the selectable state of the widget that represents a    *
 + *   GUI option.                                                    *
 + *                                                                  *
 + * Args: option      - option to change widget state for            *
 + *       selectable  - if false, update the widget so that it       *
 + *                     cannot be selected by the user.  If true,    *
 + *                     update the widget so that it can be selected.*
 + * Return: nothing                                                  *
 +\********************************************************************/
 +static void
 +gnc_option_set_selectable_internal (GNCOption *option, gboolean selectable)
 +{
 +    GtkWidget *widget;
 +
 +    widget = gnc_option_get_gtk_widget (option);
 +    if (!widget)
 +        return;
 +
 +    gtk_widget_set_sensitive (widget, selectable);
 +}
 +
 +static void
 +gnc_option_default_cb(GtkWidget *widget, GNCOption *option)
 +{
 +    gnc_option_set_ui_value (option, TRUE);
 +    gnc_option_set_changed (option, TRUE);
 +    gnc_options_dialog_changed_internal (widget, TRUE);
 +}
 +
 +static void
 +gnc_option_show_hidden_toggled_cb(GtkWidget *widget, GNCOption* option)
 +{
 +    AccountViewInfo avi;
 +    GncTreeViewAccount *tree_view;
 +
 +    tree_view = GNC_TREE_VIEW_ACCOUNT(gnc_option_get_gtk_widget (option));
 +    gnc_tree_view_account_get_view_info (tree_view, &avi);
 +    avi.show_hidden = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
 +    gnc_tree_view_account_set_view_info (tree_view, &avi);
 +    gnc_option_changed_widget_cb(widget, option);
 +}
 +
 +static void
 +gnc_option_multichoice_cb(GtkWidget *widget, gpointer data)
 +{
 +    GNCOption *option = data;
 +    /* GtkComboBox per-item tooltip changes needed below */
 +    gnc_option_changed_widget_cb(widget, option);
 +}
 +
 +static void
 +gnc_option_radiobutton_cb(GtkWidget *w, gpointer data)
 +{
 +    GNCOption *option = data;
 +    GtkWidget *widget;
 +    gpointer _current, _new_value;
 +    gint current, new_value;
 +
 +    widget = gnc_option_get_gtk_widget (option);
 +
 +    _current = g_object_get_data(G_OBJECT(widget), "gnc_radiobutton_index");
 +    current = GPOINTER_TO_INT (_current);
 +
 +    _new_value = g_object_get_data (G_OBJECT(w), "gnc_radiobutton_index");
 +    new_value = GPOINTER_TO_INT (_new_value);
 +
 +    if (current == new_value)
 +        return;
 +
 +    g_object_set_data (G_OBJECT(widget), "gnc_radiobutton_index",
 +                       GINT_TO_POINTER(new_value));
 +    gnc_option_changed_widget_cb(widget, option);
 +}
 +
 +static gboolean
 +gnc_gain_loss_account_view_filter (Account  *account, gpointer  data)
 +{
 +    GNCAccountType type = xaccAccountGetType(account);
 +
 +    /* gain/loss accts must be an Income or Expense accts and not hidden;
 +       placeholder accounts must be included, irrespective of their currency,
 +       so their children are available to be considered */
 +    if (((type == ACCT_TYPE_INCOME) || (type == ACCT_TYPE_EXPENSE)) &&
 +        (!xaccAccountIsHidden(account)))
 +    {
 +        if (xaccAccountGetPlaceholder(account))
 +        {
 +            GList *placeholder_children = gnc_account_get_children (account);
 +
 +            if(placeholder_children)
 +            { /* determine if any children qualify; just need one but don't
 +                 double count in gain_loss_accounts_in_filter */
 +                int saved_gain_loss_accounts_in_filter =
 +                                                gain_loss_accounts_in_filter;
 +                gboolean child_pass_filter = FALSE;
 +                GList *l = NULL;
 +                for (l = placeholder_children; l != NULL; l = l->next)
 +                {
 +                    Account  *child_account = l->data;
 +                    child_pass_filter =
 +                        gnc_gain_loss_account_view_filter(child_account, NULL);
 +                    if (child_pass_filter)
 +                        break;
 +                }
 +                g_list_free(placeholder_children);
 +                gain_loss_accounts_in_filter =
 +                                           saved_gain_loss_accounts_in_filter;
 +                return child_pass_filter;
 +            }
 +            else return FALSE; // no children, not interested
 +        }
 +        else
 +        {
 +            gnc_commodity *commodity = NULL;
 +
 +            /* gain/loss accts must be in book-currency; if a book currency has been
 +               specified in the widget, use it to filter */
 +            if (gtk_combo_box_get_active (GTK_COMBO_BOX(book_currency_data->book_currency_widget)) != -1)
 +                commodity = gnc_currency_edit_get_currency(
 +                                GNC_CURRENCY_EDIT(
 +                                    book_currency_data->book_currency_widget));
 +            if (commodity)
 +            {
 +                if (gnc_commodity_equal(xaccAccountGetCommodity(account),
 +                                    commodity))
 +                {
 +                    gain_loss_accounts_in_filter++;
 +                    return TRUE;
 +                }
 +                else return FALSE;
 +            }
 +            /* else use the default currency */
 +            else if (gnc_commodity_equal(xaccAccountGetCommodity(account),
 +                                gnc_default_currency()))
 +            {
 +                gain_loss_accounts_in_filter++;
 +                return TRUE;
 +            }
 +            else return FALSE;
 +        }
 +    }
 +    else return FALSE;
 +}
 +
 +static gboolean
 +gnc_gain_loss_account_all_fail_filter (Account  *account, gpointer  data)
 +{
 +    return FALSE;
 +}
 +
 +void
 +gnc_set_default_cost_policy_widget(SCM list_symbol)
 +{
 +    GList *list_of_policies = gnc_get_valid_policy_list();
 +
 +    if (list_of_policies)
 +    {
 +        GList *l = NULL;
 +        gint i = 0;
 +        for (l = list_of_policies; l != NULL; l = l->next)
 +        {
 +            GNCPolicy *pcy = l->data;
 +            if (g_strcmp0(PolicyGetName (pcy),
 +                               gnc_scm_symbol_to_locale_string(list_symbol))
 +                               == 0)
 +            {
 +                /* GtkComboBox per-item tooltip changes needed below */
 +                gnc_combott_set_active(
 +                    GNC_COMBOTT(
 +                        book_currency_data->default_cost_policy_widget), i);
 +            }
 +            i++;
 +        }
 +        g_list_free(list_of_policies);
 +    }
 +    else
 +    {
 +        gnc_combott_set_active (
 +            GNC_COMBOTT(book_currency_data->default_cost_policy_widget), -1);
 +    }
 +}
 +
 +void
 +gnc_set_default_gain_loss_account_widget(gnc_commodity *commodity)
 +{
 +    if (book_currency_data->default_gain_loss_account_widget)
 +    {
 +        gtk_widget_destroy (
 +                    book_currency_data->default_gain_loss_account_widget);
 +        book_currency_data->default_gain_loss_account_widget = NULL;
 +        book_currency_data->prior_gain_loss_account = NULL;
 +        gain_loss_accounts_in_filter = 0;
 +    }
 +    if (book_currency_data->gain_loss_account_del_button)
 +    {
 +        gtk_widget_destroy (
 +                    book_currency_data->gain_loss_account_del_button);
 +        book_currency_data->gain_loss_account_del_button = NULL;
 +    }
 +    if (book_currency_data->default_gain_loss_account_text)
 +    {
 +        gtk_widget_destroy (
 +                    book_currency_data->default_gain_loss_account_text);
 +        book_currency_data->default_gain_loss_account_text = NULL;
 +    }
 +    if (gnc_is_new_book())
 +    {
 +        book_currency_data->default_gain_loss_account_text =
 +                    gtk_label_new( _("Because no accounts have " \
 +                        "been set up yet,you will need to return to this " \
 +                        "dialog (via File->Properties), after account setup, " \
 +                        "if you want to set a default gain/loss account.") );
 +
 +        gtk_label_set_line_wrap (GTK_LABEL(book_currency_data->default_gain_loss_account_text), TRUE);
 +
 +        gtk_grid_attach (GTK_GRID(book_currency_data->gain_loss_account_table),
 +                                  book_currency_data->default_gain_loss_account_text, 0, 1, 2, 1);
 +    }
 +    else
 +    {
 +        GtkTreeSelection *selection = NULL;
 +        book_currency_data->default_gain_loss_account_widget =
 +                            GTK_WIDGET(gnc_tree_view_account_new(FALSE));
 +        gain_loss_accounts_in_filter = 0;
 +        selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(
 +                        book_currency_data->default_gain_loss_account_widget));
 +        if (!commodity) // that means not book currency
 +        {
 +            /* set the default_gain_loss_account_widget to be blank with a
 +               no-acct filter */
 +            gnc_tree_view_account_set_filter(GNC_TREE_VIEW_ACCOUNT (
 +                        book_currency_data->default_gain_loss_account_widget),
 +                        gnc_gain_loss_account_all_fail_filter,
 +                        NULL,  /* user data */
 +                        NULL  /* destroy callback */ );
 +            gtk_tree_selection_unselect_all (selection);
 +        }
 +        else // that means book currency
 +        {
 +            /* see if there are any accounts after filter */
 +            gnc_tree_view_account_set_filter(GNC_TREE_VIEW_ACCOUNT (
 +                        book_currency_data->default_gain_loss_account_widget),
 +                        gnc_gain_loss_account_view_filter,
 +                        NULL, /* user data */
 +                        NULL  /* destroy callback */);
 +            if (gain_loss_accounts_in_filter > 0)
 +            {   /* there are accounts; find out if one is selected */
 +                Account *gain_loss_account = NULL;
 +                Account *selected_account = NULL;
 +                GtkTreeViewColumn *col;
 +
 +                book_currency_data->gain_loss_account_del_button =
 +                        gtk_button_new_with_label( _("Select no account") );
 +
 +                g_signal_connect (GTK_BUTTON (
 +                        book_currency_data->gain_loss_account_del_button),
 +                        "clicked",
 +                        G_CALLBACK (
 +                            gnc_option_changed_gain_loss_account_del_button_widget_cb),
 +                        NULL);
 +                gtk_grid_attach (GTK_GRID(book_currency_data->gain_loss_account_table),
 +                                          book_currency_data->gain_loss_account_del_button, 1, 0, 1, 1);
 +
 +                gtk_tree_view_set_headers_visible (GTK_TREE_VIEW(
 +                        book_currency_data->default_gain_loss_account_widget),
 +                        TRUE);
 +                col = 
 +                    gnc_tree_view_add_text_column(GNC_TREE_VIEW(
 +                        book_currency_data->default_gain_loss_account_widget),
 +                         _("Currency"), /* title */
 +                        "commodity", /* pref name */
 +                        NULL,
 +                        "Currency--", /* sizing text */
 +                        GNC_TREE_MODEL_ACCOUNT_COL_COMMODITY,
 +                        GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
 +                        NULL);
 +                g_object_set_data(G_OBJECT(col), DEFAULT_VISIBLE,
 +                    GINT_TO_POINTER(1));
 +
 +                // add the color background data function to the column
 +                gnc_tree_view_account_column_add_color (GNC_TREE_VIEW_ACCOUNT(
 +                         book_currency_data->default_gain_loss_account_widget), col);
 +
 +                col =
 +                    gnc_tree_view_add_toggle_column(GNC_TREE_VIEW(
 +                        book_currency_data->default_gain_loss_account_widget),
 +                        _("Placeholder"),
 +                        /* Translators: This string has a context prefix; the
 +                           translation must only contain the part after
 +                           the | character. */
 +                        Q_("Column letter for 'Placeholder'|P"),
 +                        "placeholder",
 +                        GNC_TREE_MODEL_ACCOUNT_COL_PLACEHOLDER,
 +                        GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
 +                        NULL,
 +                        NULL);
 +                g_object_set_data(G_OBJECT(col), DEFAULT_VISIBLE,
 +                    GINT_TO_POINTER(1));
 +
 +                // add the color background data function to the column
 +                gnc_tree_view_account_column_add_color (GNC_TREE_VIEW_ACCOUNT(
 +                         book_currency_data->default_gain_loss_account_widget), col);
 +
 +                gnc_tree_view_configure_columns (GNC_TREE_VIEW(
 +                        book_currency_data->default_gain_loss_account_widget));
 +                gnc_tree_view_set_show_column_menu(GNC_TREE_VIEW(
 +                        book_currency_data->default_gain_loss_account_widget),
 +                        FALSE);
 +                if (book_currency_data->retrieved_gain_loss_acct_guid_scm &&
 +                    (scm_is_string(
 +                        book_currency_data->retrieved_gain_loss_acct_guid_scm)))
 +                {
 +                    GncGUID *guid= g_new (GncGUID, 1);
 +
 +                    if (string_to_guid (
 +                        gnc_scm_to_utf8_string(
 +                        book_currency_data->retrieved_gain_loss_acct_guid_scm),
 +                        guid))
 +                    gain_loss_account =
 +                                xaccAccountLookup(guid, gnc_get_current_book());
 +                    g_free (guid);
 +                }
 +                if (gain_loss_account)
 +                {
 +                    (gnc_tree_view_account_set_selected_account
 +                        (GNC_TREE_VIEW_ACCOUNT(
 +                          book_currency_data->default_gain_loss_account_widget),
 +                        gain_loss_account));
 +                    selected_account =
 +                        gnc_tree_view_account_get_selected_account(
 +                            GNC_TREE_VIEW_ACCOUNT (
 +                            book_currency_data->default_gain_loss_account_widget));
 +                }
 +                if (selected_account)
 +                {
 +                    book_currency_data->prior_gain_loss_account =
 +                        selected_account;
 +                    gtk_widget_set_sensitive(
 +                        book_currency_data->gain_loss_account_del_button,
 +                        TRUE);
 +                }
 +                else /* none selected */
 +                {
 +                    gtk_tree_selection_unselect_all (selection);
 +                    gtk_widget_set_sensitive(
 +                        book_currency_data->gain_loss_account_del_button,
 +                        FALSE);
 +                }
 +            }
 +            else /* no accts in widget?; replace widget with text */
 +            {
 +                gtk_widget_destroy (
 +                    book_currency_data->default_gain_loss_account_widget);
 +                book_currency_data->default_gain_loss_account_widget = NULL;
 +                book_currency_data->prior_gain_loss_account = NULL;
 +                gain_loss_accounts_in_filter = 0;
 +                book_currency_data->default_gain_loss_account_text =
 +                    gtk_label_new( _("There are no income " \
 +                        "or expense accounts of the specified\n" \
 +                        "book currency; you will have to return to this " \
 +                        "dialog\n(via File->Properties), after account setup, " \
 +                        "to select a\ndefault gain/loss account.") );
 +                gtk_grid_attach (GTK_GRID(book_currency_data->gain_loss_account_table),
 +                                          book_currency_data->default_gain_loss_account_text, 0, 1, 2, 1);
 +            }
 +        }
 +        if (book_currency_data->default_gain_loss_account_widget)
 +        {
 +            gtk_widget_set_hexpand (GTK_WIDGET(book_currency_data->default_gain_loss_account_widget), TRUE);
 +            g_signal_connect (G_OBJECT (selection),
 +                        "changed",
 +                        G_CALLBACK (gnc_option_changed_gain_loss_account_widget_cb),
 +                        NULL);
 +            gtk_grid_attach (GTK_GRID(book_currency_data->gain_loss_account_table),
 +                                      book_currency_data->default_gain_loss_account_widget, 0, 1, 2, 1);
 +
 +        }
 +    }
 +}
 +
 +void
 +gnc_option_changed_book_currency_widget_cb(GtkWidget *widget)
 +{
 +    /* Once the book currency widget is set, need to set the
 +       default_gain_loss_account_widget and/or del-button or text*/
 +    if (gtk_combo_box_get_active (GTK_COMBO_BOX(book_currency_data->book_currency_widget)) != -1)
 +    {
 +        gnc_commodity *commodity = gnc_currency_edit_get_currency(
 +                                GNC_CURRENCY_EDIT(
 +                                    book_currency_data->book_currency_widget));
 +
 +        gnc_set_default_gain_loss_account_widget(commodity);
 +    }
 +    gtk_widget_show_all(book_currency_data->book_currency_vbox);
 +    gnc_option_changed_widget_cb(widget, book_currency_data->option);
 +}
 +
 +void
 +gnc_option_changed_gain_loss_account_widget_cb (GtkTreeSelection *selection,
 +                                                    gpointer data)
 +{
 +    Account *account = NULL;
 +    gboolean new_eq_prior_acct = FALSE;
 +
 +    g_return_if_fail (book_currency_data->default_gain_loss_account_widget);
 +    account = gnc_tree_view_account_get_selected_account (
 +                    GNC_TREE_VIEW_ACCOUNT (
 +                        book_currency_data->default_gain_loss_account_widget));
 +    if (account && book_currency_data->prior_gain_loss_account)
 +        new_eq_prior_acct = xaccAccountEqual(account,
 +                                book_currency_data->prior_gain_loss_account,
 +                                TRUE);
 +    if (account && (!new_eq_prior_acct))
 +    { /* a new account has been selected */
 +        if (!xaccAccountGetPlaceholder(account))
 +        {
 +            GtkWidget *option_widget =
 +                        gnc_option_get_gtk_widget (book_currency_data->option);
 +            book_currency_data->prior_gain_loss_account = account;
 +            gtk_widget_set_sensitive(
 +                    book_currency_data->gain_loss_account_del_button, TRUE);
 +            gtk_widget_show_all(book_currency_data->book_currency_vbox);
 +            gnc_option_changed_option_cb(option_widget, book_currency_data->option);
 +        }
 +        else /*  new account, but placeholder */
 +        {
 +            const char *message = _("You have selected a placeholder " \
 +                        "account, which is shown so that child accounts " \
 +                        "are displayed, but is invalid. Please select " \
 +                        "another account. (You can expand the tree below " \
 +                        "the placeholder account by clicking on the arrow " \
 +                        "to the left.)");
 +
 +            gnc_error_dialog(NULL, "%s", message);
 +            if (book_currency_data->prior_gain_loss_account)
 +            {
 +                (gnc_tree_view_account_set_selected_account
 +                    (GNC_TREE_VIEW_ACCOUNT(
 +                          book_currency_data->default_gain_loss_account_widget),
 +                        book_currency_data->prior_gain_loss_account));
 +            }
 +            else
 +            {
 +                gtk_tree_selection_unselect_all (selection);
 +            }
 +        }
 +    }
 +    else /* a new account has not been selected */
 +    {
 +        if (book_currency_data->prior_gain_loss_account == NULL)
 +        {
 +            gtk_tree_selection_unselect_all (selection);
 +            if (book_currency_data->gain_loss_account_del_button)
 +            {
 +                gtk_widget_set_sensitive(
 +                    book_currency_data->gain_loss_account_del_button, FALSE);
 +            }
 +        }
 +    }
 +}
 +
 +void
 +gnc_option_changed_gain_loss_account_del_button_widget_cb (GtkButton *button, gpointer data)
 +{
 +    GtkTreeSelection *selection = NULL;
 +    GtkWidget *option_widget =
 +                        gnc_option_get_gtk_widget (book_currency_data->option);
 +
 +    g_return_if_fail (book_currency_data->default_gain_loss_account_widget);
 +    g_return_if_fail (book_currency_data->gain_loss_account_del_button);
 +
 +    selection = gtk_tree_view_get_selection (
 +                    GTK_TREE_VIEW (
 +                        book_currency_data->default_gain_loss_account_widget));
 +    gtk_tree_selection_unselect_all (selection);
 +    book_currency_data->prior_gain_loss_account = NULL;
 +    gtk_widget_set_sensitive(
 +                    book_currency_data->gain_loss_account_del_button, FALSE);
 +    gnc_option_changed_option_cb(option_widget, book_currency_data->option);
 +}
 +
 +static void
 +gnc_option_currency_accounting_non_book_cb(GtkWidget *widget, gpointer data)
 +{
 +    gnc_currency_edit_clear_display (GNC_CURRENCY_EDIT(
 +                                     book_currency_data->book_currency_widget));
 +    gnc_combott_set_active(GNC_COMBOTT(
 +                                book_currency_data->default_cost_policy_widget),
 +                                -1);
 +    gnc_set_default_gain_loss_account_widget(NULL);
 +    gtk_widget_show_all(book_currency_data->book_currency_vbox);
 +    gtk_widget_set_sensitive(book_currency_data->book_currency_vbox, FALSE);
 +    gnc_option_radiobutton_cb(widget, (gpointer) book_currency_data->option);
 +}
 +
 +static void
 +gnc_option_currency_accounting_book_cb(GtkWidget *widget, gpointer data)
 +{
 +    SCM list_symbol =
 +            gnc_currency_accounting_option_get_default_policy(
 +                                                    book_currency_data->option);
 +    SCM curr_scm = gnc_currency_accounting_option_get_default_currency(
 +                                                    book_currency_data->option);
 +    gnc_commodity *commodity = gnc_scm_to_commodity (curr_scm);
 +
 +    if (book_currency_data->retrieved_book_currency)
 +    {
 +        gnc_currency_edit_set_currency
 +                (GNC_CURRENCY_EDIT(book_currency_data->book_currency_widget),
 +                    book_currency_data->retrieved_book_currency);
 +    }
 +    else if (commodity)
 +    {
 +        gnc_currency_edit_set_currency
 +                (GNC_CURRENCY_EDIT(book_currency_data->book_currency_widget),
 +                    commodity);
 +    }
 +    else
 +    {
 +        gnc_currency_edit_set_currency
 +                (GNC_CURRENCY_EDIT(book_currency_data->book_currency_widget),
 +                    gnc_default_currency());
 +    }
 +    if (book_currency_data->retrieved_policy_scm)
 +    {
 +        gnc_set_default_cost_policy_widget(
 +                                      book_currency_data->retrieved_policy_scm);
 +    }
 +    else
 +    {
 +        gnc_set_default_cost_policy_widget(list_symbol);
 +    }
 +    gtk_widget_show_all(book_currency_data->book_currency_vbox);
 +    gtk_widget_set_sensitive(book_currency_data->book_currency_vbox, TRUE);
 +    gnc_option_radiobutton_cb(widget, (gpointer) book_currency_data->option);
 +}
 +
 +static GtkWidget *
 +gnc_option_create_date_widget (GNCOption *option)
 +{
 +    GtkWidget * box = NULL;
 +    GtkWidget *rel_button = NULL, *ab_button = NULL;
 +    GtkWidget *rel_widget = NULL, *ab_widget = NULL;
 +    GtkWidget *entry;
 +    gboolean show_time, use24;
 +    char *type;
 +    int num_values;
 +
 +    type = gnc_option_date_option_get_subtype(option);
 +    show_time = gnc_option_show_time(option);
 +    use24 = gnc_prefs_get_bool(GNC_PREFS_GROUP_GENERAL, GNC_PREF_CLOCK_24H);
 +
 +    if (g_strcmp0(type, "relative") != 0)
 +    {
 +        ab_widget = gnc_date_edit_new(time(NULL), show_time, use24);
 +        entry = GNC_DATE_EDIT(ab_widget)->date_entry;
 +        g_signal_connect(G_OBJECT(entry), "changed",
 +                         G_CALLBACK(gnc_option_changed_option_cb), option);
 +        if (show_time)
 +        {
 +            entry = GNC_DATE_EDIT(ab_widget)->time_entry;
 +            g_signal_connect(G_OBJECT(entry), "changed",
 +                             G_CALLBACK(gnc_option_changed_option_cb), option);
 +        }
 +    }
 +
 +    if (g_strcmp0(type, "absolute") != 0)
 +    {
 +        int i;
 +        num_values = gnc_option_num_permissible_values(option);
 +
 +        g_return_val_if_fail(num_values >= 0, NULL);
 +
 +        {
 +            /* GtkComboBox still does not support per-item tooltips, so have
 +               created a basic one called Combott implemented in gnc-combott.
 +               Have highlighted changes in this file with comments for when
 +               the feature of per-item tooltips is implemented in gtk,
 +               see http://bugzilla.gnome.org/show_bug.cgi?id=303717 */
 +
 +            GtkListStore *store;
 +            GtkTreeIter  iter;
 +
 +            char *itemstring;
 +            char *description;
 +            store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_STRING);
 +            /* Add values to the list store, entry and tooltip */
 +            for (i = 0; i < num_values; i++)
 +            {
 +                itemstring = gnc_option_permissible_value_name(option, i);
 +                description = gnc_option_permissible_value_description(option, i);
 +                gtk_list_store_append (store, &iter);
 +                gtk_list_store_set (store, &iter, 0, itemstring, 1, description, -1);
 +                if (itemstring)
 +                    g_free(itemstring);
 +                if (description)
 +                    g_free(description);
 +            }
 +            /* Create the new Combo with tooltip and add the store */
 +            rel_widget = GTK_WIDGET(gnc_combott_new());
 +            g_object_set( G_OBJECT(rel_widget), "model", GTK_TREE_MODEL(store), NULL );
 +            g_object_unref(store);
 +
 +            g_signal_connect(G_OBJECT(rel_widget), "changed",
 +                             G_CALLBACK(gnc_option_multichoice_cb), option);
 +        }
 +    }
 +
 +    if (g_strcmp0(type, "absolute") == 0)
 +    {
 +        free(type);
 +        gnc_option_set_widget (option, ab_widget);
 +        return ab_widget;
 +    }
 +    else if (g_strcmp0(type, "relative") == 0)
 +    {
 +        gnc_option_set_widget (option, rel_widget);
 +        free(type);
 +
 +        return rel_widget;
 +    }
 +    else if (g_strcmp0(type, "both") == 0)
 +    {
 +        box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
 +        gtk_box_set_homogeneous (GTK_BOX (box), FALSE);
 +
 +        ab_button = gtk_radio_button_new(NULL);
 +        g_signal_connect(G_OBJECT(ab_button), "toggled",
 +                         G_CALLBACK(gnc_rd_option_ab_set_cb), option);
 +
 +        rel_button = gtk_radio_button_new_from_widget(GTK_RADIO_BUTTON(ab_button));
 +        g_signal_connect(G_OBJECT(rel_button), "toggled",
 +                         G_CALLBACK(gnc_rd_option_rel_set_cb), option);
 +
 +        gtk_box_pack_start(GTK_BOX(box), ab_button, FALSE, FALSE, 0);
 +        gtk_box_pack_start(GTK_BOX(box), ab_widget, FALSE, FALSE, 0);
 +        gtk_box_pack_start(GTK_BOX(box), rel_button, FALSE, FALSE, 0);
 +        gtk_box_pack_start(GTK_BOX(box), rel_widget, FALSE, FALSE, 0);
 +
 +        free(type);
 +
 +        gnc_option_set_widget (option, box);
 +
 +        return box;
 +    }
 +    else /* can't happen */
 +    {
 +        return NULL;
 +    }
 +}
 +
 +static GtkWidget *
 +gnc_option_create_budget_widget(GNCOption *option)
 +{
 +    GtkTreeModel *tm;
 +    GtkComboBox *cb;
 +    GtkCellRenderer *cr;
 +
 +    tm = gnc_tree_model_budget_new(gnc_get_current_book());
 +    cb = GTK_COMBO_BOX(gtk_combo_box_new_with_model(tm));
 +    g_object_unref(tm);
 +    cr = gtk_cell_renderer_text_new();
 +    gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(cb), cr, TRUE);
 +
 +    gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(cb), cr, "text",
 +                                   BUDGET_NAME_COLUMN, NULL);
 +    return GTK_WIDGET(cb);
 +}
 +
 +static GtkWidget *
 +gnc_option_create_multichoice_widget(GNCOption *option)
 +{
 +    GtkWidget *widget;
 +    int num_values;
 +    int i;
 +
 +    num_values = gnc_option_num_permissible_values(option);
 +
 +    g_return_val_if_fail(num_values >= 0, NULL);
 +
 +    {
 +        /* GtkComboBox still does not support per-item tooltips, so have
 +           created a basic one called Combott implemented in gnc-combott.
 +           Have highlighted changes in this file with comments for when
 +           the feature of per-item tooltips is implemented in gtk,
 +           see http://bugzilla.gnome.org/show_bug.cgi?id=303717 */
 +        GtkListStore *store;
 +        GtkTreeIter  iter;
 +
 +        char *itemstring;
 +        char *description;
 +        store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_STRING);
 +        /* Add values to the list store, entry and tooltip */
 +        for (i = 0; i < num_values; i++)
 +        {
 +            itemstring = gnc_option_permissible_value_name(option, i);
 +            description = gnc_option_permissible_value_description(option, i);
 +            gtk_list_store_append (store, &iter);
 +            gtk_list_store_set (store, &iter, 0,
 +                                (itemstring && *itemstring) ? _(itemstring) : "", 1,
 +                                (description && *description) ? _(description) : "", -1);
 +            if (itemstring)
 +                g_free(itemstring);
 +            if (description)
 +                g_free(description);
 +        }
 +        /* Create the new Combo with tooltip and add the store */
 +        widget = GTK_WIDGET(gnc_combott_new());
 +        g_object_set( G_OBJECT( widget ), "model", GTK_TREE_MODEL(store), NULL );
 +        g_object_unref(store);
 +
 +        g_signal_connect(G_OBJECT(widget), "changed",
 +                         G_CALLBACK(gnc_option_multichoice_cb), option);
 +    }
 +
 +    return widget;
 +}
 +
 +static GtkWidget *
 +gnc_option_create_radiobutton_widget(char *name, GNCOption *option)
 +{
 +    GtkWidget *frame, *box;
 +    GtkWidget *widget = NULL;
 +    int num_values;
 +    char *label;
 +    char *tip;
 +    int i;
 +
 +    num_values = gnc_option_num_permissible_values(option);
 +
 +    g_return_val_if_fail(num_values >= 0, NULL);
 +
 +    /* Create our button frame */
 +    frame = gtk_frame_new (name);
 +
 +    /* Create the button box */
 +    box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
 +    gtk_box_set_homogeneous (GTK_BOX (box), FALSE);
 +    gtk_container_add (GTK_CONTAINER (frame), box);
 +
 +    /* Iterate over the options and create a radio button for each one */
 +    for (i = 0; i < num_values; i++)
 +    {
 +        label = gnc_option_permissible_value_name(option, i);
 +        tip = gnc_option_permissible_value_description(option, i);
 +
 +        widget =
 +            gtk_radio_button_new_with_label_from_widget (widget ?
 +                    GTK_RADIO_BUTTON (widget) :
 +                    NULL,
 +                    label && *label ? _(label) : "");
 +        g_object_set_data (G_OBJECT (widget), "gnc_radiobutton_index",
 +                           GINT_TO_POINTER (i));
 +        gtk_widget_set_tooltip_text(widget, tip && *tip ? _(tip) : "");
 +        g_signal_connect(G_OBJECT(widget), "toggled",
 +                         G_CALLBACK(gnc_option_radiobutton_cb), option);
 +        gtk_box_pack_start (GTK_BOX (box), widget, FALSE, FALSE, 0);
 +
 +        if (label)
 +            free (label);
 +        if (tip)
 +            free (tip);
 +    }
 +
 +    return frame;
 +}
 +
 +static GtkWidget *
 +gnc_option_create_currency_accounting_widget (char *name, GNCOption *option)
 +{
 +    GtkWidget *frame = NULL,
 +              *widget = NULL,
 +              *vbox = NULL;
 +    int i;
 +    int num_values = gnc_option_num_permissible_values(option);
 +
 +    g_return_val_if_fail(num_values == 3, NULL);
 +    book_currency_data = g_new0 (currency_accounting_data, 1);
 +    book_currency_data->option = option;
 +
 +    /* Create the button frame */
 +    frame = gtk_frame_new (name);
 +    gtk_widget_set_halign (GTK_WIDGET(frame), GTK_ALIGN_FILL);
 +    gtk_widget_set_hexpand (GTK_WIDGET(frame), TRUE);
 +
 +    /* Create the verticle button box */
 +    vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
 +    gtk_box_set_homogeneous (GTK_BOX (vbox), FALSE);
 +    gtk_container_add (GTK_CONTAINER (frame), vbox);
 +    gtk_widget_set_halign (GTK_WIDGET(vbox), GTK_ALIGN_FILL);
 +    gtk_widget_set_hexpand (GTK_WIDGET(vbox), TRUE);
 +
 +#if GTK_CHECK_VERSION(3,12,0)
 +    gtk_widget_set_margin_end (GTK_WIDGET(vbox), 12);
 +#else
 +    gtk_widget_set_margin_right (GTK_WIDGET(vbox), 12);
 +#endif
 +    gtk_widget_set_margin_bottom (GTK_WIDGET(vbox), 12);
 +
 +    /* Iterate over the three options and create a radio button for each one */
 +    for (i = 0; i < num_values; i++)
 +    {
 +        char *label;
 +        char *tip;
 +        GtkWidget *table = NULL;
 +
 +        label = gnc_option_permissible_value_name(option, i);
 +        tip = gnc_option_permissible_value_description(option, i);
 +
 +        widget =
 +            gtk_radio_button_new_with_label_from_widget (widget ?
 +                    GTK_RADIO_BUTTON (widget) :
 +                    NULL,
 +                    label && *label ? _(label) : "");
 +        g_object_set_data (G_OBJECT (widget), "gnc_radiobutton_index",
 +                           GINT_TO_POINTER (i));
 +        switch (i)
 +        {
 +        case 0:
 +            book_currency_data->gnc_currency_radiobutton_0 = widget;
 +            break;
 +
 +        case 1:
 +            book_currency_data->gnc_currency_radiobutton_1 = widget;
 +            break;
 +
 +        case 2:
 +            book_currency_data->gnc_currency_radiobutton_2 = widget;
 +            break;
 +
 +        default:
 +            break;
 +        }
 +        gtk_widget_set_tooltip_text(widget, tip && *tip ? _(tip) : "");
 +        if (g_strcmp0(gnc_option_permissible_value_name(option, i),
 +                                                    "Use a Book Currency") == 0)
 +        {
 +            GtkWidget *widget_label,
 +                      *policy_table = gtk_grid_new();
 +
 +            book_currency_data->book_currency_widget = gnc_currency_edit_new();
 +            book_currency_data->default_cost_policy_widget =
 +                                    gnc_cost_policy_select_new();
 +            book_currency_data->default_gain_loss_account_widget = NULL;
 +            book_currency_data->gain_loss_account_del_button = NULL;
 +            book_currency_data->default_gain_loss_account_text = NULL;
 +            book_currency_data->prior_gain_loss_account = NULL;
 +
 +            book_currency_data->book_currency_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
 +            gtk_box_set_homogeneous (GTK_BOX (book_currency_data->book_currency_vbox), FALSE);
 +
 +            table = gtk_grid_new ();
 +            gtk_grid_attach (GTK_GRID(table), widget, 0, 0, 2, 1);
 +            g_signal_connect(G_OBJECT(widget), "toggled",
 +                         G_CALLBACK(gnc_option_currency_accounting_book_cb),
 +                         book_currency_data);
 +
 +            book_currency_data->book_currency_table = gtk_grid_new ();
 +            gtk_grid_set_row_spacing (GTK_GRID (book_currency_data->book_currency_table), 6);
 +            gtk_grid_set_column_spacing (GTK_GRID (book_currency_data->book_currency_table), 6);
 +
 +            tip = gnc_currency_accounting_option_currency_documentation(option);
 +            widget_label = gtk_label_new( _("Book currency:") );
 +            gtk_widget_set_tooltip_text(book_currency_data->book_currency_table,
 +                        tip && *tip ? _(tip) : "");
 +
 +            gtk_widget_set_halign (GTK_WIDGET(widget_label), GTK_ALIGN_START);
 +            gtk_widget_set_hexpand (GTK_WIDGET(widget_label), TRUE);
 +
 +            gtk_grid_attach (GTK_GRID(book_currency_data->book_currency_table), widget_label, 0, 0, 1, 1);
 +
 +            g_signal_connect(G_OBJECT(book_currency_data->book_currency_widget),
 +                             "changed",
 +                             G_CALLBACK(gnc_option_changed_book_currency_widget_cb),
 +                             NULL);
 +
 +            gtk_grid_attach (GTK_GRID(book_currency_data->book_currency_table),
 +                                      book_currency_data->book_currency_widget, 1, 0, 1, 1);
 +
 +            gtk_box_pack_start (GTK_BOX (book_currency_data->book_currency_vbox),
 +                                         book_currency_data->book_currency_table,
 +                                         TRUE, TRUE, 0);
 +#if GTK_CHECK_VERSION(3,12,0)
 +            gtk_widget_set_margin_start (GTK_WIDGET(book_currency_data->book_currency_table), 12);
 +#else
 +            gtk_widget_set_margin_left (GTK_WIDGET(book_currency_data->book_currency_table), 12);
 +#endif
 +            gtk_grid_set_row_spacing (GTK_GRID (policy_table), 6);
 +            gtk_grid_set_column_spacing (GTK_GRID (policy_table), 6);
 +
 +            tip = gnc_currency_accounting_option_policy_documentation(option);
 +            widget_label = gtk_label_new( _("Default lot tracking policy:") );
 +            gtk_widget_set_tooltip_text(policy_table, tip && *tip ? _(tip) : "");
 +
 +            gtk_widget_set_halign (GTK_WIDGET(widget_label), GTK_ALIGN_START);
 +            gtk_widget_set_hexpand (GTK_WIDGET(widget_label), TRUE);
 +
 +            gtk_grid_attach (GTK_GRID(policy_table), widget_label, 0, 1, 1, 1);
 +
 +            g_signal_connect(G_OBJECT(
 +                             book_currency_data->default_cost_policy_widget),
 +                             "changed",
 +                             G_CALLBACK(gnc_option_multichoice_cb), option);
 +
 +            gtk_grid_attach (GTK_GRID(policy_table),
 +                             book_currency_data->default_cost_policy_widget, 1, 1, 1, 1);
 +
 +            gtk_box_pack_start (GTK_BOX (book_currency_data->book_currency_vbox),
 +                                         policy_table, TRUE, TRUE, 0);
 +#if GTK_CHECK_VERSION(3,12,0)
 +            gtk_widget_set_margin_start (GTK_WIDGET(policy_table), 12);
 +#else
 +            gtk_widget_set_margin_left (GTK_WIDGET(policy_table), 12);
 +#endif
 +            book_currency_data->gain_loss_account_table = gtk_grid_new ();
 +            gtk_grid_set_row_spacing (GTK_GRID (book_currency_data->gain_loss_account_table), 6);
 +            gtk_grid_set_column_spacing (GTK_GRID (book_currency_data->gain_loss_account_table), 6);
 +
 +            tip = gnc_currency_accounting_option_gain_loss_account_documentation(option);
 +            widget_label = gtk_label_new( _("Default gain/loss account:") );
 +            gnc_label_set_alignment (GTK_WIDGET(widget_label), 0.0, 0.5);
 +
 +            gtk_widget_set_tooltip_text(book_currency_data->gain_loss_account_table,
 +                                        tip && *tip ? _(tip) : "");
 +
 +            gtk_grid_attach (GTK_GRID(book_currency_data->gain_loss_account_table), widget_label, 0, 0, 1, 1);
 +
 +            widget_label = NULL;
 +            gtk_box_pack_start (GTK_BOX (book_currency_data->book_currency_vbox),
 +                                book_currency_data->gain_loss_account_table,
 +                                TRUE, TRUE, 0);
 +#if GTK_CHECK_VERSION(3,12,0)
 +            gtk_widget_set_margin_start (GTK_WIDGET(book_currency_data->gain_loss_account_table), 12);
 +#else
 +            gtk_widget_set_margin_left (GTK_WIDGET(book_currency_data->gain_loss_account_table), 12);
 +#endif
 +            gtk_grid_attach (GTK_GRID(table), book_currency_data->book_currency_vbox, 1, 2, 1, 1);
 +        }
 +        else /* trading or neither */
 +        {
 +            table = gtk_grid_new ();
 +            gtk_grid_attach (GTK_GRID(table), widget, 0, 1, 1, 1);
 +
 +            g_signal_connect(G_OBJECT(widget), "toggled",
 +                             G_CALLBACK(gnc_option_currency_accounting_non_book_cb),
 +                             book_currency_data);
 +        }
 +        gtk_box_pack_start (GTK_BOX (vbox), table, TRUE, TRUE, 0);
 +
 +        if (label)
 +            free (label);
 +        if (tip)
 +            free (tip);
 +    }
 +    return frame;
 +}
 +
 +static void
 +gnc_option_account_cb(GtkTreeSelection *selection, gpointer data)
 +{
 +    GNCOption *option = data;
 +    GtkTreeView *tree_view;
 +
 +    tree_view = gtk_tree_selection_get_tree_view(selection);
 +
 +    gnc_option_changed_widget_cb(GTK_WIDGET(tree_view), option);
 +}
 +
 +static void
 +gnc_option_account_select_all_cb(GtkWidget *widget, gpointer data)
 +{
 +    GNCOption *option = data;
 +    GncTreeViewAccount *tree_view;
 +    GtkTreeSelection *selection;
 +
 +    tree_view = GNC_TREE_VIEW_ACCOUNT(gnc_option_get_gtk_widget (option));
 +    gtk_tree_view_expand_all(GTK_TREE_VIEW(tree_view));
 +    selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree_view));
 +    gtk_tree_selection_select_all(selection);
 +    gnc_option_changed_widget_cb(widget, option);
 +}
 +
 +static void
 +gnc_option_account_clear_all_cb(GtkWidget *widget, gpointer data)
 +{
 +    GNCOption *option = data;
 +    GncTreeViewAccount *tree_view;
 +    GtkTreeSelection *selection;
 +
 +    tree_view = GNC_TREE_VIEW_ACCOUNT(gnc_option_get_gtk_widget (option));
 +    selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree_view));
 +    gtk_tree_selection_unselect_all(selection);
 +    gnc_option_changed_widget_cb(widget, option);
 +}
 +
 +static void
 +gnc_option_account_select_children_cb(GtkWidget *widget, gpointer data)
 +{
 +    GNCOption *option = data;
 +    GncTreeViewAccount *tree_view;
 +    GList *acct_list = NULL, *acct_iter = NULL;
 +
 +    tree_view = GNC_TREE_VIEW_ACCOUNT(gnc_option_get_gtk_widget (option));
 +    acct_list = gnc_tree_view_account_get_selected_accounts (tree_view);
 +
 +    for (acct_iter = acct_list; acct_iter; acct_iter = acct_iter->next)
 +        gnc_tree_view_account_select_subaccounts (tree_view, acct_iter->data);
 +
 +    g_list_free (acct_list);
 +}
 +
 +static GtkWidget *
 +gnc_option_create_account_widget(GNCOption *option, char *name)
 +{
 +    gboolean multiple_selection;
 +    GtkWidget *scroll_win;
 +    GtkWidget *button;
 +    GtkWidget *frame;
 +    GtkWidget *tree;
 +    GtkWidget *vbox;
 +    GtkWidget *bbox;
 +    GList *acct_type_list;
 +    GtkTreeSelection *selection;
 +
 +    multiple_selection = gnc_option_multiple_selection(option);
 +    acct_type_list = gnc_option_get_account_type_list(option);
 +
 +    frame = gtk_frame_new(name);
 +
 +    vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
 +    gtk_box_set_homogeneous (GTK_BOX (vbox), FALSE);
 +
 +    gtk_container_add(GTK_CONTAINER(frame), vbox);
 +
 +    tree = GTK_WIDGET(gnc_tree_view_account_new (FALSE));
 +    gtk_tree_view_set_headers_visible (GTK_TREE_VIEW(tree), FALSE);
 +    selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(tree));
 +    if (multiple_selection)
 +        gtk_tree_selection_set_mode (selection, GTK_SELECTION_MULTIPLE);
 +    else
 +        gtk_tree_selection_set_mode (selection, GTK_SELECTION_BROWSE);
 +
 +    if (acct_type_list)
 +    {
 +        GList *node;
 +        AccountViewInfo avi;
 +        int i;
 +
 +        gnc_tree_view_account_get_view_info (GNC_TREE_VIEW_ACCOUNT (tree), &avi);
 +
 +        for (i = 0; i < NUM_ACCOUNT_TYPES; i++)
 +            avi.include_type[i] = FALSE;
 +        avi.show_hidden = FALSE;
 +
 +        for (node = acct_type_list; node; node = node->next)
 +        {
 +            GNCAccountType type = GPOINTER_TO_INT (node->data);
 +            avi.include_type[type] = TRUE;
 +        }
 +
 +        gnc_tree_view_account_set_view_info (GNC_TREE_VIEW_ACCOUNT (tree), &avi);
 +        g_list_free (acct_type_list);
 +    }
 +    else
 +    {
 +        AccountViewInfo avi;
 +        int i;
 +
 +        gnc_tree_view_account_get_view_info (GNC_TREE_VIEW_ACCOUNT (tree), &avi);
 +
 +        for (i = 0; i < NUM_ACCOUNT_TYPES; i++)
 +            avi.include_type[i] = TRUE;
 +        avi.show_hidden = FALSE;
 +        gnc_tree_view_account_set_view_info (GNC_TREE_VIEW_ACCOUNT (tree), &avi);
 +    }
 +
 +    scroll_win = gtk_scrolled_window_new(NULL, NULL);
 +    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll_win),
 +                                   GTK_POLICY_AUTOMATIC,
 +                                   GTK_POLICY_AUTOMATIC);
 +
 +    gtk_box_pack_start(GTK_BOX(vbox), scroll_win, TRUE, TRUE, 0);
 +    gtk_container_set_border_width(GTK_CONTAINER(scroll_win), 5);
 +    gtk_container_add(GTK_CONTAINER(scroll_win), tree);
 +
 +    bbox = gtk_button_box_new (GTK_ORIENTATION_HORIZONTAL);
 +    gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_SPREAD);
 +    gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 10);
 +
 +    if (multiple_selection)
 +    {
 +        button = gtk_button_new_with_label(_("Select All"));
 +        gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
 +        gtk_widget_set_tooltip_text(button, _("Select all accounts."));
 +
 +        g_signal_connect(G_OBJECT(button), "clicked",
 +                         G_CALLBACK(gnc_option_account_select_all_cb), option);
 +
 +        button = gtk_button_new_with_label(_("Clear All"));
 +        gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
 +        gtk_widget_set_tooltip_text(button, _("Clear the selection and unselect all accounts."));
 +
 +        g_signal_connect(G_OBJECT(button), "clicked",
 +                         G_CALLBACK(gnc_option_account_clear_all_cb), option);
 +
 +        button = gtk_button_new_with_label(_("Select Children"));
 +        gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
 +        gtk_widget_set_tooltip_text(button, _("Select all descendents of selected account."));
 +
 +        g_signal_connect(G_OBJECT(button), "clicked",
 +                         G_CALLBACK(gnc_option_account_select_children_cb), option);
 +    }
 +
 +    button = gtk_button_new_with_label(_("Select Default"));
 +    gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
 +    gtk_widget_set_tooltip_text(button, _("Select the default account selection."));
 +
 +    g_signal_connect(G_OBJECT(button), "clicked",
 +                     G_CALLBACK(gnc_option_default_cb), option);
 +
 +    if (multiple_selection)
 +    {
 +        /* Put the "Show hidden" checkbox on a separate line since the 4 buttons make
 +           the dialog too wide. */
 +        bbox = gtk_button_box_new (GTK_ORIENTATION_HORIZONTAL);
 +        gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_START);
 +        gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 0);
 +    }
 +
 +    button = gtk_check_button_new_with_label(_("Show Hidden Accounts"));
 +    gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
 +    gtk_widget_set_tooltip_text(button, _("Show accounts that have been marked hidden."));
 +    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), FALSE);
 +    g_signal_connect(G_OBJECT(button), "toggled",
 +                     G_CALLBACK(gnc_option_show_hidden_toggled_cb), option);
 +
 +    gnc_option_set_widget (option, tree);
 +
 +    return frame;
 +}
 +
 +static void
 +gnc_option_list_changed_cb(GtkTreeSelection *selection,
 +                           GNCOption *option)
 +{
 +    GtkTreeView *view;
 +
 +    view = gtk_tree_selection_get_tree_view(selection);
 +    gnc_option_changed_widget_cb(GTK_WIDGET(view), option);
 +}
 +
 +static void
 +gnc_option_list_select_all_cb(GtkWidget *widget, gpointer data)
 +{
 +    GNCOption *option = data;
 +    GtkTreeView *view;
 +    GtkTreeSelection *selection;
 +
 +    view = GTK_TREE_VIEW(gnc_option_get_gtk_widget (option));
 +    selection = gtk_tree_view_get_selection(view);
 +    gtk_tree_selection_select_all(selection);
 +    gnc_option_changed_widget_cb(GTK_WIDGET(view), option);
 +}
 +
 +static void
 +gnc_option_list_clear_all_cb(GtkWidget *widget, gpointer data)
 +{
 +    GNCOption *option = data;
 +    GtkTreeView *view;
 +    GtkTreeSelection *selection;
 +
 +    view = GTK_TREE_VIEW(gnc_option_get_gtk_widget (option));
 +    selection = gtk_tree_view_get_selection(view);
 +    gtk_tree_selection_unselect_all(selection);
 +    gnc_option_changed_widget_cb(GTK_WIDGET(view), option);
 +}
 +
 +static GtkWidget *
 +gnc_option_create_list_widget(GNCOption *option, char *name)
 +{
 +    GtkListStore *store;
 +    GtkTreeView *view;
 +    GtkTreeIter iter;
 +    GtkTreeViewColumn *column;
 +    GtkCellRenderer *renderer;
 +    GtkTreeSelection *selection;
 +
 +    GtkWidget *button;
 +    GtkWidget *frame;
 +    GtkWidget *hbox;
 +    GtkWidget *bbox;
 +    gint num_values;
 +    gint i;
 +
 +    frame = gtk_frame_new(name);
 +    hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
 +    gtk_box_set_homogeneous (GTK_BOX (hbox), FALSE);
 +    gtk_container_add(GTK_CONTAINER(frame), hbox);
 +
 +    store = gtk_list_store_new(1, G_TYPE_STRING);
 +    view = GTK_TREE_VIEW(gtk_tree_view_new_with_model(GTK_TREE_MODEL(store)));
 +    g_object_unref(store);
 +    renderer = gtk_cell_renderer_text_new();
 +    column = gtk_tree_view_column_new_with_attributes("", renderer,
 +             "text", 0,
 +             NULL);
 +    gtk_tree_view_append_column(view, column);
 +    gtk_tree_view_set_headers_visible(view, FALSE);
 +
 +    num_values = gnc_option_num_permissible_values(option);
 +    for (i = 0; i < num_values; i++)
 +    {
 +        gchar *raw_string, *string;
 +
 +        raw_string = gnc_option_permissible_value_name(option, i);
 +        string = (raw_string && *raw_string) ? _(raw_string) : "";
 +        gtk_list_store_append(store, &iter);
 +        gtk_list_store_set(store, &iter,
 +                           0, string ? string : "",
 +                           -1);
 +        g_free(raw_string);
 +    }
 +
 +    gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(view), FALSE, FALSE, 0);
 +
 +    selection = gtk_tree_view_get_selection(view);
 +    gtk_tree_selection_set_mode(selection, GTK_SELECTION_MULTIPLE);
 +    g_signal_connect(selection, "changed",
 +                     G_CALLBACK(gnc_option_list_changed_cb), option);
 +
 +    bbox = gtk_button_box_new (GTK_ORIENTATION_VERTICAL);
 +    gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_SPREAD);
 +    gtk_box_pack_start(GTK_BOX(hbox), bbox, FALSE, FALSE, 10);
 +
 +    button = gtk_button_new_with_label(_("Select All"));
 +    gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
 +    gtk_widget_set_tooltip_text(button, _("Select all entries."));
 +
 +    g_signal_connect(G_OBJECT(button), "clicked",
 +                     G_CALLBACK(gnc_option_list_select_all_cb), option);
 +
 +    button = gtk_button_new_with_label(_("Clear All"));
 +    gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
 +    gtk_widget_set_tooltip_text(button, _("Clear the selection and unselect all entries."));
 +
 +    g_signal_connect(G_OBJECT(button), "clicked",
 +                     G_CALLBACK(gnc_option_list_clear_all_cb), option);
 +
 +    button = gtk_button_new_with_label(_("Select Default"));
 +    gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
 +    gtk_widget_set_tooltip_text(button, _("Select the default selection."));
 +
 +    g_signal_connect(G_OBJECT(button), "clicked",
 +                     G_CALLBACK(gnc_option_default_cb), option);
 +
 +    gnc_option_set_widget (option, GTK_WIDGET(view));
 +
 +    return frame;
 +}
 +
 +static void
 +gnc_option_color_changed_cb(GtkColorButton *color_button, GNCOption *option)
 +{
 +    gnc_option_changed_widget_cb(GTK_WIDGET(color_button), option);
 +}
 +
 +static void
 +gnc_option_font_changed_cb(GtkFontButton *font_button, GNCOption *option)
 +{
 +    gnc_option_changed_widget_cb(GTK_WIDGET(font_button), option);
 +}
 +
 +static void
 +gnc_option_set_ui_widget(GNCOption *option,
 +                         GtkBox *page_box)
 +{
 +    GtkWidget *enclosing = NULL;
 +    GtkWidget *value = NULL;
 +    gboolean packed = FALSE;
 +    char *raw_name, *raw_documentation;
 +    char *name, *documentation;
 +    char *type;
 +    GNCOptionDef_t *option_def;
 +
 +    ENTER("option %p(%s), box %p",
 +          option, gnc_option_name(option), page_box);
 +    type = gnc_option_type(option);
 +    if (type == NULL)
 +    {
 +        LEAVE("bad type");
 +        return;
 +    }
++    else if (g_strcmp0 (type, "internal") == 0)
++    {
++        LEAVE("internal type");
++        return;
++    }
 +
 +    raw_name = gnc_option_name(option);
 +    if (raw_name && *raw_name)
 +        name = _(raw_name);
 +    else
 +        name = NULL;
 +
 +    raw_documentation = gnc_option_documentation(option);
 +    if (raw_documentation && *raw_documentation)
 +        documentation = _(raw_documentation);
 +    else
 +        documentation = NULL;
 +
 +    option_def = gnc_options_ui_get_option (type);
 +    if (option_def && option_def->set_widget)
 +    {
 +        value = option_def->set_widget (option, page_box,
 +                                        name, documentation,
 +                                        /* Return values */
 +                                        &enclosing, &packed);
 +    }
 +    else
 +    {
 +        PERR("Unknown option type. Ignoring option \"%s\".\n", name);
 +    }
 +
 +    if (!packed && (enclosing != NULL))
 +    {
 +        /* Pack option widget into an extra eventbox because otherwise the
 +           "documentation" tooltip is not displayed. */
 +        GtkWidget *eventbox = gtk_event_box_new();
 +
 +        gtk_container_add (GTK_CONTAINER (eventbox), enclosing);
 +        gtk_box_pack_start (page_box, eventbox, FALSE, FALSE, 0);
 +
 +        gtk_widget_set_tooltip_text (eventbox, documentation);
 +    }
 +
 +    if (value != NULL)
 +        gtk_widget_set_tooltip_text(value, documentation);
 +
 +    if (raw_name != NULL)
 +        free(raw_name);
 +    if (raw_documentation != NULL)
 +        free(raw_documentation);
 +    free(type);
 +    LEAVE(" ");
 +}
 +
 +static void
 +gnc_options_dialog_add_option(GtkWidget *page,
 +                              GNCOption *option)
 +{
 +    gnc_option_set_ui_widget(option, GTK_BOX(page));
 +}
 +
 +static gint
 +gnc_options_dialog_append_page(GNCOptionWin * propertybox,
 +                               GNCOptionSection *section)
 +{
 +    GNCOption *option;
 +    GtkWidget *page_label;
 +    GtkWidget *options_box;
 +    GtkWidget *page_content_box;
 +    GtkWidget* notebook_page;
 +    GtkWidget *reset_button;
 +    GtkWidget *listitem = NULL;
 +    GtkWidget *buttonbox;
 +    GtkWidget *options_scrolled_win;
 +    GtkTreeView *view;
 +    GtkListStore *list;
 +    GtkTreeIter iter;
 +    gint num_options;
 +    const char *name;
 +    gint i, page_count, name_offset;
 +    gboolean advanced;
 +
 +    name = gnc_option_section_name(section);
 +    if (!name)
 +        return -1;
 +
 +    if (strncmp(name, "__", 2) == 0)
 +        return -1;
 +    advanced = (strncmp(name, "_+", 2) == 0);
 +    name_offset = (advanced) ? 2 : 0;
 +    page_label = gtk_label_new(_(name + name_offset));
 +    PINFO("Page_label is %s", _(name + name_offset));
 +    gtk_widget_show(page_label);
 +
 +    /* Build this options page */
 +    page_content_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
 +    gtk_box_set_homogeneous (GTK_BOX (page_content_box), FALSE);
 +
 +    gtk_container_set_border_width(GTK_CONTAINER(page_content_box), 12);
 +
 +    options_scrolled_win = gtk_scrolled_window_new(NULL, NULL);
 +    gtk_box_pack_start(GTK_BOX(page_content_box), options_scrolled_win, TRUE, TRUE, 0);
 +
 +    /* Build space for the content - the options box */
 +    options_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
 +    gtk_box_set_homogeneous (GTK_BOX (options_box), FALSE);
 +
 +    gtk_container_set_border_width(GTK_CONTAINER(options_box), 0);
 +    gtk_container_add (GTK_CONTAINER(options_scrolled_win), GTK_WIDGET(options_box));
 +    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(options_scrolled_win), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
 +
 +    /* Create all the options */
 +    num_options = gnc_option_section_num_options(section);
 +    for (i = 0; i < num_options; i++)
 +    {
 +        option = gnc_get_option_section_option(section, i);
 +        gnc_options_dialog_add_option(options_box, option);
 +    }
 +
 +    /* Add a button box at the bottom of the page */
 +    buttonbox = gtk_button_box_new (GTK_ORIENTATION_HORIZONTAL);
 +    gtk_button_box_set_layout (GTK_BUTTON_BOX (buttonbox),
 +                               GTK_BUTTONBOX_EDGE);
 +    gtk_container_set_border_width(GTK_CONTAINER (buttonbox), 5);
 +    gtk_box_pack_end(GTK_BOX(page_content_box), buttonbox, FALSE, FALSE, 0);
 +
 +    /* The reset button on each option page */
 +    reset_button = gtk_button_new_with_label (_("Reset defaults"));
 +    gtk_widget_set_tooltip_text(reset_button,
 +                                _("Reset all values to their defaults."));
 +
 +    g_signal_connect(G_OBJECT(reset_button), "clicked",
 +                     G_CALLBACK(gnc_options_dialog_reset_cb), propertybox);
 +    g_object_set_data(G_OBJECT(reset_button), "section", section);
 +    gtk_box_pack_end(GTK_BOX(buttonbox), reset_button, FALSE, FALSE, 0);
 +    gtk_widget_show_all(page_content_box);
 +    gtk_notebook_append_page(GTK_NOTEBOOK(propertybox->notebook),
 +                             page_content_box, page_label);
 +
 +    /* Switch to selection from a list if the page count threshold is reached */
 +    page_count = gtk_notebook_page_num(GTK_NOTEBOOK(propertybox->notebook),
 +                                       page_content_box);
 +
 +    if (propertybox->page_list_view)
 +    {
 +        /* Build the matching list item for selecting from large page sets */
 +        view = GTK_TREE_VIEW(propertybox->page_list_view);
 +        list = GTK_LIST_STORE(gtk_tree_view_get_model(view));
 +
 +        PINFO("Page name is %s and page_count is %d", name, page_count);
 +        gtk_list_store_append(list, &iter);
 +        gtk_list_store_set(list, &iter,
 +                           PAGE_NAME, _(name),
 +                           PAGE_INDEX, page_count,
 +                           -1);
 +
 +        if (page_count > MAX_TAB_COUNT - 1)   /* Convert 1-based -> 0-based */
 +        {
 +            gtk_widget_show(propertybox->page_list);
 +            gtk_notebook_set_show_tabs(GTK_NOTEBOOK(propertybox->notebook), FALSE);
 +            gtk_notebook_set_show_border(GTK_NOTEBOOK(propertybox->notebook), FALSE);
 +        }
 +        else
 +            gtk_widget_hide(propertybox->page_list);
 +
 +        /* Tweak "advanced" pages for later handling. */
 +        if (advanced)
 +        {
 +            notebook_page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(propertybox->notebook),
 +                            page_count);
 +
 +            g_object_set_data(G_OBJECT(notebook_page), "listitem", listitem);
 +            g_object_set_data(G_OBJECT(notebook_page), "advanced",
 +                              GINT_TO_POINTER(advanced));
 +        }
 +    }
 +    return(page_count);
 +}
 +
 +/********************************************************************\
 + * gnc_options_dialog_build_contents                                *
 + *   builds an options dialog given a property box and an options   *
 + *   database and make the dialog visible                           *
 + *                                                                  *
 + * Args: propertybox - gnome property box to use                    *
 + *       odb         - option database to use                       *
 + * Return: nothing                                                  *
 +\********************************************************************/
 +void
 +gnc_options_dialog_build_contents (GNCOptionWin *propertybox,
 +                                   GNCOptionDB  *odb)
 +{
 +    gnc_options_dialog_build_contents_full (propertybox, odb, TRUE);
 +}
 +
 +/********************************************************************\
 + * gnc_options_dialog_build_contents_full                                *
 + *   builds an options dialog given a property box and an options   *
 + *   database and make the dialog visible depending on the          *
 + *   show_dialog flag                                               *
 + *                                                                  *
 + * Args: propertybox - gnome property box to use                    *
 + *       odb         - option database to use                       *
 + *       show_dialog - should dialog be made visible or not         *
 + * Return: nothing                                                  *
 +\********************************************************************/
 +void
 +gnc_options_dialog_build_contents_full (GNCOptionWin *propertybox,
 +                                        GNCOptionDB  *odb, gboolean show_dialog)
 +{
 +    GNCOptionSection *section;
 +    gchar *default_section_name;
 +    gint default_page = -1;
 +    gint num_sections;
 +    gint page;
 +    gint i;
 +    guint j;
 +
 +    g_return_if_fail (propertybox != NULL);
 +    g_return_if_fail (odb != NULL);
 +
 +    gnc_option_db_set_ui_callbacks (odb,
 +                                    gnc_option_get_ui_value_internal,
 +                                    gnc_option_set_ui_value_internal,
 +                                    gnc_option_set_selectable_internal);
 +
 +    propertybox->option_db = odb;
 +
 +    num_sections = gnc_option_db_num_sections(odb);
 +    default_section_name = gnc_option_db_get_default_section(odb);
 +
 +    PINFO("Default Section name is %s", default_section_name);
 +
 +    for (i = 0; i < num_sections; i++)
 +    {
 +        const char *section_name;
 +
 +        section = gnc_option_db_get_section(odb, i);
 +        page = gnc_options_dialog_append_page(propertybox, section);
 +
 +        section_name = gnc_option_section_name(section);
 +        if (g_strcmp0(section_name, default_section_name) == 0)
 +            default_page = page;
 +    }
 +
 +    if (default_section_name != NULL)
 +        free(default_section_name);
 +
 +    /* call each option widget changed callbacks once at this point,
 +     * now that all options widgets exist.
 +     */
 +    for (i = 0; i < num_sections; i++)
 +    {
 +        section = gnc_option_db_get_section(odb, i);
 +
 +        for (j = 0; j < gnc_option_section_num_options(section); j++)
 +        {
 +            gnc_option_call_option_widget_changed_proc(
 +                gnc_get_option_section_option(section, j) );
 +        }
 +    }
 +
 +    gtk_notebook_popup_enable(GTK_NOTEBOOK(propertybox->notebook));
 +    if (default_page >= 0)
 +    {
 +        /* Find the page list and set the selection to the default page */
 +        GtkTreeSelection* selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(propertybox->page_list_view));
 +        GtkTreeIter iter;
 +        GtkTreeModel *model;
 +
 +        model = gtk_tree_view_get_model(GTK_TREE_VIEW(propertybox->page_list_view));
 +        gtk_tree_model_iter_nth_child(model, &iter, NULL, default_page);
 +        gtk_tree_selection_select_iter (selection, &iter);
 +        gtk_notebook_set_current_page(GTK_NOTEBOOK(propertybox->notebook), default_page);
 +    }
 +    gnc_options_dialog_changed_internal(propertybox->dialog, FALSE);
 +    if (show_dialog)
 +        gtk_widget_show(propertybox->dialog);
 +}
 +
 +GtkWidget *
 +gnc_options_dialog_widget(GNCOptionWin * win)
 +{
 +    return win->dialog;
 +}
 +
 +GtkWidget *
 +gnc_options_page_list(GNCOptionWin * win)
 +{
 +    return win->page_list;
 +}
 +
 +GtkWidget *
 +gnc_options_dialog_notebook(GNCOptionWin * win)
 +{
 +    return win->notebook;
 +}
 +
 +void
 +gnc_options_dialog_response_cb(GtkDialog *dialog, gint response, GNCOptionWin *window)
 +{
 +    GNCOptionWinCallback close_cb;
 +
 +    switch (response)
 +    {
 +    case GTK_RESPONSE_HELP:
 +        if (window->help_cb)
 +            (window->help_cb)(window, window->help_cb_data);
 +        break;
 +
 +    case GTK_RESPONSE_OK:
 +    case GTK_RESPONSE_APPLY:
 +        close_cb = window->close_cb;
 +        window->close_cb = NULL;
 +        if (window->apply_cb)
 +            window->apply_cb (window, window->apply_cb_data);
 +        window->close_cb = close_cb;
 +        if (response == GTK_RESPONSE_APPLY)
 +        {
 +            gnc_options_dialog_changed_internal (window->dialog, FALSE);
 +            break;
 +        }
 +        /* fall through */
 +
 +    default:
 +        if (window->close_cb)
 +        {
 +            (window->close_cb)(window, window->close_cb_data);
 +        }
 +        else
 +        {
 +            gtk_widget_hide(window->dialog);
 +        }
 +        break;
 +    }
 +}
 +
 +static void
 +gnc_options_dialog_reset_cb(GtkWidget * w, gpointer data)
 +{
 +    GNCOptionWin *win = data;
 +    GNCOptionSection *section;
 +    gpointer val;
 +
 +    val = g_object_get_data(G_OBJECT(w), "section");
 +    g_return_if_fail (val);
 +    g_return_if_fail (win);
 +
 +    section = (GNCOptionSection*)val;
 +    gnc_option_db_section_reset_widgets (section);
 +    gnc_options_dialog_changed_internal (win->dialog, TRUE);
 +}
 +
 +void
 +gnc_options_dialog_list_select_cb (GtkTreeSelection *selection,
 +                                   gpointer data)
 +{
 +    GNCOptionWin * win = data;
 +    GtkTreeModel *list;
 +    GtkTreeIter iter;
 +    gint index = 0;
 +
 +    if (!gtk_tree_selection_get_selected(selection, &list, &iter))
 +        return;
 +    gtk_tree_model_get(list, &iter,
 +                       PAGE_INDEX, &index,
 +                       -1);
 +    PINFO("Index is %d", index);
 +    gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), index);
 +}
 +
 +void
 +gnc_options_register_stocks (void)
 +{
 +#if 0
 +    static gboolean done = FALSE;
 +
 +    GtkStockItem items[] =
 +    {
 +        { GTK_STOCK_APPLY		, "gnc_option_apply_button",	0, 0, NULL },
 +        { GTK_STOCK_HELP		, "gnc_options_dialog_help",	0, 0, NULL },
 +        { GTK_STOCK_OK			, "gnc_options_dialog_ok",	0, 0, NULL },
 +        { GTK_STOCK_CANCEL		, "gnc_options_dialog_cancel",	0, 0, NULL },
 +    };
 +
 +    if (done)
 +    {
 +        return;
 +    }
 +    done = TRUE;
 +
 +    gtk_stock_add (items, G_N_ELEMENTS (items));
 +#endif
 +}
 +
 +static void
 +component_close_handler (gpointer data)
 +{
 +    GNCOptionWin *window = data;
 +    gtk_dialog_response(GTK_DIALOG(window->dialog), GTK_RESPONSE_CANCEL);
 +}
 +
 +static void
 +refresh_handler (GHashTable *changes, gpointer user_data)
 +{
 +    gnc_commodity *commodity = NULL;
 +    GtkTreeIter iter;
 +
 +    /* The default_gain_loss_account_widget needs to be refreshed if any
 +       changes have been made via account maintenance, if it exists and
 +       if the book currency widget has a selection */
 +/*    if (book_currency_data->default_gain_loss_account_widget &&
 +        gtk_combo_box_get_active_iter(
 +            GTK_COMBO_BOX(book_currency_data->book_currency_widget), &iter))
 +    {
 +        commodity = gnc_currency_edit_get_currency(
 +                                GNC_CURRENCY_EDIT(
 +                                    book_currency_data->book_currency_widget));
 +        gnc_set_default_gain_loss_account_widget(commodity);
 +        gtk_widget_show_all(book_currency_data->book_currency_vbox);
 +    } */
 +}
 +
 +/* gnc_options_dialog_new:
 + *
 + *   - Opens the dialog-options glade file
 + *   - Connects signals specified in the builder file
 + *   - Sets the window's title
 + *   - Initializes a new GtkNotebook, and adds it to the window
 + *
 + */
 +GNCOptionWin *
 +gnc_options_dialog_new(gchar *title)
 +{
 +    return gnc_options_dialog_new_modal(FALSE, title, NULL);
 +}
 +
 +/* gnc_options_dialog_new_modal:
 + *
 + *   - Opens the dialog-options glade file
 + *   - Connects signals specified in the builder file
 + *   - Sets the window's title
 + *   - Initializes a new GtkNotebook, and adds it to the window
 + *   - If modal TRUE, hides 'apply' button
 + *   - If component_class is provided, it is used, otherwise,
 + *     DIALOG_OPTIONS_CM_CLASS is used; this is used to distinguish the
 + *     book-option dialog from report dialogs. The book-option dialog is a
 + *     singleton, so if a dialog already exists it will be raised to the top of
 + *     the window stack instead of creating a new dialog.
 + */
 +GNCOptionWin *
 +gnc_options_dialog_new_modal(gboolean modal, gchar *title,
 +                                                    const char *component_class)
 +{
 +    GNCOptionWin *retval;
 +    GtkBuilder   *builder;
 +    GtkWidget    *hbox;
 +    gint component_id;
 +
 +    retval = g_new0(GNCOptionWin, 1);
 +    builder = gtk_builder_new();
 +    gnc_builder_add_from_file (builder, "dialog-options.glade", "gnucash_options_dialog");
 +    retval->dialog = GTK_WIDGET(gtk_builder_get_object (builder, "gnucash_options_dialog"));
 +    retval->page_list = GTK_WIDGET(gtk_builder_get_object (builder, "page_list_scroll"));
 +
 +    // Set the style context for this dialog so it can be easily manipulated with css
 +    gnc_widget_set_style_context (GTK_WIDGET(retval->dialog), "GncOptionsDialog");
 +
 +    /* Page List */
 +    {
 +        GtkTreeView *view;
 +        GtkListStore *store;
 +        GtkTreeSelection *selection;
 +        GtkCellRenderer *renderer;
 +        GtkTreeViewColumn *column;
 +
 +        retval->page_list_view = GTK_WIDGET(gtk_builder_get_object (builder, "page_list_treeview"));
 +
 +        view = GTK_TREE_VIEW(retval->page_list_view);
 +
 +        store = gtk_list_store_new(NUM_COLUMNS, G_TYPE_INT, G_TYPE_STRING);
 +        gtk_tree_view_set_model(view, GTK_TREE_MODEL(store));
 +        g_object_unref(store);
 +
 +        renderer = gtk_cell_renderer_text_new();
 +        column = gtk_tree_view_column_new_with_attributes(_("Page"), renderer,
 +                 "text", PAGE_NAME, NULL);
 +        gtk_tree_view_append_column(view, column);
 +
 +        gtk_tree_view_column_set_alignment(column, 0.5);
 +
 +        selection = gtk_tree_view_get_selection(view);
 +        gtk_tree_selection_set_mode(selection, GTK_SELECTION_BROWSE);
 +        g_signal_connect (selection, "changed",
 +                          G_CALLBACK (gnc_options_dialog_list_select_cb), retval);
 +
 +    }
 +
 +    gtk_builder_connect_signals_full (builder, gnc_builder_connect_full_func, retval);
 +
 +    if (title)
 +        gtk_window_set_title(GTK_WINDOW(retval->dialog), title);
 +
 +    /* modal */
 +    if (modal == TRUE)
 +    {
 +        GtkWidget *apply_button;
 +
 +        apply_button = GTK_WIDGET(gtk_builder_get_object (builder, "applybutton"));
 +        gtk_widget_hide (apply_button);
 +    }
 +
 +    /* glade doesn't support a notebook with zero pages */
 +    hbox = GTK_WIDGET(gtk_builder_get_object (builder, "notebook_placeholder"));
 +    retval->notebook = gtk_notebook_new();
 +
 +    gtk_widget_set_vexpand (retval->notebook, TRUE);
 +
 +    gtk_widget_show(retval->notebook);
 +    gtk_box_pack_start(GTK_BOX(hbox), retval->notebook, TRUE, TRUE, 5);
 +
 +    retval->component_class =
 +                (component_class ? component_class : DIALOG_OPTIONS_CM_CLASS);
 +    component_id = gnc_register_gui_component (retval->component_class,
 +                    refresh_handler, component_close_handler,
 +                    retval);
 +    gnc_gui_component_set_session (component_id, gnc_get_current_session());
 +
 +    /* Watch account maintenance events only if book option dialog */
 +    if (g_strcmp0(retval->component_class, DIALOG_BOOK_OPTIONS_CM_CLASS) == 0)
 +    {
 +        gnc_gui_component_watch_entity_type (component_id,
 +                                         GNC_ID_ACCOUNT,
 +                                         QOF_EVENT_MODIFY | QOF_EVENT_DESTROY);
 +    }
 +    g_object_unref(G_OBJECT(builder));
 +
 +    return retval;
 +}
 +
 +/* Creates a new GNCOptionWin structure, but assumes you have your own
 +   dialog widget you want to plugin */
 +GNCOptionWin *
 +gnc_options_dialog_new_w_dialog(gchar *title, GtkWidget *dialog)
 +{
 +    GNCOptionWin * retval;
 +
 +    retval = g_new0(GNCOptionWin, 1);
 +    retval->dialog = dialog;
 +    return retval;
 +}
 +
 +void
 +gnc_options_dialog_set_apply_cb(GNCOptionWin * win, GNCOptionWinCallback cb,
 +                                gpointer data)
 +{
 +    win->apply_cb = cb;
 +    win->apply_cb_data = data;
 +}
 +
 +void
 +gnc_options_dialog_set_help_cb(GNCOptionWin * win, GNCOptionWinCallback cb,
 +                               gpointer data)
 +{
 +    win->help_cb = cb;
 +    win->help_cb_data = data;
 +}
 +
 +void
 +gnc_options_dialog_set_close_cb(GNCOptionWin * win, GNCOptionWinCallback cb,
 +                                gpointer data)
 +{
 +    win->close_cb = cb;
 +    win->close_cb_data = data;
 +}
 +
 +void
 +gnc_options_dialog_set_global_help_cb(GNCOptionWinCallback thunk,
 +                                      gpointer cb_data)
 +{
 +    global_help_cb = thunk;
 +    global_help_cb_data = cb_data;
 +}
 +
 +/* This is for global program preferences. */
 +void
 +gnc_options_dialog_destroy(GNCOptionWin * win)
 +{
 +    if (!win) return;
 +
 +    gnc_unregister_gui_component_by_data(win->component_class, win);
 +
 +    gtk_widget_destroy(win->dialog);
 +
 +    win->dialog = NULL;
 +    win->notebook = NULL;
 +    win->apply_cb = NULL;
 +    win->help_cb = NULL;
 +    win->component_class = NULL;
 +
 +    g_free(win);
 +}
 +
 +/*****************************************************************/
 +/* Option Registration                                           */
 +
 +/*************************
 + *       SET WIDGET      *
 + *************************
 + *
 + * gnc_option_set_ui_widget_<type>():
 + *
 + * You should create the widget representation for the option type,
 + * and set the top-level container widget for your control in
 + * *enclosing.  If you want to pack the widget into the page yourself,
 + * then you may -- just set *packed to TRUE.  Otherwise, the widget
 + * you return in *enclosing will be packed for you.  (*packed is
 + * initialized to FALSE, so if you're not setting it to TRUE, you
 + * don't have to touch it at all.)
 + *
 + * If you need to initialize the state of your control or to connect
 + * any signals to you widgets, then you should do so in this function.
 + * If you want to create a label for the widget you should use 'name'
 + * for the label text.
 + *
 + * Somewhere in this function, you should also call
 + * gnc_option_set_widget(option, value); where 'value' is the
 + * GtkWidget you will actually store the value in.
 + *
 + * Also call gnc_option_set_ui_value(option, FALSE);
 + *
 + * You probably want to end with something like:
 + *   gtk_widget_show_all(*enclosing);
 + *
 + * If you can can detect state changes for your widget's value, you should also
 + * gnc_option_changed_widget_cb() upon changes.
 + *
 + * The widget you return from this function should be the widget in
 + * which you're storing the option value.
 + */
 +static GtkWidget *
 +gnc_option_set_ui_widget_boolean (GNCOption *option, GtkBox *page_box,
 +                                  char *name, char *documentation,
 +                                  /* Return values */
 +                                  GtkWidget **enclosing, gboolean *packed)
 +{
 +    GtkWidget *value;
 +
 +    *enclosing = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
 +    gtk_box_set_homogeneous (GTK_BOX (*enclosing), FALSE);
 +    value = gtk_check_button_new_with_label(name);
 +
 +    gnc_option_set_widget (option, value);
 +    gnc_option_set_ui_value(option, FALSE);
 +
 +    g_signal_connect(G_OBJECT(value), "toggled",
 +                     G_CALLBACK(gnc_option_changed_widget_cb), option);
 +
 +    gtk_box_pack_start(GTK_BOX(*enclosing), value, FALSE, FALSE, 0);
 +    gtk_widget_show_all(*enclosing);
 +
 +    return value;
 +}
 +
 +static GtkWidget *
 +gnc_option_set_ui_widget_string (GNCOption *option, GtkBox *page_box,
 +                                 char *name, char *documentation,
 +                                 /* Return values */
 +                                 GtkWidget **enclosing, gboolean *packed)
 +{
 +    GtkWidget *value;
 +    GtkWidget *label;
 +    gchar *colon_name;
 +
 +    colon_name = g_strconcat(name, ":", NULL);
 +    label = gtk_label_new(colon_name);
 +    gnc_label_set_alignment(label, 1.0, 0.5);
 +    g_free(colon_name);
 +
 +    *enclosing = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
 +    gtk_box_set_homogeneous (GTK_BOX (*enclosing), FALSE);
 +    value = gtk_entry_new();
 +
 +    gnc_option_set_widget (option, value);
 +    gnc_option_set_ui_value(option, FALSE);
 +
 +    g_signal_connect(G_OBJECT(value), "changed",
 +                     G_CALLBACK(gnc_option_changed_widget_cb), option);
 +
 +    gtk_box_pack_start(GTK_BOX(*enclosing), label, FALSE, FALSE, 0);
 +    gtk_box_pack_start(GTK_BOX(*enclosing), value, TRUE, TRUE, 0);
 +    gtk_widget_show_all(*enclosing);
 +    return value;
 +}
 +
 +static GtkWidget *
 +gnc_option_set_ui_widget_text (GNCOption *option, GtkBox *page_box,
 +                               char *name, char *documentation,
 +                               /* Return values */
 +                               GtkWidget **enclosing, gboolean *packed)
 +{
 +    GtkWidget *value;
 +    GtkWidget *frame;
 +    GtkWidget *scroll;
 +    GtkTextBuffer* text_buffer;
 +
 +    frame = gtk_frame_new(name);
 +
 +    scroll = gtk_scrolled_window_new(NULL, NULL);
 +    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll),
 +                                   GTK_POLICY_NEVER,
 +                                   GTK_POLICY_AUTOMATIC);
 +    gtk_container_set_border_width(GTK_CONTAINER(scroll), 2);
 +
 +    gtk_container_add(GTK_CONTAINER(frame), scroll);
 +
 +    *enclosing = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
 +    gtk_box_set_homogeneous (GTK_BOX (*enclosing), FALSE);
 +    value = gtk_text_view_new();
 +    gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(value), GTK_WRAP_WORD);
 +    gtk_text_view_set_editable(GTK_TEXT_VIEW(value), TRUE);
 +    gtk_container_add (GTK_CONTAINER (scroll), value);
 +
 +    gnc_option_set_widget (option, value);
 +    gnc_option_set_ui_value(option, FALSE);
 +
 +    text_buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(value));
 +    g_signal_connect(G_OBJECT(text_buffer), "changed",
 +                     G_CALLBACK(gnc_option_changed_option_cb), option);
 +
 +    gtk_box_pack_start(GTK_BOX(*enclosing), frame, TRUE, TRUE, 0);
 +    gtk_widget_show_all(*enclosing);
 +    return value;
 +}
 +
 +static GtkWidget *
 +gnc_option_set_ui_widget_currency (GNCOption *option, GtkBox *page_box,
 +                                   char *name, char *documentation,
 +                                   /* Return values */
 +                                   GtkWidget **enclosing, gboolean *packed)
 +{
 +    GtkWidget *value;
 +    GtkWidget *label;
 +    gchar *colon_name;
 +
 +    colon_name = g_strconcat(name, ":", NULL);
 +    label = gtk_label_new(colon_name);
 +    gnc_label_set_alignment(label, 1.0, 0.5);
 +    g_free(colon_name);
 +
 +    *enclosing = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
 +    gtk_box_set_homogeneous (GTK_BOX (*enclosing), FALSE);
 +    value = gnc_currency_edit_new();
 +
 +    gnc_option_set_widget (option, value);
 +    gnc_option_set_ui_value(option, FALSE);
 +
 +    g_signal_connect(G_OBJECT(value), "changed",
 +                     G_CALLBACK(gnc_option_changed_widget_cb), option);
 +
 +    gtk_box_pack_start(GTK_BOX(*enclosing), label, FALSE, FALSE, 0);
 +    gtk_box_pack_start(GTK_BOX(*enclosing), value, FALSE, FALSE, 0);
 +    gtk_widget_show_all(*enclosing);
 +    return value;
 +}
 +
 +static GtkWidget *
 +gnc_option_set_ui_widget_commodity (GNCOption *option, GtkBox *page_box,
 +                                    char *name, char *documentation,
 +                                    /* Return values */
 +                                    GtkWidget **enclosing, gboolean *packed)
 +{
 +    GtkWidget *value;
 +    GtkWidget *label;
 +    gchar *colon_name;
 +
 +    colon_name = g_strconcat(name, ":", NULL);
 +    label = gtk_label_new(colon_name);
 +    gnc_label_set_alignment(label, 1.0, 0.5);
 +    g_free(colon_name);
 +
 +    *enclosing = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
 +    gtk_box_set_homogeneous (GTK_BOX (*enclosing), FALSE);
 +    value = gnc_general_select_new(GNC_GENERAL_SELECT_TYPE_SELECT,
 +                                   gnc_commodity_edit_get_string,
 +                                   gnc_commodity_edit_new_select,
 +                                   NULL);
 +
 +    gnc_option_set_widget (option, value);
 +    gnc_option_set_ui_value(option, FALSE);
 +
 +    if (documentation != NULL)
 +        gtk_widget_set_tooltip_text(GNC_GENERAL_SELECT(value)->entry,
 +                                    documentation);
 +
 +    g_signal_connect(G_OBJECT(GNC_GENERAL_SELECT(value)->entry), "changed",
 +                     G_CALLBACK(gnc_option_changed_widget_cb), option);
 +
 +    gtk_box_pack_start(GTK_BOX(*enclosing), label, FALSE, FALSE, 0);
 +    gtk_box_pack_start(GTK_BOX(*enclosing), value, FALSE, FALSE, 0);
 +    gtk_widget_show_all(*enclosing);
 +    return value;
 +}
 +
 +static GtkWidget *
 +gnc_option_set_ui_widget_multichoice (GNCOption *option, GtkBox *page_box,
 +                                      char *name, char *documentation,
 +                                      /* Return values */
 +                                      GtkWidget **enclosing, gboolean *packed)
 +{
 +    GtkWidget *value;
 +    GtkWidget *label;
 +    gchar *colon_name;
 +
 +    colon_name = g_strconcat(name, ":", NULL);
 +    label = gtk_label_new(colon_name);
 +    gnc_label_set_alignment(label, 1.0, 0.5);
 +    g_free(colon_name);
 +
 +    *enclosing = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
 +    gtk_box_set_homogeneous (GTK_BOX (*enclosing), FALSE);
 +
 +    value = gnc_option_create_multichoice_widget(option);
 +    gnc_option_set_widget (option, value);
 +
 +    gnc_option_set_ui_value(option, FALSE);
 +    gtk_box_pack_start(GTK_BOX(*enclosing), label, FALSE, FALSE, 0);
 +    gtk_box_pack_start(GTK_BOX(*enclosing), value, FALSE, FALSE, 0);
 +    gtk_widget_show_all(*enclosing);
 +    return value;
 +}
 +
 +static GtkWidget *
 +gnc_option_set_ui_widget_date (GNCOption *option, GtkBox *page_box,
 +                               char *name, char *documentation,
 +                               /* Return values */
 +                               GtkWidget **enclosing, gboolean *packed)
 +{
 +    GtkWidget *value;
 +    GtkWidget *label;
 +    gchar *colon_name;
 +    GtkWidget *eventbox;
 +
 +    colon_name = g_strconcat(name, ":", NULL);
 +    label = gtk_label_new(colon_name);
 +    gnc_label_set_alignment(label, 1.0, 0.5);
 +    g_free(colon_name);
 +
 +    *enclosing = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
 +    gtk_box_set_homogeneous (GTK_BOX (*enclosing), FALSE);
 +
 +    value = gnc_option_create_date_widget(option);
 +
 +    gnc_option_set_widget (option, value);
 +
 +    gtk_box_pack_start(GTK_BOX(*enclosing), label, FALSE, FALSE, 0);
 +    gtk_box_pack_start(GTK_BOX(*enclosing), value, FALSE, FALSE, 0);
 +
 +    /* Pack option widget into an extra eventbox because otherwise the
 +       "documentation" tooltip is not displayed. */
 +    eventbox = gtk_event_box_new();
 +    gtk_container_add (GTK_CONTAINER (eventbox), *enclosing);
 +    gtk_box_pack_start(page_box, eventbox, FALSE, FALSE, 5);
 +    *packed = TRUE;
 +
 +    gtk_widget_set_tooltip_text (eventbox, documentation);
 +
 +    gnc_option_set_ui_value(option, FALSE);
 +    gtk_widget_show_all(*enclosing);
 +    return value;
 +}
 +
 +static GtkWidget *
 +gnc_option_set_ui_widget_account_list (GNCOption *option, GtkBox *page_box,
 +                                       char *name, char *documentation,
 +                                       /* Return values */
 +                                       GtkWidget **enclosing, gboolean *packed)
 +{
 +    GtkWidget *value;
 +    GtkTreeSelection *selection;
 +
 +    *enclosing = gnc_option_create_account_widget(option, name);
 +    value = gnc_option_get_gtk_widget (option);
 +
 +    gtk_widget_set_tooltip_text(*enclosing, documentation);
 +
 +    gtk_box_pack_start(page_box, *enclosing, TRUE, TRUE, 5);
 +    *packed = TRUE;
 +
 +    //gtk_widget_realize(value);
 +
 +    gnc_option_set_ui_value(option, FALSE);
 +
 +    selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(value));
 +    g_signal_connect(G_OBJECT(selection), "changed",
 +                     G_CALLBACK(gnc_option_account_cb), option);
 +
 +    //  gtk_clist_set_row_height(GTK_CLIST(value), 0);
 +    //  gtk_widget_set_size_request(value, -1, GTK_CLIST(value)->row_height * 10);
 +    gtk_widget_show_all(*enclosing);
 +    return value;
 +}
 +
 +static GtkWidget *
 +gnc_option_set_ui_widget_account_sel (GNCOption *option, GtkBox *page_box,
 +                                      char *name, char *documentation,
 +                                      /* Return values */
 +                                      GtkWidget **enclosing, gboolean *packed)
 +{
 +    GtkWidget *value;
 +    GtkWidget *label;
 +    GList *acct_type_list;
 +    gchar *colon_name;
 +
 +    colon_name = g_strconcat(name, ":", NULL);
 +    label = gtk_label_new(colon_name);
 +    gnc_label_set_alignment(label, 1.0, 0.5);
 +    g_free(colon_name);
 +
 +    acct_type_list = gnc_option_get_account_type_list(option);
 +    value = gnc_account_sel_new();
 +    gnc_account_sel_set_acct_filters(GNC_ACCOUNT_SEL(value), acct_type_list, NULL);
 +
 +    g_signal_connect(value, "account_sel_changed",
 +                     G_CALLBACK(gnc_option_changed_widget_cb), option);
 +
 +    gnc_option_set_widget (option, value);
 +    /* DOCUMENT ME: Why is the only option type that sets use_default to
 +       TRUE? */
 +    gnc_option_set_ui_value(option, TRUE);
 +
 +    *enclosing = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
 +    gtk_box_set_homogeneous (GTK_BOX (*enclosing), FALSE);
 +    gtk_box_pack_start(GTK_BOX(*enclosing), label, FALSE, FALSE, 0);
 +    gtk_box_pack_start(GTK_BOX(*enclosing), value, FALSE, FALSE, 0);
 +    gtk_widget_show_all(*enclosing);
 +    return value;
 +}
 +
 +static GtkWidget *
 +gnc_option_set_ui_widget_list (GNCOption *option, GtkBox *page_box,
 +                               char *name, char *documentation,
 +                               /* Return values */
 +                               GtkWidget **enclosing, gboolean *packed)
 +{
 +    GtkWidget *value;
 +    GtkWidget *eventbox;
 +
 +    *enclosing = gnc_option_create_list_widget(option, name);
 +    value = gnc_option_get_gtk_widget (option);
 +
 +    /* Pack option widget into an extra eventbox because otherwise the
 +       "documentation" tooltip is not displayed. */
 +    eventbox = gtk_event_box_new();
 +    gtk_container_add (GTK_CONTAINER (eventbox), *enclosing);
 +    gtk_box_pack_start(page_box, eventbox, FALSE, FALSE, 5);
 +    *packed = TRUE;
 +
 +    gtk_widget_set_tooltip_text(eventbox, documentation);
 +
 +    gnc_option_set_ui_value(option, FALSE);
 +    gtk_widget_show(*enclosing);
 +    return value;
 +}
 +
 +static GtkWidget *
 +gnc_option_set_ui_widget_number_range (GNCOption *option, GtkBox *page_box,
 +                                       char *name, char *documentation,
 +                                       /* Return values */
 +                                       GtkWidget **enclosing, gboolean *packed)
 +{
 +    GtkWidget *value;
 +    GtkWidget *label;
 +    gchar *colon_name;
 +    GtkAdjustment *adj;
 +    gdouble lower_bound = G_MINDOUBLE;
 +    gdouble upper_bound = G_MAXDOUBLE;
 +    gdouble step_size = 1.0;
 +    int num_decimals = 0;
 +
 +    colon_name = g_strconcat(name, ":", NULL);
 +    label = gtk_label_new(colon_name);
 +    gnc_label_set_alignment(label, 1.0, 0.5);
 +    g_free(colon_name);
 +
 +    *enclosing = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
 +    gtk_box_set_homogeneous (GTK_BOX (*enclosing), FALSE);
 +
 +    gnc_option_get_range_info(option, &lower_bound, &upper_bound,
 +                              &num_decimals, &step_size);
 +    adj = GTK_ADJUSTMENT(gtk_adjustment_new(lower_bound, lower_bound,
 +                                            upper_bound, step_size,
 +                                            step_size * 5.0,
 +                                            0));
 +    value = gtk_spin_button_new(adj, step_size, num_decimals);
 +    gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(value), TRUE);
 +
 +    {
 +        gdouble biggest;
 +        gint num_digits;
 +
 +        biggest = ABS(lower_bound);
 +        biggest = MAX(biggest, ABS(upper_bound));
 +
 +        num_digits = 0;
 +        while (biggest >= 1)
 +        {
 +            num_digits++;
 +            biggest = biggest / 10;
 +        }
 +
 +        if (num_digits == 0)
 +            num_digits = 1;
 +
 +        num_digits += num_decimals;
 +
 +        gtk_entry_set_width_chars(GTK_ENTRY(value), num_digits);
 +    }
 +
 +    gnc_option_set_widget (option, value);
 +    gnc_option_set_ui_value(option, FALSE);
 +
 +    g_signal_connect(G_OBJECT(value), "changed",
 +                     G_CALLBACK(gnc_option_changed_widget_cb), option);
 +
 +    gtk_box_pack_start(GTK_BOX(*enclosing), label, FALSE, FALSE, 0);
 +    gtk_box_pack_start(GTK_BOX(*enclosing), value, FALSE, FALSE, 0);
 +    gtk_widget_show_all(*enclosing);
 +    return value;
 +}
 +
 +static GtkWidget *
 +gnc_option_set_ui_widget_color (GNCOption *option, GtkBox *page_box,
 +                                char *name, char *documentation,
 +                                /* Return values */
 +                                GtkWidget **enclosing, gboolean *packed)
 +{
 +    GtkWidget *value;
 +    GtkWidget *label;
 +    gchar *colon_name;
 +    gboolean use_alpha;
 +
 +    colon_name = g_strconcat(name, ":", NULL);
 +    label = gtk_label_new(colon_name);
 +    gnc_label_set_alignment(label, 1.0, 0.5);
 +    g_free(colon_name);
 +
 +    *enclosing = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
 +    gtk_box_set_homogeneous (GTK_BOX (*enclosing), FALSE);
 +
 +    use_alpha = gnc_option_use_alpha(option);
 +
 +    value = gtk_color_button_new();
 +    gtk_color_button_set_title(GTK_COLOR_BUTTON(value), name);
 +    gtk_color_chooser_set_use_alpha(GTK_COLOR_CHOOSER(value), use_alpha);
 +
 +    gnc_option_set_widget (option, value);
 +    gnc_option_set_ui_value(option, FALSE);
 +
 +    g_signal_connect(G_OBJECT(value), "color-set",
 +                     G_CALLBACK(gnc_option_color_changed_cb), option);
 +
 +    gtk_box_pack_start(GTK_BOX(*enclosing), label, FALSE, FALSE, 0);
 +    gtk_box_pack_start(GTK_BOX(*enclosing), value, FALSE, FALSE, 0);
 +    gtk_widget_show_all(*enclosing);
 +    return value;
 +}
 +
 +static GtkWidget *
 +gnc_option_set_ui_widget_font (GNCOption *option, GtkBox *page_box,
 +                               char *name, char *documentation,
 +                               /* Return values */
 +                               GtkWidget **enclosing, gboolean *packed)
 +{
 +    GtkWidget *value;
 +    GtkWidget *label;
 +    gchar *colon_name;
 +
 +    colon_name = g_strconcat(name, ":", NULL);
 +    label = gtk_label_new(colon_name);
 +    gnc_label_set_alignment(label, 1.0, 0.5);
 +    g_free(colon_name);
 +
 +    *enclosing = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
 +    gtk_box_set_homogeneous (GTK_BOX (*enclosing), FALSE);
 +    value = gtk_font_button_new();
 +    g_object_set(G_OBJECT(value),
 +                 "use-font", TRUE,
 +                 "show-style", TRUE,
 +                 "show-size", TRUE,
 +                 (char *)NULL);
 +
 +    gnc_option_set_widget (option, value);
 +
 +    gnc_option_set_ui_value(option, FALSE);
 +
 +    g_signal_connect(G_OBJECT(value), "font-set",
 +                     G_CALLBACK(gnc_option_font_changed_cb), option);
 +
 +    gtk_box_pack_start(GTK_BOX(*enclosing), label, FALSE, FALSE, 0);
 +    gtk_box_pack_start(GTK_BOX(*enclosing), value, FALSE, FALSE, 0);
 +    gtk_widget_show_all(*enclosing);
 +    return value;
 +}
 +
 +static GtkWidget *
 +gnc_option_set_ui_widget_pixmap (GNCOption *option, GtkBox *page_box,
 +                                 char *name, char *documentation,
 +                                 /* Return values */
 +                                 GtkWidget **enclosing, gboolean *packed)
 +{
 +    GtkWidget *value;
 +    GtkWidget *label;
 +    GtkWidget *button;
 +    gchar *colon_name;
 +
 +    ENTER("option %p(%s), name %s", option, gnc_option_name(option), name);
 +    colon_name = g_strconcat(name, ":", NULL);
 +    label = gtk_label_new(colon_name);
 +    gnc_label_set_alignment(label, 1.0, 0.5);
 +    g_free(colon_name);
 +
 +    *enclosing = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
 +    gtk_box_set_homogeneous (GTK_BOX (*enclosing), FALSE);
 +
 +    button = gtk_button_new_with_label(_("Clear"));
 +    gtk_widget_set_tooltip_text(button, _("Clear any selected image file."));
 +
 +    value = gtk_file_chooser_button_new(_("Select image"),
 +                                        GTK_FILE_CHOOSER_ACTION_OPEN);
 +    gtk_widget_set_tooltip_text(value, _("Select an image file."));
 +    g_object_set(G_OBJECT(value),
 +                 "width-chars", 30,
 +                 "preview-widget", gtk_image_new(),
 +                 (char *)NULL);
 +    g_signal_connect(G_OBJECT (value), "selection-changed",
 +                     G_CALLBACK(gnc_option_changed_widget_cb), option);
 +    g_signal_connect(G_OBJECT (value), "selection-changed",
 +                     G_CALLBACK(gnc_image_option_selection_changed_cb), option);
 +    g_signal_connect(G_OBJECT (value), "update-preview",
 +                     G_CALLBACK(gnc_image_option_update_preview_cb), option);
 +    g_signal_connect_swapped(G_OBJECT (button), "clicked",
 +                             G_CALLBACK(gtk_file_chooser_unselect_all), value);
 +
 +    gnc_option_set_widget (option, value);
 +    gnc_option_set_ui_value(option, FALSE);
 +
 +    gtk_box_pack_start(GTK_BOX(*enclosing), label, FALSE, FALSE, 0);
 +    gtk_box_pack_end(GTK_BOX(*enclosing), button, FALSE, FALSE, 0);
 +    gtk_box_pack_end(GTK_BOX(*enclosing), value, FALSE, FALSE, 0);
 +
 +    gtk_widget_show(value);
 +    gtk_widget_show(label);
 +    gtk_widget_show(*enclosing);
 +    LEAVE("new widget = %p", value);
 +    return value;
 +}
 +
 +static GtkWidget *
 +gnc_option_set_ui_widget_radiobutton (GNCOption *option, GtkBox *page_box,
 +                                      char *name, char *documentation,
 +                                      /* Return values */
 +                                      GtkWidget **enclosing, gboolean *packed)
 +{
 +    GtkWidget *value;
 +
 +    *enclosing = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
 +    gtk_box_set_homogeneous (GTK_BOX (*enclosing), FALSE);
 +
 +    value = gnc_option_create_radiobutton_widget(name, option);
 +    gnc_option_set_widget (option, value);
 +
 +    gnc_option_set_ui_value(option, FALSE);
 +    gtk_box_pack_start(GTK_BOX(*enclosing), value, FALSE, FALSE, 0);
 +    gtk_widget_show_all(*enclosing);
 +    return value;
 +}
 +
 +static GtkWidget *
 +gnc_option_set_ui_widget_dateformat (GNCOption *option, GtkBox *page_box,
 +                                     char *name, char *documentation,
 +                                     /* Return values */
 +                                     GtkWidget **enclosing, gboolean *packed)
 +{
 +    *enclosing = gnc_date_format_new_with_label(name);
 +    gnc_option_set_widget (option, *enclosing);
 +
 +    gnc_option_set_ui_value(option, FALSE);
 +    g_signal_connect(G_OBJECT(*enclosing), "format_changed",
 +                     G_CALLBACK(gnc_option_changed_option_cb), option);
 +    gtk_widget_show_all(*enclosing);
 +    return *enclosing;
 +}
 +
 +static void
 +gnc_plot_size_option_set_select_method(GNCOption *option, gboolean set_buttons)
 +{
 +    GList* widget_list;
 +    GtkWidget *px_widget, *p_widget;
 +    GtkWidget *widget;
 +
 +    widget = gnc_option_get_gtk_widget (option);
 +
 +    widget_list = gtk_container_get_children(GTK_CONTAINER(widget));
 +    // px_button item 0
 +    px_widget = g_list_nth_data(widget_list, 1);
 +    // p_button item 2
 +    p_widget = g_list_nth_data(widget_list, 3);
 +    g_list_free(widget_list);
 +
 +    if (set_buttons)
 +    {
 +        gtk_widget_set_sensitive(px_widget, TRUE);
 +        gtk_widget_set_sensitive(p_widget, FALSE);
 +    }
 +    else
 +    {
 +        gtk_widget_set_sensitive(p_widget, TRUE);
 +        gtk_widget_set_sensitive(px_widget, FALSE);
 +    }
 +}
 +
 +static void
 +gnc_rd_option_px_set_cb(GtkWidget *widget, gpointer *raw_option)
 +{
 +    GNCOption *option = (GNCOption *) raw_option;
 +    gnc_plot_size_option_set_select_method(option, TRUE);
 +    gnc_option_changed_option_cb(widget, option);
 +}
 +
 +static void
 +gnc_rd_option_p_set_cb(GtkWidget *widget, gpointer *raw_option)
 +{
 +    GNCOption *option = (GNCOption *) raw_option;
 +    gnc_plot_size_option_set_select_method(option, FALSE);
 +    gnc_option_changed_option_cb(widget, option);
 +    return;
 +}
 +
 +
 +static GtkWidget *
 +gnc_option_set_ui_widget_plot_size (GNCOption *option, GtkBox *page_box,
 +                                     char *name, char *documentation,
 +                                     /* Return values */
 +                                     GtkWidget **enclosing, gboolean *packed)
 +{
 +    GtkWidget *value_px, *value_percent;
 +    GtkWidget *label;
 +    GtkWidget *px_butt, *p_butt;
 +    GtkWidget *hbox;
 +    gchar *colon_name;
 +    GtkAdjustment *adj_px, *adj_percent;
 +    gdouble lower_bound = G_MINDOUBLE;
 +    gdouble upper_bound = G_MAXDOUBLE;
 +    gdouble step_size = 1.0;
 +    int num_decimals = 0;
 +
 +    colon_name = g_strconcat(name, ":", NULL);
 +    label = gtk_label_new(colon_name);
 +    gnc_label_set_alignment(label, 1.0, 0.5);
 +    g_free(colon_name);
 +
 +    hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
 +    gtk_box_set_homogeneous (GTK_BOX (hbox), FALSE);
 +
 +    *enclosing = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
 +    gtk_box_set_homogeneous (GTK_BOX (*enclosing), FALSE);
 +
 +    gtk_box_pack_start(GTK_BOX(*enclosing), label, FALSE, FALSE, 0);
 +    gtk_box_pack_start(GTK_BOX(*enclosing), hbox, FALSE, FALSE, 0);
 +
 +    gnc_option_get_range_info(option, &lower_bound, &upper_bound,
 +                              &num_decimals, &step_size);
 +    adj_px = GTK_ADJUSTMENT(gtk_adjustment_new(lower_bound, lower_bound,
 +                                            upper_bound, step_size,
 +                                            step_size * 5.0,
 +                                            0));
 +
 +    value_px = gtk_spin_button_new(adj_px, step_size, num_decimals);
 +    gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(value_px), TRUE);
 +
 +    {
 +        gdouble biggest;
 +        gint num_digits;
 +
 +        biggest = ABS(lower_bound);
 +        biggest = MAX(biggest, ABS(upper_bound));
 +
 +        num_digits = 0;
 +        while (biggest >= 1)
 +        {
 +            num_digits++;
 +            biggest = biggest / 10;
 +        }
 +
 +        if (num_digits == 0)
 +            num_digits = 1;
 +
 +        num_digits += num_decimals;
 +
 +        gtk_entry_set_width_chars(GTK_ENTRY(value_px), num_digits);
 +    }
 +    gtk_spin_button_set_value(GTK_SPIN_BUTTON(value_px), (upper_bound / 2)); //default
 +    g_signal_connect(G_OBJECT(value_px), "changed",
 +                     G_CALLBACK(gnc_option_changed_widget_cb), option);
 +
 +    adj_percent = GTK_ADJUSTMENT(gtk_adjustment_new(1, 10, 100, 1, 5.0, 0));
 +    value_percent = gtk_spin_button_new(adj_percent, 1, 0);
 +    gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(value_percent), TRUE);
 +    gtk_spin_button_set_value(GTK_SPIN_BUTTON(value_percent), 100); //default
 +    gtk_entry_set_width_chars(GTK_ENTRY(value_percent), 3);
 +    gtk_widget_set_sensitive(value_percent, FALSE);
 +
 +    g_signal_connect(G_OBJECT(value_percent), "changed",
 +                     G_CALLBACK(gnc_option_changed_widget_cb), option);
 +
 +    px_butt = gtk_radio_button_new_with_label(NULL, _("Pixels"));
 +    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(px_butt), TRUE);
 +
 +    g_signal_connect(G_OBJECT(px_butt), "toggled",
 +                         G_CALLBACK(gnc_rd_option_px_set_cb), option);
 +
 +    p_butt = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(px_butt), _("Percent"));
 +    g_signal_connect(G_OBJECT(p_butt), "toggled",
 +                         G_CALLBACK(gnc_rd_option_p_set_cb), option);
 +
 +    gtk_box_pack_start(GTK_BOX(hbox), px_butt, FALSE, FALSE, 0);
 +    gtk_box_pack_start(GTK_BOX(hbox), value_px, FALSE, FALSE, 0);
 +    gtk_box_pack_start(GTK_BOX(hbox), p_butt, FALSE, FALSE, 0);
 +    gtk_box_pack_start(GTK_BOX(hbox), value_percent, FALSE, FALSE, 0);
 +
 +    gnc_option_set_widget (option, hbox);
 +    gnc_option_set_ui_value (option, FALSE);
 +
 +    gtk_widget_show_all(*enclosing);
 +    return hbox;
 +}
 +
 +static GtkWidget *
 +gnc_option_set_ui_widget_budget (GNCOption *option, GtkBox *page_box,
 +                                 char *name, char *documentation,
 +                                 /* Return values */
 +                                 GtkWidget **enclosing, gboolean *packed)
 +{
 +    GtkWidget *value;
 +    GtkWidget *label;
 +    gchar *colon_name;
 +
 +    colon_name = g_strconcat(name, ":", NULL);
 +    label = gtk_label_new(colon_name);
 +    gnc_label_set_alignment(label, 1.0, 0.5);
 +    g_free(colon_name);
 +
 +    *enclosing = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
 +    gtk_box_set_homogeneous (GTK_BOX (*enclosing), FALSE);
 +
 +    value = gnc_option_create_budget_widget(option);
 +
 +    gnc_option_set_widget (option, value);
 +    gnc_option_set_ui_value(option, FALSE);
 +
 +    /* Maybe connect destroy handler for tree model here? */
 +    g_signal_connect(G_OBJECT(value), "changed",
 +                     G_CALLBACK(gnc_option_changed_widget_cb), option);
 +
 +    gtk_box_pack_start(GTK_BOX(*enclosing), label, FALSE, FALSE, 0);
 +    gtk_box_pack_start(GTK_BOX(*enclosing), value, FALSE, FALSE, 0);
 +    gtk_widget_show_all(*enclosing);
 +    return value;
 +}
 +
 +static GtkWidget *
 +gnc_option_set_ui_widget_currency_accounting (GNCOption *option,
 +                                              GtkBox *page_box,
 +                                              char *name, char *documentation,
 +                                              /* Return values */
 +                                              GtkWidget **enclosing,
 +                                              gboolean *packed)
 +{
 +    GtkWidget *value;
 +
 +    *enclosing = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
 +    gtk_box_set_homogeneous (GTK_BOX (*enclosing), FALSE);
 +
 +    value = gnc_option_create_currency_accounting_widget(name, option);
 +    gnc_option_set_widget (option, value);
 +
 +    gnc_option_set_ui_value(option, FALSE);
 +    gtk_box_pack_start(GTK_BOX(*enclosing), value, TRUE, TRUE, 0);
 +    gtk_widget_show_all(*enclosing);
 +    return value;
 +}
 +
 +/*************************
 + *       SET VALUE       *
 + *************************
 + *
 + * gnc_option_set_ui_value_<type>():
 + *
 + *   In this function you should set the state of the gui widget to
 + * correspond to the value provided in 'value'.  You should return
 + * TRUE if there was an error, FALSE otherwise.
 + *
 + *
 + */
 +static gboolean
 +gnc_option_set_ui_value_boolean (GNCOption *option, gboolean use_default,
 +                                 GtkWidget *widget, SCM value)
 +{
 +    if (scm_is_bool(value))
 +    {
 +        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget),
 +                                     scm_is_true(value));
 +        return FALSE;
 +    }
 +    else
 +        return TRUE;
 +}
 +
 +static gboolean
 +gnc_option_set_ui_value_string (GNCOption *option, gboolean use_default,
 +                                GtkWidget *widget, SCM value)
 +{
 +    if (scm_is_string(value))
 +    {
 +        const gchar *string;
 +
 +        string = gnc_scm_to_utf8_string (value);
 +        gtk_entry_set_text(GTK_ENTRY(widget), string);
 +        g_free ((gpointer *) string);
 +        return FALSE;
 +    }
 +    else
 +        return TRUE;
 +}
 +
 +static gboolean
 +gnc_option_set_ui_value_text (GNCOption *option, gboolean use_default,
 +                              GObject *object, SCM value)
 +{
 +    GtkTextBuffer *buffer;
 +
 +    if (GTK_IS_TEXT_BUFFER(object))
 +        buffer = GTK_TEXT_BUFFER(object);
 +    else
 +        buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(object));
 +
 +    if (scm_is_string(value))
 +    {
 +        const gchar *string;
 +
 +        string = gnc_scm_to_utf8_string (value);
 +        gtk_text_buffer_set_text (buffer, string, scm_c_string_length(value));
 +        g_free ((gpointer *) string);
 +        return FALSE;
 +    }
 +    else
 +        return TRUE;
 +}
 +
 +static gboolean
 +gnc_option_set_ui_value_currency (GNCOption *option, gboolean use_default,
 +                                  GtkWidget *widget, SCM value)
 +{
 +    gnc_commodity *commodity;
 +
 +    commodity = gnc_scm_to_commodity (value);
 +    if (commodity)
 +    {
 +        gnc_currency_edit_set_currency(GNC_CURRENCY_EDIT(widget), commodity);
 +        return FALSE;
 +    }
 +    else
 +        return TRUE;
 +}
 +
 +static gboolean
 +gnc_option_set_ui_value_commodity (GNCOption *option, gboolean use_default,
 +                                   GtkWidget *widget, SCM value)
 +{
 +    gnc_commodity *commodity;
 +
 +    commodity = gnc_scm_to_commodity (value);
 +    if (commodity)
 +    {
 +        gnc_general_select_set_selected(GNC_GENERAL_SELECT (widget), commodity);
 +        return FALSE;
 +    }
 +    else
 +        return TRUE;
 +}
 +
 +static gboolean
 +gnc_option_set_ui_value_multichoice (GNCOption *option, gboolean use_default,
 +                                     GtkWidget *widget, SCM value)
 +{
 +    int index;
 +
 +    index = gnc_option_permissible_value_index(option, value);
 +    if (index < 0)
 +        return TRUE;
 +    else
 +    {
 +        /* GtkComboBox per-item tooltip changes needed below */
 +        gnc_combott_set_active(GNC_COMBOTT(widget), index);
 +        return FALSE;
 +    }
 +}
 +
 +static gboolean
 +gnc_option_set_ui_value_date (GNCOption *option, gboolean use_default,
 +                              GtkWidget *widget, SCM value)
 +{
 +    int index;
 +    char *date_option_type;
 +    char *symbol_str;
 +    gboolean bad_value = FALSE;
 +
 +    date_option_type = gnc_option_date_option_get_subtype(option);
 +
 +    if (scm_is_pair(value))
 +    {
 +        symbol_str = gnc_date_option_value_get_type (value);
 +        if (symbol_str)
 +        {
 +            if (g_strcmp0(symbol_str, "relative") == 0)
 +            {
 +                SCM relative = gnc_date_option_value_get_relative (value);
 +
 +                index = gnc_option_permissible_value_index(option, relative);
 +                if (g_strcmp0(date_option_type, "relative") == 0)
 +                {
 +                    /* GtkComboBox per-item tooltip changes needed below */
 +                    gnc_combott_set_active(GNC_COMBOTT(widget), index);
 +                }
 +                else if (g_strcmp0(date_option_type, "both") == 0)
 +                {
 +                    GList *widget_list;
 +                    GtkWidget *rel_date_widget;
 +
 +                    widget_list = gtk_container_get_children(GTK_CONTAINER(widget));
 +                    rel_date_widget = g_list_nth_data(widget_list,
 +                                                      GNC_RD_WID_REL_WIDGET_POS);
 +                    g_list_free(widget_list);
 +                    gnc_date_option_set_select_method(option, FALSE, TRUE);
 +                    /* GtkComboBox per-item tooltip changes needed below */
 +                    gnc_combott_set_active(GNC_COMBOTT(rel_date_widget), index);
 +                }
 +                else
 +                {
 +                    bad_value = TRUE;
 +                }
 +            }
 +            else if (g_strcmp0(symbol_str, "absolute") == 0)
 +            {
 +                Timespec ts;
 +
 +                ts = gnc_date_option_value_get_absolute (value);
 +
 +                if (g_strcmp0(date_option_type, "absolute") == 0)
 +                {
 +                    gnc_date_edit_set_time(GNC_DATE_EDIT(widget), ts.tv_sec);
 +                }
 +                else if (g_strcmp0(date_option_type, "both") == 0)
 +                {
 +                    GList *widget_list;
 +                    GtkWidget *ab_widget;
 +
 +                    widget_list = gtk_container_get_children(GTK_CONTAINER(widget));
 +                    ab_widget = g_list_nth_data(widget_list,
 +                                                GNC_RD_WID_AB_WIDGET_POS);
 +                    g_list_free(widget_list);
 +                    gnc_date_option_set_select_method(option, TRUE, TRUE);
 +                    gnc_date_edit_set_time(GNC_DATE_EDIT(ab_widget), ts.tv_sec);
 +                }
 +                else
 +                {
 +                    bad_value = TRUE;
 +                }
 +            }
 +            else
 +            {
 +                bad_value = TRUE;
 +            }
 +
 +            if (symbol_str)
 +                free(symbol_str);
 +        }
 +    }
 +    else
 +    {
 +        bad_value = TRUE;
 +    }
 +
 +    if (date_option_type)
 +        free(date_option_type);
 +
 +    return bad_value;
 +}
 +
 +static gboolean
 +gnc_option_set_ui_value_account_list (GNCOption *option, gboolean use_default,
 +                                      GtkWidget *widget, SCM value)
 +{
 +    GList *list;
 +
 +    list = gnc_scm_list_to_glist(value);
 +
 +    gnc_tree_view_account_set_selected_accounts (GNC_TREE_VIEW_ACCOUNT(widget),
 +            list, TRUE);
 +
 +    g_list_free(list);
 +    return FALSE;
 +}
 +
 +static gboolean
 +gnc_option_set_ui_value_account_sel (GNCOption *option, gboolean use_default,
 +                                     GtkWidget *widget, SCM value)
 +{
 +    Account *acc = NULL;
 +
 +    if (value != SCM_BOOL_F)
 +    {
 +        if (!SWIG_IsPointer(value))
 +            scm_misc_error("gnc_option_set_ui_value_account_sel",
 +                           "Option Value not a wcp.", value);
 +
 +        acc = SWIG_MustGetPtr(value, SWIG_TypeQuery("_p_Account"), 4, 0);
 +    }
 +
 +    //doesn't default because this function is called to set a specific account
 +    gnc_account_sel_set_account (GNC_ACCOUNT_SEL(widget), acc, FALSE);
 +
 +    return FALSE;
 +}
 +
 +static gboolean
 +gnc_option_set_ui_value_list (GNCOption *option, gboolean use_default,
 +                              GtkWidget *widget, SCM value)
 +{
 +    GtkTreeSelection *selection;
 +    GtkTreePath *path;
 +    gint row;
 +
 +    selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(widget));
 +    gtk_tree_selection_unselect_all(selection);
 +
 +    while (scm_is_list(value) && !scm_is_null(value))
 +    {
 +        SCM item;
 +
 +        item = SCM_CAR(value);
 +        value = SCM_CDR(value);
 +
 +        row = gnc_option_permissible_value_index(option, item);
 +        if (row < 0)
 +        {
 +            return TRUE;
 +        }
 +
 +        path = gtk_tree_path_new_from_indices(row, -1);
 +        gtk_tree_selection_select_path(selection, path);
 +        gtk_tree_path_free(path);
 +    }
 +
 +    if (!scm_is_list(value) || !scm_is_null(value))
 +        return TRUE;
 +
 +    return FALSE;
 +}
 +
 +static gboolean
 +gnc_option_set_ui_value_number_range (GNCOption *option, gboolean use_default,
 +                                      GtkWidget *widget, SCM value)
 +{
 +    GtkSpinButton *spinner;
 +    gdouble d_value;;
 +
 +    spinner = GTK_SPIN_BUTTON(widget);
 +
 +    if (scm_is_number(value))
 +    {
 +        d_value = scm_to_double(value);
 +        gtk_spin_button_set_value(spinner, d_value);
 +        return FALSE;
 +    }
 +    else
 +        return TRUE;
 +}
 +
 +static gboolean
 +gnc_option_set_ui_value_color (GNCOption *option, gboolean use_default,
 +                               GtkWidget *widget, SCM value)
 +{
 +
 +    GdkRGBA color;
 +    if (gnc_option_get_color_info(option, use_default,
 +                                  &color.red, &color.green,
 +                                  &color.blue, &color.alpha))
 +    {
 +        GtkColorChooser *color_button;
 +
 +        DEBUG("red %f, green %f, blue %f, alpha %f",
 +              color.red, color.green, color.blue, color.alpha);
 +        color_button = GTK_COLOR_CHOOSER(widget);
 +
 +        gtk_color_chooser_set_rgba(color_button, &color);
 +        return FALSE;
 +    }
 +
 +    LEAVE("TRUE");
 +    return TRUE;
 +}
 +
 +static gboolean
 +gnc_option_set_ui_value_font (GNCOption *option, gboolean use_default,
 +                              GtkWidget *widget, SCM value)
 +{
 +    if (scm_is_string(value))
 +    {
 +        const gchar *string;
 +
 +        string = gnc_scm_to_utf8_string (value);
 +        if ((string != NULL) && (*string != '\0'))
 +        {
 +            GtkFontButton *font_button = GTK_FONT_BUTTON(widget);
 +            gtk_font_button_set_font_name(font_button, string);
 +        }
 +        g_free ((gpointer *) string);
 +        return FALSE;
 +    }
 +    else
 +        return TRUE;
 +}
 +
 +static gboolean
 +gnc_option_set_ui_value_pixmap (GNCOption *option, gboolean use_default,
 +                                GtkWidget *widget, SCM value)
 +{
 +    ENTER("option %p(%s)", option, gnc_option_name(option));
 +    if (scm_is_string(value))
 +    {
 +        const gchar *string;
 +
 +        string = gnc_scm_to_locale_string (value);
 +        if (string && *string)
 +        {
 +            gchar *test;
 +            DEBUG("string = %s", string);
 +            gtk_file_chooser_select_filename(GTK_FILE_CHOOSER(widget), string);
 +            test = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(widget));
 +            g_object_set_data_full(G_OBJECT(widget), LAST_SELECTION,
 +                                   g_strdup(string), g_free);
 +            DEBUG("Set %s, retrieved %s", string, test ? test : "(null)");
 +            gnc_image_option_update_preview_cb(GTK_FILE_CHOOSER(widget), option);
 +        }
 +        LEAVE("FALSE");
 +        g_free ((gpointer *) string);
 +        return FALSE;
 +    }
 +
 +    LEAVE("TRUE");
 +    return TRUE;
 +}
 +
 +static gboolean gnc_option_set_ui_value_budget(
 +    GNCOption *option, gboolean use_default, GtkWidget *widget, SCM value)
 +{
 +    GncBudget *bgt;
 +
 +//    if (!scm_is_null(value)) {
 +    if (value != SCM_BOOL_F)
 +    {
 +        if (!SWIG_IsPointer(value))
 +            scm_misc_error("gnc_option_set_ui_value_budget",
 +                           "Option Value not a wcp.", value);
 +
 +        bgt = SWIG_MustGetPtr(value, SWIG_TypeQuery("GncBudget *"), 4, 0);
 +        if (bgt)
 +        {
 +            GtkComboBox *cb = GTK_COMBO_BOX(widget);
 +            GtkTreeModel *tm = gtk_combo_box_get_model(cb);
 +            GtkTreeIter iter;
 +            if (gnc_tree_model_budget_get_iter_for_budget(tm, &iter, bgt))
 +                gtk_combo_box_set_active_iter(cb, &iter);
 +        }
 +    }
 +
 +
 +    //FIXME: Unimplemented.
 +    return FALSE;
 +}
 +
 +static gboolean
 +gnc_option_set_ui_value_radiobutton (GNCOption *option, gboolean use_default,
 +                                     GtkWidget *widget, SCM value)
 +{
 +    int index;
 +
 +    index = gnc_option_permissible_value_index(option, value);
 +    if (index < 0)
 +        return TRUE;
 +    else
 +    {
 +        GtkWidget *box, *button;
 +        GList *list;
 +        int i;
 +        gpointer val;
 +
 +        list = gtk_container_get_children (GTK_CONTAINER (widget));
 +        box = list->data;
 +        g_list_free(list);
 +
 +        list = gtk_container_get_children (GTK_CONTAINER (box));
 +        for (i = 0; i < index && list; i++)
 +            list = list->next;
 +        g_return_val_if_fail (list, TRUE);
 +
 +        button = list->data;
 +        g_list_free(list);
 +        val = g_object_get_data (G_OBJECT (button), "gnc_radiobutton_index");
 +        g_return_val_if_fail (GPOINTER_TO_INT (val) == index, TRUE);
 +
 +        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
 +        //    g_object_set_data(G_OBJECT(widget), "gnc_radiobutton_index",
 +        //			GINT_TO_POINTER(index));
 +        return FALSE;
 +    }
 +}
 +
 +static gboolean
 +gnc_option_set_ui_value_dateformat (GNCOption *option, gboolean use_default,
 +                                    GtkWidget *widget, SCM value)
 +{
 +    GNCDateFormat * gdf = GNC_DATE_FORMAT(widget);
 +    QofDateFormat format;
 +    GNCDateMonthFormat months;
 +    gboolean years;
 +    char *custom;
 +
 +    if (gnc_dateformat_option_value_parse(value, &format, &months, &years, &custom))
 +        return TRUE;
 +
 +    gnc_date_format_set_format(gdf, format);
 +    gnc_date_format_set_months(gdf, months);
 +    gnc_date_format_set_years(gdf, years);
 +    gnc_date_format_set_custom(gdf, custom);
 +    gnc_date_format_refresh(gdf);
 +
 +    if (custom)
 +        free(custom);
 +
 +    return FALSE;
 +}
 +
 +static gboolean
 +gnc_option_set_ui_value_plot_size (GNCOption *option, gboolean use_default,
 +                                    GtkWidget *widget, SCM value)
 +{
 +    GList* widget_list;
 +    GtkWidget *px_button, *p_button, *px_widget, *p_widget;
 +    char *symbol_str;
 +    gdouble d_value;
 +
 +    widget_list = gtk_container_get_children(GTK_CONTAINER(widget));
 +    px_button = g_list_nth_data(widget_list, 0);
 +    px_widget = g_list_nth_data(widget_list, 1);
 +    p_button = g_list_nth_data(widget_list, 2);
 +    p_widget = g_list_nth_data(widget_list, 3);
 +    g_list_free(widget_list);
 +
 +    if (scm_is_pair(value))
 +    {
 +        symbol_str = gnc_plot_size_option_value_get_type(value);
 +        d_value = gnc_plot_size_option_value_get_value(value);
 +
 +        if (symbol_str)
 +        {
 +            if (g_strcmp0(symbol_str, "pixels") == 0) // pixel values
 +            {
 +                gtk_spin_button_set_value(GTK_SPIN_BUTTON(px_widget), d_value);
 +                gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(px_button), TRUE);
 +            }
 +            else // percent values
 +            {
 +                gtk_spin_button_set_value(GTK_SPIN_BUTTON(p_widget), (d_value));
 +                gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(p_button), TRUE);
 +            }
 +            return FALSE;
 +        }
 +    }
 +    return TRUE;
 +}
 +
 +static gboolean
 +gnc_option_set_ui_value_currency_accounting (GNCOption *option,
 +                                             gboolean use_default,
 +                                             GtkWidget *widget, SCM value)
 +{
 +    if (scm_is_pair(value))
 +    {
 +        SCM rb_symbol;
 +
 +        rb_symbol = gnc_currency_accounting_option_value_get_method (value);
 +
 +        if (rb_symbol)
 +        {
 +            int index;
 +
 +            index = gnc_option_permissible_value_index(option, rb_symbol);
 +            if (index < 0)
 +                return TRUE;
 +            else
 +            {
 +                GtkWidget *button = NULL;
 +                gpointer val;
 +
 +                switch (index)
 +                {
 +                    case 0:
 +                        button = book_currency_data->gnc_currency_radiobutton_0;
 +                        break;
 +                    case 1:
 +                        button = book_currency_data->gnc_currency_radiobutton_1;
 +                        break;
 +                    case 2:
 +                        button = book_currency_data->gnc_currency_radiobutton_2;
 +                        break;
 +                    default:
 +                        return TRUE;
 +                }
 +
 +                val = g_object_get_data (G_OBJECT (button),
 +                                            "gnc_radiobutton_index");
 +                g_return_val_if_fail (GPOINTER_TO_INT (val) == index, TRUE);
 +
 +                if (g_strcmp0(gnc_option_permissible_value_name(option,
 +                                                                 index),
 +                                "Use a Book Currency") == 0)
 +                {
 +                    gnc_commodity *commodity = NULL;
 +                    SCM curr_scm =
 +                        gnc_currency_accounting_option_value_get_book_currency
 +                            (value);
 +                    SCM list_symbol =
 +                        gnc_currency_accounting_option_value_get_default_policy
 +                            (value);
 +                    SCM acct_guid_scm =
 +                        gnc_currency_accounting_option_value_get_default_account
 +                            (value);
 +
 +                    commodity = gnc_scm_to_commodity (curr_scm);
 +                    if (commodity)
 +                    {
 +                        book_currency_data->retrieved_book_currency = commodity;
 +                    }
 +                    else
 +                    {
 +                        book_currency_data->retrieved_book_currency = NULL;
 +                    }
 +                    if (list_symbol)
 +                    {
 +                        book_currency_data->retrieved_policy_scm = list_symbol;
 +                    }
 +                    else
 +                    {
 +                        book_currency_data->retrieved_policy_scm = NULL;
 +                    }
 +                    if (acct_guid_scm)
 +                    {
 +                        book_currency_data->retrieved_gain_loss_acct_guid_scm =
 +                                                                acct_guid_scm;
 +                    }
 +                    else
 +                    {
 +                        book_currency_data->retrieved_gain_loss_acct_guid_scm =
 +                                                                        NULL;
 +                    }
 +                }
 +                gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
 +                /* when an unselected button in a group is clicked the clicked
 +                   button receives the “toggled” signal, as does the
 +                   previously selected button; however, if the first button
 +                   is active when the currency-accounting dialog is created,
 +                   that is, it's read from the option, the "toggled" handler
 +                   is not called while it is if any other button is active.
 +                   To get desired result, that is, to set sensitivity to
 +                   FALSE, explicitly call the handler here if first button */
 +                if (index == 0)
 +                {
 +                    gnc_option_currency_accounting_non_book_cb(button,
 +                        (gpointer) book_currency_data);
 +                }
 +                return FALSE;
 +            }
 +        }
 +        return TRUE;
 +    }
 +    return TRUE;
 +}
 +
 +/*************************
 + *       GET VALUE       *
 + *************************
 + *
 + * gnc_option_get_ui_value_<type>():
 + *
 + * 'widget' will be the widget returned from the
 + * gnc_option_set_ui_widget_<type>() function.
 + *
 + * You should return a SCM value corresponding to the current state of the
 + * gui widget.
 + *
 + */
 +static SCM
 +gnc_option_get_ui_value_boolean (GNCOption *option, GtkWidget *widget)
 +{
 +    gboolean active;
 +
 +    active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
 +    return SCM_BOOL(active);
 +}
 +
 +static SCM
 +gnc_option_get_ui_value_string (GNCOption *option, GtkWidget *widget)
 +{
 +    char * string;
 +    SCM result;
 +
 +    string = gtk_editable_get_chars(GTK_EDITABLE(widget), 0, -1);
 +    result = scm_from_utf8_string(string ? string : "");
 +    g_free(string);
 +    return result;
 +}
 +
 +static SCM
 +gnc_option_get_ui_value_text (GNCOption *option, GtkWidget *widget)
 +{
 +    char * string;
 +    SCM result;
 +
 +    string = xxxgtk_textview_get_text (GTK_TEXT_VIEW(widget));
 +    result = scm_from_utf8_string(string ? string : "");
 +    g_free(string);
 +    return result;
 +}
 +
 +static SCM
 +gnc_option_get_ui_value_currency (GNCOption *option, GtkWidget *widget)
 +{
 +    gnc_commodity *commodity;
 +
 +    commodity =
 +        gnc_currency_edit_get_currency(GNC_CURRENCY_EDIT(widget));
 +
 +    return (gnc_commodity_to_scm (commodity));
 +}
 +
 +static SCM
 +gnc_option_get_ui_value_commodity (GNCOption *option, GtkWidget *widget)
 +{
 +    gnc_commodity *commodity;
 +
 +    commodity =
 +        gnc_general_select_get_selected(GNC_GENERAL_SELECT(widget));
 +
 +    return (gnc_commodity_to_scm(commodity));
 +}
 +
 +static SCM
 +gnc_option_get_ui_value_multichoice (GNCOption *option, GtkWidget *widget)
 +{
 +    int index;
 +
 +    /* GtkComboBox per-item tooltip changes needed below */
 +    index = gnc_combott_get_active(GNC_COMBOTT(widget));
 +    return (gnc_option_permissible_value(option, index));
 +}
 +
 +static SCM
 +gnc_option_get_ui_value_date (GNCOption *option, GtkWidget *widget)
 +{
 +    int index;
 +    SCM type, val, result = SCM_UNDEFINED;
 +    char *subtype = gnc_option_date_option_get_subtype(option);
 +
 +    if (g_strcmp0(subtype, "relative") == 0)
 +    {
 +        /* GtkComboBox per-item tooltip changes needed below */
 +        index = gnc_combott_get_active(GNC_COMBOTT(widget));
 +
 +        type = scm_from_locale_symbol ("relative");
 +        val = gnc_option_permissible_value(option, index);
 +        result = scm_cons(type, val);
 +    }
 +    else if (g_strcmp0(subtype, "absolute") == 0)
 +    {
 +        Timespec ts;
 +
 +        ts.tv_sec  = gnc_date_edit_get_date(GNC_DATE_EDIT(widget));
 +        ts.tv_nsec = 0;
 +
 +        result = scm_cons(scm_from_locale_symbol ("absolute"), gnc_timespec2timepair(ts));
 +    }
 +    else if (g_strcmp0(subtype, "both") == 0)
 +    {
 +        Timespec ts;
 +        int index;
 +        SCM val;
 +        GList *widget_list;
 +        GtkWidget *ab_button, *rel_widget, *ab_widget;
 +
 +        widget_list = gtk_container_get_children(GTK_CONTAINER(widget));
 +        ab_button = g_list_nth_data(widget_list,  GNC_RD_WID_AB_BUTTON_POS);
 +        ab_widget = g_list_nth_data(widget_list,  GNC_RD_WID_AB_WIDGET_POS);
 +        rel_widget = g_list_nth_data(widget_list, GNC_RD_WID_REL_WIDGET_POS);
 +        g_list_free(widget_list);
 +
 +        /* if it's an absolute date */
 +        if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ab_button)))
 +        {
 +            ts.tv_sec = gnc_date_edit_get_date(GNC_DATE_EDIT(ab_widget));
 +            ts.tv_nsec = 0;
 +            result = scm_cons(scm_from_locale_symbol ("absolute"), gnc_timespec2timepair(ts));
 +        }
 +        else
 +        {
 +            /* GtkComboBox per-item tooltip changes needed below */
 +            index = gnc_combott_get_active(GNC_COMBOTT(rel_widget));
 +
 +            val = gnc_option_permissible_value(option, index);
 +            result = scm_cons(scm_from_locale_symbol ("relative"), val);
 +        }
 +    }
 +    g_free(subtype);
 +    return result;
 +}
 +
 +static SCM
 +gnc_option_get_ui_value_account_list (GNCOption *option, GtkWidget *widget)
 +{
 +    GncTreeViewAccount *tree;
 +    GList *list;
 +    SCM result;
 +
 +    tree = GNC_TREE_VIEW_ACCOUNT(widget);
 +    list = gnc_tree_view_account_get_selected_accounts (tree);
 +
 +    /* handover list */
 +    result = gnc_glist_to_scm_list(list, "_p_Account");
 +    g_list_free(list);
 +    return result;
 +}
 +
 +static SCM
 +gnc_option_get_ui_value_account_sel (GNCOption *option, GtkWidget *widget)
 +{
 +    GNCAccountSel *gas;
 +    Account* acc;
 +
 +    gas = GNC_ACCOUNT_SEL(widget);
 +    acc = gnc_account_sel_get_account (gas);
 +
 +    if (!acc)
 +        return SCM_BOOL_F;
 +
 +    return SWIG_NewPointerObj(acc, SWIG_TypeQuery("_p_Account"), 0);
 +}
 +
 +static SCM
 +gnc_option_get_ui_value_budget(GNCOption *option, GtkWidget *widget)
 +{
 +    GncBudget *bgt;
 +    GtkComboBox *cb;
 +    GtkTreeModel *tm;
 +    GtkTreeIter iter;
 +
 +    cb = GTK_COMBO_BOX(widget);
 +    gtk_combo_box_get_active_iter(cb, &iter);
 +    tm = gtk_combo_box_get_model(cb);
 +    bgt = gnc_tree_model_budget_get_budget(tm, &iter);
 +
 +    if (!bgt)
 +        return SCM_BOOL_F;
 +
 +    return SWIG_NewPointerObj(bgt, SWIG_TypeQuery("_p_budget_s"), 0);
 +}
 +
 +static SCM
 +gnc_option_get_ui_value_list (GNCOption *option, GtkWidget *widget)
 +{
 +    GtkTreeSelection *selection;
 +    GtkTreePath *path;
 +    SCM result;
 +    gboolean selected;
 +    gint num_rows;
 +    gint row;
 +
 +    selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(widget));
 +    num_rows = gnc_option_num_permissible_values(option);
 +    result = scm_c_eval_string("'()");
 +
 +    for (row = 0; row < num_rows; row++)
 +    {
 +        path = gtk_tree_path_new_from_indices(row, -1);
 +        selected = gtk_tree_selection_path_is_selected(selection, path);
 +        gtk_tree_path_free(path);
 +        if (selected)
 +            result = scm_cons(gnc_option_permissible_value(option, row), result);
 +    }
 +
 +    return (scm_reverse(result));
 +}
 +
 +static SCM
 +gnc_option_get_ui_value_number_range (GNCOption *option, GtkWidget *widget)
 +{
 +    GtkSpinButton *spinner;
 +    gdouble value;
 +
 +    spinner = GTK_SPIN_BUTTON(widget);
 +
 +    value = gtk_spin_button_get_value(spinner);
 +
 +    return (scm_from_double (value));
 +}
 +
 +static SCM
 +gnc_option_get_ui_value_color (GNCOption *option, GtkWidget *widget)
 +{
 +    SCM result;
 +    GtkColorChooser *color_button;
 +    GdkRGBA color;
 +    gdouble scale;
 +
 +    ENTER("option %p(%s), widget %p",
 +          option, gnc_option_name(option), widget);
 +
 +    color_button = GTK_COLOR_CHOOSER(widget);
 +    gtk_color_chooser_get_rgba(color_button, &color);
 +
 +    scale = gnc_option_color_range(option);
 +
 +    result = SCM_EOL;
 +    result = scm_cons(scm_from_double (color.alpha * scale), result);
 +    result = scm_cons(scm_from_double (color.blue * scale), result);
 +    result = scm_cons(scm_from_double (color.green * scale), result);
 +    result = scm_cons(scm_from_double (color.red * scale), result);
 +    return result;
 +}
 +
 +static SCM
 +gnc_option_get_ui_value_font (GNCOption *option, GtkWidget *widget)
 +{
 +    GtkFontButton *font_button = GTK_FONT_BUTTON(widget);
 +    const gchar * string;
 +
 +    string = gtk_font_button_get_font_name(font_button);
 +    return (string ? scm_from_utf8_string(string) : SCM_BOOL_F);
 +}
 +
 +static SCM
 +gnc_option_get_ui_value_pixmap (GNCOption *option, GtkWidget *widget)
 +{
 +    gchar *string;
 +    SCM result;
 +
 +    string = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(widget));
 +    DEBUG("filename %s", string ? string : "(null)");
 +    result = scm_from_utf8_string(string ? string : "");
 +    g_free(string);
 +    return result;
 +}
 +
 +static SCM
 +gnc_option_get_ui_value_radiobutton (GNCOption *option, GtkWidget *widget)
 +{
 +    gpointer _index;
 +    int index;
 +
 +    _index = g_object_get_data(G_OBJECT(widget), "gnc_radiobutton_index");
 +    index = GPOINTER_TO_INT(_index);
 +
 +    return (gnc_option_permissible_value(option, index));
 +}
 +
 +static SCM
 +gnc_option_get_ui_value_dateformat (GNCOption *option, GtkWidget *widget)
 +{
 +    GNCDateFormat *gdf = GNC_DATE_FORMAT(widget);
 +    QofDateFormat format;
 +    GNCDateMonthFormat months;
 +    gboolean years;
 +    const char* custom;
 +
 +    format = gnc_date_format_get_format(gdf);
 +    months = gnc_date_format_get_months(gdf);
 +    years = gnc_date_format_get_years(gdf);
 +    custom = gnc_date_format_get_custom(gdf);
 +
 +    return (gnc_dateformat_option_set_value(format, months, years, custom));
 +}
 +
 +static SCM
 +gnc_option_get_ui_value_plot_size (GNCOption *option, GtkWidget *widget)
 +{
 +    GList* widget_list;
 +    GtkWidget *px_button, *px_widget, *p_widget;
 +    gdouble d_value;
 +    SCM type, val;
 +
 +    widget_list = gtk_container_get_children(GTK_CONTAINER(widget));
 +    px_button = g_list_nth_data(widget_list, 0);
 +    px_widget = g_list_nth_data(widget_list, 1);
 +    // p_button item 2
 +    p_widget = g_list_nth_data(widget_list, 3);
 +    g_list_free(widget_list);
 +
 +    if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(px_button)))
 +    {
 +        type = scm_from_locale_symbol("pixels");
 +        d_value = gtk_spin_button_get_value(GTK_SPIN_BUTTON(px_widget));
 +    }
 +    else
 +    {
 +        type = scm_from_locale_symbol("percent");
 +        d_value = gtk_spin_button_get_value(GTK_SPIN_BUTTON(p_widget));
 +    }
 +    val = scm_from_double(d_value);
 +    return scm_cons(type, val);
 +}
 +
 +static SCM
 +gnc_option_get_ui_value_currency_accounting (
 +                                        GNCOption *option, GtkWidget *widget)
 +{
 +    gpointer _index;
 +    int index;
 +    SCM value = SCM_EOL;
 +
 +    _index = g_object_get_data(G_OBJECT(widget), "gnc_radiobutton_index");
 +    index = GPOINTER_TO_INT(_index);
 +
 +    /* build the return list in reverse order */
 +    if (g_strcmp0(gnc_option_permissible_value_name(option, index),
 +                  "Use a Book Currency") == 0)
 +    {
 +        gnc_commodity *commodity = NULL;
 +        int policy_index;
 +        SCM val;
 +        GList *list_of_policies = NULL;
 +        const char *str = NULL;
 +
 +        if (book_currency_data->default_gain_loss_account_widget)
 +        {
 +            /* get account from widget, if one selected */
 +            Account *gain_loss_account = NULL;
 +
 +            gain_loss_account =
 +                gnc_tree_view_account_get_selected_account
 +                    (GNC_TREE_VIEW_ACCOUNT (
 +                        book_currency_data->default_gain_loss_account_widget));
 +
 +            if (gain_loss_account == NULL)
 +            {
 +                val = SCM_BOOL_F;
 +            }
 +            else
 +            {
 +                gchar *gain_loss_account_guid = guid_to_string (
 +                                        xaccAccountGetGUID (gain_loss_account));
 +
 +                val = scm_from_utf8_string (gain_loss_account_guid);
 +                g_free (gain_loss_account_guid);
 +            }
 +        }
 +        else
 +        {
 +            val = SCM_BOOL_F;
 +        }
 +        value = scm_cons(val, value);
 +
 +        list_of_policies = gnc_get_valid_policy_list();
 +        if (list_of_policies && book_currency_data->default_cost_policy_widget)
 +        {
 +            GList *l = NULL;
 +            gint i = 0;
 +            /* GtkComboBox per-item tooltip changes needed below */
 +            policy_index =
 +                gnc_combott_get_active(GNC_COMBOTT(
 +                            book_currency_data->default_cost_policy_widget));
 +            for (l = list_of_policies; l != NULL; l = l->next)
 +            {
 +                GNCPolicy *pcy = l->data;
 +                if(i == policy_index)
 +                    str = PolicyGetName (pcy);
 +                i++;
 +            }
 +            g_list_free(list_of_policies);
 +        }
 +        if (str)
 +        {
 +            val = scm_from_locale_symbol(str);
 +        }
 +        else
 +        {
 +            val = SCM_BOOL_F;
 +        }
 +        value = scm_cons(val, value);
 +
 +        if (gtk_combo_box_get_active (GTK_COMBO_BOX(book_currency_data->book_currency_widget)) != -1)
 +        {
 +            commodity =
 +                gnc_currency_edit_get_currency(
 +                    GNC_CURRENCY_EDIT(
 +                        book_currency_data->book_currency_widget));
 +            if (commodity)
 +            {
 +                val = gnc_commodity_to_scm(commodity);
 +            }
 +            else
 +            {
 +                val = SCM_BOOL_F;
 +            }
 +        }
 +        else
 +        {
 +            val = SCM_BOOL_F;
 +        }
 +        value = scm_cons(val, value);
 +    }
 +
 +    return (scm_cons (gnc_option_permissible_value(option, index), value));
 +}
 +
 +/************************************/
 +/*          INITIALIZATION          */
 +/************************************/
 +static void gnc_options_initialize_options (void)
 +{
 +    static GNCOptionDef_t options[] =
 +    {
 +        {
 +            "boolean", gnc_option_set_ui_widget_boolean,
 +            gnc_option_set_ui_value_boolean, gnc_option_get_ui_value_boolean
 +        },
 +        {
 +            "string", gnc_option_set_ui_widget_string,
 +            gnc_option_set_ui_value_string, gnc_option_get_ui_value_string
 +        },
 +        {
 +            "text", gnc_option_set_ui_widget_text,
 +            (GNCOptionUISetValue)gnc_option_set_ui_value_text,
 +            gnc_option_get_ui_value_text
 +        },
 +        {
 +            "currency", gnc_option_set_ui_widget_currency,
 +            gnc_option_set_ui_value_currency, gnc_option_get_ui_value_currency
 +        },
 +        {
 +            "commodity", gnc_option_set_ui_widget_commodity,
 +            gnc_option_set_ui_value_commodity, gnc_option_get_ui_value_commodity
 +        },
 +        {
 +            "multichoice", gnc_option_set_ui_widget_multichoice,
 +            gnc_option_set_ui_value_multichoice, gnc_option_get_ui_value_multichoice
 +        },
 +        {
 +            "date", gnc_option_set_ui_widget_date,
 +            gnc_option_set_ui_value_date, gnc_option_get_ui_value_date
 +        },
 +        {
 +            "account-list", gnc_option_set_ui_widget_account_list,
 +            gnc_option_set_ui_value_account_list, gnc_option_get_ui_value_account_list
 +        },
 +        {
 +            "account-sel", gnc_option_set_ui_widget_account_sel,
 +            gnc_option_set_ui_value_account_sel, gnc_option_get_ui_value_account_sel
 +        },
 +        {
 +            "list", gnc_option_set_ui_widget_list,
 +            gnc_option_set_ui_value_list, gnc_option_get_ui_value_list
 +        },
 +        {
 +            "number-range", gnc_option_set_ui_widget_number_range,
 +            gnc_option_set_ui_value_number_range, gnc_option_get_ui_value_number_range
 +        },
 +        {
 +            "color", gnc_option_set_ui_widget_color,
 +            gnc_option_set_ui_value_color, gnc_option_get_ui_value_color
 +        },
 +        {
 +            "font", gnc_option_set_ui_widget_font,
 +            gnc_option_set_ui_value_font, gnc_option_get_ui_value_font
 +        },
 +        {
 +            "pixmap", gnc_option_set_ui_widget_pixmap,
 +            gnc_option_set_ui_value_pixmap, gnc_option_get_ui_value_pixmap
 +        },
 +        {
 +            "radiobutton", gnc_option_set_ui_widget_radiobutton,
 +            gnc_option_set_ui_value_radiobutton, gnc_option_get_ui_value_radiobutton
 +        },
 +        {
 +            "dateformat", gnc_option_set_ui_widget_dateformat,
 +            gnc_option_set_ui_value_dateformat, gnc_option_get_ui_value_dateformat
 +        },
 +        {
 +            "plot-size", gnc_option_set_ui_widget_plot_size,
 +            gnc_option_set_ui_value_plot_size, gnc_option_get_ui_value_plot_size
 +        },
 +        {
 +            "budget", gnc_option_set_ui_widget_budget,
 +            gnc_option_set_ui_value_budget, gnc_option_get_ui_value_budget
 +        },
 +        {
 +            "currency-accounting",
 +            gnc_option_set_ui_widget_currency_accounting,
 +            gnc_option_set_ui_value_currency_accounting,
 +            gnc_option_get_ui_value_currency_accounting
 +        },
 +        { NULL, NULL, NULL, NULL }
 +    };
 +    int i;
 +
 +    for (i = 0; options[i].option_name; i++)
 +        gnc_options_ui_register_option (&(options[i]));
 +}
 +
 +/* Register a new option type in the UI */
 +void gnc_options_ui_register_option (GNCOptionDef_t *option)
 +{
 +    g_return_if_fail (optionTable);
 +    g_return_if_fail (option);
 +
 +    /* FIXME: should protect against repeat insertion. */
 +    g_hash_table_insert (optionTable, (gpointer)(option->option_name), option);
 +}
 +
 +GNCOptionDef_t * gnc_options_ui_get_option (const char *option_name)
 +{
 +    GNCOptionDef_t *retval;
 +    g_return_val_if_fail (optionTable, NULL);
 +    g_return_val_if_fail (option_name, NULL);
 +
 +    retval = g_hash_table_lookup (optionTable, option_name);
 +    if (!retval)
 +    {
 +        PERR("Option lookup for type '%s' failed!", option_name);
 +    }
 +    return retval;
 +}
 +
 +void gnc_options_ui_initialize (void)
 +{
 +    SWIG_GetModule(NULL); /* Work-around for SWIG bug. */
 +    //  gnc_options_register_stocks ();
 +    g_return_if_fail (optionTable == NULL);
 +    optionTable = g_hash_table_new (g_str_hash, g_str_equal);
 +
 +    /* add known types */
 +    gnc_options_initialize_options ();
 +}
 +
 +struct scm_cb
 +{
 +    SCM	apply_cb;
 +    SCM	close_cb;
 +};
 +
 +static void
 +scm_apply_cb (GNCOptionWin *win, gpointer data)
 +{
 +    struct scm_cb *cbdata = data;
 +
 +    if (gnc_option_db_get_changed (win->option_db))
 +    {
 +        GList *results = NULL, *iter;
 +        results = gnc_option_db_commit (win->option_db);
 +        for (iter = results; iter; iter = iter->next)
 +        {
 +            GtkWidget *dialog = gtk_message_dialog_new(NULL,
 +                                                       0,
 +                                                       GTK_MESSAGE_ERROR,
 +                                                       GTK_BUTTONS_OK,
 +                                                       "%s",
 +                                                       (char*)iter->data);
 +            gtk_dialog_run(GTK_DIALOG(dialog));
 +            gtk_widget_destroy(dialog);
 +            g_free (iter->data);
 +        }
 +        g_list_free (results);
 +
 +        if (cbdata->apply_cb != SCM_BOOL_F)
 +        {
 +            scm_call_0 (cbdata->apply_cb);
 +        }
 +    }
 +}
 +
 +static void
 +scm_close_cb (GNCOptionWin *win, gpointer data)
 +{
 +    struct scm_cb *cbdata = data;
 +
 +    if (cbdata->close_cb != SCM_BOOL_F)
 +    {
 +        scm_call_0 (cbdata->close_cb);
 +        scm_gc_unprotect_object (cbdata->close_cb);
 +    }
 +
 +    if (cbdata->apply_cb != SCM_BOOL_F)
 +        scm_gc_unprotect_object (cbdata->apply_cb);
 +
 +    g_free (cbdata);
 +}
 +
 +/* Both apply_cb and close_cb should be scheme functions with 0 arguments.
 + * References to these functions will be held until the close_cb is called
 + */
 +void
 +gnc_options_dialog_set_scm_callbacks (GNCOptionWin *win, SCM apply_cb,
 +                                      SCM close_cb)
 +{
 +    struct scm_cb *cbdata;
 +
 +    cbdata = g_new0 (struct scm_cb, 1);
 +    cbdata->apply_cb = apply_cb;
 +    cbdata->close_cb = close_cb;
 +
 +    if (apply_cb != SCM_BOOL_F)
 +        scm_gc_protect_object (cbdata->apply_cb);
 +
 +    if (close_cb != SCM_BOOL_F)
 +        scm_gc_protect_object (cbdata->close_cb);
 +
 +    gnc_options_dialog_set_apply_cb (win, scm_apply_cb, cbdata);
 +    gnc_options_dialog_set_close_cb (win, scm_close_cb, cbdata);
 +}

commit 0b85bbc1bf8db418314d83aa8664957c9367482a
Author: Geert Janssens <geert at kobaltwit.be>
Date:   Thu Sep 21 14:24:02 2017 +0200

    Add income-gst-statement.scm to POTFILES.in

diff --git a/po/POTFILES.in b/po/POTFILES.in
index 9cba02a..eaf0f39 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -470,6 +470,7 @@ gnucash/report/standard-reports/daily-reports.scm
 gnucash/report/standard-reports/equity-statement.scm
 gnucash/report/standard-reports/general-journal.scm
 gnucash/report/standard-reports/general-ledger.scm
+gnucash/report/standard-reports/income-gst-statement.scm
 gnucash/report/standard-reports/income-statement.scm
 gnucash/report/standard-reports/net-barchart.scm
 gnucash/report/standard-reports/net-linechart.scm

commit 5b99835cb1f2a5623d3153673783aa0efecd5d38
Author: christopherlam <christopher.lck at gmail.com>
Date:   Thu Sep 21 19:51:03 2017 +0800

    Fix some (gnc:make-gnc-monetary) errors
    
    These errors didn't appear in the tracefile. They only appeared on Linux terminal.

diff --git a/gnucash/report/standard-reports/income-gst-statement.scm b/gnucash/report/standard-reports/income-gst-statement.scm
index 36a2ae8..a74092f 100644
--- a/gnucash/report/standard-reports/income-gst-statement.scm
+++ b/gnucash/report/standard-reports/income-gst-statement.scm
@@ -524,9 +524,10 @@ accounts must be of type ASSET for taxes paid on expenses, and type LIABILITY fo
              (let* ((calculator (vector-ref cell 1))
                     (reverse-column? (vector-ref cell 2))
                     (calculated (calculator split)))
-               (if (and sign-reverses? reverse-column? calculated)
-                   (converted (gnc-numeric-neg calculated))
-                   (converted calculated))))
+               (cond
+                 ((and sign-reverses? reverse-column? calculated) (converted (gnc-numeric-neg calculated)))
+                 (calculated  (converted calculated))
+                 (else #f))))
            cell-calculators))
 
     (if (used-date column-vector)
@@ -622,7 +623,7 @@ accounts must be of type ASSET for taxes paid on expenses, and type LIABILITY fo
                              "number-cell"
                              (gnc:html-transaction-anchor
                               parent
-                              (gnc:make-gnc-monetary report-currency cell))))
+                              cell)))
                     (addto! row-contents (gnc:html-make-empty-cell))))
               cells)
 
@@ -1800,4 +1801,4 @@ for taxes paid on expenses, and type LIABILITY for taxes collected on sales.")
  'name reportname
  'report-guid "5bf27f249a0d11e7abc4cec278b6b50a"
  'options-generator trep-options-generator
- 'renderer trep-renderer)
\ No newline at end of file
+ 'renderer trep-renderer)

commit 678794c8002a9240077958a6f360f5c7c6bd8d15
Author: christopherlam <christopher.lck at gmail.com>
Date:   Sun Sep 17 16:47:38 2017 +0800

    Restore "sign reverses" option
    This was removed during development.

diff --git a/gnucash/report/standard-reports/income-gst-statement.scm b/gnucash/report/standard-reports/income-gst-statement.scm
index 2b2cea6..36a2ae8 100644
--- a/gnucash/report/standard-reports/income-gst-statement.scm
+++ b/gnucash/report/standard-reports/income-gst-statement.scm
@@ -483,11 +483,11 @@ accounts must be of type ASSET for taxes paid on expenses, and type LIABILITY fo
     (if (used-amount-double-negative column-vector)
         (addto! heading-list (_ "Credit")))
 
-    (for-each (lambda (arg)
+    (for-each (lambda (cell)
                 (addto! heading-list
                         (gnc:make-html-table-cell/markup
                          "column-heading-right"
-                         (car arg))))
+                         (vector-ref cell 0))))
               calculated-cells)
 
     (reverse heading-list)))
@@ -511,6 +511,7 @@ accounts must be of type ASSET for taxes paid on expenses, and type LIABILITY fo
          (report-currency (if (opt-val gnc:pagename-general optname-common-currency)
                               (opt-val gnc:pagename-general optname-currency)
                               currency))
+         (sign-reverses? (opt-val gnc:pagename-display (N_ "Sign Reverses")))
          (trans-date (gnc-transaction-get-date-posted parent))
          (converted (lambda (num)
                       (gnc:exchange-by-pricedb-nearest
@@ -520,7 +521,12 @@ accounts must be of type ASSET for taxes paid on expenses, and type LIABILITY fo
 
     (define cells
       (map (lambda (cell)
-             (converted ((cdr cell) split)))
+             (let* ((calculator (vector-ref cell 1))
+                    (reverse-column? (vector-ref cell 2))
+                    (calculated (calculator split)))
+               (if (and sign-reverses? reverse-column? calculated)
+                   (converted (gnc-numeric-neg calculated))
+                   (converted calculated))))
            cell-calculators))
 
     (if (used-date column-vector)
@@ -1038,13 +1044,14 @@ for taxes paid on expenses, and type LIABILITY for taxes collected on sales.")
     ;(list (N_ "Shares")                       "k"  (N_ "Display the number of shares?") #f)
     ;(list (N_ "Price")                        "l"  (N_ "Display the shares price?") #f)
     ;; note the "Amount" multichoice option in between here
-    (list (N_ "Totals")                       "o"  (N_ "Display the totals?") #t)
+    (list (N_ "Totals")                       "o" (N_ "Display the totals?") #t)
     (list (N_ "Individual income columns")    "p" (N_ "Display individual income columns rather than their sum") #f)
     (list (N_ "Individual expense columns")   "q" (N_ "Display individual expense columns rather than their sum") #f)
-    (list (N_ "Individual tax columns")       "r"  (N_ "Display individual tax columns rather than their sum") #f)
-    (list (N_ "Remittance amount")            "s"  (N_ "Display the remittance amount (total sales - total purchases)") #f)
-    (list (N_ "Net Income")                   "t"  (N_ "Display the net income (sales without tax - purchases without tax)") #f)
-    (list (N_ "Tax payable")                  "t"  (N_ "Display the tax payable (tax on sales - tax on purchases)") #f)
+    (list (N_ "Individual tax columns")       "r" (N_ "Display individual tax columns rather than their sum") #f)
+    (list (N_ "Remittance amount")            "s" (N_ "Display the remittance amount (total sales - total purchases)") #f)
+    (list (N_ "Net Income")                   "t" (N_ "Display the net income (sales without tax - purchases without tax)") #f)
+    (list (N_ "Tax payable")                  "u" (N_ "Display the tax payable (tax on sales - tax on purchases)") #f)
+    (list (N_ "Sign Reverses")                "z" (N_ "Reverse amount display for income-related columns.") #t)
     ))
 
   (if (qof-book-use-split-action-for-num-field (gnc-get-current-book))
@@ -1101,18 +1108,6 @@ for taxes paid on expenses, and type LIABILITY for taxes collected on sales.")
   ;   (vector 'double (N_ "Double") (N_ "Two Column Display."))
   ;   )))
 
-  ;(gnc:register-trep-option
-  ; (gnc:make-multichoice-option
-  ;  gnc:pagename-display (N_ "Sign Reverses")
-  ;  "p" (N_ "Reverse amount display for certain account types.")
-  ;  'none
-  ;  (list
-  ;   (vector 'none (N_ "None") (N_ "Don't change any displayed amounts."))
-  ;   (vector 'income-expense (N_ "Income and Expense")
-  ;           (N_ "Reverse amount display for Income and Expense Accounts."))
-  ;   (vector 'credit-accounts (N_ "Credit Accounts")
-  ;           (N_ "Reverse amount display for Liability, Payable, Equity, Credit Card, and Income accounts.")))))
-
   (gnc:options-set-default-section gnc:*transaction-report-options*
                                    gnc:pagename-general)
 
@@ -1210,47 +1205,35 @@ for taxes paid on expenses, and type LIABILITY for taxes collected on sales.")
            (net-income (lambda (s) (myneg (myadd (sales-without-tax s) (purchases-without-tax s)))))
            (tax-payable (lambda (s) (myneg (myadd (tax-on-purchases s) (tax-on-sales s))))))
         (append
-         (list (cons "Total Sales" total-sales))
+         ; each column will be a vector
+         ; (vector heading calculator-function reverse-column?)
+         (list (vector "Total Sales" total-sales #t))
          (if (gnc:option-value (gnc:lookup-option options gnc:pagename-display (N_ "Individual income columns")))
-             (map (lambda (acc) (cons (xaccAccountGetName acc) (account-adder acc)))
+             (map (lambda (acc) (vector (xaccAccountGetName acc) (account-adder acc) #t))
                   accounts-sales)
-             (list (cons "Net Sales" sales-without-tax)))
+             (list (vector "Net Sales" sales-without-tax #t)))
          (if (gnc:option-value (gnc:lookup-option options gnc:pagename-display (N_ "Individual tax columns")))
-             (map (lambda (acc) (cons (xaccAccountGetName acc) (account-adder acc)))
+             (map (lambda (acc) (vector (xaccAccountGetName acc) (account-adder acc) #t))
                   accounts-tax-collected)
-             (list (cons "Tax on Sales" tax-on-sales)))
-         (list (cons "Total Purchases" total-purchases))
+             (list (vector "Tax on Sales" tax-on-sales #t)))
+         (list (vector "Total Purchases" total-purchases #f))
          (if (gnc:option-value (gnc:lookup-option options gnc:pagename-display (N_ "Individual expense columns")))
-             (map (lambda (acc) (cons (xaccAccountGetName acc) (account-adder acc)))
+             (map (lambda (acc) (vector (xaccAccountGetName acc) (account-adder acc) #f))
                   accounts-purchases)
-             (list (cons "Net Purchases" purchases-without-tax)))
+             (list (vector "Net Purchases" purchases-without-tax #f)))
          (if (gnc:option-value (gnc:lookup-option options gnc:pagename-display (N_ "Individual tax columns")))
-             (map (lambda (acc) (cons (xaccAccountGetName acc) (account-adder acc)))
+             (map (lambda (acc) (vector (xaccAccountGetName acc) (account-adder acc) #f))
                   accounts-tax-paid)
-             (list (cons "Tax on Purchases" tax-on-purchases)))
+             (list (vector "Tax on Purchases" tax-on-purchases #f)))
          (if (gnc:option-value (gnc:lookup-option options gnc:pagename-display (N_ "Remittance amount")))
-             (list (cons "Remittance" bank-remittance))
+             (list (vector "Remittance" bank-remittance #f))
              '())
          (if (gnc:option-value (gnc:lookup-option options gnc:pagename-display (N_ "Net Income")))
-             (list (cons "Net Income" net-income))
+             (list (vector "Net Income" net-income #f))
              '())
          (if (gnc:option-value (gnc:lookup-option options gnc:pagename-display (N_ "Tax payable")))
-             (list (cons "Tax Payable" tax-payable))
-             '())
-         )))
-
-
-    ;(define (get-account-types-to-reverse options)
-    ;  (cdr (assq (gnc:option-value
-    ;              (gnc:lookup-option options
-    ;                                 gnc:pagename-display
-    ;                                 (N_ "Sign Reverses")))
-    ;             account-types-to-reverse-assoc-list)))
-
-    ;(define (transaction-report-multi-rows-p options)
-    ;  (eq? (gnc:option-value
-    ;        (gnc:lookup-option options gnc:pagename-general (N_ "Style")))
-    ;       'multi-line))
+             (list (vector "Tax Payable" tax-payable #f))
+             '()))))
 
     (define (transaction-report-export-p options)
       (gnc:option-value
@@ -1413,7 +1396,7 @@ for taxes paid on expenses, and type LIABILITY for taxes collected on sales.")
            (width (num-columns-required used-columns))
            (multi-rows? #f) ;disable. (transaction-report-multi-rows-p options))
            (export?  (transaction-report-export-p options))
-           (account-types-to-reverse '())) ;disabled.            (get-account-types-to-reverse '()))options)))
+           (account-types-to-reverse '()))
 
       (gnc:html-table-set-col-headers!
        table
@@ -1440,11 +1423,7 @@ for taxes paid on expenses, and type LIABILITY for taxes collected on sales.")
                                     secondary-subtotal-renderer
                                     (map (lambda (x) (gnc:make-commodity-collector)) calculated-cells)
                                     (map (lambda (x) (gnc:make-commodity-collector)) calculated-cells)
-                                    (map (lambda (x) (gnc:make-commodity-collector)) calculated-cells)
-                                    ;(gnc:make-commodity-collector)
-                                    ;(gnc:make-commodity-collector)
-                                    ;(gnc:make-commodity-collector)
-                                    )))
+                                    (map (lambda (x) (gnc:make-commodity-collector)) calculated-cells))))
       table)))
 
 ;; ;;;;;;;;;;;;;;;;;;;;

commit ff32ddc9069aff1f6ab286e9ec61ee13fe829024
Author: christopherlam <christopher.lck at gmail.com>
Date:   Sun Sep 17 01:04:57 2017 +0100

    Initial commit income-gst-statement.scm

diff --git a/gnucash/report/standard-reports/income-gst-statement.scm b/gnucash/report/standard-reports/income-gst-statement.scm
index 859cfde..2b2cea6 100644
--- a/gnucash/report/standard-reports/income-gst-statement.scm
+++ b/gnucash/report/standard-reports/income-gst-statement.scm
@@ -1,7 +1,8 @@
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; transaction-report.scm : Report on all transactions in account(s)
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Income-GST-Statement.scm : Produce report suitable for
+;; annual income tax returns and periodic VAT/GST reporting.
 ;;
-;; Original report by Robert Merkel <rgmerk at mira.net>
+;; Original transaction.scm report by Robert Merkel <rgmerk at mira.net>
 ;; Contributions by Bryan Larsen <blarsen at ada-works.com>
 ;; More contributions for new report generation code by Robert Merkel
 ;; More contributions by Christian Stimming <stimming at tuhh.de>
@@ -9,17 +10,19 @@
 ;; Michael T. Garrison Stuber
 ;; Modified account names display by Tomas Pospisek
 ;; <tpo_deb at sourcepole.ch> with a lot of help from "warlord"
+;; Heavily amended by Christopher Lam to add calculations
+;; appropriate for GST/VAT, building on efforts by Doug Doughty.
+;;
+;; 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.
 ;;
-;; 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:
 ;;
@@ -29,16 +32,14 @@
 ;;
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
-(define-module (gnucash report standard-reports transaction))
+(define-module (gnucash report standard-reports income-gst-statement))
 
 (use-modules (gnucash main)) ;; FIXME: delete after we finish modularizing.
 (use-modules (srfi srfi-1))
 (use-modules (srfi srfi-13))
 (use-modules (gnucash gnc-module))
 (use-modules (gnucash gettext))
-
 (use-modules (gnucash printf))
-
 (gnc:module-load "gnucash/report/report-system" 0)
 
 (define-macro (addto! alist element)
@@ -46,8 +47,7 @@
 
 ;; Define the strings here to avoid typos and make changes easier.
 
-(define reportname (N_ "Transaction Report"))
-(define optname-detail-level (N_ "Detail Level"))
+(define reportname (N_ "Income & GST Statement"))
 (define pagename-sorting (N_ "Sorting"))
 (define optname-prime-sortkey (N_ "Primary Key"))
 (define optname-prime-subtotal (N_ "Primary Subtotal"))
@@ -62,6 +62,10 @@
 (define optname-void-transactions (N_ "Void Transactions"))
 (define optname-table-export (N_ "Table for Exporting"))
 (define optname-common-currency (N_ "Common Currency"))
+(define TAX-SETUP-DESC "From the Report Options, you will need to select the accounts which will \
+hold the GST/VAT taxes collected or paid. These accounts must contain splits which document the \
+monies which are wholly sent or claimed from tax authorities during periodic GST/VAT returns. These \
+accounts must be of type ASSET for taxes paid on expenses, and type LIABILITY for taxes collected on sales.")
 (define optname-currency (N_ "Report's currency"))
 (define def:grand-total-style "grand-total")
 (define def:normal-row-style "normal-row")
@@ -71,7 +75,7 @@
 ;; The option-values of the sorting key multichoice option, for
 ;; which a subtotal should be enabled.
 (define subtotal-enabled '(account-name
-                           account-code 
+                           account-code
                            corresponding-acc-name
                            corresponding-acc-code))
 
@@ -92,12 +96,12 @@
      (gnc:timepair-get-year tp-b)))
 
 (define (timepair-same-quarter tp-a tp-b)
-  (and (timepair-same-year tp-a tp-b) 
+  (and (timepair-same-year tp-a tp-b)
        (= (gnc:timepair-get-quarter tp-a)
           (gnc:timepair-get-quarter tp-b))))
 
 (define (timepair-same-month tp-a tp-b)
-  (and (timepair-same-year tp-a tp-b) 
+  (and (timepair-same-year tp-a tp-b)
        (= (gnc:timepair-get-month tp-a)
           (gnc:timepair-get-month tp-b))))
 
@@ -127,8 +131,8 @@
     (timepair-same-year tp-a tp-b)))
 
 (define (set-last-row-style! table tag . rest)
-  (let ((arg-list 
-         (cons table 
+  (let ((arg-list
+         (cons table
                (cons (- (gnc:html-table-num-rows table) 1)
                      (cons tag rest)))))
     (apply gnc:html-table-set-row-style! arg-list)))
@@ -146,7 +150,7 @@
   ;;# on multi-line splits we can get an empty ('()) account
   (if (null? account)
       (_ "Split Transaction")
-      (string-append 
+      (string-append
        ;; display account code?
        (if show-account-code
            (string-append (xaccAccountGetCode account) " ")
@@ -172,7 +176,7 @@
                                               (used-sort-account-full-name column-vector))))
                         table width subheading-style)))
 
-(define (render-corresponding-account-subheading 
+(define (render-corresponding-account-subheading
          split table width subheading-style column-vector)
   (let ((account (xaccSplitGetAccount (xaccSplitGetOtherSplit split))))
     (add-subheading-row (gnc:make-html-text
@@ -195,62 +199,76 @@
 
 (define (render-month-subheading split table width subheading-style column-vector)
   (add-subheading-row (gnc:date-get-month-year-string
-                       (gnc:timepair->date 
+                       (gnc:timepair->date
                         (gnc-transaction-get-date-posted
                          (xaccSplitGetParent split))))
                       table width subheading-style))
 
 (define (render-quarter-subheading split table width subheading-style column-vector)
-  (add-subheading-row (gnc:date-get-quarter-year-string 
-                       (gnc:timepair->date 
+  (add-subheading-row (gnc:date-get-quarter-year-string
+                       (gnc:timepair->date
                         (gnc-transaction-get-date-posted
                          (xaccSplitGetParent split))))
                       table width subheading-style))
 
 (define (render-year-subheading split table width subheading-style column-vector)
-  (add-subheading-row (gnc:date-get-year-string 
-                       (gnc:timepair->date 
+  (add-subheading-row (gnc:date-get-year-string
+                       (gnc:timepair->date
                         (gnc-transaction-get-date-posted
                          (xaccSplitGetParent split))))
                       table width subheading-style))
 
 
-(define (add-subtotal-row table width subtotal-string subtotal-collector 
+(define (add-subtotal-row table width subtotal-string subtotal-collectors
                           subtotal-style export?)
-  (let ((currency-totals (subtotal-collector
-                          'format gnc:make-gnc-monetary #f))
-        (blanks (gnc:make-html-table-cell/size 1 (- width 1) #f)))
-    (gnc:html-table-append-row/markup!
-     table
-     subtotal-style 
-     (if export?
-         (append! (cons (gnc:make-html-table-cell/markup "total-label-cell" subtotal-string)
-                        (gnc:html-make-empty-cells (- width 2)))
-                  (list (gnc:make-html-table-cell/markup 
-                         "total-number-cell"
-                         (car currency-totals))))
-         (list (gnc:make-html-table-cell/size/markup 1 (- width 1) "total-label-cell"
-                                                     subtotal-string)
-               (gnc:make-html-table-cell/markup 
-                "total-number-cell"
-                (car currency-totals)))))
-    (for-each (lambda (currency)
-                (gnc:html-table-append-row/markup! 
-                 table
-                 subtotal-style
-                 (append!
-                  (if export?
-                      (gnc:html-make-empty-cells (- width 1))
-                      (list blanks))
-                  (list (gnc:make-html-table-cell/markup
-                         "total-number-cell" currency)))))
-              (cdr currency-totals))))
+  (let* ((row-contents '())
+         (columns (map (lambda (coll) (coll 'format gnc:make-gnc-monetary #f)) subtotal-collectors))
+         (list-of-commodities (delete-duplicates (map gnc:gnc-monetary-commodity (apply append columns)))))
+
+    (define (retrieve-commodity list-of-monetary commodity)
+      (if (null? list-of-monetary)
+          #f
+          (if (gnc-commodity-equal (gnc:gnc-monetary-commodity (car list-of-monetary)) commodity)
+              (car list-of-monetary)
+              (retrieve-commodity (cdr list-of-monetary) commodity))))
+
+    (define (add-first-column string)
+      (if export?
+          (begin
+            (addto! row-contents (gnc:make-html-table-cell/markup "total-label-cell" string))
+            (for-each (lambda (cell) (addto! row-contents cell))
+                      (gnc:html-make-empty-cells (- width 1))))
+          (addto! row-contents (gnc:make-html-table-cell/size/markup 1 width "total-label-cell" string))))
+
+    (define (add-columns commodity)
+      (for-each (lambda (column)
+                  (addto! row-contents
+                          (gnc:make-html-table-cell/markup
+                           "total-number-cell"
+                           (retrieve-commodity column commodity))))
+                columns))
+
+    ;first row
+    (add-first-column subtotal-string)
+    (add-columns (if (pair? list-of-commodities)
+                     (car list-of-commodities)
+                     #f)) ;to account for empty-row subtotals
+    (gnc:html-table-append-row/markup! table subtotal-style (reverse row-contents))
+
+    ;subsequent rows
+    (if (pair? list-of-commodities)
+        (for-each (lambda (commodity)
+                    (set! row-contents '())
+                    (add-first-column "")
+                    (add-columns commodity)
+                    (gnc:html-table-append-row/markup! table subtotal-style (reverse row-contents)))
+                  (cdr list-of-commodities)))))
 
 (define (total-string str) (string-append (_ "Total For ") str))
 
-(define (render-account-subtotal 
+(define (render-account-subtotal
          table width split total-collector subtotal-style column-vector export?)
-  (add-subtotal-row table width 
+  (add-subtotal-row table width
                     (total-string (account-namestring (xaccSplitGetAccount split)
                                                       (used-sort-account-code      column-vector)
                                                       #t
@@ -279,7 +297,7 @@
          table width split total-collector subtotal-style column-vector export?)
   (let ((tm (gnc:timepair->date (gnc-transaction-get-date-posted
                                  (xaccSplitGetParent split)))))
-    (add-subtotal-row table width 
+    (add-subtotal-row table width
                       (total-string (gnc:date-get-month-year-string tm))
                       total-collector subtotal-style export?)))
 
@@ -288,7 +306,7 @@
          table width split total-collector subtotal-style column-vector export?)
   (let ((tm (gnc:timepair->date (gnc-transaction-get-date-posted
                                  (xaccSplitGetParent split)))))
-    (add-subtotal-row table width 
+    (add-subtotal-row table width
                       (total-string (gnc:date-get-quarter-year-string tm))
                       total-collector subtotal-style export?)))
 
@@ -296,7 +314,7 @@
          table width split total-collector subtotal-style column-vector export?)
   (let ((tm (gnc:timepair->date (gnc-transaction-get-date-posted
                                  (xaccSplitGetParent split)))))
-    (add-subtotal-row table width 
+    (add-subtotal-row table width
                       (total-string (strftime "%Y" tm))
                       total-collector subtotal-style export?)))
 
@@ -326,19 +344,17 @@
 (define (used-account-name columns-used)
   (vector-ref columns-used 4))
 (define (used-other-account-name columns-used)
-  (vector-ref columns-used 5))	
+  (vector-ref columns-used 5))
 (define (used-shares columns-used)
-  (vector-ref columns-used 6))	
+  (vector-ref columns-used 6))
 (define (used-price columns-used)
-  (vector-ref columns-used 7))	
+  (vector-ref columns-used 7))
 (define (used-amount-single columns-used)
-  (vector-ref columns-used 8))	
+  (vector-ref columns-used 8))
 (define (used-amount-double-positive columns-used)
-  (vector-ref columns-used 9))	
+  (vector-ref columns-used 9))
 (define (used-amount-double-negative columns-used)
-  (vector-ref columns-used 10))	
-(define (used-running-balance columns-used)
-  (vector-ref columns-used 11))
+  (vector-ref columns-used 10))
 (define (used-account-full-name columns-used)
   (vector-ref columns-used 12))
 (define (used-memo columns-used)
@@ -358,9 +374,9 @@
 
 (define columns-used-size 20)
 
-(define (num-columns-required columns-used)  
-  (do ((i 0 (+ i 1)) 
-       (col-req 0 col-req)) 
+(define (num-columns-required columns-used)
+  (do ((i 0 (+ i 1))
+       (col-req 0 col-req))
     ((>= i columns-used-size) col-req)
     ; If column toggle is true, increase column count. But attention:
     ; some toggles only change the meaning of another toggle. Don't count these modifier toggles
@@ -378,12 +394,11 @@
             (and (= i 15) (vector-ref columns-used 15) (vector-ref columns-used 5))) ; Other Account Code and Name
         (set! col-req (- col-req 1)))))
 
-(define (build-column-used options)   
+(define (build-column-used options)
   (define (opt-val section name)
-    (gnc:option-value 
+    (gnc:option-value
      (gnc:lookup-option options section name)))
-  (let ((column-list (make-vector columns-used-size #f))
-        (is-single? (eq? (opt-val gnc:pagename-display optname-detail-level) 'single)))
+  (let ((column-list (make-vector columns-used-size #f)))
     (if (opt-val gnc:pagename-display (N_ "Date"))
         (vector-set! column-list 0 #t))
     (if (opt-val gnc:pagename-display (N_ "Reconciled Date"))
@@ -396,29 +411,28 @@
         (vector-set! column-list 3 #t))
     (if (opt-val gnc:pagename-display (N_ "Account Name"))
         (vector-set! column-list 4 #t))
-    (if (and is-single? (opt-val gnc:pagename-display (N_ "Other Account Name")))
+    (if (opt-val gnc:pagename-display (N_ "Other Account Name"))
         (vector-set! column-list 5 #t))
-    (if (opt-val gnc:pagename-display (N_ "Shares"))
-        (vector-set! column-list 6 #t))
-    (if (opt-val gnc:pagename-display (N_ "Price"))
-        (vector-set! column-list 7 #t))
-    (let ((amount-setting (opt-val gnc:pagename-display (N_ "Amount"))))
-      (if (eq? amount-setting 'single)
-          (vector-set! column-list 8 #t))
-      (if (eq? amount-setting 'double)
-          (begin (vector-set! column-list 9 #t)
-                 (vector-set! column-list 10 #t))))
-    (if (opt-val gnc:pagename-display (N_ "Running Balance"))
-        (vector-set! column-list 11 #t))
+    ;(if (opt-val gnc:pagename-display (N_ "Shares"))
+    ;    (vector-set! column-list 6 #t))
+    ;(if (opt-val gnc:pagename-display (N_ "Price"))
+    ;    (vector-set! column-list 7 #t))
+    ;(let ((amount-setting (opt-val gnc:pagename-display (N_ "Amount"))))
+    ;  (if (eq? amount-setting 'single)
+    ;      (vector-set! column-list 8 #t))
+    ;  (if (eq? amount-setting 'double)
+    ;      (begin (vector-set! column-list 9 #t)
+    ;             (vector-set! column-list 10 #t))))
+
     (if (opt-val gnc:pagename-display  (N_ "Use Full Account Name"))
         (vector-set! column-list 12 #t))
     (if (opt-val gnc:pagename-display (N_ "Memo"))
         (vector-set! column-list 13 #t))
     (if (opt-val gnc:pagename-display (N_ "Account Code"))
         (vector-set! column-list 14 #t))
-    (if (and is-single? (opt-val gnc:pagename-display (N_ "Other Account Code")))
+    (if (opt-val gnc:pagename-display (N_ "Other Account Code"))
         (vector-set! column-list 15 #t))
-    (if (and is-single? (opt-val gnc:pagename-display (N_ "Use Full Other Account Name")))
+    (if (opt-val gnc:pagename-display (N_ "Use Full Other Account Name"))
         (vector-set! column-list 16 #t))
     (if (opt-val pagename-sorting (N_ "Show Account Code"))
         (vector-set! column-list 17 #t))
@@ -428,7 +442,7 @@
         (vector-set! column-list 19 #t))
     column-list))
 
-(define (make-heading-list column-vector options)
+(define (make-heading-list column-vector calculated-cells options)
   (let ((heading-list '()))
     (if (used-date column-vector)
         (addto! heading-list (_ "Date")))
@@ -440,7 +454,7 @@
                                       (if (gnc:lookup-option options
                                                              gnc:pagename-display
                                                              (N_ "Trans Number"))
-                                          (gnc:option-value 
+                                          (gnc:option-value
                                            (gnc:lookup-option options
                                                               gnc:pagename-display
                                                               (N_ "Trans Number")))
@@ -457,55 +471,58 @@
         (addto! heading-list (_ "Account")))
     (if (or (used-other-account-name column-vector) (used-other-account-code column-vector))
         (addto! heading-list (_ "Transfer from/to")))
-    (if (used-shares column-vector)
-        (addto! heading-list (_ "Shares")))
-    (if (used-price column-vector)
-        (addto! heading-list (_ "Price")))
-    (if (used-amount-single column-vector)
-        (addto! heading-list (_ "Amount")))
+    ;(if (used-shares column-vector)
+    ;    (addto! heading-list (_ "Shares")))
+    ;(if (used-price column-vector)
+    ;    (addto! heading-list (_ "Price")))
+    ;(if (used-amount-single column-vector)
+    ;    (addto! heading-list (_ "Amount")))
     ;; FIXME: Proper labels: what?
     (if (used-amount-double-positive column-vector)
         (addto! heading-list (_ "Debit")))
     (if (used-amount-double-negative column-vector)
         (addto! heading-list (_ "Credit")))
-    (if (used-running-balance column-vector)
-        (addto! heading-list (_ "Balance")))
+
+    (for-each (lambda (arg)
+                (addto! heading-list
+                        (gnc:make-html-table-cell/markup
+                         "column-heading-right"
+                         (car arg))))
+              calculated-cells)
+
     (reverse heading-list)))
 
-(define (add-split-row table split column-vector options
+(define (add-split-row table split column-vector cell-calculators options
                        row-style account-types-to-reverse transaction-row?)
-  
   (define (opt-val section name)
-    (gnc:option-value 
+    (gnc:option-value
      (gnc:lookup-option options section name)))
-  
+
   (let* ((row-contents '())
          (dummy  (gnc:debug "split is originally" split))
          (parent (xaccSplitGetParent split))
          (account (xaccSplitGetAccount split))
          (account-type (xaccAccountGetType account))
-         (currency (if (not (null? account))
-                       (xaccAccountGetCommodity account)
-                       (gnc-default-currency)))
+         (currency (xaccTransGetCurrency parent))
+         ;the following cannot be used, because we're using each split's tax currency
+         ;(if (not (null? account))
+         ;             (xaccAccountGetCommodity account)
+         ;             (gnc-default-currency)))
          (report-currency (if (opt-val gnc:pagename-general optname-common-currency)
                               (opt-val gnc:pagename-general optname-currency)
                               currency))
-         (damount (if (gnc:split-voided? split)
-                      (xaccSplitVoidFormerAmount split)
-                      (xaccSplitGetAmount split)))
          (trans-date (gnc-transaction-get-date-posted parent))
-         (split-value (gnc:exchange-by-pricedb-nearest
-                       (gnc:make-gnc-monetary 
-                        currency
-                        (if (member account-type account-types-to-reverse) 
-                            (gnc-numeric-neg damount)
-                            damount))
+         (converted (lambda (num)
+                      (gnc:exchange-by-pricedb-nearest
+                       (gnc:make-gnc-monetary currency num)
                        report-currency
-                       ;; Use midday as the transaction time so it matches a price
-                       ;; on the same day.  Otherwise it uses midnight which will
-                       ;; likely match a price on the previous day
-                       (timespecCanonicalDayTime trans-date))))
-    
+                       (timespecCanonicalDayTime trans-date)))))
+
+    (define cells
+      (map (lambda (cell)
+             (converted ((cdr cell) split)))
+           cell-calculators))
+
     (if (used-date column-vector)
         (addto! row-contents
                 (if transaction-row?
@@ -541,84 +558,97 @@
                         (gnc:make-html-table-cell/markup "text-cell"
                                                          (gnc-get-num-action parent split)))
                     " ")))
-    
+
     (if (used-description column-vector)
         (addto! row-contents
                 (if transaction-row?
                     (gnc:make-html-table-cell/markup "text-cell"
                                                      (xaccTransGetDescription parent))
                     " ")))
-    
+
     (if (used-memo column-vector)
         (let ((memo (xaccSplitGetMemo split)))
           (if (and (equal? memo "") (used-notes column-vector))
               (addto! row-contents (xaccTransGetNotes parent))
               (addto! row-contents memo))))
-    
+
     (if (or (used-account-name column-vector) (used-account-code column-vector))
         (addto! row-contents (account-namestring account
                                                  (used-account-code      column-vector)
                                                  (used-account-name      column-vector)
                                                  (used-account-full-name column-vector))))
-    
+
     (if (or (used-other-account-name column-vector) (used-other-account-code column-vector))
         (addto! row-contents (account-namestring (xaccSplitGetAccount
                                                   (xaccSplitGetOtherSplit split))
                                                  (used-other-account-code      column-vector)
                                                  (used-other-account-name      column-vector)
                                                  (used-other-account-full-name column-vector))))
-    
-    (if (used-shares column-vector)
-        (addto! row-contents (xaccSplitGetAmount split)))
-    (if (used-price column-vector)
-        (addto! 
-         row-contents 
-         (gnc:make-gnc-monetary (xaccTransGetCurrency parent)
-                                (xaccSplitGetSharePrice split))))
-    (if (used-amount-single column-vector)
-        (addto! row-contents
-                (gnc:make-html-table-cell/markup "number-cell"
-                                                 (gnc:html-transaction-anchor parent split-value))))
-    (if (used-amount-double-positive column-vector)
-        (if (gnc-numeric-positive-p (gnc:gnc-monetary-amount split-value))
-            (addto! row-contents
-                    (gnc:make-html-table-cell/markup "number-cell"
-                                                     (gnc:html-transaction-anchor parent split-value)))
-            (addto! row-contents " ")))
-    (if (used-amount-double-negative column-vector)
-        (if (gnc-numeric-negative-p (gnc:gnc-monetary-amount split-value))
-            (addto! row-contents
-                    (gnc:make-html-table-cell/markup
-                     "number-cell" (gnc:html-transaction-anchor parent (gnc:monetary-neg split-value))))
-            (addto! row-contents " ")))
-    (if (used-running-balance column-vector)
-        (begin
-          (gnc:debug "split is " split)
-          (gnc:debug "split get balance:" (xaccSplitGetBalance split))
-          (addto! row-contents
-                  (gnc:make-html-table-cell/markup
-                   "number-cell"
-                   (gnc:make-gnc-monetary currency
-                                          (xaccSplitGetBalance split))))))
+
+    ;(if (used-shares column-vector)
+    ;    (addto! row-contents (xaccSplitGetAmount split)))
+    ;(if (used-price column-vector)
+    ;    (addto!
+    ;     row-contents
+    ;     (gnc:make-gnc-monetary (xaccTransGetCurrency parent)
+    ;                            (xaccSplitGetSharePrice split))))
+    ;(if (used-amount-single column-vector)
+    ;    (addto! row-contents
+    ;            (gnc:make-html-table-cell/markup "number-cell"
+    ;                                             (gnc:html-transaction-anchor parent split-value))))
+    ;(if (used-amount-double-positive column-vector)
+    ;    (if (gnc-numeric-positive-p (gnc:gnc-monetary-amount split-value))
+    ;        (addto! row-contents
+    ;                (gnc:make-html-table-cell/markup "number-cell"
+    ;                                                 (gnc:html-transaction-anchor parent split-value)))
+    ;        (addto! row-contents " ")))
+    ;(if (used-amount-double-negative column-vector)
+    ;    (if (gnc-numeric-negative-p (gnc:gnc-monetary-amount split-value))
+    ;        (addto! row-contents
+    ;                (gnc:make-html-table-cell/markup
+    ;                 "number-cell" (gnc:html-transaction-anchor parent (gnc:monetary-neg split-value))))
+    ;        (addto! row-contents " ")))
+
+    (for-each (lambda (cell)
+                (if cell
+                    (addto! row-contents
+                            (gnc:make-html-table-cell/markup
+                             "number-cell"
+                             (gnc:html-transaction-anchor
+                              parent
+                              (gnc:make-gnc-monetary report-currency cell))))
+                    (addto! row-contents (gnc:html-make-empty-cell))))
+              cells)
+
     (gnc:html-table-append-row/markup! table row-style
                                        (reverse row-contents))
-    split-value))
+    cells))
 
-
-(define date-sorting-types (list 'date 'exact-time 'register-order))
+(define date-sorting-types (list 'date 'register-order))
 
 (define (trep-options-generator)
   (define gnc:*transaction-report-options* (gnc:new-options))
   (define (gnc:register-trep-option new-option)
     (gnc:register-option gnc:*transaction-report-options* new-option))
-  
+
   ;; General options
-  
+
   (gnc:options-add-date-interval!
    gnc:*transaction-report-options*
    gnc:pagename-general (N_ "Start Date") (N_ "End Date") "a")
-  
-  
+
+  ;(gnc:register-trep-option
+  ; (gnc:make-multichoice-option
+  ;  gnc:pagename-general (N_ "Style")
+  ;  "d" (N_ "Report style.")
+  ;  'single
+  ;  (list (vector 'multi-line
+  ;                (N_ "Multi-Line")
+  ;                (N_ "Display N lines."))
+  ;        (vector 'single
+  ;                (N_ "Single")
+  ;                (N_ "Display 1 line.")))))
+
   (gnc:register-trep-option
    (gnc:make-complex-boolean-option
     gnc:pagename-general optname-common-currency
@@ -628,24 +658,24 @@
                  gnc:*transaction-report-options*
                  gnc:pagename-general
                  optname-currency
-                 x))
-    ))
-  
+                 x))))
+
   (gnc:options-add-currency!
    gnc:*transaction-report-options* gnc:pagename-general optname-currency "f")
-  
+
   (gnc:register-trep-option
    (gnc:make-simple-boolean-option
     gnc:pagename-general optname-table-export
-    "g" (N_ "Formats the table suitable for cut & paste exporting with extra cells.") #f))  
-  
+    "g" (N_ "Formats the table suitable for cut & paste exporting with extra cells.") #f))
+
   ;; Accounts options
-  
+
   ;; account to do report on
+
   (gnc:register-trep-option
-   (gnc:make-account-list-option
+   (gnc:make-account-list-limited-option
     gnc:pagename-accounts (N_ "Accounts")
-    "a" (N_ "Report on these accounts.")
+    "b1" (N_ "Report on these accounts.")
     ;; select, by default, no accounts! Selecting all accounts will
     ;; always imply an insanely long waiting time upon opening, and it
     ;; is almost never useful. So we instead display the normal error
@@ -653,20 +683,33 @@
     ;; continue.
     (lambda ()
       '())
-    #f #t))
-  
+    #f #t
+    (list ACCT-TYPE-INCOME ACCT-TYPE-EXPENSE ACCT-TYPE-PAYABLE ACCT-TYPE-RECEIVABLE)))
+
   (gnc:register-trep-option
    (gnc:make-string-option
     gnc:pagename-accounts (N_ "Account Substring")
-    "a5" (N_ "Match only above accounts whose fullname contains substring e.g. ':Travel' will \
+    "b15" (N_ "Match only above accounts whose fullname contains substring e.g. ':Travel' will \
 match Expenses:Travel:Holiday and Expenses:Business:Travel. Can be left blank, which will \
 disable the substring filter. This filter is case-sensitive.")
     ""))
-  
+
+  (gnc:register-trep-option
+   (gnc:make-account-list-limited-option
+    gnc:pagename-accounts (N_ "Tax Accounts")
+    "b17" (N_ "Please find and select the accounts which will hold the tax collected or paid. \
+These accounts must contain splits which document the monies which are wholly sent or claimed \
+from tax authorities during periodic GST/VAT returns. These accounts must be of type ASSET \
+for taxes paid on expenses, and type LIABILITY for taxes collected on sales.")
+    (lambda ()
+      '())
+    #f #t
+    (list ACCT-TYPE-ASSET ACCT-TYPE-LIABILITY)))
+
   (gnc:register-trep-option
    (gnc:make-account-list-option
     gnc:pagename-accounts (N_ "Filter By...")
-    "b" (N_ "Filter on these accounts.")
+    "b2" (N_ "Filter on these accounts.")
     (lambda ()
       ;; FIXME : gnc:get-current-accounts disappeared.
       (let* ((current-accounts '())
@@ -678,7 +721,7 @@ disable the substring filter. This filter is case-sensitive.")
               ((> num-accounts 0) (list first-account))
               (else '()))))
     #f #t))
-  
+
   (gnc:register-trep-option
    (gnc:make-multichoice-option
     gnc:pagename-accounts (N_ "Filter Type")
@@ -694,9 +737,9 @@ disable the substring filter. This filter is case-sensitive.")
                   (N_ "Exclude Transactions to/from Filter Accounts")
                   (N_ "Exclude transactions to/from all filter accounts."))
           )))
-  
+
   ;;
-  
+
   (gnc:register-trep-option
    (gnc:make-multichoice-option
     gnc:pagename-accounts optname-void-transactions
@@ -710,125 +753,117 @@ disable the substring filter. This filter is case-sensitive.")
            'void-only
            (N_ "Void only")
            (N_ "Show only voided transactions."))
-          (vector 
+          (vector
            'both
            (N_ "Both")
            (N_ "Show both (and include void transactions in totals).")))))
-  
+
   ;; Sorting options
-  
+
   (let ((options gnc:*transaction-report-options*)
-        
-        (key-choice-list 
+
+        (key-choice-list
          (if (qof-book-use-split-action-for-num-field (gnc-get-current-book))
              (list (vector 'none
                            (N_ "None")
                            (N_ "Do not sort."))
-                   
+
                    (vector 'account-name
                            (N_ "Account Name")
                            (N_ "Sort & subtotal by account name."))
-                   
+
                    (vector 'account-code
                            (N_ "Account Code")
                            (N_ "Sort & subtotal by account code."))
-                   
+
                    (vector 'date
                            (N_ "Date")
                            (N_ "Sort by date."))
-                   
-                   (vector 'exact-time
-                           (N_ "Exact Time")
-                           (N_ "Sort by exact time."))
-                   
+
                    (vector 'reconciled-date
                            (N_ "Reconciled Date")
                            (N_ "Sort by the Reconciled Date."))
-                   
+
                    (vector 'register-order
                            (N_ "Register Order")
                            (N_ "Sort as in the register."))
-                   
-                   (vector 'corresponding-acc-name 
+
+                   (vector 'corresponding-acc-name
                            (N_ "Other Account Name")
                            (N_ "Sort by account transferred from/to's name."))
-                   
+
                    (vector 'corresponding-acc-code
                            (N_ "Other Account Code")
                            (N_ "Sort by account transferred from/to's code."))
-                   
+
                    (vector 'amount
                            (N_ "Amount")
                            (N_ "Sort by amount."))
-                   
+
                    (vector 'description
                            (N_ "Description")
                            (N_ "Sort by description."))
-                   
+
                    (vector 'number
                            (N_ "Number/Action")
                            (N_ "Sort by check number/action."))
-                   
+
                    (vector 't-number
                            (N_ "Transaction Number")
                            (N_ "Sort by transaction number."))
-                   
+
                    (vector 'memo
                            (N_ "Memo")
                            (N_ "Sort by memo.")))
              (list (vector 'none
                            (N_ "None")
                            (N_ "Do not sort."))
-                   
+
                    (vector 'account-name
                            (N_ "Account Name")
                            (N_ "Sort & subtotal by account name."))
-                   
+
                    (vector 'account-code
                            (N_ "Account Code")
                            (N_ "Sort & subtotal by account code."))
-                   
+
                    (vector 'date
                            (N_ "Date")
                            (N_ "Sort by date."))
-                   
-                   (vector 'exact-time
-                           (N_ "Exact Time")
-                           (N_ "Sort by exact time."))
-                   
+
                    (vector 'reconciled-date
                            (N_ "Reconciled Date")
                            (N_ "Sort by the Reconciled Date."))
-                   
+
                    (vector 'register-order
                            (N_ "Register Order")
                            (N_ "Sort as in the register."))
-                   
-                   (vector 'corresponding-acc-name 
+
+                   (vector 'corresponding-acc-name
                            (N_ "Other Account Name")
                            (N_ "Sort by account transferred from/to's name."))
-                   
+
                    (vector 'corresponding-acc-code
                            (N_ "Other Account Code")
                            (N_ "Sort by account transferred from/to's code."))
-                   
+
                    (vector 'amount
                            (N_ "Amount")
                            (N_ "Sort by amount."))
-                   
+
                    (vector 'description
                            (N_ "Description")
                            (N_ "Sort by description."))
-                   
+
                    (vector 'number
                            (N_ "Number")
                            (N_ "Sort by check/transaction number."))
-                   
+
                    (vector 'memo
                            (N_ "Memo")
                            (N_ "Sort by memo.")))))
-        
-        (ascending-choice-list 
+
+        (ascending-choice-list
          (list
           (vector 'ascend
                   (N_ "Ascending")
@@ -836,7 +871,7 @@ disable the substring filter. This filter is case-sensitive.")
           (vector 'descend
                   (N_ "Descending")
                   (N_ "Largest to smallest, latest to earliest."))))
-        
+
         (subtotal-choice-list
          (list
           (vector 'none (N_ "None") (N_ "None."))
@@ -844,12 +879,12 @@ disable the substring filter. This filter is case-sensitive.")
           (vector 'monthly (N_ "Monthly") (N_ "Monthly."))
           (vector 'quarterly (N_ "Quarterly") (N_ "Quarterly."))
           (vector 'yearly (N_ "Yearly") (N_ "Yearly."))))
-        
+
         (prime-sortkey 'account-name)
         (prime-sortkey-subtotal-true #t)
         (sec-sortkey 'register-order)
         (sec-sortkey-subtotal-true #f))
-    
+
     (define (apply-selectable-by-name-sorting-options)
       (let* ((prime-sortkey-enabled (not (eq? prime-sortkey 'none)))
              (prime-sortkey-subtotal-enabled (member prime-sortkey subtotal-enabled))
@@ -857,41 +892,41 @@ disable the substring filter. This filter is case-sensitive.")
              (sec-sortkey-enabled (not (eq? sec-sortkey 'none)))
              (sec-sortkey-subtotal-enabled (member sec-sortkey subtotal-enabled))
              (sec-date-sortingtype-enabled (member sec-sortkey date-sorting-types)))
-        
+
         (gnc-option-db-set-option-selectable-by-name
          options pagename-sorting optname-prime-subtotal
          prime-sortkey-subtotal-enabled)
-        
+
         (gnc-option-db-set-option-selectable-by-name
          options pagename-sorting optname-prime-sortorder
          prime-sortkey-enabled)
-        
+
         (gnc-option-db-set-option-selectable-by-name
          options pagename-sorting optname-sec-subtotal
          sec-sortkey-subtotal-enabled)
-        
+
         (gnc-option-db-set-option-selectable-by-name
          options pagename-sorting optname-sec-sortorder
          sec-sortkey-enabled)
-        
+
         (gnc-option-db-set-option-selectable-by-name
          options pagename-sorting optname-full-account-name
          (or (and prime-sortkey-subtotal-enabled prime-sortkey-subtotal-true)
              (and sec-sortkey-subtotal-enabled sec-sortkey-subtotal-true)))
-        
+
         (gnc-option-db-set-option-selectable-by-name
          options pagename-sorting optname-show-account-code
          (or (and prime-sortkey-subtotal-enabled prime-sortkey-subtotal-true)
              (and sec-sortkey-subtotal-enabled sec-sortkey-subtotal-true)))
-        
+
         (gnc-option-db-set-option-selectable-by-name
          options pagename-sorting optname-prime-date-subtotal
          prime-date-sortingtype-enabled)
-        
+
         (gnc-option-db-set-option-selectable-by-name
          options pagename-sorting optname-sec-date-subtotal
          sec-date-sortingtype-enabled)))
-    
+
     ;; primary sorting criterion
     (gnc:register-trep-option
      (gnc:make-multichoice-callback-option
@@ -902,21 +937,21 @@ disable the substring filter. This filter is case-sensitive.")
       (lambda (x)
         (set! prime-sortkey x)
         (apply-selectable-by-name-sorting-options))))
-    
+
     (gnc:register-trep-option
      (gnc:make-simple-boolean-option
       pagename-sorting optname-full-account-name
       "j1"
       (N_ "Show the full account name for subtotals and subtitles?")
       #f))
-    
+
     (gnc:register-trep-option
      (gnc:make-simple-boolean-option
       pagename-sorting optname-show-account-code
       "j2"
       (N_ "Show the account code for subtotals and subtitles?")
       #f))
-    
+
     (gnc:register-trep-option
      (gnc:make-complex-boolean-option
       pagename-sorting optname-prime-subtotal
@@ -926,21 +961,21 @@ disable the substring filter. This filter is case-sensitive.")
       (lambda (x)
         (set! prime-sortkey-subtotal-true x)
         (apply-selectable-by-name-sorting-options))))
-    
+
     (gnc:register-trep-option
      (gnc:make-multichoice-option
       pagename-sorting optname-prime-date-subtotal
       "e2" (N_ "Do a date subtotal.")
       'monthly
       subtotal-choice-list))
-    
+
     (gnc:register-trep-option
      (gnc:make-multichoice-option
       pagename-sorting optname-prime-sortorder
       "e" (N_ "Order of primary sorting.")
       'ascend
       ascending-choice-list))
-    
+
     ;; Secondary sorting criterion
     (gnc:register-trep-option
      (gnc:make-multichoice-callback-option
@@ -952,7 +987,7 @@ disable the substring filter. This filter is case-sensitive.")
       (lambda (x)
         (set! sec-sortkey x)
         (apply-selectable-by-name-sorting-options))))
-    
+
     (gnc:register-trep-option
      (gnc:make-complex-boolean-option
       pagename-sorting optname-sec-subtotal
@@ -962,157 +997,125 @@ disable the substring filter. This filter is case-sensitive.")
       (lambda (x)
         (set! sec-sortkey-subtotal-true x)
         (apply-selectable-by-name-sorting-options))))
-    
+
     (gnc:register-trep-option
      (gnc:make-multichoice-option
       pagename-sorting optname-sec-date-subtotal
       "i2" (N_ "Do a date subtotal.")
-      'monthly
+      'none
       subtotal-choice-list))
-    
+
     (gnc:register-trep-option
      (gnc:make-multichoice-option
       pagename-sorting optname-sec-sortorder
       "i" (N_ "Order of Secondary sorting.")
       'ascend
       ascending-choice-list)))
-  
+
   ;; Display options
-  
-  (let ((options gnc:*transaction-report-options*)
-        (disp-memo? #t)
-        (disp-accname? #t)
-        (disp-other-accname? #f)
-        (is-single? #t))
-    
-    (define (apply-selectable-by-name-display-options)
-      (gnc-option-db-set-option-selectable-by-name
-       options gnc:pagename-display (N_ "Use Full Account Name")
-       disp-accname?)
-      
-      (gnc-option-db-set-option-selectable-by-name
-       options gnc:pagename-display (N_ "Other Account Name")
-       is-single?)
-      
-      (gnc-option-db-set-option-selectable-by-name
-       options gnc:pagename-display (N_ "Use Full Other Account Name")
-       (and disp-other-accname? is-single?))
-      
-      (gnc-option-db-set-option-selectable-by-name
-       options gnc:pagename-display (N_ "Other Account Code")
-       is-single?)
-      
-      (gnc-option-db-set-option-selectable-by-name
-       options gnc:pagename-display (N_ "Notes")
-       disp-memo?))
-    
-    (for-each
-     (lambda (l)
-       (gnc:register-trep-option
-        (gnc:make-simple-boolean-option
-         gnc:pagename-display (car l) (cadr l) (caddr l) (cadddr l))))
-     ;; One list per option here with: option-name, sort-tag,
-     ;; help-string, default-value
-     (list
-      (list (N_ "Date")                         "a"  (N_ "Display the date?") #t)
-      (list (N_ "Reconciled Date")              "a2" (N_ "Display the reconciled date?") #f)
-      (if (qof-book-use-split-action-for-num-field (gnc-get-current-book))
-          (list (N_ "Num/Action")               "b"  (N_ "Display the check number?") #t)
-          (list (N_ "Num")                      "b"  (N_ "Display the check number?") #t))
-      (list (N_ "Description")                  "c"  (N_ "Display the description?") #t)
-      (list (N_ "Notes")                        "d2" (N_ "Display the notes if the memo is unavailable?") #t)
-      ;; account name option appears here
-      (list (N_ "Use Full Account Name")        "f"  (N_ "Display the full account name?") #t)
-      (list (N_ "Account Code")                 "g"  (N_ "Display the account code?") #f)
-      ;; other account name option appears here
-      (list (N_ "Use Full Other Account Name")  "i"  (N_ "Display the full account name?") #f)
-      (list (N_ "Other Account Code")           "j"  (N_ "Display the other account code?") #f)
-      (list (N_ "Shares")                       "k"  (N_ "Display the number of shares?") #f)
-      (list (N_ "Price")                        "l"  (N_ "Display the shares price?") #f)
-      ;; note the "Amount" multichoice option in between here
-      (list (N_ "Running Balance")              "n"  (N_ "Display a running balance?") #f)
-      (list (N_ "Totals")                       "o"  (N_ "Display the totals?") #t)))
-    
+
+  (for-each
+   (lambda (l)
+     (gnc:register-trep-option
+      (gnc:make-simple-boolean-option
+       gnc:pagename-display (car l) (cadr l) (caddr l) (cadddr l))))
+   ;; One list per option here with: option-name, sort-tag,
+   ;; help-string, default-value
+   (list
+    (list (N_ "Date")                         "a"  (N_ "Display the date?") #t)
+    (list (N_ "Reconciled Date")              "a2" (N_ "Display the reconciled date?") #f)
     (if (qof-book-use-split-action-for-num-field (gnc-get-current-book))
-        (gnc:register-trep-option
-         (gnc:make-simple-boolean-option
-          gnc:pagename-display (N_ "Trans Number")
-          "b2" (N_ "Display the trans number?") #f)))
-    
-    ;; Add an option to display the memo, and disable the notes option
-    ;; when memos are not included.
-    (gnc:register-trep-option
-     (gnc:make-complex-boolean-option
-      gnc:pagename-display (N_ "Memo")
-      "d"  (N_ "Display the memo?") #t
-      #f
-      (lambda (x)
-        (set! disp-memo? x)
-        (apply-selectable-by-name-display-options))))
-    
-    ;; Ditto for Account Name #t -> Use Full Account Name is selectable
-    (gnc:register-trep-option
-     (gnc:make-complex-boolean-option
-      gnc:pagename-display (N_ "Account Name")
-      "e"  (N_ "Display the account name?") #t
-      #f
-      (lambda (x)
-        (set! disp-accname? x)
-        (apply-selectable-by-name-display-options))))
-    
-    ;; Ditto for Other Account Name #t -> Use Full Other Account Name is selectable
-    (gnc:register-trep-option
-     (gnc:make-complex-boolean-option
-      gnc:pagename-display (N_ "Other Account Name")
-      "h5"  (N_ "Display the other account name? (if this is a split transaction, this parameter is guessed).") #f
-      #f
-      (lambda (x)
-        (set! disp-other-accname? x)
-        (apply-selectable-by-name-display-options))))
-    
-    (gnc:register-trep-option
-     (gnc:make-multichoice-callback-option
-      gnc:pagename-display optname-detail-level
-      "h" (N_ "Amount of detail to display per transaction.")
-      'single
-      (list (vector 'multi-line
-                    (N_ "Multi-Line")
-                    (N_ "Display all splits in a transaction on a separate line."))
-            (vector 'single
-                    (N_ "Single")
-                    (N_ "Display one line per transaction, merging multiple splits where required.")))
-      #f
-      (lambda (x)
-        (set! is-single? (eq? x 'single))
-        (apply-selectable-by-name-display-options))))
-    
-    (gnc:register-trep-option
-     (gnc:make-multichoice-option
-      gnc:pagename-display (N_ "Amount")
-      "m" (N_ "Display the amount?")  
-      'single
-      (list
-       (vector 'none (N_ "None") (N_ "No amount display."))
-       (vector 'single (N_ "Single") (N_ "Single Column Display."))
-       (vector 'double (N_ "Double") (N_ "Two Column Display.")))))
-    
-    (gnc:register-trep-option
-     (gnc:make-multichoice-option
-      gnc:pagename-display (N_ "Sign Reverses")
-      "p" (N_ "Reverse amount display for certain account types.")
-      'credit-accounts
-      (list 
-       (vector 'none (N_ "None") (N_ "Don't change any displayed amounts."))
-       (vector 'income-expense (N_ "Income and Expense")
-               (N_ "Reverse amount display for Income and Expense Accounts."))
-       (vector 'credit-accounts (N_ "Credit Accounts")
-               (N_ "Reverse amount display for Liability, Payable, Equity, \
-Credit Card, and Income accounts."))))))
-  
-  
+        (list (N_ "Num/Action")               "b"  (N_ "Display the check number?") #t)
+        (list (N_ "Num")                      "b"  (N_ "Display the check number?") #t))
+    (list (N_ "Description")                  "c"  (N_ "Display the description?") #t)
+    (list (N_ "Notes")                        "d2" (N_ "Display the notes if the memo is unavailable?") #t)
+    ;; account name option appears here
+    (list (N_ "Use Full Account Name")        "f"  (N_ "Display the full account name?") #t)
+    (list (N_ "Account Code")                 "g"  (N_ "Display the account code?") #f)
+    ;; other account name option appears here
+    (list (N_ "Use Full Other Account Name")  "i"  (N_ "Display the full account name?") #f)
+    (list (N_ "Other Account Code")           "j"  (N_ "Display the other account code?") #f)
+    ;(list (N_ "Shares")                       "k"  (N_ "Display the number of shares?") #f)
+    ;(list (N_ "Price")                        "l"  (N_ "Display the shares price?") #f)
+    ;; note the "Amount" multichoice option in between here
+    (list (N_ "Totals")                       "o"  (N_ "Display the totals?") #t)
+    (list (N_ "Individual income columns")    "p" (N_ "Display individual income columns rather than their sum") #f)
+    (list (N_ "Individual expense columns")   "q" (N_ "Display individual expense columns rather than their sum") #f)
+    (list (N_ "Individual tax columns")       "r"  (N_ "Display individual tax columns rather than their sum") #f)
+    (list (N_ "Remittance amount")            "s"  (N_ "Display the remittance amount (total sales - total purchases)") #f)
+    (list (N_ "Net Income")                   "t"  (N_ "Display the net income (sales without tax - purchases without tax)") #f)
+    (list (N_ "Tax payable")                  "t"  (N_ "Display the tax payable (tax on sales - tax on purchases)") #f)
+    ))
+
+  (if (qof-book-use-split-action-for-num-field (gnc-get-current-book))
+      (gnc:register-trep-option
+       (gnc:make-simple-boolean-option
+        gnc:pagename-display (N_ "Trans Number")
+        "b2" (N_ "Display the trans number?") #f)))
+
+  ;; Add an option to display the memo, and disable the notes option
+  ;; when memos are not included.
+  (gnc:register-trep-option
+   (gnc:make-complex-boolean-option
+    gnc:pagename-display (N_ "Memo")
+    "d"  (N_ "Display the memo?") #t
+    #f
+    (lambda (x) (gnc-option-db-set-option-selectable-by-name
+                 gnc:*transaction-report-options*
+                 gnc:pagename-display
+                 (N_ "Notes")
+                 x))))
+
+  ;; Ditto for Account Name #t -> Use Full Account Name is selectable
+  (gnc:register-trep-option
+   (gnc:make-complex-boolean-option
+    gnc:pagename-display (N_ "Account Name")
+    "e"  (N_ "Display the account name?") #t
+    #f
+    (lambda (x) (gnc-option-db-set-option-selectable-by-name
+                 gnc:*transaction-report-options*
+                 gnc:pagename-display
+                 (N_ "Use Full Account Name")
+                 x))))
+
+  ;; Ditto for Other Account Name #t -> Use Full Other Account Name is selectable
+  (gnc:register-trep-option
+   (gnc:make-complex-boolean-option
+    gnc:pagename-display (N_ "Other Account Name")
+    "h5"  (N_ "Display the other account name? (if this is a split transaction, this parameter is guessed).") #f
+    #f
+    (lambda (x) (gnc-option-db-set-option-selectable-by-name
+                 gnc:*transaction-report-options*
+                 gnc:pagename-display
+                 (N_ "Use Full Other Account Name")
+                 x))))
+
+  ;(gnc:register-trep-option
+  ; (gnc:make-multichoice-option
+  ;  gnc:pagename-display (N_ "Amount")
+  ;  "m" (N_ "Display the amount?")
+  ;  'single
+  ;  (list
+  ;   (vector 'none (N_ "None") (N_ "No amount display."))
+  ;   (vector 'single (N_ "Single") (N_ "Single Column Display."))
+  ;   (vector 'double (N_ "Double") (N_ "Two Column Display."))
+  ;   )))
+
+  ;(gnc:register-trep-option
+  ; (gnc:make-multichoice-option
+  ;  gnc:pagename-display (N_ "Sign Reverses")
+  ;  "p" (N_ "Reverse amount display for certain account types.")
+  ;  'none
+  ;  (list
+  ;   (vector 'none (N_ "None") (N_ "Don't change any displayed amounts."))
+  ;   (vector 'income-expense (N_ "Income and Expense")
+  ;           (N_ "Reverse amount display for Income and Expense Accounts."))
+  ;   (vector 'credit-accounts (N_ "Credit Accounts")
+  ;           (N_ "Reverse amount display for Liability, Payable, Equity, Credit Card, and Income accounts.")))))
+
   (gnc:options-set-default-section gnc:*transaction-report-options*
                                    gnc:pagename-general)
-  
+
   gnc:*transaction-report-options*)
 
 
@@ -1122,7 +1125,7 @@ Credit Card, and Income accounts."))))))
     (sprintf #f (_ "From %s To %s") begin-string end-string)))
 
 (define (get-primary-subtotal-style options)
-  (let ((bgcolor (gnc:lookup-option options 
+  (let ((bgcolor (gnc:lookup-option options
                                     (N_ "Colors")
                                     (N_ "Primary Subtotals/headings"))))
     (list 'attribute (list "bgcolor" (gnc:color-option->html bgcolor)))))
@@ -1155,34 +1158,105 @@ Credit Card, and Income accounts."))))))
 ;; ;;;;;;;;;;;;;;;;;;;;
 ;; Here comes the big function that builds the whole table.
 (define (make-split-table splits options
+                          accounts-tax-paid
+                          accounts-tax-collected
+                          accounts-sales
+                          accounts-purchases
                           primary-subtotal-pred
                           secondary-subtotal-pred
                           primary-subheading-renderer
                           secondary-subheading-renderer
                           primary-subtotal-renderer
                           secondary-subtotal-renderer)
-  
+
   (let ((work-to-do (length splits))
         (work-done 0)
         (used-columns (build-column-used options)))
-    (define (get-account-types-to-reverse options)
-      (cdr (assq (gnc:option-value 
-                  (gnc:lookup-option options
-                                     gnc:pagename-display
-                                     (N_ "Sign Reverses")))
-                 account-types-to-reverse-assoc-list)))
-    
-    
-    (define (transaction-report-multi-rows-p options)
-      (eq? (gnc:option-value
-            (gnc:lookup-option options gnc:pagename-display optname-detail-level))
-           'multi-line))
-    
+
+    (define calculated-cells
+      (letrec
+          ((myadd (lambda (X Y) (if X (if Y (gnc-numeric-add X Y GNC-DENOM-AUTO GNC-RND-ROUND) X) Y)))
+           (myneg (lambda (X) (if X (gnc-numeric-neg X) #f)))
+           (split-adder (lambda (split accountlist typefilter)
+                          (let* ((transaction (xaccSplitGetParent split))
+                                 (splits-in-transaction (xaccTransGetSplitList transaction))
+                                 (sum #f))
+                            (for-each (lambda (s)
+                                        (let* ((splitAcc (xaccSplitGetAccount s))
+                                               (splitVal (if (xaccTransGetVoidStatus transaction)
+                                                             (xaccSplitVoidFormerValue s)
+                                                             (xaccSplitGetValue s)))
+                                               (splitCommodity (xaccAccountGetCommodity splitAcc))
+                                               (splitAccType (xaccAccountGetType splitAcc))
+                                               (splitAccName (xaccAccountGetName splitAcc)))
+                                          (if accountlist
+                                              (if (member splitAcc accountlist)
+                                                  (set! sum (myadd sum splitVal))))
+                                          (if typefilter
+                                              (if (eq? typefilter splitAccType)
+                                                  (set! sum (myadd sum splitVal))))))
+                                      splits-in-transaction)
+                            sum)))
+           ;(sales-without-tax (lambda (s) (split-adder s #f ACCT-TYPE-INCOME)))
+           ;(purchases-without-tax (lambda (s) (split-adder s #f ACCT-TYPE-EXPENSE)))
+           (tax-on-sales (lambda (s) (split-adder s accounts-tax-collected #f)))
+           (tax-on-purchases (lambda (s) (split-adder s accounts-tax-paid #f)))
+           (sales-without-tax (lambda (s) (split-adder s accounts-sales #f)))
+           (purchases-without-tax (lambda (s) (split-adder s accounts-purchases #f)))
+           (account-adder (lambda (acc) (lambda (s) (split-adder s (list acc) #f))))
+           (total-sales (lambda (s) (myadd (tax-on-sales s) (sales-without-tax s))))
+           (total-purchases (lambda (s) (myadd (tax-on-purchases s) (purchases-without-tax s))))
+           (bank-remittance (lambda (s) (myneg (myadd (total-sales s) (total-purchases s)))))
+           (net-income (lambda (s) (myneg (myadd (sales-without-tax s) (purchases-without-tax s)))))
+           (tax-payable (lambda (s) (myneg (myadd (tax-on-purchases s) (tax-on-sales s))))))
+        (append
+         (list (cons "Total Sales" total-sales))
+         (if (gnc:option-value (gnc:lookup-option options gnc:pagename-display (N_ "Individual income columns")))
+             (map (lambda (acc) (cons (xaccAccountGetName acc) (account-adder acc)))
+                  accounts-sales)
+             (list (cons "Net Sales" sales-without-tax)))
+         (if (gnc:option-value (gnc:lookup-option options gnc:pagename-display (N_ "Individual tax columns")))
+             (map (lambda (acc) (cons (xaccAccountGetName acc) (account-adder acc)))
+                  accounts-tax-collected)
+             (list (cons "Tax on Sales" tax-on-sales)))
+         (list (cons "Total Purchases" total-purchases))
+         (if (gnc:option-value (gnc:lookup-option options gnc:pagename-display (N_ "Individual expense columns")))
+             (map (lambda (acc) (cons (xaccAccountGetName acc) (account-adder acc)))
+                  accounts-purchases)
+             (list (cons "Net Purchases" purchases-without-tax)))
+         (if (gnc:option-value (gnc:lookup-option options gnc:pagename-display (N_ "Individual tax columns")))
+             (map (lambda (acc) (cons (xaccAccountGetName acc) (account-adder acc)))
+                  accounts-tax-paid)
+             (list (cons "Tax on Purchases" tax-on-purchases)))
+         (if (gnc:option-value (gnc:lookup-option options gnc:pagename-display (N_ "Remittance amount")))
+             (list (cons "Remittance" bank-remittance))
+             '())
+         (if (gnc:option-value (gnc:lookup-option options gnc:pagename-display (N_ "Net Income")))
+             (list (cons "Net Income" net-income))
+             '())
+         (if (gnc:option-value (gnc:lookup-option options gnc:pagename-display (N_ "Tax payable")))
+             (list (cons "Tax Payable" tax-payable))
+             '())
+         )))
+
+
+    ;(define (get-account-types-to-reverse options)
+    ;  (cdr (assq (gnc:option-value
+    ;              (gnc:lookup-option options
+    ;                                 gnc:pagename-display
+    ;                                 (N_ "Sign Reverses")))
+    ;             account-types-to-reverse-assoc-list)))
+
+    ;(define (transaction-report-multi-rows-p options)
+    ;  (eq? (gnc:option-value
+    ;        (gnc:lookup-option options gnc:pagename-general (N_ "Style")))
+    ;       'multi-line))
+
     (define (transaction-report-export-p options)
       (gnc:option-value
        (gnc:lookup-option options gnc:pagename-general
                           optname-table-export)))
-    
+
     (define (add-other-split-rows split table used-columns
                                   row-style account-types-to-reverse)
       (define (other-rows-driver split parent table used-columns i)
@@ -1191,16 +1265,16 @@ Credit Card, and Income accounts."))))))
                 ((equal? current split)
                  (other-rows-driver split parent table used-columns (+ i 1)))
                 (else (begin
-                        (add-split-row table current used-columns options
+                        (add-split-row table current used-columns calculated-cells options
                                        row-style account-types-to-reverse #f)
                         (other-rows-driver split parent table used-columns
                                            (+ i 1)))))))
-      
+
       (other-rows-driver split (xaccSplitGetParent split)
                          table used-columns 0))
-    
-    (define (do-rows-with-subtotals splits 
-                                    table 
+
+    (define (do-rows-with-subtotals splits
+                                    table
                                     used-columns
                                     width
                                     multi-rows?
@@ -1208,15 +1282,15 @@ Credit Card, and Income accounts."))))))
                                     export?
                                     account-types-to-reverse
                                     primary-subtotal-pred
-                                    secondary-subtotal-pred 
+                                    secondary-subtotal-pred
                                     primary-subheading-renderer
                                     secondary-subheading-renderer
                                     primary-subtotal-renderer
                                     secondary-subtotal-renderer
-                                    primary-subtotal-collector 
-                                    secondary-subtotal-collector 
-                                    total-collector)
-      
+                                    primary-subtotal-collectors
+                                    secondary-subtotal-collectors
+                                    total-collectors)
+
       (gnc:report-percent-done (* 100 (/ work-done work-to-do)))
       (set! work-done (+ 1 work-done))
       (if (null? splits)
@@ -1228,74 +1302,79 @@ Credit Card, and Income accounts."))))))
               (gnc:make-html-table-cell/size
                1 width (gnc:make-html-text (gnc:html-markup-hr)))))
             (if (gnc:option-value (gnc:lookup-option options "Display" "Totals"))
-                (render-grand-total table width total-collector export?)))
-          
+                (render-grand-total table width total-collectors export?)))
+
           (let* ((current (car splits))
                  (current-row-style (if multi-rows? def:normal-row-style
-                                        (if odd-row? def:normal-row-style 
+                                        (if odd-row? def:normal-row-style
                                             def:alternate-row-style)))
                  (rest (cdr splits))
                  (next (if (null? rest) #f
                            (car rest)))
-                 (split-value (add-split-row 
-                               table 
-                               current 
-                               used-columns
-                               options
-                               current-row-style
-                               account-types-to-reverse
-                               #t)))
+                 (split-values (add-split-row
+                                table
+                                current
+                                used-columns
+                                calculated-cells
+                                options
+                                current-row-style
+                                account-types-to-reverse
+                                #t)))
             (if multi-rows?
                 (add-other-split-rows
                  current table used-columns def:alternate-row-style
                  account-types-to-reverse))
-            
-            (primary-subtotal-collector 'add 
-                                        (gnc:gnc-monetary-commodity
-                                         split-value) 
-                                        (gnc:gnc-monetary-amount
-                                         split-value))
-            (secondary-subtotal-collector 'add
-                                          (gnc:gnc-monetary-commodity
-                                           split-value)
-                                          (gnc:gnc-monetary-amount
-                                           split-value))
-            (total-collector 'add
-                             (gnc:gnc-monetary-commodity split-value)
-                             (gnc:gnc-monetary-amount split-value))
-            
+
+            (map (lambda (collector value)
+                   (if value
+                       (collector 'add (gnc:gnc-monetary-commodity value) (gnc:gnc-monetary-amount value))))
+                 primary-subtotal-collectors
+                 split-values)
+
+            (map (lambda (collector value)
+                   (if value
+                       (collector 'add (gnc:gnc-monetary-commodity value) (gnc:gnc-monetary-amount value))))
+                 secondary-subtotal-collectors
+                 split-values)
+
+            (map (lambda (collector value)
+                   (if value
+                       (collector 'add (gnc:gnc-monetary-commodity value) (gnc:gnc-monetary-amount value))))
+                 total-collectors
+                 split-values)
+
             (if (and primary-subtotal-pred
                      (or (not next)
                          (and next
                               (not (primary-subtotal-pred current next)))))
-                (begin 
+                (begin
                   (if secondary-subtotal-pred
-                      
                       (begin
                         (secondary-subtotal-renderer
                          table width current
-                         secondary-subtotal-collector
+                         secondary-subtotal-collectors
                          def:secondary-subtotal-style used-columns export?)
-                        (secondary-subtotal-collector 'reset #f #f)))
-                  
+                        (for-each (lambda (coll) (coll 'reset #f #f))
+                                  secondary-subtotal-collectors)))
+
                   (primary-subtotal-renderer table width current
-                                             primary-subtotal-collector
+                                             primary-subtotal-collectors
                                              def:primary-subtotal-style used-columns
                                              export?)
-                  
-                  (primary-subtotal-collector 'reset #f #f)
-                  
+
+                  (for-each (lambda (coll) (coll 'reset #f #f))
+                            primary-subtotal-collectors)
+
                   (if next
-                      (begin 
+                      (begin
                         (primary-subheading-renderer
                          next table width def:primary-subtotal-style used-columns)
-                        
                         (if secondary-subtotal-pred
                             (secondary-subheading-renderer
-                             next 
-                             table 
+                             next
+                             table
                              width def:secondary-subtotal-style used-columns)))))
-                
+
                 (if (and secondary-subtotal-pred
                          (or (not next)
                              (and next
@@ -1303,52 +1382,52 @@ Credit Card, and Income accounts."))))))
                                         current next)))))
                     (begin (secondary-subtotal-renderer
                             table width current
-                            secondary-subtotal-collector
+                            secondary-subtotal-collectors
                             def:secondary-subtotal-style used-columns export?)
-                           (secondary-subtotal-collector 'reset #f #f)
+                           (for-each (lambda (coll) (coll 'reset #f #f))
+                                     secondary-subtotal-collectors)
                            (if next
                                (secondary-subheading-renderer
                                 next table width
                                 def:secondary-subtotal-style used-columns)))))
-            
-            (do-rows-with-subtotals rest 
-                                    table 
+
+            (do-rows-with-subtotals rest
+                                    table
                                     used-columns
-                                    width 
+                                    width
                                     multi-rows?
                                     (not odd-row?)
                                     export?
                                     account-types-to-reverse
-                                    primary-subtotal-pred 
+                                    primary-subtotal-pred
                                     secondary-subtotal-pred
-                                    primary-subheading-renderer 
+                                    primary-subheading-renderer
                                     secondary-subheading-renderer
                                     primary-subtotal-renderer
                                     secondary-subtotal-renderer
-                                    primary-subtotal-collector 
-                                    secondary-subtotal-collector 
-                                    total-collector))))
-    
+                                    primary-subtotal-collectors
+                                    secondary-subtotal-collectors
+                                    total-collectors))))
+
     (let* ((table (gnc:make-html-table))
            (width (num-columns-required used-columns))
-           (multi-rows? (transaction-report-multi-rows-p options))
-           (export? (transaction-report-export-p options))
-           (account-types-to-reverse
-            (get-account-types-to-reverse options)))
-      
+           (multi-rows? #f) ;disable. (transaction-report-multi-rows-p options))
+           (export?  (transaction-report-export-p options))
+           (account-types-to-reverse '())) ;disabled.            (get-account-types-to-reverse '()))options)))
+
       (gnc:html-table-set-col-headers!
        table
-       (make-heading-list used-columns options))
-      ;;     (gnc:warn "Splits:" splits)
+       (make-heading-list used-columns calculated-cells options))
+
       (if (not (null? splits))
           (begin
-            (if primary-subheading-renderer 
+            (if primary-subheading-renderer
                 (primary-subheading-renderer
                  (car splits) table width def:primary-subtotal-style used-columns))
             (if secondary-subheading-renderer
                 (secondary-subheading-renderer
                  (car splits) table width def:secondary-subtotal-style used-columns))
-            
+
             (do-rows-with-subtotals splits table used-columns width
                                     multi-rows? #t
                                     export?
@@ -1359,22 +1438,22 @@ Credit Card, and Income accounts."))))))
                                     secondary-subheading-renderer
                                     primary-subtotal-renderer
                                     secondary-subtotal-renderer
-                                    (gnc:make-commodity-collector)
-                                    (gnc:make-commodity-collector)
-                                    (gnc:make-commodity-collector))))
-      
+                                    (map (lambda (x) (gnc:make-commodity-collector)) calculated-cells)
+                                    (map (lambda (x) (gnc:make-commodity-collector)) calculated-cells)
+                                    (map (lambda (x) (gnc:make-commodity-collector)) calculated-cells)
+                                    ;(gnc:make-commodity-collector)
+                                    ;(gnc:make-commodity-collector)
+                                    ;(gnc:make-commodity-collector)
+                                    )))
       table)))
 
 ;; ;;;;;;;;;;;;;;;;;;;;
 ;; Here comes the renderer function for this report.
 (define (trep-renderer report-obj)
-  
   (define options (gnc:report-options report-obj))
-  
   (define (opt-val section name)
     (gnc:option-value
      (gnc:lookup-option options section name)))
-  
   (define comp-funcs-assoc-list
     ;; Defines the different sorting keys, together with the
     ;; subtotal functions. Each entry: (cons
@@ -1382,19 +1461,16 @@ Credit Card, and Income accounts."))))))
     ;; subtotal-function subtotal-renderer))
     ;;  (let* ((used-columns (build-column-used options))) ;; tpo: gives unbound variable options?
     (let* ((used-columns (build-column-used (gnc:report-options report-obj))))
-      (list (cons 'account-name  (vector 
+      (list (cons 'account-name  (vector
                                   (list SPLIT-ACCT-FULLNAME)
-                                  split-account-full-name-same-p 
+                                  split-account-full-name-same-p
                                   render-account-subheading
                                   render-account-subtotal))
-            (cons 'account-code  (vector 
+            (cons 'account-code  (vector
                                   (list SPLIT-ACCOUNT ACCOUNT-CODE-)
                                   split-account-code-same-p
                                   render-account-subheading
                                   render-account-subtotal))
-            (cons 'exact-time    (vector
-                                  (list SPLIT-TRANS TRANS-DATE-POSTED)
-                                  #f #f #f))
             (cons 'date          (vector
                                   (list SPLIT-TRANS TRANS-DATE-POSTED)
                                   #f #f #f))
@@ -1407,13 +1483,13 @@ Credit Card, and Income accounts."))))))
             (cons 'corresponding-acc-name
                   (vector
                    (list SPLIT-CORR-ACCT-NAME)
-                   split-same-corr-account-full-name-p 
+                   split-same-corr-account-full-name-p
                    render-corresponding-account-subheading
                    render-corresponding-account-subtotal))
             (cons 'corresponding-acc-code
                   (vector
                    (list SPLIT-CORR-ACCT-CODE)
-                   split-same-corr-account-code-p 
+                   split-same-corr-account-code-p
                    render-corresponding-account-subheading
                    render-corresponding-account-subtotal))
             (cons 'amount        (vector (list SPLIT-VALUE) #f #f #f))
@@ -1424,7 +1500,7 @@ Credit Card, and Income accounts."))))))
             (cons 't-number      (vector (list SPLIT-TRANS TRANS-NUM) #f #f #f))
             (cons 'memo          (vector (list SPLIT-MEMO) #f #f #f))
             (cons 'none          (vector '() #f #f #f)))))
-  
+
   (define date-comp-funcs-assoc-list
     ;; Extra list for date option. Each entry: (cons
     ;; 'date-subtotal-option-value (vector subtotal-function
@@ -1433,14 +1509,14 @@ Credit Card, and Income accounts."))))))
      (cons 'none (vector #f #f #f))
      (cons 'weekly (vector split-same-week-p render-week-subheading
                            render-week-subtotal))
-     (cons 'monthly (vector split-same-month-p render-month-subheading 
+     (cons 'monthly (vector split-same-month-p render-month-subheading
                             render-month-subtotal))
-     (cons 'quarterly (vector split-same-quarter-p render-quarter-subheading 
+     (cons 'quarterly (vector split-same-quarter-p render-quarter-subheading
                               render-quarter-subtotal))
      (cons 'yearly (vector split-same-year-p render-year-subheading
                            render-year-subtotal))))
-  
-  (define (get-subtotalstuff-helper 
+
+  (define (get-subtotalstuff-helper
            name-sortkey name-subtotal name-date-subtotal
            comp-index date-index)
     ;; The value of the sorting-key multichoice option.
@@ -1451,48 +1527,60 @@ Credit Card, and Income accounts."))))))
           ;; corresponding funcs in the assoc-list.
           (vector-ref
            (cdr (assq (opt-val pagename-sorting name-date-subtotal)
-                      date-comp-funcs-assoc-list)) 
+                      date-comp-funcs-assoc-list))
            date-index)
           ;; For everything else: 1. check whether sortkey has
           ;; subtotalling enabled at all, 2. check whether the
           ;; enable-subtotal boolean option is #t, 3. look up the
           ;; appropriate funcs in the assoc-list.
-          (and (member sortkey subtotal-enabled) 
+          (and (member sortkey subtotal-enabled)
                (and (opt-val pagename-sorting name-subtotal)
-                    (vector-ref 
-                     (cdr (assq sortkey comp-funcs-assoc-list)) 
+                    (vector-ref
+                     (cdr (assq sortkey comp-funcs-assoc-list))
                      comp-index))))))
-  
+
   (define (get-query-sortkey sort-option-value)
-    (vector-ref 
-     (cdr (assq sort-option-value comp-funcs-assoc-list)) 
+    (vector-ref
+     (cdr (assq sort-option-value comp-funcs-assoc-list))
      0))
-  
-  (define (get-subtotal-pred 
+
+  (define (get-subtotal-pred
            name-sortkey name-subtotal name-date-subtotal)
-    (get-subtotalstuff-helper 
+    (get-subtotalstuff-helper
      name-sortkey name-subtotal name-date-subtotal
      1 0))
-  
+
   (define (get-subheading-renderer
            name-sortkey name-subtotal name-date-subtotal)
-    (get-subtotalstuff-helper 
+    (get-subtotalstuff-helper
      name-sortkey name-subtotal name-date-subtotal
      2 1))
-  
+
   (define (get-subtotal-renderer
            name-sortkey name-subtotal name-date-subtotal)
     (get-subtotalstuff-helper
      name-sortkey name-subtotal name-date-subtotal
      3 2))
-  
+
   ;;(define (get-other-account-names account-list)
   ;;  ( map (lambda (acct)  (gnc-account-get-full-name acct)) account-list))
-  
+
+  (define (splits-filter-unique-transactions splits)
+    (let ((have-trans-hash (make-hash-table)))
+      (define (only-one-copy? split)
+        (let* ((parent (xaccSplitGetParent split))
+               (trans-guid (gncTransGetGUID parent)))
+          (if (hash-ref have-trans-hash trans-guid #f)
+              #f  ; already have a copy of this transaction
+              (begin
+                (hash-set! have-trans-hash trans-guid #t)
+                #t))))
+      (filter only-one-copy? splits)))
+
   (define (is-filter-member split account-list)
     (let* ((txn (xaccSplitGetParent split))
            (splitcount (xaccTransCountSplits txn)))
-      
+
       (cond
         ;; A 2-split transaction - test separately so it can be optimized
         ;; to significantly reduce the number of splits to traverse
@@ -1501,11 +1589,11 @@ Credit Card, and Income accounts."))))))
          (let* ((other      (xaccSplitGetOtherSplit split))
                 (other-acct (xaccSplitGetAccount other)))
            (member other-acct account-list)))
-        
+
         ;; A multi-split transaction - run over all splits
         ((> splitcount 2)
          (let ((splits (xaccTransGetSplitList txn)))
-           
+
            ;; Walk through the list of splits.
            ;; if we reach the end, return #f
            ;; if the 'this' != 'split' and the split->account is a member
@@ -1520,44 +1608,49 @@ Credit Card, and Income accounts."))))))
                             (member acct account-list))
                        #t
                        (is-member rest)))))
-           
+
            (is-member splits)))
-        
+
         ;; Single transaction splits
         (else #f))))
-  
-  
+
   (gnc:report-starting reportname)
-  (let ((document (gnc:make-html-document))
-        (c_account_1 (opt-val gnc:pagename-accounts "Accounts"))
-        (c_account_substring (opt-val gnc:pagename-accounts "Account Substring"))
-        (c_account_2 (opt-val gnc:pagename-accounts "Filter By..."))
-        (filter-mode (opt-val gnc:pagename-accounts "Filter Type"))
-        (begindate (gnc:timepair-start-day-time
-                    (gnc:date-option-absolute-time
-                     (opt-val gnc:pagename-general "Start Date"))))
-        (enddate (gnc:timepair-end-day-time
-                  (gnc:date-option-absolute-time
-                   (opt-val gnc:pagename-general "End Date"))))
-        (report-title (opt-val 
-                       gnc:pagename-general
-                       gnc:optname-reportname))
-        (primary-key (opt-val pagename-sorting optname-prime-sortkey))
-        (primary-order (opt-val pagename-sorting "Primary Sort Order"))
-        (secondary-key (opt-val pagename-sorting optname-sec-sortkey))
-        (secondary-order (opt-val pagename-sorting "Secondary Sort Order"))
-        (void-status (opt-val gnc:pagename-accounts optname-void-transactions))
-        (splits '())
-        (query (qof-query-create-for-splits)))
-    
-    ;;(gnc:warn "accts in trep-renderer:" c_account_1)
-    ;;(gnc:warn "Report Account names:" (get-other-account-names c_account_1))
-    
-    (set! c_account_1
-          (filter (lambda (acc)
-                    (string-contains (gnc-account-get-full-name acc) c_account_substring))
-                  c_account_1))
-    
+
+  (let* ((document (gnc:make-html-document))
+         (c_account_0 (opt-val gnc:pagename-accounts "Accounts"))
+         (c_account_substring (opt-val gnc:pagename-accounts "Account Substring"))
+         (c_account_1 (filter
+                       (lambda (acc)
+                         (string-contains (gnc-account-get-full-name acc) c_account_substring))
+                       c_account_0))
+         (c_account_2 (opt-val gnc:pagename-accounts "Filter By..."))
+         (tax-accounts (opt-val gnc:pagename-accounts "Tax Accounts"))
+         (accounts-tax-collected (filter (lambda (acc) (eq? (xaccAccountGetType acc) ACCT-TYPE-LIABILITY)) tax-accounts))
+         (accounts-tax-paid (filter (lambda (acc) (eq? (xaccAccountGetType acc) ACCT-TYPE-ASSET)) tax-accounts))
+         (accounts-sales (filter (lambda (acc) (eq? (xaccAccountGetType acc) ACCT-TYPE-INCOME)) c_account_1))
+         (accounts-purchases (filter (lambda (acc) (eq? (xaccAccountGetType acc) ACCT-TYPE-EXPENSE)) c_account_1))
+         (filter-mode (opt-val gnc:pagename-accounts "Filter Type"))
+         (begindate (gnc:timepair-start-day-time
+                     (gnc:date-option-absolute-time
+                      (opt-val gnc:pagename-general "Start Date"))))
+         (enddate (gnc:timepair-end-day-time
+                   (gnc:date-option-absolute-time
+                    (opt-val gnc:pagename-general "End Date"))))
+         (report-title (opt-val
+                        gnc:pagename-general
+                        gnc:optname-reportname))
+         (primary-key (opt-val pagename-sorting optname-prime-sortkey))
+         (primary-order (opt-val pagename-sorting "Primary Sort Order"))
+         (secondary-key (opt-val pagename-sorting optname-sec-sortkey))
+         (secondary-order (opt-val pagename-sorting "Secondary Sort Order"))
+         (void-status (opt-val gnc:pagename-accounts optname-void-transactions))
+         (splits '())
+         (query (qof-query-create-for-splits)))
+
+    ;(gnc:warn "c1 is " c_account_1)
+    ;(gnc:warn "c2 is " c_account_2)
+    ;(gnc:warn "first c1 is " (xaccAccountGetName (car c_account_1)))
+
     (if (not (or (null? c_account_1) (and-map not c_account_1)))
         (begin
           (qof-query-set-book query (gnc-get-current-book))
@@ -1571,60 +1664,74 @@ Credit Card, and Income accounts."))))))
                                     (get-query-sortkey primary-key)
                                     (get-query-sortkey secondary-key)
                                     '())
-          
+
           (qof-query-set-sort-increasing query
                                          (eq? primary-order 'ascend)
                                          (eq? secondary-order 'ascend)
                                          #t)
-          
+
           (case void-status
-            ((non-void-only) 
+            ((non-void-only)
              (gnc:query-set-match-non-voids-only! query (gnc-get-current-book)))
             ((void-only)
              (gnc:query-set-match-voids-only! query (gnc-get-current-book)))
             (else #f))
-          
+
           (set! splits (qof-query-run query))
-          
+
           ;;(gnc:warn "Splits in trep-renderer:" splits)
-          
+
           ;;(gnc:warn "Filter account names:" (get-other-account-names c_account_2))
-          
+
           ;;This should probably a cond or a case to allow for different filter types.
           ;;(gnc:warn "Filter Mode: " filter-mode)
           (if (eq? filter-mode 'include)
               (begin
                 ;;(gnc:warn "Including Filter Accounts")
-                (set! splits (filter (lambda (split) 
+                (set! splits (filter (lambda (split)
                                        (is-filter-member split c_account_2))
-                                     splits))
-                )
-              )
-          
+                                     splits))))
+
           (if (eq? filter-mode 'exclude)
               (begin
                 ;;(gnc:warn "Excluding Filter Accounts")
-                (set! splits (filter (lambda (split) 
+                (set! splits (filter (lambda (split)
                                        (not (is-filter-member split c_account_2)))
-                                     splits))
-                )
-              )
-          
+                                     splits))))
+
+          ; We have to remove duplicates because the report will *sum* amounts in a transaction
+          ; otherwise it will double count where transaction contains 2 splits in same account
+          (set! splits (splits-filter-unique-transactions splits))
+
+          ; For each split, we will only keep those which contain useful data
+          ; e.g. show invoices & regular transactions. We will also disallow closing txns.
+          (set! splits (filter
+                        (lambda (split)
+                          (let* ((trans (xaccSplitGetParent split))
+                                 (txn-type (xaccTransGetTxnType trans)))
+                            (and (member txn-type (list TXN-TYPE-NONE TXN-TYPE-INVOICE))
+                                 (not (xaccTransGetIsClosingTxn trans)))))
+                        splits))
+
           (if (not (null? splits))
-              (let ((table 
-                     (make-split-table 
-                      splits 
+              (let ((table
+                     (make-split-table
+                      splits
                       options
-                      (get-subtotal-pred optname-prime-sortkey 
+                      accounts-tax-paid
+                      accounts-tax-collected
+                      accounts-sales
+                      accounts-purchases
+                      (get-subtotal-pred optname-prime-sortkey
                                          optname-prime-subtotal
                                          optname-prime-date-subtotal)
-                      (get-subtotal-pred optname-sec-sortkey 
+                      (get-subtotal-pred optname-sec-sortkey
                                          optname-sec-subtotal
                                          optname-sec-date-subtotal)
-                      (get-subheading-renderer optname-prime-sortkey 
+                      (get-subheading-renderer optname-prime-sortkey
                                                optname-prime-subtotal
                                                optname-prime-date-subtotal)
-                      (get-subheading-renderer optname-sec-sortkey 
+                      (get-subheading-renderer optname-sec-sortkey
                                                optname-sec-subtotal
                                                optname-sec-date-subtotal)
                       (get-subtotal-renderer   optname-prime-sortkey
@@ -1633,48 +1740,85 @@ Credit Card, and Income accounts."))))))
                       (get-subtotal-renderer   optname-sec-sortkey
                                                optname-sec-subtotal
                                                optname-sec-date-subtotal))))
-                
+
                 (gnc:html-document-set-title! document
                                               report-title)
-                (gnc:html-document-add-object! 
+                (gnc:html-document-add-object!
                  document
                  (gnc:make-html-text
-                  (gnc:html-markup-h3 
+                  (gnc:html-markup-h3
                    (display-date-interval begindate enddate))))
+
                 (gnc:html-document-add-object!
-                 document 
+                 document
+                 (gnc:make-html-text
+                  (gnc:html-markup-p
+                   "Input Tax accounts: "
+                   (string-join (map gnc-account-get-full-name accounts-tax-paid) ", "))))
+
+                (gnc:html-document-add-object!
+                 document
+                 (gnc:make-html-text
+                  (gnc:html-markup-p
+                   "Output Tax accounts: "
+                   (string-join (map gnc-account-get-full-name accounts-tax-collected) ", "))))
+
+                (if (null? (append accounts-tax-collected accounts-tax-paid))
+                    (gnc:html-document-add-object!
+                     document
+                     (gnc:make-html-text
+                      (gnc:html-markup-p
+                       "There are no input/output tax accounts set up. This is probably not what"
+                       " you want. "
+                       TAX-SETUP-DESC))))
+
+                (gnc:html-document-add-object!
+                 document
                  table)
                 (qof-query-destroy query))
               ;; error condition: no splits found
               (let ((p (gnc:make-html-text)))
-                (gnc:html-text-append! 
-                 p 
-                 (gnc:html-markup-h2 
+                (gnc:html-text-append!
+                 p
+                 (gnc:html-markup-h2
                   (_ "No matching transactions found"))
                  (gnc:html-markup-p
-                  (_ "No transactions were found that \
-match the time interval and account selection specified \
-in the Options panel.")))
+                  (_ "No transactions were found that match the time interval and account selection specified in the Options panel.")))
                 (gnc:html-document-add-object! document p))))
-        
+
         ;; error condition: no accounts specified
-        
-        (gnc:html-document-add-object!
-         document 
-         (gnc:html-make-no-account-warning 
-          report-title (gnc:report-id report-obj))))
-    
+
+        (begin
+          (gnc:html-document-add-object!
+           document
+           (gnc:html-make-no-account-warning
+            report-title (gnc:report-id report-obj)))
+
+          (gnc:html-document-add-object!
+           document
+           (gnc:make-html-text
+            (gnc:html-markup-p
+             "This report is useful to calculate periodic business tax payable/receivable from"
+             " authorities. From <i>Edit report options</i> above, choose your Business Income and Business Expense accounts."
+             " Each transaction may contain, in addition to the accounts payable/receivable or bank accounts,"
+             " a split to a tax account, e.g. Income:Sales -$1000, Liability:GST on Sales -$100, Asset:Bank $1100.")
+            (gnc:html-markup-p
+             " These tax accounts can either be populated using the standard register, or from Business Invoices and Bills "
+             " which will require Business > Sales Tax Tables to be set up correctly. Please see the documentation.")))
+
+          (gnc:html-document-add-object!
+           document
+           (gnc:make-html-text
+            (gnc:html-markup-p TAX-SETUP-DESC)))))
+
     (gnc:report-finished)
     document))
 
 ;; Define the report.
 (gnc:define-report
- 
  'version 1
- 
+ 'menu-path (list gnc:menuname-income-expense)
  'name reportname
- 'report-guid "2fe3b9833af044abb929a88d5a59620f"
- 
+ 'report-guid "5bf27f249a0d11e7abc4cec278b6b50a"
  'options-generator trep-options-generator
- 
- 'renderer trep-renderer)
+ 'renderer trep-renderer)
\ No newline at end of file

commit 40006a3f04ba70496a87f8f9db97b1f486ad2448
Author: christopherlam <christopher.lck at gmail.com>
Date:   Sun Sep 17 00:58:42 2017 +0100

    Reindent from transaction.scm

diff --git a/gnucash/report/standard-reports/income-gst-statement.scm b/gnucash/report/standard-reports/income-gst-statement.scm
index 4fbab7d..859cfde 100644
--- a/gnucash/report/standard-reports/income-gst-statement.scm
+++ b/gnucash/report/standard-reports/income-gst-statement.scm
@@ -104,11 +104,11 @@
 (define (timepair-same-week tp-a tp-b)
   (and (timepair-same-year tp-a tp-b)
        (= (gnc:timepair-get-week tp-a)
-	  (gnc:timepair-get-week tp-b))))
+          (gnc:timepair-get-week tp-b))))
 
 (define (split-same-week-p a b)
   (let ((tp-a (gnc-transaction-get-date-posted (xaccSplitGetParent a)))
-	(tp-b (gnc-transaction-get-date-posted (xaccSplitGetParent b))))
+        (tp-b (gnc-transaction-get-date-posted (xaccSplitGetParent b))))
     (timepair-same-week tp-a tp-b)))
 
 (define (split-same-month-p a b)
@@ -145,19 +145,19 @@
 (define (account-namestring account show-account-code show-account-name show-account-full-name)
   ;;# on multi-line splits we can get an empty ('()) account
   (if (null? account)
-        (_ "Split Transaction")
-        (string-append 
-           ;; display account code?
-           (if show-account-code
-                 (string-append (xaccAccountGetCode account) " ")
-                 "")
-           ;; display account name?
-           (if show-account-name
-                 ;; display full account name?
-                 (if show-account-full-name
-                      (gnc-account-get-full-name account)
-                      (xaccAccountGetName account))
-                 ""))))
+      (_ "Split Transaction")
+      (string-append 
+       ;; display account code?
+       (if show-account-code
+           (string-append (xaccAccountGetCode account) " ")
+           "")
+       ;; display account name?
+       (if show-account-name
+           ;; display full account name?
+           (if show-account-full-name
+               (gnc-account-get-full-name account)
+               (xaccAccountGetName account))
+           ""))))
 
 ;; render an account subheading - column-vector determines what is displayed
 (define (render-account-subheading
@@ -165,11 +165,11 @@
   (let ((account (xaccSplitGetAccount split)))
     (add-subheading-row (gnc:make-html-text
                          (gnc:html-markup-anchor
-                           (gnc:account-anchor-text account)
-                           (account-namestring account
-                                               (used-sort-account-code      column-vector)
-                                               #t
-                                               (used-sort-account-full-name column-vector))))
+                          (gnc:account-anchor-text account)
+                          (account-namestring account
+                                              (used-sort-account-code      column-vector)
+                                              #t
+                                              (used-sort-account-full-name column-vector))))
                         table width subheading-style)))
 
 (define (render-corresponding-account-subheading 
@@ -178,40 +178,40 @@
     (add-subheading-row (gnc:make-html-text
                          (gnc:html-markup-anchor
                           (if (not (null? account))
-                           (gnc:account-anchor-text account)
-                           "")
-                           (account-namestring account
-                                               (used-sort-account-code      column-vector)
-                                               #t
-                                               (used-sort-account-full-name column-vector))))
+                              (gnc:account-anchor-text account)
+                              "")
+                          (account-namestring account
+                                              (used-sort-account-code      column-vector)
+                                              #t
+                                              (used-sort-account-full-name column-vector))))
                         table width subheading-style)))
 
 (define (render-week-subheading split table width subheading-style column-vector)
   (add-subheading-row (gnc:date-get-week-year-string
-		       (gnc:timepair->date
-			(gnc-transaction-get-date-posted
-			 (xaccSplitGetParent split))))
-		      table width subheading-style))
+                       (gnc:timepair->date
+                        (gnc-transaction-get-date-posted
+                         (xaccSplitGetParent split))))
+                      table width subheading-style))
 
 (define (render-month-subheading split table width subheading-style column-vector)
   (add-subheading-row (gnc:date-get-month-year-string
-                      (gnc:timepair->date 
-                       (gnc-transaction-get-date-posted
-                        (xaccSplitGetParent split))))
-                     table width subheading-style))
+                       (gnc:timepair->date 
+                        (gnc-transaction-get-date-posted
+                         (xaccSplitGetParent split))))
+                      table width subheading-style))
 
 (define (render-quarter-subheading split table width subheading-style column-vector)
   (add-subheading-row (gnc:date-get-quarter-year-string 
-                      (gnc:timepair->date 
-                       (gnc-transaction-get-date-posted
-                        (xaccSplitGetParent split))))
-                     table width subheading-style))
+                       (gnc:timepair->date 
+                        (gnc-transaction-get-date-posted
+                         (xaccSplitGetParent split))))
+                      table width subheading-style))
 
 (define (render-year-subheading split table width subheading-style column-vector)
   (add-subheading-row (gnc:date-get-year-string 
-                      (gnc:timepair->date 
-                       (gnc-transaction-get-date-posted
-                        (xaccSplitGetParent split))))
+                       (gnc:timepair->date 
+                        (gnc-transaction-get-date-posted
+                         (xaccSplitGetParent split))))
                       table width subheading-style))
 
 
@@ -224,56 +224,56 @@
      table
      subtotal-style 
      (if export?
-      (append! (cons (gnc:make-html-table-cell/markup "total-label-cell" subtotal-string)
-                     (gnc:html-make-empty-cells (- width 2)))
-               (list (gnc:make-html-table-cell/markup 
-                      "total-number-cell"
-                      (car currency-totals))))
-     (list (gnc:make-html-table-cell/size/markup 1 (- width 1) "total-label-cell"
-                                          subtotal-string)
-           (gnc:make-html-table-cell/markup 
-            "total-number-cell"
-             (car currency-totals)))))
+         (append! (cons (gnc:make-html-table-cell/markup "total-label-cell" subtotal-string)
+                        (gnc:html-make-empty-cells (- width 2)))
+                  (list (gnc:make-html-table-cell/markup 
+                         "total-number-cell"
+                         (car currency-totals))))
+         (list (gnc:make-html-table-cell/size/markup 1 (- width 1) "total-label-cell"
+                                                     subtotal-string)
+               (gnc:make-html-table-cell/markup 
+                "total-number-cell"
+                (car currency-totals)))))
     (for-each (lambda (currency)
                 (gnc:html-table-append-row/markup! 
                  table
                  subtotal-style
                  (append!
                   (if export?
-                   (gnc:html-make-empty-cells (- width 1))
-                   (list blanks))
-                         (list (gnc:make-html-table-cell/markup
-                                "total-number-cell" currency)))))
+                      (gnc:html-make-empty-cells (- width 1))
+                      (list blanks))
+                  (list (gnc:make-html-table-cell/markup
+                         "total-number-cell" currency)))))
               (cdr currency-totals))))
 
 (define (total-string str) (string-append (_ "Total For ") str))
 
 (define (render-account-subtotal 
          table width split total-collector subtotal-style column-vector export?)
-    (add-subtotal-row table width 
-                      (total-string (account-namestring (xaccSplitGetAccount split)
-                                                        (used-sort-account-code      column-vector)
-                                                        #t
-                                                        (used-sort-account-full-name column-vector)))
-                      total-collector subtotal-style export?))
+  (add-subtotal-row table width 
+                    (total-string (account-namestring (xaccSplitGetAccount split)
+                                                      (used-sort-account-code      column-vector)
+                                                      #t
+                                                      (used-sort-account-full-name column-vector)))
+                    total-collector subtotal-style export?))
 
 (define (render-corresponding-account-subtotal
          table width split total-collector subtotal-style column-vector export?)
-    (add-subtotal-row table width
-                      (total-string (account-namestring (xaccSplitGetAccount
-                                                          (xaccSplitGetOtherSplit split))
-                                                        (used-sort-account-code      column-vector)
-                                                        #t
-                                                        (used-sort-account-full-name column-vector)))
+  (add-subtotal-row table width
+                    (total-string (account-namestring (xaccSplitGetAccount
+                                                       (xaccSplitGetOtherSplit split))
+                                                      (used-sort-account-code      column-vector)
+                                                      #t
+                                                      (used-sort-account-full-name column-vector)))
                     total-collector subtotal-style export?))
 
 (define (render-week-subtotal
-	 table width split total-collector subtotal-style column-vector export?)
+         table width split total-collector subtotal-style column-vector export?)
   (let ((tm (gnc:timepair->date (gnc-transaction-get-date-posted
-				 (xaccSplitGetParent split)))))
+                                 (xaccSplitGetParent split)))))
     (add-subtotal-row table width
-		      (total-string (gnc:date-get-week-year-string tm))
-		      total-collector subtotal-style export?)))
+                      (total-string (gnc:date-get-week-year-string tm))
+                      total-collector subtotal-style export?)))
 
 (define (render-month-subtotal
          table width split total-collector subtotal-style column-vector export?)
@@ -290,7 +290,7 @@
                                  (xaccSplitGetParent split)))))
     (add-subtotal-row table width 
                       (total-string (gnc:date-get-quarter-year-string tm))
-                     total-collector subtotal-style export?)))
+                      total-collector subtotal-style export?)))
 
 (define (render-year-subtotal
          table width split total-collector subtotal-style column-vector export?)
@@ -361,7 +361,7 @@
 (define (num-columns-required columns-used)  
   (do ((i 0 (+ i 1)) 
        (col-req 0 col-req)) 
-      ((>= i columns-used-size) col-req)
+    ((>= i columns-used-size) col-req)
     ; If column toggle is true, increase column count. But attention:
     ; some toggles only change the meaning of another toggle. Don't count these modifier toggles
     (if (and (not (= i 12)) ; Skip Account Full Name toggle - modifies Account Name column
@@ -370,13 +370,13 @@
              (not (= i 18)) ; Skip Sort Account Full Name - modifies Account Name subheading
              (not (= i 19)) ; Skip Note toggle - modifies Memo column
              (vector-ref columns-used i))
-      (set! col-req (+ col-req 1)))
+        (set! col-req (+ col-req 1)))
     ; Account Code and Account Name share one column so if both were ticked the
     ; the check above would have set up one column too much. The check below
     ; will compensate these again.
     (if (or (and (= i 14) (vector-ref columns-used 14) (vector-ref columns-used 4)) ; Account Code and Name
             (and (= i 15) (vector-ref columns-used 15) (vector-ref columns-used 5))) ; Other Account Code and Name
-      (set! col-req (- col-req 1)))))
+        (set! col-req (- col-req 1)))))
 
 (define (build-column-used options)   
   (define (opt-val section name)
@@ -436,14 +436,14 @@
         (addto! heading-list (_ "Reconciled Date")))
     (if (used-num column-vector)
         (addto! heading-list (if (and (qof-book-use-split-action-for-num-field
-                                                        (gnc-get-current-book))
+                                       (gnc-get-current-book))
                                       (if (gnc:lookup-option options
-                                                    gnc:pagename-display
-                                                    (N_ "Trans Number"))
+                                                             gnc:pagename-display
+                                                             (N_ "Trans Number"))
                                           (gnc:option-value 
-                                            (gnc:lookup-option options
-                                                    gnc:pagename-display
-                                                    (N_ "Trans Number")))
+                                           (gnc:lookup-option options
+                                                              gnc:pagename-display
+                                                              (N_ "Trans Number")))
                                           #f))
                                  (_ "Num/T-Num")
                                  (_ "Num"))))
@@ -474,11 +474,11 @@
 
 (define (add-split-row table split column-vector options
                        row-style account-types-to-reverse transaction-row?)
-
+  
   (define (opt-val section name)
     (gnc:option-value 
      (gnc:lookup-option options section name)))
-
+  
   (let* ((row-contents '())
          (dummy  (gnc:debug "split is originally" split))
          (parent (xaccSplitGetParent split))
@@ -487,66 +487,66 @@
          (currency (if (not (null? account))
                        (xaccAccountGetCommodity account)
                        (gnc-default-currency)))
-	 (report-currency (if (opt-val gnc:pagename-general optname-common-currency)
-			       (opt-val gnc:pagename-general optname-currency)
-			       currency))
+         (report-currency (if (opt-val gnc:pagename-general optname-common-currency)
+                              (opt-val gnc:pagename-general optname-currency)
+                              currency))
          (damount (if (gnc:split-voided? split)
-					 (xaccSplitVoidFormerAmount split)
-					 (xaccSplitGetAmount split)))
-	 (trans-date (gnc-transaction-get-date-posted parent))
-	 (split-value (gnc:exchange-by-pricedb-nearest
-		       (gnc:make-gnc-monetary 
-			currency
-			(if (member account-type account-types-to-reverse) 
-			    (gnc-numeric-neg damount)
-			    damount))
-		       report-currency
-		       ;; Use midday as the transaction time so it matches a price
-		       ;; on the same day.  Otherwise it uses midnight which will
-		       ;; likely match a price on the previous day
-		       (timespecCanonicalDayTime trans-date))))
+                      (xaccSplitVoidFormerAmount split)
+                      (xaccSplitGetAmount split)))
+         (trans-date (gnc-transaction-get-date-posted parent))
+         (split-value (gnc:exchange-by-pricedb-nearest
+                       (gnc:make-gnc-monetary 
+                        currency
+                        (if (member account-type account-types-to-reverse) 
+                            (gnc-numeric-neg damount)
+                            damount))
+                       report-currency
+                       ;; Use midday as the transaction time so it matches a price
+                       ;; on the same day.  Otherwise it uses midnight which will
+                       ;; likely match a price on the previous day
+                       (timespecCanonicalDayTime trans-date))))
     
     (if (used-date column-vector)
         (addto! row-contents
                 (if transaction-row?
                     (gnc:make-html-table-cell/markup "date-cell"
-                        (gnc-print-date (gnc-transaction-get-date-posted parent)))
+                                                     (gnc-print-date (gnc-transaction-get-date-posted parent)))
                     " ")))
     (if (used-reconciled-date column-vector)
         (addto! row-contents
                 (gnc:make-html-table-cell/markup "date-cell"
-		    (let ((date (gnc-split-get-date-reconciled split)))
-		      (if (equal? date (cons 0 0))
-		          " "
-		          (gnc-print-date date))))))
+                                                 (let ((date (gnc-split-get-date-reconciled split)))
+                                                   (if (equal? date (cons 0 0))
+                                                       " "
+                                                       (gnc-print-date date))))))
     (if (used-num column-vector)
         (addto! row-contents
                 (if transaction-row?
                     (if (qof-book-use-split-action-for-num-field
-                                                        (gnc-get-current-book))
+                         (gnc-get-current-book))
                         (let* ((num (gnc-get-num-action parent split))
                                (t-num (if (if (gnc:lookup-option options
-                                                    gnc:pagename-display
-                                                    (N_ "Trans Number"))
+                                                                 gnc:pagename-display
+                                                                 (N_ "Trans Number"))
                                               (opt-val gnc:pagename-display
-                                                    (N_ "Trans Number"))
+                                                       (N_ "Trans Number"))
                                               #f)
                                           (gnc-get-num-action parent #f)
                                           ""))
                                (num-string (if (equal? t-num "")
                                                num
                                                (string-append num "/" t-num))))
-                              (gnc:make-html-table-cell/markup "text-cell"
-                                   num-string))
+                          (gnc:make-html-table-cell/markup "text-cell"
+                                                           num-string))
                         (gnc:make-html-table-cell/markup "text-cell"
-                            (gnc-get-num-action parent split)))
+                                                         (gnc-get-num-action parent split)))
                     " ")))
-
+    
     (if (used-description column-vector)
         (addto! row-contents
                 (if transaction-row?
                     (gnc:make-html-table-cell/markup "text-cell"
-                        (xaccTransGetDescription parent))
+                                                     (xaccTransGetDescription parent))
                     " ")))
     
     (if (used-memo column-vector)
@@ -556,17 +556,17 @@
               (addto! row-contents memo))))
     
     (if (or (used-account-name column-vector) (used-account-code column-vector))
-       (addto! row-contents (account-namestring account
-                                                (used-account-code      column-vector)
-                                                (used-account-name      column-vector)
-                                                (used-account-full-name column-vector))))
+        (addto! row-contents (account-namestring account
+                                                 (used-account-code      column-vector)
+                                                 (used-account-name      column-vector)
+                                                 (used-account-full-name column-vector))))
     
     (if (or (used-other-account-name column-vector) (used-other-account-code column-vector))
-       (addto! row-contents (account-namestring (xaccSplitGetAccount
-                                                   (xaccSplitGetOtherSplit split))
-                                                (used-other-account-code      column-vector)
-                                                (used-other-account-name      column-vector)
-                                                (used-other-account-full-name column-vector))))
+        (addto! row-contents (account-namestring (xaccSplitGetAccount
+                                                  (xaccSplitGetOtherSplit split))
+                                                 (used-other-account-code      column-vector)
+                                                 (used-other-account-name      column-vector)
+                                                 (used-other-account-full-name column-vector))))
     
     (if (used-shares column-vector)
         (addto! row-contents (xaccSplitGetAmount split)))
@@ -592,15 +592,15 @@
                      "number-cell" (gnc:html-transaction-anchor parent (gnc:monetary-neg split-value))))
             (addto! row-contents " ")))
     (if (used-running-balance column-vector)
-	(begin
-	  (gnc:debug "split is " split)
-	  (gnc:debug "split get balance:" (xaccSplitGetBalance split))
-	  (addto! row-contents
-		  (gnc:make-html-table-cell/markup
-		   "number-cell"
-		   (gnc:make-gnc-monetary currency
-					  (xaccSplitGetBalance split))))))
-	(gnc:html-table-append-row/markup! table row-style
+        (begin
+          (gnc:debug "split is " split)
+          (gnc:debug "split get balance:" (xaccSplitGetBalance split))
+          (addto! row-contents
+                  (gnc:make-html-table-cell/markup
+                   "number-cell"
+                   (gnc:make-gnc-monetary currency
+                                          (xaccSplitGetBalance split))))))
+    (gnc:html-table-append-row/markup! table row-style
                                        (reverse row-contents))
     split-value))
 
@@ -625,15 +625,15 @@
     "e" (N_ "Convert all transactions into a common currency.") #f
     #f
     (lambda (x) (gnc-option-db-set-option-selectable-by-name
-		 gnc:*transaction-report-options*
-		 gnc:pagename-general
-		 optname-currency
-		 x))
+                 gnc:*transaction-report-options*
+                 gnc:pagename-general
+                 optname-currency
+                 x))
     ))
-
+  
   (gnc:options-add-currency!
    gnc:*transaction-report-options* gnc:pagename-general optname-currency "f")
-
+  
   (gnc:register-trep-option
    (gnc:make-simple-boolean-option
     gnc:pagename-general optname-table-export
@@ -654,7 +654,7 @@
     (lambda ()
       '())
     #f #t))
-
+  
   (gnc:register-trep-option
    (gnc:make-string-option
     gnc:pagename-accounts (N_ "Account Substring")
@@ -662,7 +662,7 @@
 match Expenses:Travel:Holiday and Expenses:Business:Travel. Can be left blank, which will \
 disable the substring filter. This filter is case-sensitive.")
     ""))
-
+  
   (gnc:register-trep-option
    (gnc:make-account-list-option
     gnc:pagename-accounts (N_ "Filter By...")
@@ -670,164 +670,164 @@ disable the substring filter. This filter is case-sensitive.")
     (lambda ()
       ;; FIXME : gnc:get-current-accounts disappeared.
       (let* ((current-accounts '())
-	     (root (gnc-get-current-root-account))
-	     (num-accounts (gnc-account-n-children root))
-	     (first-account (gnc-account-nth-child root 0)))
-	(cond ((not (null? current-accounts))
-	       (list (car current-accounts)))
-	      ((> num-accounts 0) (list first-account))
-	      (else '()))))
+             (root (gnc-get-current-root-account))
+             (num-accounts (gnc-account-n-children root))
+             (first-account (gnc-account-nth-child root 0)))
+        (cond ((not (null? current-accounts))
+               (list (car current-accounts)))
+              ((> num-accounts 0) (list first-account))
+              (else '()))))
     #f #t))
-
+  
   (gnc:register-trep-option
    (gnc:make-multichoice-option
     gnc:pagename-accounts (N_ "Filter Type")
     "c" (N_ "Filter account.")
     'none
     (list (vector 'none
-		  (N_ "None")
-		  (N_ "Do not do any filtering."))
-	  (vector 'include
-		  (N_ "Include Transactions to/from Filter Accounts")
-		  (N_ "Include transactions to/from filter accounts only."))
-	  (vector 'exclude
-		  (N_ "Exclude Transactions to/from Filter Accounts")
-		  (N_ "Exclude transactions to/from all filter accounts."))
-	  )))
-
+                  (N_ "None")
+                  (N_ "Do not do any filtering."))
+          (vector 'include
+                  (N_ "Include Transactions to/from Filter Accounts")
+                  (N_ "Include transactions to/from filter accounts only."))
+          (vector 'exclude
+                  (N_ "Exclude Transactions to/from Filter Accounts")
+                  (N_ "Exclude transactions to/from all filter accounts."))
+          )))
+  
   ;;
-
+  
   (gnc:register-trep-option
    (gnc:make-multichoice-option
     gnc:pagename-accounts optname-void-transactions
     "d" (N_ "How to handle void transactions.")
     'non-void-only
     (list (vector
-	   'non-void-only
-	   (N_ "Non-void only")
-	   (N_ "Show only non-voided transactions."))
-	  (vector
-	   'void-only
-	   (N_ "Void only")
-	   (N_ "Show only voided transactions."))
-	  (vector 
-	   'both
-	   (N_ "Both")
-	   (N_ "Show both (and include void transactions in totals).")))))
-
+           'non-void-only
+           (N_ "Non-void only")
+           (N_ "Show only non-voided transactions."))
+          (vector
+           'void-only
+           (N_ "Void only")
+           (N_ "Show only voided transactions."))
+          (vector 
+           'both
+           (N_ "Both")
+           (N_ "Show both (and include void transactions in totals).")))))
+  
   ;; Sorting options
-      
+  
   (let ((options gnc:*transaction-report-options*)
-
+        
         (key-choice-list 
          (if (qof-book-use-split-action-for-num-field (gnc-get-current-book))
              (list (vector 'none
                            (N_ "None")
                            (N_ "Do not sort."))
-
+                   
                    (vector 'account-name
                            (N_ "Account Name")
                            (N_ "Sort & subtotal by account name."))
-
+                   
                    (vector 'account-code
                            (N_ "Account Code")
                            (N_ "Sort & subtotal by account code."))
-
+                   
                    (vector 'date
                            (N_ "Date")
                            (N_ "Sort by date."))
-
+                   
                    (vector 'exact-time
                            (N_ "Exact Time")
                            (N_ "Sort by exact time."))
-
+                   
                    (vector 'reconciled-date
                            (N_ "Reconciled Date")
                            (N_ "Sort by the Reconciled Date."))
-
+                   
                    (vector 'register-order
                            (N_ "Register Order")
                            (N_ "Sort as in the register."))
-
+                   
                    (vector 'corresponding-acc-name 
                            (N_ "Other Account Name")
                            (N_ "Sort by account transferred from/to's name."))
-
+                   
                    (vector 'corresponding-acc-code
                            (N_ "Other Account Code")
                            (N_ "Sort by account transferred from/to's code."))
-               
+                   
                    (vector 'amount
                            (N_ "Amount")
                            (N_ "Sort by amount."))
-               
+                   
                    (vector 'description
                            (N_ "Description")
                            (N_ "Sort by description."))
-               
+                   
                    (vector 'number
                            (N_ "Number/Action")
                            (N_ "Sort by check number/action."))
-
+                   
                    (vector 't-number
                            (N_ "Transaction Number")
                            (N_ "Sort by transaction number."))
-               
+                   
                    (vector 'memo
                            (N_ "Memo")
                            (N_ "Sort by memo.")))
              (list (vector 'none
                            (N_ "None")
                            (N_ "Do not sort."))
-
+                   
                    (vector 'account-name
                            (N_ "Account Name")
                            (N_ "Sort & subtotal by account name."))
-
+                   
                    (vector 'account-code
                            (N_ "Account Code")
                            (N_ "Sort & subtotal by account code."))
-
+                   
                    (vector 'date
                            (N_ "Date")
                            (N_ "Sort by date."))
-
+                   
                    (vector 'exact-time
                            (N_ "Exact Time")
                            (N_ "Sort by exact time."))
-
+                   
                    (vector 'reconciled-date
                            (N_ "Reconciled Date")
                            (N_ "Sort by the Reconciled Date."))
-
+                   
                    (vector 'register-order
                            (N_ "Register Order")
                            (N_ "Sort as in the register."))
-
+                   
                    (vector 'corresponding-acc-name 
                            (N_ "Other Account Name")
                            (N_ "Sort by account transferred from/to's name."))
-
+                   
                    (vector 'corresponding-acc-code
                            (N_ "Other Account Code")
                            (N_ "Sort by account transferred from/to's code."))
-               
+                   
                    (vector 'amount
                            (N_ "Amount")
                            (N_ "Sort by amount."))
-               
+                   
                    (vector 'description
                            (N_ "Description")
                            (N_ "Sort by description."))
-               
+                   
                    (vector 'number
                            (N_ "Number")
                            (N_ "Sort by check/transaction number."))
-
+                   
                    (vector 'memo
                            (N_ "Memo")
                            (N_ "Sort by memo.")))))
-
+        
         (ascending-choice-list 
          (list
           (vector 'ascend
@@ -836,7 +836,7 @@ disable the substring filter. This filter is case-sensitive.")
           (vector 'descend
                   (N_ "Descending")
                   (N_ "Largest to smallest, latest to earliest."))))
-
+        
         (subtotal-choice-list
          (list
           (vector 'none (N_ "None") (N_ "None."))
@@ -844,12 +844,12 @@ disable the substring filter. This filter is case-sensitive.")
           (vector 'monthly (N_ "Monthly") (N_ "Monthly."))
           (vector 'quarterly (N_ "Quarterly") (N_ "Quarterly."))
           (vector 'yearly (N_ "Yearly") (N_ "Yearly."))))
-
+        
         (prime-sortkey 'account-name)
         (prime-sortkey-subtotal-true #t)
         (sec-sortkey 'register-order)
         (sec-sortkey-subtotal-true #f))
-
+    
     (define (apply-selectable-by-name-sorting-options)
       (let* ((prime-sortkey-enabled (not (eq? prime-sortkey 'none)))
              (prime-sortkey-subtotal-enabled (member prime-sortkey subtotal-enabled))
@@ -857,41 +857,41 @@ disable the substring filter. This filter is case-sensitive.")
              (sec-sortkey-enabled (not (eq? sec-sortkey 'none)))
              (sec-sortkey-subtotal-enabled (member sec-sortkey subtotal-enabled))
              (sec-date-sortingtype-enabled (member sec-sortkey date-sorting-types)))
-
+        
         (gnc-option-db-set-option-selectable-by-name
          options pagename-sorting optname-prime-subtotal
          prime-sortkey-subtotal-enabled)
-
+        
         (gnc-option-db-set-option-selectable-by-name
          options pagename-sorting optname-prime-sortorder
          prime-sortkey-enabled)
-
+        
         (gnc-option-db-set-option-selectable-by-name
          options pagename-sorting optname-sec-subtotal
          sec-sortkey-subtotal-enabled)
-
+        
         (gnc-option-db-set-option-selectable-by-name
          options pagename-sorting optname-sec-sortorder
          sec-sortkey-enabled)
-
+        
         (gnc-option-db-set-option-selectable-by-name
          options pagename-sorting optname-full-account-name
          (or (and prime-sortkey-subtotal-enabled prime-sortkey-subtotal-true)
              (and sec-sortkey-subtotal-enabled sec-sortkey-subtotal-true)))
-
+        
         (gnc-option-db-set-option-selectable-by-name
          options pagename-sorting optname-show-account-code
          (or (and prime-sortkey-subtotal-enabled prime-sortkey-subtotal-true)
              (and sec-sortkey-subtotal-enabled sec-sortkey-subtotal-true)))
-
+        
         (gnc-option-db-set-option-selectable-by-name
          options pagename-sorting optname-prime-date-subtotal
          prime-date-sortingtype-enabled)
-
+        
         (gnc-option-db-set-option-selectable-by-name
          options pagename-sorting optname-sec-date-subtotal
          sec-date-sortingtype-enabled)))
-
+    
     ;; primary sorting criterion
     (gnc:register-trep-option
      (gnc:make-multichoice-callback-option
@@ -926,7 +926,7 @@ disable the substring filter. This filter is case-sensitive.")
       (lambda (x)
         (set! prime-sortkey-subtotal-true x)
         (apply-selectable-by-name-sorting-options))))
-
+    
     (gnc:register-trep-option
      (gnc:make-multichoice-option
       pagename-sorting optname-prime-date-subtotal
@@ -952,7 +952,7 @@ disable the substring filter. This filter is case-sensitive.")
       (lambda (x)
         (set! sec-sortkey x)
         (apply-selectable-by-name-sorting-options))))
-
+    
     (gnc:register-trep-option
      (gnc:make-complex-boolean-option
       pagename-sorting optname-sec-subtotal
@@ -962,7 +962,7 @@ disable the substring filter. This filter is case-sensitive.")
       (lambda (x)
         (set! sec-sortkey-subtotal-true x)
         (apply-selectable-by-name-sorting-options))))
-
+    
     (gnc:register-trep-option
      (gnc:make-multichoice-option
       pagename-sorting optname-sec-date-subtotal
@@ -979,140 +979,140 @@ disable the substring filter. This filter is case-sensitive.")
   
   ;; Display options
   
-    (let ((options gnc:*transaction-report-options*)
-          (disp-memo? #t)
-          (disp-accname? #t)
-          (disp-other-accname? #f)
-          (is-single? #t))
-
-      (define (apply-selectable-by-name-display-options)
-        (gnc-option-db-set-option-selectable-by-name
-         options gnc:pagename-display (N_ "Use Full Account Name")
-         disp-accname?)
-
-        (gnc-option-db-set-option-selectable-by-name
-         options gnc:pagename-display (N_ "Other Account Name")
-         is-single?)
-
-        (gnc-option-db-set-option-selectable-by-name
-         options gnc:pagename-display (N_ "Use Full Other Account Name")
-         (and disp-other-accname? is-single?))
-
-        (gnc-option-db-set-option-selectable-by-name
-         options gnc:pagename-display (N_ "Other Account Code")
-         is-single?)
-
-        (gnc-option-db-set-option-selectable-by-name
-         options gnc:pagename-display (N_ "Notes")
-         disp-memo?))
-
-  (for-each
-   (lambda (l)
-     (gnc:register-trep-option
-      (gnc:make-simple-boolean-option
-       gnc:pagename-display (car l) (cadr l) (caddr l) (cadddr l))))
-   ;; One list per option here with: option-name, sort-tag,
-   ;; help-string, default-value
-   (list
-    (list (N_ "Date")                         "a"  (N_ "Display the date?") #t)
-    (list (N_ "Reconciled Date")              "a2" (N_ "Display the reconciled date?") #f)
+  (let ((options gnc:*transaction-report-options*)
+        (disp-memo? #t)
+        (disp-accname? #t)
+        (disp-other-accname? #f)
+        (is-single? #t))
+    
+    (define (apply-selectable-by-name-display-options)
+      (gnc-option-db-set-option-selectable-by-name
+       options gnc:pagename-display (N_ "Use Full Account Name")
+       disp-accname?)
+      
+      (gnc-option-db-set-option-selectable-by-name
+       options gnc:pagename-display (N_ "Other Account Name")
+       is-single?)
+      
+      (gnc-option-db-set-option-selectable-by-name
+       options gnc:pagename-display (N_ "Use Full Other Account Name")
+       (and disp-other-accname? is-single?))
+      
+      (gnc-option-db-set-option-selectable-by-name
+       options gnc:pagename-display (N_ "Other Account Code")
+       is-single?)
+      
+      (gnc-option-db-set-option-selectable-by-name
+       options gnc:pagename-display (N_ "Notes")
+       disp-memo?))
+    
+    (for-each
+     (lambda (l)
+       (gnc:register-trep-option
+        (gnc:make-simple-boolean-option
+         gnc:pagename-display (car l) (cadr l) (caddr l) (cadddr l))))
+     ;; One list per option here with: option-name, sort-tag,
+     ;; help-string, default-value
+     (list
+      (list (N_ "Date")                         "a"  (N_ "Display the date?") #t)
+      (list (N_ "Reconciled Date")              "a2" (N_ "Display the reconciled date?") #f)
+      (if (qof-book-use-split-action-for-num-field (gnc-get-current-book))
+          (list (N_ "Num/Action")               "b"  (N_ "Display the check number?") #t)
+          (list (N_ "Num")                      "b"  (N_ "Display the check number?") #t))
+      (list (N_ "Description")                  "c"  (N_ "Display the description?") #t)
+      (list (N_ "Notes")                        "d2" (N_ "Display the notes if the memo is unavailable?") #t)
+      ;; account name option appears here
+      (list (N_ "Use Full Account Name")        "f"  (N_ "Display the full account name?") #t)
+      (list (N_ "Account Code")                 "g"  (N_ "Display the account code?") #f)
+      ;; other account name option appears here
+      (list (N_ "Use Full Other Account Name")  "i"  (N_ "Display the full account name?") #f)
+      (list (N_ "Other Account Code")           "j"  (N_ "Display the other account code?") #f)
+      (list (N_ "Shares")                       "k"  (N_ "Display the number of shares?") #f)
+      (list (N_ "Price")                        "l"  (N_ "Display the shares price?") #f)
+      ;; note the "Amount" multichoice option in between here
+      (list (N_ "Running Balance")              "n"  (N_ "Display a running balance?") #f)
+      (list (N_ "Totals")                       "o"  (N_ "Display the totals?") #t)))
+    
     (if (qof-book-use-split-action-for-num-field (gnc-get-current-book))
-        (list (N_ "Num/Action")               "b"  (N_ "Display the check number?") #t)
-        (list (N_ "Num")                      "b"  (N_ "Display the check number?") #t))
-    (list (N_ "Description")                  "c"  (N_ "Display the description?") #t)
-    (list (N_ "Notes")                        "d2" (N_ "Display the notes if the memo is unavailable?") #t)
-    ;; account name option appears here
-    (list (N_ "Use Full Account Name")        "f"  (N_ "Display the full account name?") #t)
-    (list (N_ "Account Code")                 "g"  (N_ "Display the account code?") #f)
-    ;; other account name option appears here
-    (list (N_ "Use Full Other Account Name")  "i"  (N_ "Display the full account name?") #f)
-    (list (N_ "Other Account Code")           "j"  (N_ "Display the other account code?") #f)
-    (list (N_ "Shares")                       "k"  (N_ "Display the number of shares?") #f)
-    (list (N_ "Price")                        "l"  (N_ "Display the shares price?") #f)
-    ;; note the "Amount" multichoice option in between here
-    (list (N_ "Running Balance")              "n"  (N_ "Display a running balance?") #f)
-    (list (N_ "Totals")                       "o"  (N_ "Display the totals?") #t)))
-
-  (if (qof-book-use-split-action-for-num-field (gnc-get-current-book))
-      (gnc:register-trep-option
-       (gnc:make-simple-boolean-option
-        gnc:pagename-display (N_ "Trans Number")
-                                    "b2" (N_ "Display the trans number?") #f)))
-
-  ;; Add an option to display the memo, and disable the notes option
-  ;; when memos are not included.
-  (gnc:register-trep-option
-   (gnc:make-complex-boolean-option
-    gnc:pagename-display (N_ "Memo")
-    "d"  (N_ "Display the memo?") #t
-    #f
-    (lambda (x)
+        (gnc:register-trep-option
+         (gnc:make-simple-boolean-option
+          gnc:pagename-display (N_ "Trans Number")
+          "b2" (N_ "Display the trans number?") #f)))
+    
+    ;; Add an option to display the memo, and disable the notes option
+    ;; when memos are not included.
+    (gnc:register-trep-option
+     (gnc:make-complex-boolean-option
+      gnc:pagename-display (N_ "Memo")
+      "d"  (N_ "Display the memo?") #t
+      #f
+      (lambda (x)
         (set! disp-memo? x)
         (apply-selectable-by-name-display-options))))
-
-  ;; Ditto for Account Name #t -> Use Full Account Name is selectable
-  (gnc:register-trep-option
-   (gnc:make-complex-boolean-option
-    gnc:pagename-display (N_ "Account Name")
-    "e"  (N_ "Display the account name?") #t
-    #f
-    (lambda (x)
+    
+    ;; Ditto for Account Name #t -> Use Full Account Name is selectable
+    (gnc:register-trep-option
+     (gnc:make-complex-boolean-option
+      gnc:pagename-display (N_ "Account Name")
+      "e"  (N_ "Display the account name?") #t
+      #f
+      (lambda (x)
         (set! disp-accname? x)
         (apply-selectable-by-name-display-options))))
-
-  ;; Ditto for Other Account Name #t -> Use Full Other Account Name is selectable
-  (gnc:register-trep-option
-   (gnc:make-complex-boolean-option
-    gnc:pagename-display (N_ "Other Account Name")
-    "h5"  (N_ "Display the other account name? (if this is a split transaction, this parameter is guessed).") #f
-    #f
-    (lambda (x)
+    
+    ;; Ditto for Other Account Name #t -> Use Full Other Account Name is selectable
+    (gnc:register-trep-option
+     (gnc:make-complex-boolean-option
+      gnc:pagename-display (N_ "Other Account Name")
+      "h5"  (N_ "Display the other account name? (if this is a split transaction, this parameter is guessed).") #f
+      #f
+      (lambda (x)
         (set! disp-other-accname? x)
         (apply-selectable-by-name-display-options))))
-
-  (gnc:register-trep-option
-   (gnc:make-multichoice-callback-option
-    gnc:pagename-display optname-detail-level
-    "h" (N_ "Amount of detail to display per transaction.")
-    'single
-    (list (vector 'multi-line
-                  (N_ "Multi-Line")
-                  (N_ "Display all splits in a transaction on a separate line."))
-          (vector 'single
-                  (N_ "Single")
-                  (N_ "Display one line per transaction, merging multiple splits where required.")))
-    #f
-    (lambda (x)
+    
+    (gnc:register-trep-option
+     (gnc:make-multichoice-callback-option
+      gnc:pagename-display optname-detail-level
+      "h" (N_ "Amount of detail to display per transaction.")
+      'single
+      (list (vector 'multi-line
+                    (N_ "Multi-Line")
+                    (N_ "Display all splits in a transaction on a separate line."))
+            (vector 'single
+                    (N_ "Single")
+                    (N_ "Display one line per transaction, merging multiple splits where required.")))
+      #f
+      (lambda (x)
         (set! is-single? (eq? x 'single))
         (apply-selectable-by-name-display-options))))
-
-  (gnc:register-trep-option
-   (gnc:make-multichoice-option
-    gnc:pagename-display (N_ "Amount")
-    "m" (N_ "Display the amount?")  
-    'single
-    (list
-     (vector 'none (N_ "None") (N_ "No amount display."))
-     (vector 'single (N_ "Single") (N_ "Single Column Display."))
-     (vector 'double (N_ "Double") (N_ "Two Column Display.")))))
-  
-  (gnc:register-trep-option
-   (gnc:make-multichoice-option
-    gnc:pagename-display (N_ "Sign Reverses")
-    "p" (N_ "Reverse amount display for certain account types.")
-    'credit-accounts
-    (list 
-     (vector 'none (N_ "None") (N_ "Don't change any displayed amounts."))
-     (vector 'income-expense (N_ "Income and Expense")
-             (N_ "Reverse amount display for Income and Expense Accounts."))
-     (vector 'credit-accounts (N_ "Credit Accounts")
-             (N_ "Reverse amount display for Liability, Payable, Equity, \
+    
+    (gnc:register-trep-option
+     (gnc:make-multichoice-option
+      gnc:pagename-display (N_ "Amount")
+      "m" (N_ "Display the amount?")  
+      'single
+      (list
+       (vector 'none (N_ "None") (N_ "No amount display."))
+       (vector 'single (N_ "Single") (N_ "Single Column Display."))
+       (vector 'double (N_ "Double") (N_ "Two Column Display.")))))
+    
+    (gnc:register-trep-option
+     (gnc:make-multichoice-option
+      gnc:pagename-display (N_ "Sign Reverses")
+      "p" (N_ "Reverse amount display for certain account types.")
+      'credit-accounts
+      (list 
+       (vector 'none (N_ "None") (N_ "Don't change any displayed amounts."))
+       (vector 'income-expense (N_ "Income and Expense")
+               (N_ "Reverse amount display for Income and Expense Accounts."))
+       (vector 'credit-accounts (N_ "Credit Accounts")
+               (N_ "Reverse amount display for Liability, Payable, Equity, \
 Credit Card, and Income accounts."))))))
-
-
+  
+  
   (gnc:options-set-default-section gnc:*transaction-report-options*
                                    gnc:pagename-general)
-
+  
   gnc:*transaction-report-options*)
 
 
@@ -1162,225 +1162,225 @@ Credit Card, and Income accounts."))))))
                           primary-subtotal-renderer
                           secondary-subtotal-renderer)
   
- (let ((work-to-do (length splits))
-       (work-done 0)
-       (used-columns (build-column-used options)))
-  (define (get-account-types-to-reverse options)
-    (cdr (assq (gnc:option-value 
-                (gnc:lookup-option options
-                                   gnc:pagename-display
-                                   (N_ "Sign Reverses")))
-               account-types-to-reverse-assoc-list)))
-  
-
-  (define (transaction-report-multi-rows-p options)
-    (eq? (gnc:option-value
-          (gnc:lookup-option options gnc:pagename-display optname-detail-level))
-         'multi-line))
-
-  (define (transaction-report-export-p options)
-    (gnc:option-value
-     (gnc:lookup-option options gnc:pagename-general
-       optname-table-export)))
-
-  (define (add-other-split-rows split table used-columns
-                                row-style account-types-to-reverse)
-    (define (other-rows-driver split parent table used-columns i)
-      (let ((current (xaccTransGetSplit parent i)))
-        (cond ((null? current) #f)
-              ((equal? current split)
-               (other-rows-driver split parent table used-columns (+ i 1)))
-              (else (begin
-                      (add-split-row table current used-columns options
-                                     row-style account-types-to-reverse #f)
-                      (other-rows-driver split parent table used-columns
-                                         (+ i 1)))))))
-
-    (other-rows-driver split (xaccSplitGetParent split)
-                       table used-columns 0))
-
-  (define (do-rows-with-subtotals splits 
-                                  table 
-                                  used-columns
-                                  width
-                                  multi-rows?
-                                  odd-row?
-                                  export?
-                                  account-types-to-reverse
-                                  primary-subtotal-pred
-                                  secondary-subtotal-pred 
-                                  primary-subheading-renderer
-                                  secondary-subheading-renderer
-                                  primary-subtotal-renderer
-                                  secondary-subtotal-renderer
-                                  primary-subtotal-collector 
-                                  secondary-subtotal-collector 
-                                  total-collector)
-
-    (gnc:report-percent-done (* 100 (/ work-done work-to-do)))
-    (set! work-done (+ 1 work-done))
-    (if (null? splits)
-        (begin
-          (gnc:html-table-append-row/markup!
-           table
-           def:grand-total-style
-           (list
-            (gnc:make-html-table-cell/size
-             1 width (gnc:make-html-text (gnc:html-markup-hr)))))
-	  (if (gnc:option-value (gnc:lookup-option options "Display" "Totals"))
-	      (render-grand-total table width total-collector export?)))
-	
-        (let* ((current (car splits))
-               (current-row-style (if multi-rows? def:normal-row-style
-                                      (if odd-row? def:normal-row-style 
-                                          def:alternate-row-style)))
-               (rest (cdr splits))
-               (next (if (null? rest) #f
-                         (car rest)))
-               (split-value (add-split-row 
-                             table 
-                             current 
-                             used-columns
-			     options
-                             current-row-style
-                             account-types-to-reverse
-                             #t)))
-          (if multi-rows?
-              (add-other-split-rows
-               current table used-columns def:alternate-row-style
-               account-types-to-reverse))
-
-          (primary-subtotal-collector 'add 
-                                      (gnc:gnc-monetary-commodity
-                                       split-value) 
-                                      (gnc:gnc-monetary-amount
-                                       split-value))
-          (secondary-subtotal-collector 'add
+  (let ((work-to-do (length splits))
+        (work-done 0)
+        (used-columns (build-column-used options)))
+    (define (get-account-types-to-reverse options)
+      (cdr (assq (gnc:option-value 
+                  (gnc:lookup-option options
+                                     gnc:pagename-display
+                                     (N_ "Sign Reverses")))
+                 account-types-to-reverse-assoc-list)))
+    
+    
+    (define (transaction-report-multi-rows-p options)
+      (eq? (gnc:option-value
+            (gnc:lookup-option options gnc:pagename-display optname-detail-level))
+           'multi-line))
+    
+    (define (transaction-report-export-p options)
+      (gnc:option-value
+       (gnc:lookup-option options gnc:pagename-general
+                          optname-table-export)))
+    
+    (define (add-other-split-rows split table used-columns
+                                  row-style account-types-to-reverse)
+      (define (other-rows-driver split parent table used-columns i)
+        (let ((current (xaccTransGetSplit parent i)))
+          (cond ((null? current) #f)
+                ((equal? current split)
+                 (other-rows-driver split parent table used-columns (+ i 1)))
+                (else (begin
+                        (add-split-row table current used-columns options
+                                       row-style account-types-to-reverse #f)
+                        (other-rows-driver split parent table used-columns
+                                           (+ i 1)))))))
+      
+      (other-rows-driver split (xaccSplitGetParent split)
+                         table used-columns 0))
+    
+    (define (do-rows-with-subtotals splits 
+                                    table 
+                                    used-columns
+                                    width
+                                    multi-rows?
+                                    odd-row?
+                                    export?
+                                    account-types-to-reverse
+                                    primary-subtotal-pred
+                                    secondary-subtotal-pred 
+                                    primary-subheading-renderer
+                                    secondary-subheading-renderer
+                                    primary-subtotal-renderer
+                                    secondary-subtotal-renderer
+                                    primary-subtotal-collector 
+                                    secondary-subtotal-collector 
+                                    total-collector)
+      
+      (gnc:report-percent-done (* 100 (/ work-done work-to-do)))
+      (set! work-done (+ 1 work-done))
+      (if (null? splits)
+          (begin
+            (gnc:html-table-append-row/markup!
+             table
+             def:grand-total-style
+             (list
+              (gnc:make-html-table-cell/size
+               1 width (gnc:make-html-text (gnc:html-markup-hr)))))
+            (if (gnc:option-value (gnc:lookup-option options "Display" "Totals"))
+                (render-grand-total table width total-collector export?)))
+          
+          (let* ((current (car splits))
+                 (current-row-style (if multi-rows? def:normal-row-style
+                                        (if odd-row? def:normal-row-style 
+                                            def:alternate-row-style)))
+                 (rest (cdr splits))
+                 (next (if (null? rest) #f
+                           (car rest)))
+                 (split-value (add-split-row 
+                               table 
+                               current 
+                               used-columns
+                               options
+                               current-row-style
+                               account-types-to-reverse
+                               #t)))
+            (if multi-rows?
+                (add-other-split-rows
+                 current table used-columns def:alternate-row-style
+                 account-types-to-reverse))
+            
+            (primary-subtotal-collector 'add 
                                         (gnc:gnc-monetary-commodity
-                                         split-value)
+                                         split-value) 
                                         (gnc:gnc-monetary-amount
                                          split-value))
-          (total-collector 'add
-                           (gnc:gnc-monetary-commodity split-value)
-                           (gnc:gnc-monetary-amount split-value))
-
-          (if (and primary-subtotal-pred
-                   (or (not next)
-                       (and next
-                            (not (primary-subtotal-pred current next)))))
-              (begin 
-                (if secondary-subtotal-pred
-
-                    (begin
-                      (secondary-subtotal-renderer
-                       table width current
-                       secondary-subtotal-collector
-                       def:secondary-subtotal-style used-columns export?)
-                      (secondary-subtotal-collector 'reset #f #f)))
-
-                (primary-subtotal-renderer table width current
-                                           primary-subtotal-collector
-                                           def:primary-subtotal-style used-columns
-                                           export?)
-
-                (primary-subtotal-collector 'reset #f #f)
-
-                (if next
-                    (begin 
-                      (primary-subheading-renderer
-                       next table width def:primary-subtotal-style used-columns)
-
-                      (if secondary-subtotal-pred
-                          (secondary-subheading-renderer
-                           next 
-                           table 
-                           width def:secondary-subtotal-style used-columns)))))
-
-              (if (and secondary-subtotal-pred
-                       (or (not next)
-                           (and next
-                                (not (secondary-subtotal-pred
-                                      current next)))))
-                  (begin (secondary-subtotal-renderer
-                          table width current
-                          secondary-subtotal-collector
-                          def:secondary-subtotal-style used-columns export?)
-                         (secondary-subtotal-collector 'reset #f #f)
-                         (if next
-                             (secondary-subheading-renderer
-                              next table width
-                              def:secondary-subtotal-style used-columns)))))
-
-          (do-rows-with-subtotals rest 
-                                  table 
-                                  used-columns
-                                  width 
-                                  multi-rows?
-                                  (not odd-row?)
-                                  export?
-                                  account-types-to-reverse
-                                  primary-subtotal-pred 
-                                  secondary-subtotal-pred
-                                  primary-subheading-renderer 
-                                  secondary-subheading-renderer
-                                  primary-subtotal-renderer
-                                  secondary-subtotal-renderer
-                                  primary-subtotal-collector 
-                                  secondary-subtotal-collector 
-                                  total-collector))))
-
-  (let* ((table (gnc:make-html-table))
-         (width (num-columns-required used-columns))
-         (multi-rows? (transaction-report-multi-rows-p options))
-	 (export? (transaction-report-export-p options))
-         (account-types-to-reverse
-          (get-account-types-to-reverse options)))
-
-    (gnc:html-table-set-col-headers!
-     table
-     (make-heading-list used-columns options))
-    ;;     (gnc:warn "Splits:" splits)
-    (if (not (null? splits))
-        (begin
-          (if primary-subheading-renderer 
-              (primary-subheading-renderer
-               (car splits) table width def:primary-subtotal-style used-columns))
-          (if secondary-subheading-renderer
-              (secondary-subheading-renderer
-               (car splits) table width def:secondary-subtotal-style used-columns))
-
-          (do-rows-with-subtotals splits table used-columns width
-                                  multi-rows? #t
-                                  export?
-                                  account-types-to-reverse
-                                  primary-subtotal-pred
-                                  secondary-subtotal-pred
-                                  primary-subheading-renderer
-                                  secondary-subheading-renderer
-                                  primary-subtotal-renderer
-                                  secondary-subtotal-renderer
-                                  (gnc:make-commodity-collector)
-                                  (gnc:make-commodity-collector)
-                                  (gnc:make-commodity-collector))))
+            (secondary-subtotal-collector 'add
+                                          (gnc:gnc-monetary-commodity
+                                           split-value)
+                                          (gnc:gnc-monetary-amount
+                                           split-value))
+            (total-collector 'add
+                             (gnc:gnc-monetary-commodity split-value)
+                             (gnc:gnc-monetary-amount split-value))
+            
+            (if (and primary-subtotal-pred
+                     (or (not next)
+                         (and next
+                              (not (primary-subtotal-pred current next)))))
+                (begin 
+                  (if secondary-subtotal-pred
+                      
+                      (begin
+                        (secondary-subtotal-renderer
+                         table width current
+                         secondary-subtotal-collector
+                         def:secondary-subtotal-style used-columns export?)
+                        (secondary-subtotal-collector 'reset #f #f)))
+                  
+                  (primary-subtotal-renderer table width current
+                                             primary-subtotal-collector
+                                             def:primary-subtotal-style used-columns
+                                             export?)
+                  
+                  (primary-subtotal-collector 'reset #f #f)
+                  
+                  (if next
+                      (begin 
+                        (primary-subheading-renderer
+                         next table width def:primary-subtotal-style used-columns)
+                        
+                        (if secondary-subtotal-pred
+                            (secondary-subheading-renderer
+                             next 
+                             table 
+                             width def:secondary-subtotal-style used-columns)))))
+                
+                (if (and secondary-subtotal-pred
+                         (or (not next)
+                             (and next
+                                  (not (secondary-subtotal-pred
+                                        current next)))))
+                    (begin (secondary-subtotal-renderer
+                            table width current
+                            secondary-subtotal-collector
+                            def:secondary-subtotal-style used-columns export?)
+                           (secondary-subtotal-collector 'reset #f #f)
+                           (if next
+                               (secondary-subheading-renderer
+                                next table width
+                                def:secondary-subtotal-style used-columns)))))
+            
+            (do-rows-with-subtotals rest 
+                                    table 
+                                    used-columns
+                                    width 
+                                    multi-rows?
+                                    (not odd-row?)
+                                    export?
+                                    account-types-to-reverse
+                                    primary-subtotal-pred 
+                                    secondary-subtotal-pred
+                                    primary-subheading-renderer 
+                                    secondary-subheading-renderer
+                                    primary-subtotal-renderer
+                                    secondary-subtotal-renderer
+                                    primary-subtotal-collector 
+                                    secondary-subtotal-collector 
+                                    total-collector))))
     
-    table)))
+    (let* ((table (gnc:make-html-table))
+           (width (num-columns-required used-columns))
+           (multi-rows? (transaction-report-multi-rows-p options))
+           (export? (transaction-report-export-p options))
+           (account-types-to-reverse
+            (get-account-types-to-reverse options)))
+      
+      (gnc:html-table-set-col-headers!
+       table
+       (make-heading-list used-columns options))
+      ;;     (gnc:warn "Splits:" splits)
+      (if (not (null? splits))
+          (begin
+            (if primary-subheading-renderer 
+                (primary-subheading-renderer
+                 (car splits) table width def:primary-subtotal-style used-columns))
+            (if secondary-subheading-renderer
+                (secondary-subheading-renderer
+                 (car splits) table width def:secondary-subtotal-style used-columns))
+            
+            (do-rows-with-subtotals splits table used-columns width
+                                    multi-rows? #t
+                                    export?
+                                    account-types-to-reverse
+                                    primary-subtotal-pred
+                                    secondary-subtotal-pred
+                                    primary-subheading-renderer
+                                    secondary-subheading-renderer
+                                    primary-subtotal-renderer
+                                    secondary-subtotal-renderer
+                                    (gnc:make-commodity-collector)
+                                    (gnc:make-commodity-collector)
+                                    (gnc:make-commodity-collector))))
+      
+      table)))
 
 ;; ;;;;;;;;;;;;;;;;;;;;
 ;; Here comes the renderer function for this report.
 (define (trep-renderer report-obj)
-
+  
   (define options (gnc:report-options report-obj))
-
+  
   (define (opt-val section name)
     (gnc:option-value
      (gnc:lookup-option options section name)))
-
+  
   (define comp-funcs-assoc-list
     ;; Defines the different sorting keys, together with the
     ;; subtotal functions. Each entry: (cons
     ;; 'sorting-key-option-value (vector 'query-sorting-key
     ;; subtotal-function subtotal-renderer))
-;;  (let* ((used-columns (build-column-used options))) ;; tpo: gives unbound variable options?
+    ;;  (let* ((used-columns (build-column-used options))) ;; tpo: gives unbound variable options?
     (let* ((used-columns (build-column-used (gnc:report-options report-obj))))
       (list (cons 'account-name  (vector 
                                   (list SPLIT-ACCT-FULLNAME)
@@ -1399,23 +1399,23 @@ Credit Card, and Income accounts."))))))
                                   (list SPLIT-TRANS TRANS-DATE-POSTED)
                                   #f #f #f))
             (cons 'reconciled-date (vector
-                                  (list SPLIT-DATE-RECONCILED)
-                                  #f #f #f))
+                                    (list SPLIT-DATE-RECONCILED)
+                                    #f #f #f))
             (cons 'register-order (vector
-                                  (list QUERY-DEFAULT-SORT)
-                                  #f #f #f))
+                                   (list QUERY-DEFAULT-SORT)
+                                   #f #f #f))
             (cons 'corresponding-acc-name
-                                 (vector
-                                  (list SPLIT-CORR-ACCT-NAME)
-                                  split-same-corr-account-full-name-p 
-                                  render-corresponding-account-subheading
-                                  render-corresponding-account-subtotal))
+                  (vector
+                   (list SPLIT-CORR-ACCT-NAME)
+                   split-same-corr-account-full-name-p 
+                   render-corresponding-account-subheading
+                   render-corresponding-account-subtotal))
             (cons 'corresponding-acc-code
-                                 (vector
-                                  (list SPLIT-CORR-ACCT-CODE)
-                                  split-same-corr-account-code-p 
-                                  render-corresponding-account-subheading
-                                  render-corresponding-account-subtotal))
+                  (vector
+                   (list SPLIT-CORR-ACCT-CODE)
+                   split-same-corr-account-code-p 
+                   render-corresponding-account-subheading
+                   render-corresponding-account-subtotal))
             (cons 'amount        (vector (list SPLIT-VALUE) #f #f #f))
             (cons 'description   (vector (list SPLIT-TRANS TRANS-DESCRIPTION) #f #f #f))
             (if (qof-book-use-split-action-for-num-field (gnc-get-current-book))
@@ -1424,7 +1424,7 @@ Credit Card, and Income accounts."))))))
             (cons 't-number      (vector (list SPLIT-TRANS TRANS-NUM) #f #f #f))
             (cons 'memo          (vector (list SPLIT-MEMO) #f #f #f))
             (cons 'none          (vector '() #f #f #f)))))
-
+  
   (define date-comp-funcs-assoc-list
     ;; Extra list for date option. Each entry: (cons
     ;; 'date-subtotal-option-value (vector subtotal-function
@@ -1432,14 +1432,14 @@ Credit Card, and Income accounts."))))))
     (list
      (cons 'none (vector #f #f #f))
      (cons 'weekly (vector split-same-week-p render-week-subheading
-			   render-week-subtotal))
+                           render-week-subtotal))
      (cons 'monthly (vector split-same-month-p render-month-subheading 
                             render-month-subtotal))
      (cons 'quarterly (vector split-same-quarter-p render-quarter-subheading 
-                            render-quarter-subtotal))
+                              render-quarter-subtotal))
      (cons 'yearly (vector split-same-year-p render-year-subheading
                            render-year-subtotal))))
-
+  
   (define (get-subtotalstuff-helper 
            name-sortkey name-subtotal name-date-subtotal
            comp-index date-index)
@@ -1467,32 +1467,32 @@ Credit Card, and Income accounts."))))))
     (vector-ref 
      (cdr (assq sort-option-value comp-funcs-assoc-list)) 
      0))
-
+  
   (define (get-subtotal-pred 
            name-sortkey name-subtotal name-date-subtotal)
     (get-subtotalstuff-helper 
      name-sortkey name-subtotal name-date-subtotal
      1 0))
-
+  
   (define (get-subheading-renderer
            name-sortkey name-subtotal name-date-subtotal)
     (get-subtotalstuff-helper 
      name-sortkey name-subtotal name-date-subtotal
      2 1))
-
+  
   (define (get-subtotal-renderer
            name-sortkey name-subtotal name-date-subtotal)
     (get-subtotalstuff-helper
      name-sortkey name-subtotal name-date-subtotal
      3 2))
-
+  
   ;;(define (get-other-account-names account-list)
   ;;  ( map (lambda (acct)  (gnc-account-get-full-name acct)) account-list))
-
+  
   (define (is-filter-member split account-list)
     (let* ((txn (xaccSplitGetParent split))
            (splitcount (xaccTransCountSplits txn)))
-
+      
       (cond
         ;; A 2-split transaction - test separately so it can be optimized
         ;; to significantly reduce the number of splits to traverse
@@ -1500,39 +1500,39 @@ Credit Card, and Income accounts."))))))
         ((= splitcount 2)
          (let* ((other      (xaccSplitGetOtherSplit split))
                 (other-acct (xaccSplitGetAccount other)))
-               (member other-acct account-list)))
-
+           (member other-acct account-list)))
+        
         ;; A multi-split transaction - run over all splits
         ((> splitcount 2)
          (let ((splits (xaccTransGetSplitList txn)))
-
-                ;; Walk through the list of splits.
-                ;; if we reach the end, return #f
-                ;; if the 'this' != 'split' and the split->account is a member
-                ;; of the account-list, then return #t, else recurse
-                (define (is-member splits)
-                  (if (null? splits)
-                      #f
-                      (let* ((this (car splits))
-                             (rest (cdr splits))
-                             (acct (xaccSplitGetAccount this)))
-                        (if (and (not (eq? this split))
-                                 (member acct account-list))
-                            #t
-                            (is-member rest)))))
-
-                (is-member splits)))
-
+           
+           ;; Walk through the list of splits.
+           ;; if we reach the end, return #f
+           ;; if the 'this' != 'split' and the split->account is a member
+           ;; of the account-list, then return #t, else recurse
+           (define (is-member splits)
+             (if (null? splits)
+                 #f
+                 (let* ((this (car splits))
+                        (rest (cdr splits))
+                        (acct (xaccSplitGetAccount this)))
+                   (if (and (not (eq? this split))
+                            (member acct account-list))
+                       #t
+                       (is-member rest)))))
+           
+           (is-member splits)))
+        
         ;; Single transaction splits
         (else #f))))
-
-
+  
+  
   (gnc:report-starting reportname)
   (let ((document (gnc:make-html-document))
-	(c_account_1 (opt-val gnc:pagename-accounts "Accounts"))
-	(c_account_substring (opt-val gnc:pagename-accounts "Account Substring"))
-	(c_account_2 (opt-val gnc:pagename-accounts "Filter By..."))
-	(filter-mode (opt-val gnc:pagename-accounts "Filter Type"))
+        (c_account_1 (opt-val gnc:pagename-accounts "Accounts"))
+        (c_account_substring (opt-val gnc:pagename-accounts "Account Substring"))
+        (c_account_2 (opt-val gnc:pagename-accounts "Filter By..."))
+        (filter-mode (opt-val gnc:pagename-accounts "Filter Type"))
         (begindate (gnc:timepair-start-day-time
                     (gnc:date-option-absolute-time
                      (opt-val gnc:pagename-general "Start Date"))))
@@ -1546,13 +1546,13 @@ Credit Card, and Income accounts."))))))
         (primary-order (opt-val pagename-sorting "Primary Sort Order"))
         (secondary-key (opt-val pagename-sorting optname-sec-sortkey))
         (secondary-order (opt-val pagename-sorting "Secondary Sort Order"))
-	(void-status (opt-val gnc:pagename-accounts optname-void-transactions))
+        (void-status (opt-val gnc:pagename-accounts optname-void-transactions))
         (splits '())
         (query (qof-query-create-for-splits)))
-
+    
     ;;(gnc:warn "accts in trep-renderer:" c_account_1)
     ;;(gnc:warn "Report Account names:" (get-other-account-names c_account_1))
-
+    
     (set! c_account_1
           (filter (lambda (acc)
                     (string-contains (gnc-account-get-full-name acc) c_account_substring))
@@ -1561,55 +1561,55 @@ Credit Card, and Income accounts."))))))
     (if (not (or (null? c_account_1) (and-map not c_account_1)))
         (begin
           (qof-query-set-book query (gnc-get-current-book))
-	      ;;(gnc:warn "query is:" query)
+          ;;(gnc:warn "query is:" query)
           (xaccQueryAddAccountMatch query
-                                       c_account_1
-                                       QOF-GUID-MATCH-ANY QOF-QUERY-AND)
+                                    c_account_1
+                                    QOF-GUID-MATCH-ANY QOF-QUERY-AND)
           (xaccQueryAddDateMatchTS
            query #t begindate #t enddate QOF-QUERY-AND)
           (qof-query-set-sort-order query
-				    (get-query-sortkey primary-key)
-				    (get-query-sortkey secondary-key)
-				    '())
-
+                                    (get-query-sortkey primary-key)
+                                    (get-query-sortkey secondary-key)
+                                    '())
+          
           (qof-query-set-sort-increasing query
                                          (eq? primary-order 'ascend)
                                          (eq? secondary-order 'ascend)
                                          #t)
-
-	  (case void-status
-	   ((non-void-only) 
-	    (gnc:query-set-match-non-voids-only! query (gnc-get-current-book)))
-	   ((void-only)
-	    (gnc:query-set-match-voids-only! query (gnc-get-current-book)))
-	   (else #f))
-
+          
+          (case void-status
+            ((non-void-only) 
+             (gnc:query-set-match-non-voids-only! query (gnc-get-current-book)))
+            ((void-only)
+             (gnc:query-set-match-voids-only! query (gnc-get-current-book)))
+            (else #f))
+          
           (set! splits (qof-query-run query))
-
+          
           ;;(gnc:warn "Splits in trep-renderer:" splits)
-
-	  ;;(gnc:warn "Filter account names:" (get-other-account-names c_account_2))
-
-	  ;;This should probably a cond or a case to allow for different filter types.
-	  ;;(gnc:warn "Filter Mode: " filter-mode)
-	  (if (eq? filter-mode 'include)
-	      (begin
-		;;(gnc:warn "Including Filter Accounts")
-		(set! splits (filter (lambda (split) 
-				       (is-filter-member split c_account_2))
-				     splits))
-		)
-	      )
-
-	  (if (eq? filter-mode 'exclude)
-	      (begin
-		;;(gnc:warn "Excluding Filter Accounts")
-		(set! splits (filter (lambda (split) 
-				       (not (is-filter-member split c_account_2)))
-				     splits))
-		)
-	      )
-	
+          
+          ;;(gnc:warn "Filter account names:" (get-other-account-names c_account_2))
+          
+          ;;This should probably a cond or a case to allow for different filter types.
+          ;;(gnc:warn "Filter Mode: " filter-mode)
+          (if (eq? filter-mode 'include)
+              (begin
+                ;;(gnc:warn "Including Filter Accounts")
+                (set! splits (filter (lambda (split) 
+                                       (is-filter-member split c_account_2))
+                                     splits))
+                )
+              )
+          
+          (if (eq? filter-mode 'exclude)
+              (begin
+                ;;(gnc:warn "Excluding Filter Accounts")
+                (set! splits (filter (lambda (split) 
+                                       (not (is-filter-member split c_account_2)))
+                                     splits))
+                )
+              )
+          
           (if (not (null? splits))
               (let ((table 
                      (make-split-table 
@@ -1633,7 +1633,7 @@ Credit Card, and Income accounts."))))))
                       (get-subtotal-renderer   optname-sec-sortkey
                                                optname-sec-subtotal
                                                optname-sec-date-subtotal))))
-
+                
                 (gnc:html-document-set-title! document
                                               report-title)
                 (gnc:html-document-add-object! 
@@ -1656,14 +1656,14 @@ Credit Card, and Income accounts."))))))
 match the time interval and account selection specified \
 in the Options panel.")))
                 (gnc:html-document-add-object! document p))))
-
+        
         ;; error condition: no accounts specified
         
         (gnc:html-document-add-object!
          document 
-	 (gnc:html-make-no-account-warning 
-	  report-title (gnc:report-id report-obj))))
-
+         (gnc:html-make-no-account-warning 
+          report-title (gnc:report-id report-obj))))
+    
     (gnc:report-finished)
     document))
 

commit 62824e003606fd26191553af3818202ecdf7d951
Author: christopherlam <christopher.lck at gmail.com>
Date:   Sun Sep 17 00:53:39 2017 +0100

    cp transaction.scm income-gst-statement.scm

diff --git a/gnucash/report/standard-reports/CMakeLists.txt b/gnucash/report/standard-reports/CMakeLists.txt
index a2ddcc7..35c53c2 100644
--- a/gnucash/report/standard-reports/CMakeLists.txt
+++ b/gnucash/report/standard-reports/CMakeLists.txt
@@ -20,6 +20,7 @@ SET (standard_reports_SCHEME_2
     equity-statement.scm
     general-journal.scm
     general-ledger.scm
+    income-gst-statement.scm
     income-statement.scm
     net-barchart.scm
     net-linechart.scm
diff --git a/gnucash/report/standard-reports/Makefile.am b/gnucash/report/standard-reports/Makefile.am
index 5d0bf60..e95f369 100644
--- a/gnucash/report/standard-reports/Makefile.am
+++ b/gnucash/report/standard-reports/Makefile.am
@@ -22,6 +22,7 @@ gncscmrpt_DATA = \
    equity-statement.scm \
    general-journal.scm \
    general-ledger.scm \
+   income-gst-statement.scm \
    income-statement.scm \
    net-barchart.scm \
    net-linechart.scm \
diff --git a/gnucash/report/standard-reports/income-gst-statement.scm b/gnucash/report/standard-reports/income-gst-statement.scm
new file mode 100644
index 0000000..4fbab7d
--- /dev/null
+++ b/gnucash/report/standard-reports/income-gst-statement.scm
@@ -0,0 +1,1680 @@
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; transaction-report.scm : Report on all transactions in account(s)
+;;
+;; Original report by Robert Merkel <rgmerk at mira.net>
+;; Contributions by Bryan Larsen <blarsen at ada-works.com>
+;; More contributions for new report generation code by Robert Merkel
+;; More contributions by Christian Stimming <stimming at tuhh.de>
+;; Modified to support the intersection of two account lists by
+;; Michael T. Garrison Stuber
+;; Modified account names display by Tomas Pospisek
+;; <tpo_deb at sourcepole.ch> with a lot of help from "warlord"
+;;
+;; 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
+;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(define-module (gnucash report standard-reports transaction))
+
+(use-modules (gnucash main)) ;; FIXME: delete after we finish modularizing.
+(use-modules (srfi srfi-1))
+(use-modules (srfi srfi-13))
+(use-modules (gnucash gnc-module))
+(use-modules (gnucash gettext))
+
+(use-modules (gnucash printf))
+
+(gnc:module-load "gnucash/report/report-system" 0)
+
+(define-macro (addto! alist element)
+  `(set! ,alist (cons ,element ,alist)))
+
+;; Define the strings here to avoid typos and make changes easier.
+
+(define reportname (N_ "Transaction Report"))
+(define optname-detail-level (N_ "Detail Level"))
+(define pagename-sorting (N_ "Sorting"))
+(define optname-prime-sortkey (N_ "Primary Key"))
+(define optname-prime-subtotal (N_ "Primary Subtotal"))
+(define optname-prime-sortorder (N_ "Primary Sort Order"))
+(define optname-prime-date-subtotal (N_ "Primary Subtotal for Date Key"))
+(define optname-full-account-name (N_ "Show Full Account Name"))
+(define optname-show-account-code (N_ "Show Account Code"))
+(define optname-sec-sortkey (N_ "Secondary Key"))
+(define optname-sec-subtotal (N_ "Secondary Subtotal"))
+(define optname-sec-sortorder  (N_ "Secondary Sort Order"))
+(define optname-sec-date-subtotal (N_ "Secondary Subtotal for Date Key"))
+(define optname-void-transactions (N_ "Void Transactions"))
+(define optname-table-export (N_ "Table for Exporting"))
+(define optname-common-currency (N_ "Common Currency"))
+(define optname-currency (N_ "Report's currency"))
+(define def:grand-total-style "grand-total")
+(define def:normal-row-style "normal-row")
+(define def:alternate-row-style "alternate-row")
+(define def:primary-subtotal-style "primary-subheading")
+(define def:secondary-subtotal-style "secondary-subheading")
+;; The option-values of the sorting key multichoice option, for
+;; which a subtotal should be enabled.
+(define subtotal-enabled '(account-name
+                           account-code 
+                           corresponding-acc-name
+                           corresponding-acc-code))
+
+(define (split-account-full-name-same-p a b)
+  (= (xaccSplitCompareAccountFullNames a b) 0))
+
+(define (split-account-code-same-p a b)
+  (= (xaccSplitCompareAccountCodes a b) 0))
+
+(define (split-same-corr-account-full-name-p a b)
+  (= (xaccSplitCompareOtherAccountFullNames a b) 0))
+
+(define (split-same-corr-account-code-p a b)
+  (= (xaccSplitCompareOtherAccountCodes a b) 0))
+
+(define (timepair-same-year tp-a tp-b)
+  (= (gnc:timepair-get-year tp-a)
+     (gnc:timepair-get-year tp-b)))
+
+(define (timepair-same-quarter tp-a tp-b)
+  (and (timepair-same-year tp-a tp-b) 
+       (= (gnc:timepair-get-quarter tp-a)
+          (gnc:timepair-get-quarter tp-b))))
+
+(define (timepair-same-month tp-a tp-b)
+  (and (timepair-same-year tp-a tp-b) 
+       (= (gnc:timepair-get-month tp-a)
+          (gnc:timepair-get-month tp-b))))
+
+(define (timepair-same-week tp-a tp-b)
+  (and (timepair-same-year tp-a tp-b)
+       (= (gnc:timepair-get-week tp-a)
+	  (gnc:timepair-get-week tp-b))))
+
+(define (split-same-week-p a b)
+  (let ((tp-a (gnc-transaction-get-date-posted (xaccSplitGetParent a)))
+	(tp-b (gnc-transaction-get-date-posted (xaccSplitGetParent b))))
+    (timepair-same-week tp-a tp-b)))
+
+(define (split-same-month-p a b)
+  (let ((tp-a (gnc-transaction-get-date-posted (xaccSplitGetParent a)))
+        (tp-b (gnc-transaction-get-date-posted (xaccSplitGetParent b))))
+    (timepair-same-month tp-a tp-b)))
+
+(define (split-same-quarter-p a b)
+  (let ((tp-a (gnc-transaction-get-date-posted (xaccSplitGetParent a)))
+        (tp-b (gnc-transaction-get-date-posted (xaccSplitGetParent b))))
+    (timepair-same-quarter tp-a tp-b)))
+
+(define (split-same-year-p a b)
+  (let ((tp-a (gnc-transaction-get-date-posted (xaccSplitGetParent a)))
+        (tp-b (gnc-transaction-get-date-posted (xaccSplitGetParent b))))
+    (timepair-same-year tp-a tp-b)))
+
+(define (set-last-row-style! table tag . rest)
+  (let ((arg-list 
+         (cons table 
+               (cons (- (gnc:html-table-num-rows table) 1)
+                     (cons tag rest)))))
+    (apply gnc:html-table-set-row-style! arg-list)))
+
+(define (add-subheading-row data table width subheading-style)
+  (let ((heading-cell (gnc:make-html-table-cell data)))
+    (gnc:html-table-cell-set-colspan! heading-cell width)
+    (gnc:html-table-append-row/markup!
+     table
+     subheading-style
+     (list heading-cell))))
+
+;; display an account name depending on the options the user has set
+(define (account-namestring account show-account-code show-account-name show-account-full-name)
+  ;;# on multi-line splits we can get an empty ('()) account
+  (if (null? account)
+        (_ "Split Transaction")
+        (string-append 
+           ;; display account code?
+           (if show-account-code
+                 (string-append (xaccAccountGetCode account) " ")
+                 "")
+           ;; display account name?
+           (if show-account-name
+                 ;; display full account name?
+                 (if show-account-full-name
+                      (gnc-account-get-full-name account)
+                      (xaccAccountGetName account))
+                 ""))))
+
+;; render an account subheading - column-vector determines what is displayed
+(define (render-account-subheading
+         split table width subheading-style column-vector)
+  (let ((account (xaccSplitGetAccount split)))
+    (add-subheading-row (gnc:make-html-text
+                         (gnc:html-markup-anchor
+                           (gnc:account-anchor-text account)
+                           (account-namestring account
+                                               (used-sort-account-code      column-vector)
+                                               #t
+                                               (used-sort-account-full-name column-vector))))
+                        table width subheading-style)))
+
+(define (render-corresponding-account-subheading 
+         split table width subheading-style column-vector)
+  (let ((account (xaccSplitGetAccount (xaccSplitGetOtherSplit split))))
+    (add-subheading-row (gnc:make-html-text
+                         (gnc:html-markup-anchor
+                          (if (not (null? account))
+                           (gnc:account-anchor-text account)
+                           "")
+                           (account-namestring account
+                                               (used-sort-account-code      column-vector)
+                                               #t
+                                               (used-sort-account-full-name column-vector))))
+                        table width subheading-style)))
+
+(define (render-week-subheading split table width subheading-style column-vector)
+  (add-subheading-row (gnc:date-get-week-year-string
+		       (gnc:timepair->date
+			(gnc-transaction-get-date-posted
+			 (xaccSplitGetParent split))))
+		      table width subheading-style))
+
+(define (render-month-subheading split table width subheading-style column-vector)
+  (add-subheading-row (gnc:date-get-month-year-string
+                      (gnc:timepair->date 
+                       (gnc-transaction-get-date-posted
+                        (xaccSplitGetParent split))))
+                     table width subheading-style))
+
+(define (render-quarter-subheading split table width subheading-style column-vector)
+  (add-subheading-row (gnc:date-get-quarter-year-string 
+                      (gnc:timepair->date 
+                       (gnc-transaction-get-date-posted
+                        (xaccSplitGetParent split))))
+                     table width subheading-style))
+
+(define (render-year-subheading split table width subheading-style column-vector)
+  (add-subheading-row (gnc:date-get-year-string 
+                      (gnc:timepair->date 
+                       (gnc-transaction-get-date-posted
+                        (xaccSplitGetParent split))))
+                      table width subheading-style))
+
+
+(define (add-subtotal-row table width subtotal-string subtotal-collector 
+                          subtotal-style export?)
+  (let ((currency-totals (subtotal-collector
+                          'format gnc:make-gnc-monetary #f))
+        (blanks (gnc:make-html-table-cell/size 1 (- width 1) #f)))
+    (gnc:html-table-append-row/markup!
+     table
+     subtotal-style 
+     (if export?
+      (append! (cons (gnc:make-html-table-cell/markup "total-label-cell" subtotal-string)
+                     (gnc:html-make-empty-cells (- width 2)))
+               (list (gnc:make-html-table-cell/markup 
+                      "total-number-cell"
+                      (car currency-totals))))
+     (list (gnc:make-html-table-cell/size/markup 1 (- width 1) "total-label-cell"
+                                          subtotal-string)
+           (gnc:make-html-table-cell/markup 
+            "total-number-cell"
+             (car currency-totals)))))
+    (for-each (lambda (currency)
+                (gnc:html-table-append-row/markup! 
+                 table
+                 subtotal-style
+                 (append!
+                  (if export?
+                   (gnc:html-make-empty-cells (- width 1))
+                   (list blanks))
+                         (list (gnc:make-html-table-cell/markup
+                                "total-number-cell" currency)))))
+              (cdr currency-totals))))
+
+(define (total-string str) (string-append (_ "Total For ") str))
+
+(define (render-account-subtotal 
+         table width split total-collector subtotal-style column-vector export?)
+    (add-subtotal-row table width 
+                      (total-string (account-namestring (xaccSplitGetAccount split)
+                                                        (used-sort-account-code      column-vector)
+                                                        #t
+                                                        (used-sort-account-full-name column-vector)))
+                      total-collector subtotal-style export?))
+
+(define (render-corresponding-account-subtotal
+         table width split total-collector subtotal-style column-vector export?)
+    (add-subtotal-row table width
+                      (total-string (account-namestring (xaccSplitGetAccount
+                                                          (xaccSplitGetOtherSplit split))
+                                                        (used-sort-account-code      column-vector)
+                                                        #t
+                                                        (used-sort-account-full-name column-vector)))
+                    total-collector subtotal-style export?))
+
+(define (render-week-subtotal
+	 table width split total-collector subtotal-style column-vector export?)
+  (let ((tm (gnc:timepair->date (gnc-transaction-get-date-posted
+				 (xaccSplitGetParent split)))))
+    (add-subtotal-row table width
+		      (total-string (gnc:date-get-week-year-string tm))
+		      total-collector subtotal-style export?)))
+
+(define (render-month-subtotal
+         table width split total-collector subtotal-style column-vector export?)
+  (let ((tm (gnc:timepair->date (gnc-transaction-get-date-posted
+                                 (xaccSplitGetParent split)))))
+    (add-subtotal-row table width 
+                      (total-string (gnc:date-get-month-year-string tm))
+                      total-collector subtotal-style export?)))
+
+
+(define (render-quarter-subtotal
+         table width split total-collector subtotal-style column-vector export?)
+  (let ((tm (gnc:timepair->date (gnc-transaction-get-date-posted
+                                 (xaccSplitGetParent split)))))
+    (add-subtotal-row table width 
+                      (total-string (gnc:date-get-quarter-year-string tm))
+                     total-collector subtotal-style export?)))
+
+(define (render-year-subtotal
+         table width split total-collector subtotal-style column-vector export?)
+  (let ((tm (gnc:timepair->date (gnc-transaction-get-date-posted
+                                 (xaccSplitGetParent split)))))
+    (add-subtotal-row table width 
+                      (total-string (strftime "%Y" tm))
+                      total-collector subtotal-style export?)))
+
+
+(define (render-grand-total
+         table width total-collector export?)
+  (add-subtotal-row table width
+                    (_ "Grand Total")
+                    total-collector def:grand-total-style export?))
+
+(define account-types-to-reverse-assoc-list
+  (list (cons 'none '())
+        (cons 'income-expense
+              (list ACCT-TYPE-INCOME ACCT-TYPE-EXPENSE))
+        (cons 'credit-accounts
+              (list ACCT-TYPE-LIABILITY ACCT-TYPE-PAYABLE ACCT-TYPE-EQUITY
+                    ACCT-TYPE-CREDIT ACCT-TYPE-INCOME))))
+
+(define (used-date columns-used)
+  (vector-ref columns-used 0))
+(define (used-reconciled-date columns-used)
+  (vector-ref columns-used 1))
+(define (used-num columns-used)
+  (vector-ref columns-used 2))
+(define (used-description columns-used)
+  (vector-ref columns-used 3))
+(define (used-account-name columns-used)
+  (vector-ref columns-used 4))
+(define (used-other-account-name columns-used)
+  (vector-ref columns-used 5))	
+(define (used-shares columns-used)
+  (vector-ref columns-used 6))	
+(define (used-price columns-used)
+  (vector-ref columns-used 7))	
+(define (used-amount-single columns-used)
+  (vector-ref columns-used 8))	
+(define (used-amount-double-positive columns-used)
+  (vector-ref columns-used 9))	
+(define (used-amount-double-negative columns-used)
+  (vector-ref columns-used 10))	
+(define (used-running-balance columns-used)
+  (vector-ref columns-used 11))
+(define (used-account-full-name columns-used)
+  (vector-ref columns-used 12))
+(define (used-memo columns-used)
+  (vector-ref columns-used 13))
+(define (used-account-code columns-used)
+  (vector-ref columns-used 14))
+(define (used-other-account-code columns-used)
+  (vector-ref columns-used 15))
+(define (used-other-account-full-name columns-used)
+  (vector-ref columns-used 16))
+(define (used-sort-account-code columns-used)
+  (vector-ref columns-used 17))
+(define (used-sort-account-full-name columns-used)
+  (vector-ref columns-used 18))
+(define (used-notes columns-used)
+  (vector-ref columns-used 19))
+
+(define columns-used-size 20)
+
+(define (num-columns-required columns-used)  
+  (do ((i 0 (+ i 1)) 
+       (col-req 0 col-req)) 
+      ((>= i columns-used-size) col-req)
+    ; If column toggle is true, increase column count. But attention:
+    ; some toggles only change the meaning of another toggle. Don't count these modifier toggles
+    (if (and (not (= i 12)) ; Skip Account Full Name toggle - modifies Account Name column
+             (not (= i 16)) ; Skip Other Account Full Name toggle - modifies Other Account Name column
+             (not (= i 17)) ; Skip Sort Account Code - modifies Account Name subheading
+             (not (= i 18)) ; Skip Sort Account Full Name - modifies Account Name subheading
+             (not (= i 19)) ; Skip Note toggle - modifies Memo column
+             (vector-ref columns-used i))
+      (set! col-req (+ col-req 1)))
+    ; Account Code and Account Name share one column so if both were ticked the
+    ; the check above would have set up one column too much. The check below
+    ; will compensate these again.
+    (if (or (and (= i 14) (vector-ref columns-used 14) (vector-ref columns-used 4)) ; Account Code and Name
+            (and (= i 15) (vector-ref columns-used 15) (vector-ref columns-used 5))) ; Other Account Code and Name
+      (set! col-req (- col-req 1)))))
+
+(define (build-column-used options)   
+  (define (opt-val section name)
+    (gnc:option-value 
+     (gnc:lookup-option options section name)))
+  (let ((column-list (make-vector columns-used-size #f))
+        (is-single? (eq? (opt-val gnc:pagename-display optname-detail-level) 'single)))
+    (if (opt-val gnc:pagename-display (N_ "Date"))
+        (vector-set! column-list 0 #t))
+    (if (opt-val gnc:pagename-display (N_ "Reconciled Date"))
+        (vector-set! column-list 1 #t))
+    (if (if (gnc:lookup-option options gnc:pagename-display (N_ "Num"))
+            (opt-val gnc:pagename-display (N_ "Num"))
+            (opt-val gnc:pagename-display (N_ "Num/Action")))
+        (vector-set! column-list 2 #t))
+    (if (opt-val gnc:pagename-display (N_ "Description"))
+        (vector-set! column-list 3 #t))
+    (if (opt-val gnc:pagename-display (N_ "Account Name"))
+        (vector-set! column-list 4 #t))
+    (if (and is-single? (opt-val gnc:pagename-display (N_ "Other Account Name")))
+        (vector-set! column-list 5 #t))
+    (if (opt-val gnc:pagename-display (N_ "Shares"))
+        (vector-set! column-list 6 #t))
+    (if (opt-val gnc:pagename-display (N_ "Price"))
+        (vector-set! column-list 7 #t))
+    (let ((amount-setting (opt-val gnc:pagename-display (N_ "Amount"))))
+      (if (eq? amount-setting 'single)
+          (vector-set! column-list 8 #t))
+      (if (eq? amount-setting 'double)
+          (begin (vector-set! column-list 9 #t)
+                 (vector-set! column-list 10 #t))))
+    (if (opt-val gnc:pagename-display (N_ "Running Balance"))
+        (vector-set! column-list 11 #t))
+    (if (opt-val gnc:pagename-display  (N_ "Use Full Account Name"))
+        (vector-set! column-list 12 #t))
+    (if (opt-val gnc:pagename-display (N_ "Memo"))
+        (vector-set! column-list 13 #t))
+    (if (opt-val gnc:pagename-display (N_ "Account Code"))
+        (vector-set! column-list 14 #t))
+    (if (and is-single? (opt-val gnc:pagename-display (N_ "Other Account Code")))
+        (vector-set! column-list 15 #t))
+    (if (and is-single? (opt-val gnc:pagename-display (N_ "Use Full Other Account Name")))
+        (vector-set! column-list 16 #t))
+    (if (opt-val pagename-sorting (N_ "Show Account Code"))
+        (vector-set! column-list 17 #t))
+    (if (opt-val pagename-sorting (N_ "Show Full Account Name"))
+        (vector-set! column-list 18 #t))
+    (if (opt-val gnc:pagename-display (N_ "Notes"))
+        (vector-set! column-list 19 #t))
+    column-list))
+
+(define (make-heading-list column-vector options)
+  (let ((heading-list '()))
+    (if (used-date column-vector)
+        (addto! heading-list (_ "Date")))
+    (if (used-reconciled-date column-vector)
+        (addto! heading-list (_ "Reconciled Date")))
+    (if (used-num column-vector)
+        (addto! heading-list (if (and (qof-book-use-split-action-for-num-field
+                                                        (gnc-get-current-book))
+                                      (if (gnc:lookup-option options
+                                                    gnc:pagename-display
+                                                    (N_ "Trans Number"))
+                                          (gnc:option-value 
+                                            (gnc:lookup-option options
+                                                    gnc:pagename-display
+                                                    (N_ "Trans Number")))
+                                          #f))
+                                 (_ "Num/T-Num")
+                                 (_ "Num"))))
+    (if (used-description column-vector)
+        (addto! heading-list (_ "Description")))
+    (if (used-memo column-vector)
+        (if (used-notes column-vector)
+            (addto! heading-list (string-append (_ "Memo") "/" (_ "Notes")))
+            (addto! heading-list (_ "Memo"))))
+    (if (or (used-account-name column-vector) (used-account-code column-vector))
+        (addto! heading-list (_ "Account")))
+    (if (or (used-other-account-name column-vector) (used-other-account-code column-vector))
+        (addto! heading-list (_ "Transfer from/to")))
+    (if (used-shares column-vector)
+        (addto! heading-list (_ "Shares")))
+    (if (used-price column-vector)
+        (addto! heading-list (_ "Price")))
+    (if (used-amount-single column-vector)
+        (addto! heading-list (_ "Amount")))
+    ;; FIXME: Proper labels: what?
+    (if (used-amount-double-positive column-vector)
+        (addto! heading-list (_ "Debit")))
+    (if (used-amount-double-negative column-vector)
+        (addto! heading-list (_ "Credit")))
+    (if (used-running-balance column-vector)
+        (addto! heading-list (_ "Balance")))
+    (reverse heading-list)))
+
+(define (add-split-row table split column-vector options
+                       row-style account-types-to-reverse transaction-row?)
+
+  (define (opt-val section name)
+    (gnc:option-value 
+     (gnc:lookup-option options section name)))
+
+  (let* ((row-contents '())
+         (dummy  (gnc:debug "split is originally" split))
+         (parent (xaccSplitGetParent split))
+         (account (xaccSplitGetAccount split))
+         (account-type (xaccAccountGetType account))
+         (currency (if (not (null? account))
+                       (xaccAccountGetCommodity account)
+                       (gnc-default-currency)))
+	 (report-currency (if (opt-val gnc:pagename-general optname-common-currency)
+			       (opt-val gnc:pagename-general optname-currency)
+			       currency))
+         (damount (if (gnc:split-voided? split)
+					 (xaccSplitVoidFormerAmount split)
+					 (xaccSplitGetAmount split)))
+	 (trans-date (gnc-transaction-get-date-posted parent))
+	 (split-value (gnc:exchange-by-pricedb-nearest
+		       (gnc:make-gnc-monetary 
+			currency
+			(if (member account-type account-types-to-reverse) 
+			    (gnc-numeric-neg damount)
+			    damount))
+		       report-currency
+		       ;; Use midday as the transaction time so it matches a price
+		       ;; on the same day.  Otherwise it uses midnight which will
+		       ;; likely match a price on the previous day
+		       (timespecCanonicalDayTime trans-date))))
+    
+    (if (used-date column-vector)
+        (addto! row-contents
+                (if transaction-row?
+                    (gnc:make-html-table-cell/markup "date-cell"
+                        (gnc-print-date (gnc-transaction-get-date-posted parent)))
+                    " ")))
+    (if (used-reconciled-date column-vector)
+        (addto! row-contents
+                (gnc:make-html-table-cell/markup "date-cell"
+		    (let ((date (gnc-split-get-date-reconciled split)))
+		      (if (equal? date (cons 0 0))
+		          " "
+		          (gnc-print-date date))))))
+    (if (used-num column-vector)
+        (addto! row-contents
+                (if transaction-row?
+                    (if (qof-book-use-split-action-for-num-field
+                                                        (gnc-get-current-book))
+                        (let* ((num (gnc-get-num-action parent split))
+                               (t-num (if (if (gnc:lookup-option options
+                                                    gnc:pagename-display
+                                                    (N_ "Trans Number"))
+                                              (opt-val gnc:pagename-display
+                                                    (N_ "Trans Number"))
+                                              #f)
+                                          (gnc-get-num-action parent #f)
+                                          ""))
+                               (num-string (if (equal? t-num "")
+                                               num
+                                               (string-append num "/" t-num))))
+                              (gnc:make-html-table-cell/markup "text-cell"
+                                   num-string))
+                        (gnc:make-html-table-cell/markup "text-cell"
+                            (gnc-get-num-action parent split)))
+                    " ")))
+
+    (if (used-description column-vector)
+        (addto! row-contents
+                (if transaction-row?
+                    (gnc:make-html-table-cell/markup "text-cell"
+                        (xaccTransGetDescription parent))
+                    " ")))
+    
+    (if (used-memo column-vector)
+        (let ((memo (xaccSplitGetMemo split)))
+          (if (and (equal? memo "") (used-notes column-vector))
+              (addto! row-contents (xaccTransGetNotes parent))
+              (addto! row-contents memo))))
+    
+    (if (or (used-account-name column-vector) (used-account-code column-vector))
+       (addto! row-contents (account-namestring account
+                                                (used-account-code      column-vector)
+                                                (used-account-name      column-vector)
+                                                (used-account-full-name column-vector))))
+    
+    (if (or (used-other-account-name column-vector) (used-other-account-code column-vector))
+       (addto! row-contents (account-namestring (xaccSplitGetAccount
+                                                   (xaccSplitGetOtherSplit split))
+                                                (used-other-account-code      column-vector)
+                                                (used-other-account-name      column-vector)
+                                                (used-other-account-full-name column-vector))))
+    
+    (if (used-shares column-vector)
+        (addto! row-contents (xaccSplitGetAmount split)))
+    (if (used-price column-vector)
+        (addto! 
+         row-contents 
+         (gnc:make-gnc-monetary (xaccTransGetCurrency parent)
+                                (xaccSplitGetSharePrice split))))
+    (if (used-amount-single column-vector)
+        (addto! row-contents
+                (gnc:make-html-table-cell/markup "number-cell"
+                                                 (gnc:html-transaction-anchor parent split-value))))
+    (if (used-amount-double-positive column-vector)
+        (if (gnc-numeric-positive-p (gnc:gnc-monetary-amount split-value))
+            (addto! row-contents
+                    (gnc:make-html-table-cell/markup "number-cell"
+                                                     (gnc:html-transaction-anchor parent split-value)))
+            (addto! row-contents " ")))
+    (if (used-amount-double-negative column-vector)
+        (if (gnc-numeric-negative-p (gnc:gnc-monetary-amount split-value))
+            (addto! row-contents
+                    (gnc:make-html-table-cell/markup
+                     "number-cell" (gnc:html-transaction-anchor parent (gnc:monetary-neg split-value))))
+            (addto! row-contents " ")))
+    (if (used-running-balance column-vector)
+	(begin
+	  (gnc:debug "split is " split)
+	  (gnc:debug "split get balance:" (xaccSplitGetBalance split))
+	  (addto! row-contents
+		  (gnc:make-html-table-cell/markup
+		   "number-cell"
+		   (gnc:make-gnc-monetary currency
+					  (xaccSplitGetBalance split))))))
+	(gnc:html-table-append-row/markup! table row-style
+                                       (reverse row-contents))
+    split-value))
+
+
+(define date-sorting-types (list 'date 'exact-time 'register-order))
+
+(define (trep-options-generator)
+  (define gnc:*transaction-report-options* (gnc:new-options))
+  (define (gnc:register-trep-option new-option)
+    (gnc:register-option gnc:*transaction-report-options* new-option))
+  
+  ;; General options
+  
+  (gnc:options-add-date-interval!
+   gnc:*transaction-report-options*
+   gnc:pagename-general (N_ "Start Date") (N_ "End Date") "a")
+  
+  
+  (gnc:register-trep-option
+   (gnc:make-complex-boolean-option
+    gnc:pagename-general optname-common-currency
+    "e" (N_ "Convert all transactions into a common currency.") #f
+    #f
+    (lambda (x) (gnc-option-db-set-option-selectable-by-name
+		 gnc:*transaction-report-options*
+		 gnc:pagename-general
+		 optname-currency
+		 x))
+    ))
+
+  (gnc:options-add-currency!
+   gnc:*transaction-report-options* gnc:pagename-general optname-currency "f")
+
+  (gnc:register-trep-option
+   (gnc:make-simple-boolean-option
+    gnc:pagename-general optname-table-export
+    "g" (N_ "Formats the table suitable for cut & paste exporting with extra cells.") #f))  
+  
+  ;; Accounts options
+  
+  ;; account to do report on
+  (gnc:register-trep-option
+   (gnc:make-account-list-option
+    gnc:pagename-accounts (N_ "Accounts")
+    "a" (N_ "Report on these accounts.")
+    ;; select, by default, no accounts! Selecting all accounts will
+    ;; always imply an insanely long waiting time upon opening, and it
+    ;; is almost never useful. So we instead display the normal error
+    ;; message saying "Click here", and the user knows how to
+    ;; continue.
+    (lambda ()
+      '())
+    #f #t))
+
+  (gnc:register-trep-option
+   (gnc:make-string-option
+    gnc:pagename-accounts (N_ "Account Substring")
+    "a5" (N_ "Match only above accounts whose fullname contains substring e.g. ':Travel' will \
+match Expenses:Travel:Holiday and Expenses:Business:Travel. Can be left blank, which will \
+disable the substring filter. This filter is case-sensitive.")
+    ""))
+
+  (gnc:register-trep-option
+   (gnc:make-account-list-option
+    gnc:pagename-accounts (N_ "Filter By...")
+    "b" (N_ "Filter on these accounts.")
+    (lambda ()
+      ;; FIXME : gnc:get-current-accounts disappeared.
+      (let* ((current-accounts '())
+	     (root (gnc-get-current-root-account))
+	     (num-accounts (gnc-account-n-children root))
+	     (first-account (gnc-account-nth-child root 0)))
+	(cond ((not (null? current-accounts))
+	       (list (car current-accounts)))
+	      ((> num-accounts 0) (list first-account))
+	      (else '()))))
+    #f #t))
+
+  (gnc:register-trep-option
+   (gnc:make-multichoice-option
+    gnc:pagename-accounts (N_ "Filter Type")
+    "c" (N_ "Filter account.")
+    'none
+    (list (vector 'none
+		  (N_ "None")
+		  (N_ "Do not do any filtering."))
+	  (vector 'include
+		  (N_ "Include Transactions to/from Filter Accounts")
+		  (N_ "Include transactions to/from filter accounts only."))
+	  (vector 'exclude
+		  (N_ "Exclude Transactions to/from Filter Accounts")
+		  (N_ "Exclude transactions to/from all filter accounts."))
+	  )))
+
+  ;;
+
+  (gnc:register-trep-option
+   (gnc:make-multichoice-option
+    gnc:pagename-accounts optname-void-transactions
+    "d" (N_ "How to handle void transactions.")
+    'non-void-only
+    (list (vector
+	   'non-void-only
+	   (N_ "Non-void only")
+	   (N_ "Show only non-voided transactions."))
+	  (vector
+	   'void-only
+	   (N_ "Void only")
+	   (N_ "Show only voided transactions."))
+	  (vector 
+	   'both
+	   (N_ "Both")
+	   (N_ "Show both (and include void transactions in totals).")))))
+
+  ;; Sorting options
+      
+  (let ((options gnc:*transaction-report-options*)
+
+        (key-choice-list 
+         (if (qof-book-use-split-action-for-num-field (gnc-get-current-book))
+             (list (vector 'none
+                           (N_ "None")
+                           (N_ "Do not sort."))
+
+                   (vector 'account-name
+                           (N_ "Account Name")
+                           (N_ "Sort & subtotal by account name."))
+
+                   (vector 'account-code
+                           (N_ "Account Code")
+                           (N_ "Sort & subtotal by account code."))
+
+                   (vector 'date
+                           (N_ "Date")
+                           (N_ "Sort by date."))
+
+                   (vector 'exact-time
+                           (N_ "Exact Time")
+                           (N_ "Sort by exact time."))
+
+                   (vector 'reconciled-date
+                           (N_ "Reconciled Date")
+                           (N_ "Sort by the Reconciled Date."))
+
+                   (vector 'register-order
+                           (N_ "Register Order")
+                           (N_ "Sort as in the register."))
+
+                   (vector 'corresponding-acc-name 
+                           (N_ "Other Account Name")
+                           (N_ "Sort by account transferred from/to's name."))
+
+                   (vector 'corresponding-acc-code
+                           (N_ "Other Account Code")
+                           (N_ "Sort by account transferred from/to's code."))
+               
+                   (vector 'amount
+                           (N_ "Amount")
+                           (N_ "Sort by amount."))
+               
+                   (vector 'description
+                           (N_ "Description")
+                           (N_ "Sort by description."))
+               
+                   (vector 'number
+                           (N_ "Number/Action")
+                           (N_ "Sort by check number/action."))
+
+                   (vector 't-number
+                           (N_ "Transaction Number")
+                           (N_ "Sort by transaction number."))
+               
+                   (vector 'memo
+                           (N_ "Memo")
+                           (N_ "Sort by memo.")))
+             (list (vector 'none
+                           (N_ "None")
+                           (N_ "Do not sort."))
+
+                   (vector 'account-name
+                           (N_ "Account Name")
+                           (N_ "Sort & subtotal by account name."))
+
+                   (vector 'account-code
+                           (N_ "Account Code")
+                           (N_ "Sort & subtotal by account code."))
+
+                   (vector 'date
+                           (N_ "Date")
+                           (N_ "Sort by date."))
+
+                   (vector 'exact-time
+                           (N_ "Exact Time")
+                           (N_ "Sort by exact time."))
+
+                   (vector 'reconciled-date
+                           (N_ "Reconciled Date")
+                           (N_ "Sort by the Reconciled Date."))
+
+                   (vector 'register-order
+                           (N_ "Register Order")
+                           (N_ "Sort as in the register."))
+
+                   (vector 'corresponding-acc-name 
+                           (N_ "Other Account Name")
+                           (N_ "Sort by account transferred from/to's name."))
+
+                   (vector 'corresponding-acc-code
+                           (N_ "Other Account Code")
+                           (N_ "Sort by account transferred from/to's code."))
+               
+                   (vector 'amount
+                           (N_ "Amount")
+                           (N_ "Sort by amount."))
+               
+                   (vector 'description
+                           (N_ "Description")
+                           (N_ "Sort by description."))
+               
+                   (vector 'number
+                           (N_ "Number")
+                           (N_ "Sort by check/transaction number."))
+
+                   (vector 'memo
+                           (N_ "Memo")
+                           (N_ "Sort by memo.")))))
+
+        (ascending-choice-list 
+         (list
+          (vector 'ascend
+                  (N_ "Ascending")
+                  (N_ "Smallest to largest, earliest to latest."))
+          (vector 'descend
+                  (N_ "Descending")
+                  (N_ "Largest to smallest, latest to earliest."))))
+
+        (subtotal-choice-list
+         (list
+          (vector 'none (N_ "None") (N_ "None."))
+          (vector 'weekly (N_ "Weekly") (N_ "Weekly."))
+          (vector 'monthly (N_ "Monthly") (N_ "Monthly."))
+          (vector 'quarterly (N_ "Quarterly") (N_ "Quarterly."))
+          (vector 'yearly (N_ "Yearly") (N_ "Yearly."))))
+
+        (prime-sortkey 'account-name)
+        (prime-sortkey-subtotal-true #t)
+        (sec-sortkey 'register-order)
+        (sec-sortkey-subtotal-true #f))
+
+    (define (apply-selectable-by-name-sorting-options)
+      (let* ((prime-sortkey-enabled (not (eq? prime-sortkey 'none)))
+             (prime-sortkey-subtotal-enabled (member prime-sortkey subtotal-enabled))
+             (prime-date-sortingtype-enabled (member prime-sortkey date-sorting-types))
+             (sec-sortkey-enabled (not (eq? sec-sortkey 'none)))
+             (sec-sortkey-subtotal-enabled (member sec-sortkey subtotal-enabled))
+             (sec-date-sortingtype-enabled (member sec-sortkey date-sorting-types)))
+
+        (gnc-option-db-set-option-selectable-by-name
+         options pagename-sorting optname-prime-subtotal
+         prime-sortkey-subtotal-enabled)
+
+        (gnc-option-db-set-option-selectable-by-name
+         options pagename-sorting optname-prime-sortorder
+         prime-sortkey-enabled)
+
+        (gnc-option-db-set-option-selectable-by-name
+         options pagename-sorting optname-sec-subtotal
+         sec-sortkey-subtotal-enabled)
+
+        (gnc-option-db-set-option-selectable-by-name
+         options pagename-sorting optname-sec-sortorder
+         sec-sortkey-enabled)
+
+        (gnc-option-db-set-option-selectable-by-name
+         options pagename-sorting optname-full-account-name
+         (or (and prime-sortkey-subtotal-enabled prime-sortkey-subtotal-true)
+             (and sec-sortkey-subtotal-enabled sec-sortkey-subtotal-true)))
+
+        (gnc-option-db-set-option-selectable-by-name
+         options pagename-sorting optname-show-account-code
+         (or (and prime-sortkey-subtotal-enabled prime-sortkey-subtotal-true)
+             (and sec-sortkey-subtotal-enabled sec-sortkey-subtotal-true)))
+
+        (gnc-option-db-set-option-selectable-by-name
+         options pagename-sorting optname-prime-date-subtotal
+         prime-date-sortingtype-enabled)
+
+        (gnc-option-db-set-option-selectable-by-name
+         options pagename-sorting optname-sec-date-subtotal
+         sec-date-sortingtype-enabled)))
+
+    ;; primary sorting criterion
+    (gnc:register-trep-option
+     (gnc:make-multichoice-callback-option
+      pagename-sorting optname-prime-sortkey
+      "a" (N_ "Sort by this criterion first.")
+      prime-sortkey
+      key-choice-list #f
+      (lambda (x)
+        (set! prime-sortkey x)
+        (apply-selectable-by-name-sorting-options))))
+    
+    (gnc:register-trep-option
+     (gnc:make-simple-boolean-option
+      pagename-sorting optname-full-account-name
+      "j1"
+      (N_ "Show the full account name for subtotals and subtitles?")
+      #f))
+    
+    (gnc:register-trep-option
+     (gnc:make-simple-boolean-option
+      pagename-sorting optname-show-account-code
+      "j2"
+      (N_ "Show the account code for subtotals and subtitles?")
+      #f))
+    
+    (gnc:register-trep-option
+     (gnc:make-complex-boolean-option
+      pagename-sorting optname-prime-subtotal
+      "e5"
+      (N_ "Subtotal according to the primary key?")
+      prime-sortkey-subtotal-true #f
+      (lambda (x)
+        (set! prime-sortkey-subtotal-true x)
+        (apply-selectable-by-name-sorting-options))))
+
+    (gnc:register-trep-option
+     (gnc:make-multichoice-option
+      pagename-sorting optname-prime-date-subtotal
+      "e2" (N_ "Do a date subtotal.")
+      'monthly
+      subtotal-choice-list))
+    
+    (gnc:register-trep-option
+     (gnc:make-multichoice-option
+      pagename-sorting optname-prime-sortorder
+      "e" (N_ "Order of primary sorting.")
+      'ascend
+      ascending-choice-list))
+    
+    ;; Secondary sorting criterion
+    (gnc:register-trep-option
+     (gnc:make-multichoice-callback-option
+      pagename-sorting optname-sec-sortkey
+      "f"
+      (N_ "Sort by this criterion second.")
+      sec-sortkey
+      key-choice-list #f
+      (lambda (x)
+        (set! sec-sortkey x)
+        (apply-selectable-by-name-sorting-options))))
+
+    (gnc:register-trep-option
+     (gnc:make-complex-boolean-option
+      pagename-sorting optname-sec-subtotal
+      "i5"
+      (N_ "Subtotal according to the secondary key?")
+      sec-sortkey-subtotal-true #f
+      (lambda (x)
+        (set! sec-sortkey-subtotal-true x)
+        (apply-selectable-by-name-sorting-options))))
+
+    (gnc:register-trep-option
+     (gnc:make-multichoice-option
+      pagename-sorting optname-sec-date-subtotal
+      "i2" (N_ "Do a date subtotal.")
+      'monthly
+      subtotal-choice-list))
+    
+    (gnc:register-trep-option
+     (gnc:make-multichoice-option
+      pagename-sorting optname-sec-sortorder
+      "i" (N_ "Order of Secondary sorting.")
+      'ascend
+      ascending-choice-list)))
+  
+  ;; Display options
+  
+    (let ((options gnc:*transaction-report-options*)
+          (disp-memo? #t)
+          (disp-accname? #t)
+          (disp-other-accname? #f)
+          (is-single? #t))
+
+      (define (apply-selectable-by-name-display-options)
+        (gnc-option-db-set-option-selectable-by-name
+         options gnc:pagename-display (N_ "Use Full Account Name")
+         disp-accname?)
+
+        (gnc-option-db-set-option-selectable-by-name
+         options gnc:pagename-display (N_ "Other Account Name")
+         is-single?)
+
+        (gnc-option-db-set-option-selectable-by-name
+         options gnc:pagename-display (N_ "Use Full Other Account Name")
+         (and disp-other-accname? is-single?))
+
+        (gnc-option-db-set-option-selectable-by-name
+         options gnc:pagename-display (N_ "Other Account Code")
+         is-single?)
+
+        (gnc-option-db-set-option-selectable-by-name
+         options gnc:pagename-display (N_ "Notes")
+         disp-memo?))
+
+  (for-each
+   (lambda (l)
+     (gnc:register-trep-option
+      (gnc:make-simple-boolean-option
+       gnc:pagename-display (car l) (cadr l) (caddr l) (cadddr l))))
+   ;; One list per option here with: option-name, sort-tag,
+   ;; help-string, default-value
+   (list
+    (list (N_ "Date")                         "a"  (N_ "Display the date?") #t)
+    (list (N_ "Reconciled Date")              "a2" (N_ "Display the reconciled date?") #f)
+    (if (qof-book-use-split-action-for-num-field (gnc-get-current-book))
+        (list (N_ "Num/Action")               "b"  (N_ "Display the check number?") #t)
+        (list (N_ "Num")                      "b"  (N_ "Display the check number?") #t))
+    (list (N_ "Description")                  "c"  (N_ "Display the description?") #t)
+    (list (N_ "Notes")                        "d2" (N_ "Display the notes if the memo is unavailable?") #t)
+    ;; account name option appears here
+    (list (N_ "Use Full Account Name")        "f"  (N_ "Display the full account name?") #t)
+    (list (N_ "Account Code")                 "g"  (N_ "Display the account code?") #f)
+    ;; other account name option appears here
+    (list (N_ "Use Full Other Account Name")  "i"  (N_ "Display the full account name?") #f)
+    (list (N_ "Other Account Code")           "j"  (N_ "Display the other account code?") #f)
+    (list (N_ "Shares")                       "k"  (N_ "Display the number of shares?") #f)
+    (list (N_ "Price")                        "l"  (N_ "Display the shares price?") #f)
+    ;; note the "Amount" multichoice option in between here
+    (list (N_ "Running Balance")              "n"  (N_ "Display a running balance?") #f)
+    (list (N_ "Totals")                       "o"  (N_ "Display the totals?") #t)))
+
+  (if (qof-book-use-split-action-for-num-field (gnc-get-current-book))
+      (gnc:register-trep-option
+       (gnc:make-simple-boolean-option
+        gnc:pagename-display (N_ "Trans Number")
+                                    "b2" (N_ "Display the trans number?") #f)))
+
+  ;; Add an option to display the memo, and disable the notes option
+  ;; when memos are not included.
+  (gnc:register-trep-option
+   (gnc:make-complex-boolean-option
+    gnc:pagename-display (N_ "Memo")
+    "d"  (N_ "Display the memo?") #t
+    #f
+    (lambda (x)
+        (set! disp-memo? x)
+        (apply-selectable-by-name-display-options))))
+
+  ;; Ditto for Account Name #t -> Use Full Account Name is selectable
+  (gnc:register-trep-option
+   (gnc:make-complex-boolean-option
+    gnc:pagename-display (N_ "Account Name")
+    "e"  (N_ "Display the account name?") #t
+    #f
+    (lambda (x)
+        (set! disp-accname? x)
+        (apply-selectable-by-name-display-options))))
+
+  ;; Ditto for Other Account Name #t -> Use Full Other Account Name is selectable
+  (gnc:register-trep-option
+   (gnc:make-complex-boolean-option
+    gnc:pagename-display (N_ "Other Account Name")
+    "h5"  (N_ "Display the other account name? (if this is a split transaction, this parameter is guessed).") #f
+    #f
+    (lambda (x)
+        (set! disp-other-accname? x)
+        (apply-selectable-by-name-display-options))))
+
+  (gnc:register-trep-option
+   (gnc:make-multichoice-callback-option
+    gnc:pagename-display optname-detail-level
+    "h" (N_ "Amount of detail to display per transaction.")
+    'single
+    (list (vector 'multi-line
+                  (N_ "Multi-Line")
+                  (N_ "Display all splits in a transaction on a separate line."))
+          (vector 'single
+                  (N_ "Single")
+                  (N_ "Display one line per transaction, merging multiple splits where required.")))
+    #f
+    (lambda (x)
+        (set! is-single? (eq? x 'single))
+        (apply-selectable-by-name-display-options))))
+
+  (gnc:register-trep-option
+   (gnc:make-multichoice-option
+    gnc:pagename-display (N_ "Amount")
+    "m" (N_ "Display the amount?")  
+    'single
+    (list
+     (vector 'none (N_ "None") (N_ "No amount display."))
+     (vector 'single (N_ "Single") (N_ "Single Column Display."))
+     (vector 'double (N_ "Double") (N_ "Two Column Display.")))))
+  
+  (gnc:register-trep-option
+   (gnc:make-multichoice-option
+    gnc:pagename-display (N_ "Sign Reverses")
+    "p" (N_ "Reverse amount display for certain account types.")
+    'credit-accounts
+    (list 
+     (vector 'none (N_ "None") (N_ "Don't change any displayed amounts."))
+     (vector 'income-expense (N_ "Income and Expense")
+             (N_ "Reverse amount display for Income and Expense Accounts."))
+     (vector 'credit-accounts (N_ "Credit Accounts")
+             (N_ "Reverse amount display for Liability, Payable, Equity, \
+Credit Card, and Income accounts."))))))
+
+
+  (gnc:options-set-default-section gnc:*transaction-report-options*
+                                   gnc:pagename-general)
+
+  gnc:*transaction-report-options*)
+
+
+(define (display-date-interval begin end)
+  (let ((begin-string (gnc-print-date begin))
+        (end-string (gnc-print-date end)))
+    (sprintf #f (_ "From %s To %s") begin-string end-string)))
+
+(define (get-primary-subtotal-style options)
+  (let ((bgcolor (gnc:lookup-option options 
+                                    (N_ "Colors")
+                                    (N_ "Primary Subtotals/headings"))))
+    (list 'attribute (list "bgcolor" (gnc:color-option->html bgcolor)))))
+
+(define (get-secondary-subtotal-style options)
+  (let ((bgcolor (gnc:lookup-option options
+                                    (N_ "Colors")
+                                    (N_ "Secondary Subtotals/headings"))))
+    (list 'attribute (list "bgcolor" (gnc:color-option->html bgcolor)))))
+
+(define (get-grand-total-style options)
+  (let ((bgcolor (gnc:lookup-option options
+                                    (N_ "Colors")
+                                    (N_ "Grand Total"))))
+    (list 'attribute (list "bgcolor" (gnc:color-option->html bgcolor)))))
+
+(define (get-odd-row-style options)
+  (let ((bgcolor (gnc:lookup-option options
+                                    (N_ "Colors")
+                                    (N_ "Split Odd"))))
+    (list 'attribute (list "bgcolor" (gnc:color-option->html bgcolor)))))
+
+(define (get-even-row-style options)
+  (let ((bgcolor (gnc:lookup-option options
+                                    (N_ "Colors")
+                                    (N_ "Split Even"))))
+    (list 'attribute (list "bgcolor" (gnc:color-option->html bgcolor)))))
+
+
+;; ;;;;;;;;;;;;;;;;;;;;
+;; Here comes the big function that builds the whole table.
+(define (make-split-table splits options
+                          primary-subtotal-pred
+                          secondary-subtotal-pred
+                          primary-subheading-renderer
+                          secondary-subheading-renderer
+                          primary-subtotal-renderer
+                          secondary-subtotal-renderer)
+  
+ (let ((work-to-do (length splits))
+       (work-done 0)
+       (used-columns (build-column-used options)))
+  (define (get-account-types-to-reverse options)
+    (cdr (assq (gnc:option-value 
+                (gnc:lookup-option options
+                                   gnc:pagename-display
+                                   (N_ "Sign Reverses")))
+               account-types-to-reverse-assoc-list)))
+  
+
+  (define (transaction-report-multi-rows-p options)
+    (eq? (gnc:option-value
+          (gnc:lookup-option options gnc:pagename-display optname-detail-level))
+         'multi-line))
+
+  (define (transaction-report-export-p options)
+    (gnc:option-value
+     (gnc:lookup-option options gnc:pagename-general
+       optname-table-export)))
+
+  (define (add-other-split-rows split table used-columns
+                                row-style account-types-to-reverse)
+    (define (other-rows-driver split parent table used-columns i)
+      (let ((current (xaccTransGetSplit parent i)))
+        (cond ((null? current) #f)
+              ((equal? current split)
+               (other-rows-driver split parent table used-columns (+ i 1)))
+              (else (begin
+                      (add-split-row table current used-columns options
+                                     row-style account-types-to-reverse #f)
+                      (other-rows-driver split parent table used-columns
+                                         (+ i 1)))))))
+
+    (other-rows-driver split (xaccSplitGetParent split)
+                       table used-columns 0))
+
+  (define (do-rows-with-subtotals splits 
+                                  table 
+                                  used-columns
+                                  width
+                                  multi-rows?
+                                  odd-row?
+                                  export?
+                                  account-types-to-reverse
+                                  primary-subtotal-pred
+                                  secondary-subtotal-pred 
+                                  primary-subheading-renderer
+                                  secondary-subheading-renderer
+                                  primary-subtotal-renderer
+                                  secondary-subtotal-renderer
+                                  primary-subtotal-collector 
+                                  secondary-subtotal-collector 
+                                  total-collector)
+
+    (gnc:report-percent-done (* 100 (/ work-done work-to-do)))
+    (set! work-done (+ 1 work-done))
+    (if (null? splits)
+        (begin
+          (gnc:html-table-append-row/markup!
+           table
+           def:grand-total-style
+           (list
+            (gnc:make-html-table-cell/size
+             1 width (gnc:make-html-text (gnc:html-markup-hr)))))
+	  (if (gnc:option-value (gnc:lookup-option options "Display" "Totals"))
+	      (render-grand-total table width total-collector export?)))
+	
+        (let* ((current (car splits))
+               (current-row-style (if multi-rows? def:normal-row-style
+                                      (if odd-row? def:normal-row-style 
+                                          def:alternate-row-style)))
+               (rest (cdr splits))
+               (next (if (null? rest) #f
+                         (car rest)))
+               (split-value (add-split-row 
+                             table 
+                             current 
+                             used-columns
+			     options
+                             current-row-style
+                             account-types-to-reverse
+                             #t)))
+          (if multi-rows?
+              (add-other-split-rows
+               current table used-columns def:alternate-row-style
+               account-types-to-reverse))
+
+          (primary-subtotal-collector 'add 
+                                      (gnc:gnc-monetary-commodity
+                                       split-value) 
+                                      (gnc:gnc-monetary-amount
+                                       split-value))
+          (secondary-subtotal-collector 'add
+                                        (gnc:gnc-monetary-commodity
+                                         split-value)
+                                        (gnc:gnc-monetary-amount
+                                         split-value))
+          (total-collector 'add
+                           (gnc:gnc-monetary-commodity split-value)
+                           (gnc:gnc-monetary-amount split-value))
+
+          (if (and primary-subtotal-pred
+                   (or (not next)
+                       (and next
+                            (not (primary-subtotal-pred current next)))))
+              (begin 
+                (if secondary-subtotal-pred
+
+                    (begin
+                      (secondary-subtotal-renderer
+                       table width current
+                       secondary-subtotal-collector
+                       def:secondary-subtotal-style used-columns export?)
+                      (secondary-subtotal-collector 'reset #f #f)))
+
+                (primary-subtotal-renderer table width current
+                                           primary-subtotal-collector
+                                           def:primary-subtotal-style used-columns
+                                           export?)
+
+                (primary-subtotal-collector 'reset #f #f)
+
+                (if next
+                    (begin 
+                      (primary-subheading-renderer
+                       next table width def:primary-subtotal-style used-columns)
+
+                      (if secondary-subtotal-pred
+                          (secondary-subheading-renderer
+                           next 
+                           table 
+                           width def:secondary-subtotal-style used-columns)))))
+
+              (if (and secondary-subtotal-pred
+                       (or (not next)
+                           (and next
+                                (not (secondary-subtotal-pred
+                                      current next)))))
+                  (begin (secondary-subtotal-renderer
+                          table width current
+                          secondary-subtotal-collector
+                          def:secondary-subtotal-style used-columns export?)
+                         (secondary-subtotal-collector 'reset #f #f)
+                         (if next
+                             (secondary-subheading-renderer
+                              next table width
+                              def:secondary-subtotal-style used-columns)))))
+
+          (do-rows-with-subtotals rest 
+                                  table 
+                                  used-columns
+                                  width 
+                                  multi-rows?
+                                  (not odd-row?)
+                                  export?
+                                  account-types-to-reverse
+                                  primary-subtotal-pred 
+                                  secondary-subtotal-pred
+                                  primary-subheading-renderer 
+                                  secondary-subheading-renderer
+                                  primary-subtotal-renderer
+                                  secondary-subtotal-renderer
+                                  primary-subtotal-collector 
+                                  secondary-subtotal-collector 
+                                  total-collector))))
+
+  (let* ((table (gnc:make-html-table))
+         (width (num-columns-required used-columns))
+         (multi-rows? (transaction-report-multi-rows-p options))
+	 (export? (transaction-report-export-p options))
+         (account-types-to-reverse
+          (get-account-types-to-reverse options)))
+
+    (gnc:html-table-set-col-headers!
+     table
+     (make-heading-list used-columns options))
+    ;;     (gnc:warn "Splits:" splits)
+    (if (not (null? splits))
+        (begin
+          (if primary-subheading-renderer 
+              (primary-subheading-renderer
+               (car splits) table width def:primary-subtotal-style used-columns))
+          (if secondary-subheading-renderer
+              (secondary-subheading-renderer
+               (car splits) table width def:secondary-subtotal-style used-columns))
+
+          (do-rows-with-subtotals splits table used-columns width
+                                  multi-rows? #t
+                                  export?
+                                  account-types-to-reverse
+                                  primary-subtotal-pred
+                                  secondary-subtotal-pred
+                                  primary-subheading-renderer
+                                  secondary-subheading-renderer
+                                  primary-subtotal-renderer
+                                  secondary-subtotal-renderer
+                                  (gnc:make-commodity-collector)
+                                  (gnc:make-commodity-collector)
+                                  (gnc:make-commodity-collector))))
+    
+    table)))
+
+;; ;;;;;;;;;;;;;;;;;;;;
+;; Here comes the renderer function for this report.
+(define (trep-renderer report-obj)
+
+  (define options (gnc:report-options report-obj))
+
+  (define (opt-val section name)
+    (gnc:option-value
+     (gnc:lookup-option options section name)))
+
+  (define comp-funcs-assoc-list
+    ;; Defines the different sorting keys, together with the
+    ;; subtotal functions. Each entry: (cons
+    ;; 'sorting-key-option-value (vector 'query-sorting-key
+    ;; subtotal-function subtotal-renderer))
+;;  (let* ((used-columns (build-column-used options))) ;; tpo: gives unbound variable options?
+    (let* ((used-columns (build-column-used (gnc:report-options report-obj))))
+      (list (cons 'account-name  (vector 
+                                  (list SPLIT-ACCT-FULLNAME)
+                                  split-account-full-name-same-p 
+                                  render-account-subheading
+                                  render-account-subtotal))
+            (cons 'account-code  (vector 
+                                  (list SPLIT-ACCOUNT ACCOUNT-CODE-)
+                                  split-account-code-same-p
+                                  render-account-subheading
+                                  render-account-subtotal))
+            (cons 'exact-time    (vector
+                                  (list SPLIT-TRANS TRANS-DATE-POSTED)
+                                  #f #f #f))
+            (cons 'date          (vector
+                                  (list SPLIT-TRANS TRANS-DATE-POSTED)
+                                  #f #f #f))
+            (cons 'reconciled-date (vector
+                                  (list SPLIT-DATE-RECONCILED)
+                                  #f #f #f))
+            (cons 'register-order (vector
+                                  (list QUERY-DEFAULT-SORT)
+                                  #f #f #f))
+            (cons 'corresponding-acc-name
+                                 (vector
+                                  (list SPLIT-CORR-ACCT-NAME)
+                                  split-same-corr-account-full-name-p 
+                                  render-corresponding-account-subheading
+                                  render-corresponding-account-subtotal))
+            (cons 'corresponding-acc-code
+                                 (vector
+                                  (list SPLIT-CORR-ACCT-CODE)
+                                  split-same-corr-account-code-p 
+                                  render-corresponding-account-subheading
+                                  render-corresponding-account-subtotal))
+            (cons 'amount        (vector (list SPLIT-VALUE) #f #f #f))
+            (cons 'description   (vector (list SPLIT-TRANS TRANS-DESCRIPTION) #f #f #f))
+            (if (qof-book-use-split-action-for-num-field (gnc-get-current-book))
+                (cons 'number    (vector (list SPLIT-ACTION) #f #f #f))
+                (cons 'number    (vector (list SPLIT-TRANS TRANS-NUM) #f #f #f)))
+            (cons 't-number      (vector (list SPLIT-TRANS TRANS-NUM) #f #f #f))
+            (cons 'memo          (vector (list SPLIT-MEMO) #f #f #f))
+            (cons 'none          (vector '() #f #f #f)))))
+
+  (define date-comp-funcs-assoc-list
+    ;; Extra list for date option. Each entry: (cons
+    ;; 'date-subtotal-option-value (vector subtotal-function
+    ;; subtotal-renderer))
+    (list
+     (cons 'none (vector #f #f #f))
+     (cons 'weekly (vector split-same-week-p render-week-subheading
+			   render-week-subtotal))
+     (cons 'monthly (vector split-same-month-p render-month-subheading 
+                            render-month-subtotal))
+     (cons 'quarterly (vector split-same-quarter-p render-quarter-subheading 
+                            render-quarter-subtotal))
+     (cons 'yearly (vector split-same-year-p render-year-subheading
+                           render-year-subtotal))))
+
+  (define (get-subtotalstuff-helper 
+           name-sortkey name-subtotal name-date-subtotal
+           comp-index date-index)
+    ;; The value of the sorting-key multichoice option.
+    (let ((sortkey (opt-val pagename-sorting name-sortkey)))
+      (if (member sortkey date-sorting-types)
+          ;; If sorting by date, look up the value of the
+          ;; date-subtotalling multichoice option and return the
+          ;; corresponding funcs in the assoc-list.
+          (vector-ref
+           (cdr (assq (opt-val pagename-sorting name-date-subtotal)
+                      date-comp-funcs-assoc-list)) 
+           date-index)
+          ;; For everything else: 1. check whether sortkey has
+          ;; subtotalling enabled at all, 2. check whether the
+          ;; enable-subtotal boolean option is #t, 3. look up the
+          ;; appropriate funcs in the assoc-list.
+          (and (member sortkey subtotal-enabled) 
+               (and (opt-val pagename-sorting name-subtotal)
+                    (vector-ref 
+                     (cdr (assq sortkey comp-funcs-assoc-list)) 
+                     comp-index))))))
+  
+  (define (get-query-sortkey sort-option-value)
+    (vector-ref 
+     (cdr (assq sort-option-value comp-funcs-assoc-list)) 
+     0))
+
+  (define (get-subtotal-pred 
+           name-sortkey name-subtotal name-date-subtotal)
+    (get-subtotalstuff-helper 
+     name-sortkey name-subtotal name-date-subtotal
+     1 0))
+
+  (define (get-subheading-renderer
+           name-sortkey name-subtotal name-date-subtotal)
+    (get-subtotalstuff-helper 
+     name-sortkey name-subtotal name-date-subtotal
+     2 1))
+
+  (define (get-subtotal-renderer
+           name-sortkey name-subtotal name-date-subtotal)
+    (get-subtotalstuff-helper
+     name-sortkey name-subtotal name-date-subtotal
+     3 2))
+
+  ;;(define (get-other-account-names account-list)
+  ;;  ( map (lambda (acct)  (gnc-account-get-full-name acct)) account-list))
+
+  (define (is-filter-member split account-list)
+    (let* ((txn (xaccSplitGetParent split))
+           (splitcount (xaccTransCountSplits txn)))
+
+      (cond
+        ;; A 2-split transaction - test separately so it can be optimized
+        ;; to significantly reduce the number of splits to traverse
+        ;; in guile code
+        ((= splitcount 2)
+         (let* ((other      (xaccSplitGetOtherSplit split))
+                (other-acct (xaccSplitGetAccount other)))
+               (member other-acct account-list)))
+
+        ;; A multi-split transaction - run over all splits
+        ((> splitcount 2)
+         (let ((splits (xaccTransGetSplitList txn)))
+
+                ;; Walk through the list of splits.
+                ;; if we reach the end, return #f
+                ;; if the 'this' != 'split' and the split->account is a member
+                ;; of the account-list, then return #t, else recurse
+                (define (is-member splits)
+                  (if (null? splits)
+                      #f
+                      (let* ((this (car splits))
+                             (rest (cdr splits))
+                             (acct (xaccSplitGetAccount this)))
+                        (if (and (not (eq? this split))
+                                 (member acct account-list))
+                            #t
+                            (is-member rest)))))
+
+                (is-member splits)))
+
+        ;; Single transaction splits
+        (else #f))))
+
+
+  (gnc:report-starting reportname)
+  (let ((document (gnc:make-html-document))
+	(c_account_1 (opt-val gnc:pagename-accounts "Accounts"))
+	(c_account_substring (opt-val gnc:pagename-accounts "Account Substring"))
+	(c_account_2 (opt-val gnc:pagename-accounts "Filter By..."))
+	(filter-mode (opt-val gnc:pagename-accounts "Filter Type"))
+        (begindate (gnc:timepair-start-day-time
+                    (gnc:date-option-absolute-time
+                     (opt-val gnc:pagename-general "Start Date"))))
+        (enddate (gnc:timepair-end-day-time
+                  (gnc:date-option-absolute-time
+                   (opt-val gnc:pagename-general "End Date"))))
+        (report-title (opt-val 
+                       gnc:pagename-general
+                       gnc:optname-reportname))
+        (primary-key (opt-val pagename-sorting optname-prime-sortkey))
+        (primary-order (opt-val pagename-sorting "Primary Sort Order"))
+        (secondary-key (opt-val pagename-sorting optname-sec-sortkey))
+        (secondary-order (opt-val pagename-sorting "Secondary Sort Order"))
+	(void-status (opt-val gnc:pagename-accounts optname-void-transactions))
+        (splits '())
+        (query (qof-query-create-for-splits)))
+
+    ;;(gnc:warn "accts in trep-renderer:" c_account_1)
+    ;;(gnc:warn "Report Account names:" (get-other-account-names c_account_1))
+
+    (set! c_account_1
+          (filter (lambda (acc)
+                    (string-contains (gnc-account-get-full-name acc) c_account_substring))
+                  c_account_1))
+    
+    (if (not (or (null? c_account_1) (and-map not c_account_1)))
+        (begin
+          (qof-query-set-book query (gnc-get-current-book))
+	      ;;(gnc:warn "query is:" query)
+          (xaccQueryAddAccountMatch query
+                                       c_account_1
+                                       QOF-GUID-MATCH-ANY QOF-QUERY-AND)
+          (xaccQueryAddDateMatchTS
+           query #t begindate #t enddate QOF-QUERY-AND)
+          (qof-query-set-sort-order query
+				    (get-query-sortkey primary-key)
+				    (get-query-sortkey secondary-key)
+				    '())
+
+          (qof-query-set-sort-increasing query
+                                         (eq? primary-order 'ascend)
+                                         (eq? secondary-order 'ascend)
+                                         #t)
+
+	  (case void-status
+	   ((non-void-only) 
+	    (gnc:query-set-match-non-voids-only! query (gnc-get-current-book)))
+	   ((void-only)
+	    (gnc:query-set-match-voids-only! query (gnc-get-current-book)))
+	   (else #f))
+
+          (set! splits (qof-query-run query))
+
+          ;;(gnc:warn "Splits in trep-renderer:" splits)
+
+	  ;;(gnc:warn "Filter account names:" (get-other-account-names c_account_2))
+
+	  ;;This should probably a cond or a case to allow for different filter types.
+	  ;;(gnc:warn "Filter Mode: " filter-mode)
+	  (if (eq? filter-mode 'include)
+	      (begin
+		;;(gnc:warn "Including Filter Accounts")
+		(set! splits (filter (lambda (split) 
+				       (is-filter-member split c_account_2))
+				     splits))
+		)
+	      )
+
+	  (if (eq? filter-mode 'exclude)
+	      (begin
+		;;(gnc:warn "Excluding Filter Accounts")
+		(set! splits (filter (lambda (split) 
+				       (not (is-filter-member split c_account_2)))
+				     splits))
+		)
+	      )
+	
+          (if (not (null? splits))
+              (let ((table 
+                     (make-split-table 
+                      splits 
+                      options
+                      (get-subtotal-pred optname-prime-sortkey 
+                                         optname-prime-subtotal
+                                         optname-prime-date-subtotal)
+                      (get-subtotal-pred optname-sec-sortkey 
+                                         optname-sec-subtotal
+                                         optname-sec-date-subtotal)
+                      (get-subheading-renderer optname-prime-sortkey 
+                                               optname-prime-subtotal
+                                               optname-prime-date-subtotal)
+                      (get-subheading-renderer optname-sec-sortkey 
+                                               optname-sec-subtotal
+                                               optname-sec-date-subtotal)
+                      (get-subtotal-renderer   optname-prime-sortkey
+                                               optname-prime-subtotal
+                                               optname-prime-date-subtotal)
+                      (get-subtotal-renderer   optname-sec-sortkey
+                                               optname-sec-subtotal
+                                               optname-sec-date-subtotal))))
+
+                (gnc:html-document-set-title! document
+                                              report-title)
+                (gnc:html-document-add-object! 
+                 document
+                 (gnc:make-html-text
+                  (gnc:html-markup-h3 
+                   (display-date-interval begindate enddate))))
+                (gnc:html-document-add-object!
+                 document 
+                 table)
+                (qof-query-destroy query))
+              ;; error condition: no splits found
+              (let ((p (gnc:make-html-text)))
+                (gnc:html-text-append! 
+                 p 
+                 (gnc:html-markup-h2 
+                  (_ "No matching transactions found"))
+                 (gnc:html-markup-p
+                  (_ "No transactions were found that \
+match the time interval and account selection specified \
+in the Options panel.")))
+                (gnc:html-document-add-object! document p))))
+
+        ;; error condition: no accounts specified
+        
+        (gnc:html-document-add-object!
+         document 
+	 (gnc:html-make-no-account-warning 
+	  report-title (gnc:report-id report-obj))))
+
+    (gnc:report-finished)
+    document))
+
+;; Define the report.
+(gnc:define-report
+ 
+ 'version 1
+ 
+ 'name reportname
+ 'report-guid "2fe3b9833af044abb929a88d5a59620f"
+ 
+ 'options-generator trep-options-generator
+ 
+ 'renderer trep-renderer)

commit c6f5118b9d0f7735917e2e509c8fc587da74c07b
Author: Geert Janssens <geert at kobaltwit.be>
Date:   Thu Sep 21 12:22:04 2017 +0200

    Fixup for Catalan account charts

diff --git a/configure.ac b/configure.ac
index a1c7085..0649065 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1414,6 +1414,7 @@ AC_CONFIG_FILES(
   Makefile
   accounts/Makefile
   accounts/C/Makefile
+  accounts/ca/Makefile
   accounts/cs/Makefile
   accounts/da/Makefile
   accounts/de_AT/Makefile

commit df7646263b0abc1a3d60e9e0b6546011daa3e5ff
Author: Geert Janssens <geert at kobaltwit.be>
Date:   Thu Sep 21 11:18:35 2017 +0200

    Add boilerplate to get Catalan account charts installed and added to the distribution

diff --git a/accounts/CMakeLists.txt b/accounts/CMakeLists.txt
index 7b71b8e..d02aa52 100644
--- a/accounts/CMakeLists.txt
+++ b/accounts/CMakeLists.txt
@@ -1,5 +1,6 @@
 SET(accounts_SUBDIRS
   C
+  ca
   cs
   da
   de_AT
@@ -41,6 +42,7 @@ SET(ACCOUNTS_BUILD_DIR ${DATADIR_BUILD}/gnucash/accounts)
 
 
 ADD_SUBDIRECTORY(C)
+ADD_SUBDIRECTORY(ca)
 ADD_SUBDIRECTORY(cs)
 ADD_SUBDIRECTORY(da)
 ADD_SUBDIRECTORY(de_AT)
@@ -77,7 +79,7 @@ ADD_SUBDIRECTORY(zh_TW)
 
 SET_LOCAL_DIST(dist_list CMakeLists.txt Makefile.am)
 
-SET(accounts_DIST ${C_DIST} ${CS_DIST} ${DA_DIST} ${DE_AT_DIST} ${DE_CH_DIST} ${DE_DE_DIST} ${EL_GR_DIST}
+SET(accounts_DIST ${C_DIST} ${CA_DIST} ${CS_DIST} ${DA_DIST} ${DE_AT_DIST} ${DE_CH_DIST} ${DE_DE_DIST} ${EL_GR_DIST}
                   ${EN_GB_DIST} ${ES_ES_DIST} ${ES_MX_DIST} ${FI_FI_DIST} ${FR_CA_DIST} ${FR_CH_DIST}
                   ${FR_FR_DIST} ${HU_HU_DIST} ${IT_DIST} ${JA_DIST} ${KO_DIST} ${LT_DIST} ${LV_DIST}
                   ${NB_DIST} ${NL_DIST} ${PL_DIST} ${PT_BR_DIST} ${PT_PT_DIST} ${RU_DIST} ${SK_DIST}
diff --git a/accounts/Makefile.am b/accounts/Makefile.am
index b43c773..8a0b2fb 100644
--- a/accounts/Makefile.am
+++ b/accounts/Makefile.am
@@ -1,6 +1,7 @@
 
 SUBDIRS = \
 	C \
+	ca \
 	cs \
 	da \
 	de_AT \

commit daf1bf35a009aa4c4df5fc15502de31a5e85f229
Author: Josep-Maria Prat <jpftgn at gmail.com>
Date:   Thu Sep 21 10:10:34 2017 +0200

    Catalan accounts missing

diff --git a/accounts/ca/CMakeLists.txt b/accounts/ca/CMakeLists.txt
new file mode 100644
index 0000000..768fae4
--- /dev/null
+++ b/accounts/ca/CMakeLists.txt
@@ -0,0 +1,21 @@
+SET(account_DATA
+  acctchrt_brokerage.gnucash-xea
+  acctchrt_carloan.gnucash-xea
+  acctchrt_cdmoneymkt.gnucash-xea
+  acctchrt_childcare.gnucash-xea
+  acctchrt_common.gnucash-xea
+  acctchrt_currency.gnucash-xea
+  acctchrt_eduloan.gnucash-xea
+  acctchrt_fixedassets.gnucash-xea
+  acctchrt_homeloan.gnucash-xea
+  acctchrt_homeown.gnucash-xea
+  acctchrt_otherloan.gnucash-xea
+  acctchrt_renter.gnucash-xea
+  acctchrt_retiremt.gnucash-xea
+  acctchrt_spouseinc.gnucash-xea
+  acctchrt_spouseretire.gnucash-xea)
+
+SET_DIST_LIST(ca_DIST ${account_DATA} Makefile.am CMakeLists.txt)
+
+INSTALL(FILES ${account_DATA} DESTINATION ${ACCOUNTS_INSTALL_DIR}/ca)
+FILE(COPY ${account_DATA} DESTINATION ${ACCOUNTS_BUILD_DIR}/ca)
diff --git a/accounts/ca/Makefile.am b/accounts/ca/Makefile.am
new file mode 100644
index 0000000..5b2b814
--- /dev/null
+++ b/accounts/ca/Makefile.am
@@ -0,0 +1,24 @@
+
+accountdir = ${GNC_ACCOUNTS_DIR}/ca
+
+account_DATA = \
+  acctchrt_brokerage.gnucash-xea \
+  acctchrt_carloan.gnucash-xea \
+  acctchrt_cdmoneymkt.gnucash-xea \
+  acctchrt_childcare.gnucash-xea \
+  acctchrt_common.gnucash-xea \
+  acctchrt_currency.gnucash-xea \
+  acctchrt_eduloan.gnucash-xea \
+  acctchrt_fixedassets.gnucash-xea \
+  acctchrt_homeloan.gnucash-xea \
+  acctchrt_homeown.gnucash-xea \
+  acctchrt_otherloan.gnucash-xea \
+  acctchrt_renter.gnucash-xea \
+  acctchrt_retiremt.gnucash-xea \
+  acctchrt_spouseinc.gnucash-xea \
+  acctchrt_spouseretire.gnucash-xea
+
+EXTRA_DIST = \
+  ${account_DATA} \
+  CMakeLists.txt
+
diff --git a/accounts/ca/acctchrt_brokerage.gnucash-xea b/accounts/ca/acctchrt_brokerage.gnucash-xea
new file mode 100644
index 0000000..f7dd0f2
--- /dev/null
+++ b/accounts/ca/acctchrt_brokerage.gnucash-xea
@@ -0,0 +1,165 @@
+<?xml version="1.0" encoding="utf-8"?>
+<gnc-account-example>
+    <gnc-act:title>
+     Compte d'Inversió
+    </gnc-act:title>
+    <gnc-act:short-description>
+      Compte de corredor de borsa amb els comptes d'inversions associades
+    </gnc-act:short-description>
+    <gnc-act:long-description>
+    Hauríeu d'escollir aquest joc de comptes si teniu inversions (accions, bons, fons d'inversió, fons indexats, interessos, dividents).
+  </gnc-act:long-description>
+<gnc:account version="2.0.0">
+  <act:name>Root Account</act:name>
+  <act:id type="new">1972cce2e2364f95b2b0bc014502661d</act:id>
+  <act:type>ROOT</act:type>
+  <act:commodity-scu>0</act:commodity-scu>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Actiu</act:name>
+  <act:id type="new">52b5942b5beaec856eaca5a75ee71592</act:id>
+  <act:type>ASSET</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Actiu</act:description>
+  <act:parent type="new">1972cce2e2364f95b2b0bc014502661d</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Inversions</act:name>
+  <act:id type="new">7ff59d92615cce4d8388d7e179ee3ff6</act:id>
+  <act:type>ASSET</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Inversions</act:description>
+  <act:parent type="new">52b5942b5beaec856eaca5a75ee71592</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Compte d'inversió</act:name>
+  <act:id type="new">f15ec9568727f08a5ebd8f3e66483876</act:id>
+  <act:type>BANK</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Compte d'inversió</act:description>
+  <act:parent type="new">7ff59d92615cce4d8388d7e179ee3ff6</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Bons</act:name>
+  <act:id type="new">8196bf0015c25f501338f07a87c512d8</act:id>
+  <act:type>ASSET</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Bons</act:description>
+  <act:parent type="new">f15ec9568727f08a5ebd8f3e66483876</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Accions</act:name>
+  <act:id type="new">7d7db9bed07f21fc0b1f50674702aff0</act:id>
+  <act:type>ASSET</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Accions</act:description>
+  <act:parent type="new">f15ec9568727f08a5ebd8f3e66483876</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Fons d'índex</act:name>
+  <act:id type="new">fe9db8a7eedf2990e9846f634a922143</act:id>
+  <act:type>ASSET</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Fons d'índex</act:description>
+  <act:parent type="new">f15ec9568727f08a5ebd8f3e66483876</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Fons d'inversió</act:name>
+  <act:id type="new">9da28c1aa7789e84bdc8484ba8f527b3</act:id>
+  <act:type>ASSET</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Fons d'inversió</act:description>
+  <act:parent type="new">f15ec9568727f08a5ebd8f3e66483876</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Ingressos</act:name>
+  <act:id type="new">9da3c880bd04b9db49eb7f5b06403bda</act:id>
+  <act:type>INCOME</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Ingressos</act:description>
+  <act:parent type="new">1972cce2e2364f95b2b0bc014502661d</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Ingressos per dividents</act:name>
+  <act:id type="new">1af1f4894aeab96d840e66254d023b88</act:id>
+  <act:type>INCOME</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Ingressos per dividents</act:description>
+  <act:parent type="new">9da3c880bd04b9db49eb7f5b06403bda</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Ingressos per interessos</act:name>
+  <act:id type="new">7943bc59ffbb9a7be4afcd2996147119</act:id>
+  <act:type>INCOME</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Ingressos per interessos</act:description>
+  <act:parent type="new">9da3c880bd04b9db49eb7f5b06403bda</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Interessos de bons</act:name>
+  <act:id type="new">8ceb4752a11e2d342b9009b343fdba38</act:id>
+  <act:type>INCOME</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Interessos de bons</act:description>
+  <act:parent type="new">7943bc59ffbb9a7be4afcd2996147119</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Despeses</act:name>
+  <act:id type="new">6de23244232785031501171abcc1d4aa</act:id>
+  <act:type>EXPENSE</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Despeses</act:description>
+  <act:parent type="new">1972cce2e2364f95b2b0bc014502661d</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Comissions</act:name>
+  <act:id type="new">77fdffddc79c662c93c482cefa5a4744</act:id>
+  <act:type>EXPENSE</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Comissions</act:description>
+  <act:parent type="new">6de23244232785031501171abcc1d4aa</act:parent>
+</gnc:account>
+</gnc-account-example>
+
+<!-- Local variables: -->
+<!-- mode: xml        -->
+<!-- End:             -->
diff --git a/accounts/ca/acctchrt_carloan.gnucash-xea b/accounts/ca/acctchrt_carloan.gnucash-xea
new file mode 100644
index 0000000..499b172
--- /dev/null
+++ b/accounts/ca/acctchrt_carloan.gnucash-xea
@@ -0,0 +1,89 @@
+<?xml version="1.0" encoding="utf-8"?>
+<gnc-account-example>
+    <gnc-act:title>
+      Préstec d'automòbil
+    </gnc-act:title>
+    <gnc-act:short-description>
+      Comptes per pagar a terminis l'automòbil i interessos associats
+    </gnc-act:short-description>
+    <gnc-act:long-description>
+    Hauríeu de seleccionar aquest joc de comptes si esteu pagant a terminis el vostre automòbil (terminis d'automòbil, interessos per terminis d'automòbil).
+  </gnc-act:long-description>
+<gnc:account version="2.0.0">
+  <act:name>Root Account</act:name>
+  <act:id type="new">1972cce2e2364f95b2b0bc014502661d</act:id>
+  <act:type>ROOT</act:type>
+  <act:commodity-scu>0</act:commodity-scu>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Passiu</act:name>
+  <act:id type="new">33a326fe16ae360f777a94b3f5bdfbdc</act:id>
+  <act:type>LIABILITY</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Passiu</act:description>
+  <act:parent type="new">1972cce2e2364f95b2b0bc014502661d</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Préstecs</act:name>
+  <act:id type="new">023e2343114b3d695feaeb96904e0da6</act:id>
+  <act:type>LIABILITY</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Préstecs</act:description>
+  <act:parent type="new">33a326fe16ae360f777a94b3f5bdfbdc</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Vehicle a terminis</act:name>
+  <act:id type="new">3e5f44fd7bfaa9cae737a4113a749e36</act:id>
+  <act:type>LIABILITY</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Vehicle a terminis</act:description>
+  <act:parent type="new">023e2343114b3d695feaeb96904e0da6</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Despeses</act:name>
+  <act:id type="new">acacdcb998e45fb741766622e8542f0b</act:id>
+  <act:type>EXPENSE</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Despeses</act:description>
+  <act:parent type="new">1972cce2e2364f95b2b0bc014502661d</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Interessos</act:name>
+  <act:id type="new">9e8495e80ebfb762089be917dff7ab72</act:id>
+  <act:type>EXPENSE</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Interessos</act:description>
+  <act:parent type="new">acacdcb998e45fb741766622e8542f0b</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Interessos per pagament a terminis del vehicle</act:name>
+  <act:id type="new">e9bd8477e27361238d2f53c4fe7594ab</act:id>
+  <act:type>EXPENSE</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Interessos per pagament a terminis del vehicle</act:description>
+  <act:parent type="new">9e8495e80ebfb762089be917dff7ab72</act:parent>
+</gnc:account>
+</gnc-account-example>
+
+
+<!-- Local variables: -->
+<!-- mode: xml        -->
+<!-- End:             -->
diff --git a/accounts/ca/acctchrt_cdmoneymkt.gnucash-xea b/accounts/ca/acctchrt_cdmoneymkt.gnucash-xea
new file mode 100644
index 0000000..c77b3c8
--- /dev/null
+++ b/accounts/ca/acctchrt_cdmoneymkt.gnucash-xea
@@ -0,0 +1,110 @@
+<?xml version="1.0" encoding="utf-8"?>
+<gnc-account-example>
+    <gnc-act:title>
+      Pagarés i mercat monetari
+    </gnc-act:title>
+    <gnc-act:short-description>
+     Comptes per pagarés i inversions de mercat monetari
+    </gnc-act:short-description>
+    <gnc-act:long-description>
+    Hauríeu de seleccionar aquest joc de comptes si empreu pagarés o comptes de mercat monetari (pagarés, interessos de pagarés, mercat monetari, interessos de mercat monetari).
+  </gnc-act:long-description>
+<gnc:account version="2.0.0">
+  <act:name>Root Account</act:name>
+  <act:id type="new">1972cce2e2364f95b2b0bc014502661d</act:id>
+  <act:type>ROOT</act:type>
+  <act:commodity-scu>0</act:commodity-scu>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Actiu</act:name>
+  <act:id type="new">7b1a39efc6234d1db148baa722c9471e</act:id>
+  <act:type>ASSET</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Actiu</act:description>
+  <act:parent type="new">1972cce2e2364f95b2b0bc014502661d</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Actiu circulant</act:name>
+  <act:id type="new">1880e89ec9fe82622b8648df481dd2b7</act:id>
+  <act:type>ASSET</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Actiu circulant</act:description>
+  <act:parent type="new">7b1a39efc6234d1db148baa722c9471e</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Pagaré de banc</act:name>
+  <act:id type="new">c1620f9c3082e33d8fd559e17f90a122</act:id>
+  <act:type>BANK</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Pagaré de banc</act:description>
+  <act:parent type="new">1880e89ec9fe82622b8648df481dd2b7</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Mercat monetari</act:name>
+  <act:id type="new">3a01e5b0132ba26803b49732a3242654</act:id>
+  <act:type>BANK</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Mercat monetari</act:description>
+  <act:parent type="new">1880e89ec9fe82622b8648df481dd2b7</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Ingressos</act:name>
+  <act:id type="new">4b3e36f325569b80efc7d3331bdf851b</act:id>
+  <act:type>INCOME</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Ingressos</act:description>
+  <act:parent type="new">1972cce2e2364f95b2b0bc014502661d</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Ingressos per interessos</act:name>
+  <act:id type="new">fd131cae797d1fb83c2e2bf57254eca5</act:id>
+  <act:type>INCOME</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Ingressos per interessos</act:description>
+  <act:parent type="new">4b3e36f325569b80efc7d3331bdf851b</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Interès de pagarés</act:name>
+  <act:id type="new">28d311f0f38da5e35628e76ad8bcc853</act:id>
+  <act:type>INCOME</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Interès de pagarés</act:description>
+  <act:parent type="new">fd131cae797d1fb83c2e2bf57254eca5</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Interès de mercat monetari</act:name>
+  <act:id type="new">dc537946f39e84ccef7ce38f016249af</act:id>
+  <act:type>INCOME</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Interès de mercat monetari</act:description>
+  <act:parent type="new">fd131cae797d1fb83c2e2bf57254eca5</act:parent>
+</gnc:account>
+</gnc-account-example>
+
+<!-- Local variables: -->
+<!-- mode: xml        -->
+<!-- End:             -->
diff --git a/accounts/ca/acctchrt_childcare.gnucash-xea b/accounts/ca/acctchrt_childcare.gnucash-xea
new file mode 100644
index 0000000..3cfea6b
--- /dev/null
+++ b/accounts/ca/acctchrt_childcare.gnucash-xea
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="utf-8"?>
+<gnc-account-example>
+    <gnc-act:title>
+      Despeses de la llar d'infants
+    </gnc-act:title>
+    <gnc-act:short-description>
+      Compte per gestionar despeses de la llar d'infants
+    </gnc-act:short-description>
+    <gnc-act:long-description>
+    Hauríeu de seleccionar aquest joc de comptes si teniu despeses de llar d'infants.
+  </gnc-act:long-description>
+<gnc:account version="2.0.0">
+  <act:name>Root Account</act:name>
+  <act:id type="new">1972cce2e2364f95b2b0bc014502661d</act:id>
+  <act:type>ROOT</act:type>
+  <act:commodity-scu>0</act:commodity-scu>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Despeses</act:name>
+  <act:id type="new">ee8238ee2c2ce590160761df09b99b72</act:id>
+  <act:type>EXPENSE</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Despeses</act:description>
+  <act:parent type="new">1972cce2e2364f95b2b0bc014502661d</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Llar d'infants</act:name>
+  <act:id type="new">8999739a6bfc46088a3ea5ec45e5f8a4</act:id>
+  <act:type>EXPENSE</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Llar d'infants</act:description>
+  <act:parent type="new">ee8238ee2c2ce590160761df09b99b72</act:parent>
+</gnc:account>
+</gnc-account-example>
+
+<!-- Local variables: -->
+<!-- mode: xml        -->
+<!-- End:             -->
diff --git a/accounts/ca/acctchrt_common.gnucash-xea b/accounts/ca/acctchrt_common.gnucash-xea
new file mode 100644
index 0000000..e61093f
--- /dev/null
+++ b/accounts/ca/acctchrt_common.gnucash-xea
@@ -0,0 +1,728 @@
+<?xml version="1.0" encoding="utf-8"?>
+<gnc-account-example>
+    <gnc-act:title>
+      Comptes comuns
+    </gnc-act:title>
+    <gnc-act:short-description>
+      Un joc bàsic de comptes emprats majoritàriament
+    </gnc-act:short-description>
+    <gnc-act:long-description>
+      La majoria dels usuaris desitjarà escollir aquest joc de comptes.
+      Inclou els comptes emprats més habitualment (compte corrent, d'estalvis, metàl·lic, tarjeta de crèdit, ingressos, despeses comuns)
+  </gnc-act:long-description>
+  <gnc-act:start-selected>1</gnc-act:start-selected>
+<gnc:account version="2.0.0">
+  <act:name>Root Account</act:name>
+  <act:id type="new">1972cce2e2364f95b2b0bc014502661d</act:id>
+  <act:type>ROOT</act:type>
+  <act:commodity-scu>0</act:commodity-scu>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Actiu</act:name>
+  <act:id type="new">98f262dfab9a2b99ac42919dcf58d304</act:id>
+  <act:type>ASSET</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Actiu</act:description>
+  <act:parent type="new">1972cce2e2364f95b2b0bc014502661d</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Actiu circulant</act:name>
+  <act:id type="new">a1dd5f225156f110689c204fefded0ab</act:id>
+  <act:type>ASSET</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Actiu circulant</act:description>
+  <act:parent type="new">98f262dfab9a2b99ac42919dcf58d304</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Compte corrent</act:name>
+  <act:id type="new">b477aa9e0d4eb67c34e1e35903fb3f99</act:id>
+  <act:type>BANK</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Compte corrent</act:description>
+  <act:parent type="new">a1dd5f225156f110689c204fefded0ab</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Compte d'estalvis</act:name>
+  <act:id type="new">eeae5a1892e88adbc3b369c76ee4e889</act:id>
+  <act:type>BANK</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Compte d'estalvis</act:description>
+  <act:parent type="new">a1dd5f225156f110689c204fefded0ab</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Metàl·lic</act:name>
+  <act:id type="new">07b454b9dd6f68c4b613c5f1ef76f884</act:id>
+  <act:type>CASH</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Metàl·lic</act:description>
+  <act:parent type="new">a1dd5f225156f110689c204fefded0ab</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Passiu</act:name>
+  <act:id type="new">19a911feed9b41b8b01be036a2aed9fe</act:id>
+  <act:type>LIABILITY</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Passiu</act:description>
+  <act:parent type="new">1972cce2e2364f95b2b0bc014502661d</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Comptes per pagar</act:name>
+  <act:id type="new">a8186db64d71dc2ca5fdccb3234b531b</act:id>
+  <act:type>LIABILITY</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Comptes per pagar</act:description>
+  <act:parent type="new">19a911feed9b41b8b01be036a2aed9fe</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Tarjeta de crèdit</act:name>
+  <act:id type="new">efc3caac2619666c53e6e27f02d5e716</act:id>
+  <act:type>CREDIT</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Tarjeta de crèdit</act:description>
+  <act:parent type="new">a8186db64d71dc2ca5fdccb3234b531b</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Ingressos</act:name>
+  <act:id type="new">a7ab23dd2d41616042034d5a012a0850</act:id>
+  <act:type>INCOME</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Ingressos</act:description>
+  <act:parent type="new">1972cce2e2364f95b2b0bc014502661d</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Pagues extra</act:name>
+  <act:id type="new">59b72cd943a2ca6f077748bba9a942cd</act:id>
+  <act:type>INCOME</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Pagues extra</act:description>
+  <act:parent type="new">a7ab23dd2d41616042034d5a012a0850</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Regals rebuts</act:name>
+  <act:id type="new">1adcf2c65d7a66f32144ccd9ce4f438f</act:id>
+  <act:type>INCOME</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Regals rebuts</act:description>
+  <act:parent type="new">a7ab23dd2d41616042034d5a012a0850</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Ingressos per interessos</act:name>
+  <act:id type="new">c47361e40d9478ec11758097e64d693c</act:id>
+  <act:type>INCOME</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Ingressos per interessos</act:description>
+  <act:parent type="new">a7ab23dd2d41616042034d5a012a0850</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Interessos de compte corrent</act:name>
+  <act:id type="new">73481e2da7461fc34e7003b7ec560bdf</act:id>
+  <act:type>INCOME</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Interessos de compte corrent</act:description>
+  <act:parent type="new">c47361e40d9478ec11758097e64d693c</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Altres interessos</act:name>
+  <act:id type="new">be17363347a8578c48cecd06bc8b7aa8</act:id>
+  <act:type>INCOME</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Altres interessos</act:description>
+  <act:parent type="new">c47361e40d9478ec11758097e64d693c</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Interessos del compte d'estalvis</act:name>
+  <act:id type="new">2802ac0d1bff1c09a903f2ad6fde2725</act:id>
+  <act:type>INCOME</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Interessos del compte d'estalvis</act:description>
+  <act:parent type="new">c47361e40d9478ec11758097e64d693c</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Altres ingressos</act:name>
+  <act:id type="new">49525ad0fb4ced06b9874d365d53f505</act:id>
+  <act:type>INCOME</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Altres ingressos</act:description>
+  <act:parent type="new">a7ab23dd2d41616042034d5a012a0850</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Sou</act:name>
+  <act:id type="new">a750b99cb8487a5e47daedcd3a69fe85</act:id>
+  <act:type>INCOME</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Sou</act:description>
+  <act:parent type="new">a7ab23dd2d41616042034d5a012a0850</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Despeses</act:name>
+  <act:id type="new">1884bbd7394883ebafec8b9e2eb091a4</act:id>
+  <act:type>EXPENSE</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Despeses</act:description>
+  <act:parent type="new">1972cce2e2364f95b2b0bc014502661d</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Ajustos</act:name>
+  <act:id type="new">72f85277a7a7f8b4de175405e20d83bd</act:id>
+  <act:type>EXPENSE</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Ajustos</act:description>
+  <act:parent type="new">1884bbd7394883ebafec8b9e2eb091a4</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Automòbil</act:name>
+  <act:id type="new">56df186f1ce6114ddca7b9e5d03af390</act:id>
+  <act:type>EXPENSE</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Automòbil</act:description>
+  <act:parent type="new">1884bbd7394883ebafec8b9e2eb091a4</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Quotes</act:name>
+  <act:id type="new">2ff007a389bd23d8970afeba2d58c9a8</act:id>
+  <act:type>EXPENSE</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Quotes</act:description>
+  <act:parent type="new">56df186f1ce6114ddca7b9e5d03af390</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Benzina</act:name>
+  <act:id type="new">e64b5eecf86ce4e27a64c477a4c77477</act:id>
+  <act:type>EXPENSE</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Benzina</act:description>
+  <act:parent type="new">56df186f1ce6114ddca7b9e5d03af390</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Aparcament</act:name>
+  <act:id type="new">d72262c1c0e2c3388183ebb44a98b011</act:id>
+  <act:type>EXPENSE</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Aparcament</act:description>
+  <act:parent type="new">56df186f1ce6114ddca7b9e5d03af390</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Reparacions i manteniment</act:name>
+  <act:id type="new">665dd78f0cc75dd331f556949337de68</act:id>
+  <act:type>EXPENSE</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Reparacions i manteniment</act:description>
+  <act:parent type="new">56df186f1ce6114ddca7b9e5d03af390</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Càrrec de servei bancari</act:name>
+  <act:id type="new">fb6c8e25a50737e70fffde432a2355ee</act:id>
+  <act:type>EXPENSE</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Càrrec de servei bancari</act:description>
+  <act:parent type="new">1884bbd7394883ebafec8b9e2eb091a4</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Llibres</act:name>
+  <act:id type="new">36479bbc17680f4b9663a9842736153f</act:id>
+  <act:type>EXPENSE</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Llibres</act:description>
+  <act:parent type="new">1884bbd7394883ebafec8b9e2eb091a4</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>TV per Cable</act:name>
+  <act:id type="new">a1393344fb199f08f751ac3154694e87</act:id>
+  <act:type>EXPENSE</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>TV per Cable</act:description>
+  <act:parent type="new">1884bbd7394883ebafec8b9e2eb091a4</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Obres benèfiques</act:name>
+  <act:id type="new">ec8eec3d46c69aa861fda836e11346c0</act:id>
+  <act:type>EXPENSE</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Obres benèfiques</act:description>
+  <act:parent type="new">1884bbd7394883ebafec8b9e2eb091a4</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Roba</act:name>
+  <act:id type="new">c27a040a73eac2688d85d29b5b5309c8</act:id>
+  <act:type>EXPENSE</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Roba</act:description>
+  <act:parent type="new">1884bbd7394883ebafec8b9e2eb091a4</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Informàtica</act:name>
+  <act:id type="new">fc4390b6214ad1576c5ffffc2b3c268c</act:id>
+  <act:type>EXPENSE</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Informàtica</act:description>
+  <act:parent type="new">1884bbd7394883ebafec8b9e2eb091a4</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Restaurants</act:name>
+  <act:id type="new">0a59a3347e4ff02b862de41ef59d7351</act:id>
+  <act:type>EXPENSE</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Restaurants</act:description>
+  <act:parent type="new">1884bbd7394883ebafec8b9e2eb091a4</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Educació</act:name>
+  <act:id type="new">5b5ac050529b0f553752babe4a6a35d2</act:id>
+  <act:type>EXPENSE</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Educació</act:description>
+  <act:parent type="new">1884bbd7394883ebafec8b9e2eb091a4</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Oci</act:name>
+  <act:id type="new">0ebd1d5f40d9e9e8bb1a4bf539650dd1</act:id>
+  <act:type>EXPENSE</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Oci</act:description>
+  <act:parent type="new">1884bbd7394883ebafec8b9e2eb091a4</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Música/Pel·lícules</act:name>
+  <act:id type="new">4570ea8f4ac5cbd7d8927c905f0978ae</act:id>
+  <act:type>EXPENSE</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Música/Pel·lícules</act:description>
+  <act:parent type="new">0ebd1d5f40d9e9e8bb1a4bf539650dd1</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Esbarjo</act:name>
+  <act:id type="new">7db9b0aa3bc348da9900f95fc67541a1</act:id>
+  <act:type>EXPENSE</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Esbarjo</act:description>
+  <act:parent type="new">0ebd1d5f40d9e9e8bb1a4bf539650dd1</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Viatges</act:name>
+  <act:id type="new">def0eac939dbd668f503d84860de8d6e</act:id>
+  <act:type>EXPENSE</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Viatges</act:description>
+  <act:parent type="new">0ebd1d5f40d9e9e8bb1a4bf539650dd1</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Regals</act:name>
+  <act:id type="new">f86b1cebc619455ada23952a0e810909</act:id>
+  <act:type>EXPENSE</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Regals</act:description>
+  <act:parent type="new">1884bbd7394883ebafec8b9e2eb091a4</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Comestibles</act:name>
+  <act:id type="new">83bc2bd915ab6b74c7107b55f8783523</act:id>
+  <act:type>EXPENSE</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Comestibles</act:description>
+  <act:parent type="new">1884bbd7394883ebafec8b9e2eb091a4</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Hobbies</act:name>
+  <act:id type="new">89f6400a94cd87fea0b056faf6ab7744</act:id>
+  <act:type>EXPENSE</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Hobbies</act:description>
+  <act:parent type="new">1884bbd7394883ebafec8b9e2eb091a4</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Assegurances</act:name>
+  <act:id type="new">5bda5ff833bc395dc1b00f95c66ce555</act:id>
+  <act:type>EXPENSE</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Assegurances</act:description>
+  <act:parent type="new">1884bbd7394883ebafec8b9e2eb091a4</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Assegurança d'Automòbil</act:name>
+  <act:id type="new">cd72695526906a15ba1a1d9a7680b8e7</act:id>
+  <act:type>EXPENSE</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Assegurança d'Automòbil</act:description>
+  <act:parent type="new">5bda5ff833bc395dc1b00f95c66ce555</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Assegurança sanitària</act:name>
+  <act:id type="new">d80613194a52340c9e5eb62e853c72cf</act:id>
+  <act:type>EXPENSE</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Assegurança sanitària</act:description>
+  <act:parent type="new">5bda5ff833bc395dc1b00f95c66ce555</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Assegurança de vida</act:name>
+  <act:id type="new">70a327f54be53ef187a52b1d8df70fdd</act:id>
+  <act:type>EXPENSE</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Assegurança de vida</act:description>
+  <act:parent type="new">5bda5ff833bc395dc1b00f95c66ce555</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Bugaderia</act:name>
+  <act:id type="new">1006551b2458631dfc8507b7451c9631</act:id>
+  <act:type>EXPENSE</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Bugaderia</act:description>
+  <act:parent type="new">1884bbd7394883ebafec8b9e2eb091a4</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Despeses mèdiques</act:name>
+  <act:id type="new">62752930dd1b2b4c90c6d198bd2ff33f</act:id>
+  <act:type>EXPENSE</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Despeses mèdiques</act:description>
+  <act:parent type="new">1884bbd7394883ebafec8b9e2eb091a4</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Altres Despeses</act:name>
+  <act:id type="new">759deef82e73587bf48a7dd76aa6abe8</act:id>
+  <act:type>EXPENSE</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Altres Despeses</act:description>
+  <act:parent type="new">1884bbd7394883ebafec8b9e2eb091a4</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Serveis d'Internet</act:name>
+  <act:id type="new">2170a1a631cc3b6fc32813fa49a12f77</act:id>
+  <act:type>EXPENSE</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Serveis d'Internet</act:description>
+  <act:parent type="new">1884bbd7394883ebafec8b9e2eb091a4</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Telèfon</act:name>
+  <act:id type="new">1d9d7265e25c6c84dda514d2e8899e87</act:id>
+  <act:type>EXPENSE</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Telèfon</act:description>
+  <act:parent type="new">1884bbd7394883ebafec8b9e2eb091a4</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Transport públic</act:name>
+  <act:id type="new">64aa760163c7768518e49a104d1c171f</act:id>
+  <act:type>EXPENSE</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Transport públic</act:description>
+  <act:parent type="new">1884bbd7394883ebafec8b9e2eb091a4</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Suscripcions</act:name>
+  <act:id type="new">0336712690d36bcb02e0ce59b5d7653b</act:id>
+  <act:type>EXPENSE</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Suscripcions</act:description>
+  <act:parent type="new">1884bbd7394883ebafec8b9e2eb091a4</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Material d'oficina</act:name>
+  <act:id type="new">e2b34f49d4cf916cf4d45525e1e7319d</act:id>
+  <act:type>EXPENSE</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Material d'oficina</act:description>
+  <act:parent type="new">1884bbd7394883ebafec8b9e2eb091a4</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Impostos</act:name>
+  <act:id type="new">2c53a8a0c8b36f7de3f4052653886c2b</act:id>
+  <act:type>EXPENSE</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Impostos</act:description>
+  <act:parent type="new">1884bbd7394883ebafec8b9e2eb091a4</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>IRPF</act:name>
+  <act:id type="new">090a786357463ec7fbee8066cb999097</act:id>
+  <act:type>EXPENSE</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>IRPF</act:description>
+  <act:parent type="new">2c53a8a0c8b36f7de3f4052653886c2b</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Retencions</act:name>
+  <act:id type="new">0785932c5de43e814659420762c9b577</act:id>
+  <act:type>EXPENSE</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Retencions</act:description>
+  <act:parent type="new">2c53a8a0c8b36f7de3f4052653886c2b</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Altres impostos</act:name>
+  <act:id type="new">51875f8aaa0e4f2295a2ae13cf780b2e</act:id>
+  <act:type>EXPENSE</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Altres impostos</act:description>
+  <act:parent type="new">2c53a8a0c8b36f7de3f4052653886c2b</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Seguretat Social</act:name>
+  <act:id type="new">c252f10f3d57dd05c500856164b1729e</act:id>
+  <act:type>EXPENSE</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Seguretat Social</act:description>
+  <act:parent type="new">2c53a8a0c8b36f7de3f4052653886c2b</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Municipals</act:name>
+  <act:id type="new">cd1f1b512ed51a069fd83a5ffcaf6e11</act:id>
+  <act:type>EXPENSE</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Municipals</act:description>
+  <act:parent type="new">2c53a8a0c8b36f7de3f4052653886c2b</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Serveis</act:name>
+  <act:id type="new">57635fa5f71dee8ffc207c277250e773</act:id>
+  <act:type>EXPENSE</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Serveis</act:description>
+  <act:parent type="new">1884bbd7394883ebafec8b9e2eb091a4</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Electricitat</act:name>
+  <act:id type="new">2fe462e202e2daffd845359b08a7eefe</act:id>
+  <act:type>EXPENSE</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Electricitat</act:description>
+  <act:parent type="new">57635fa5f71dee8ffc207c277250e773</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Recollida de brossa</act:name>i
+  <act:id type="new">2d0315d7b2f8f11a8a8b32d805bca6eb</act:id>
+  <act:type>EXPENSE</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Recollida de brossa</act:description>
+  <act:parent type="new">57635fa5f71dee8ffc207c277250e773</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Gas</act:name>
+  <act:id type="new">dcc33ce7edf402e327318aa1890d35ea</act:id>
+  <act:type>EXPENSE</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Gas</act:description>
+  <act:parent type="new">57635fa5f71dee8ffc207c277250e773</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Aigua</act:name>
+  <act:id type="new">8cdc91b733444f9f0dfae9773b8f408c</act:id>
+  <act:type>EXPENSE</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Aigua</act:description>
+  <act:parent type="new">57635fa5f71dee8ffc207c277250e773</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Resultat</act:name>
+  <act:id type="new">3ab6a6d97b216c11333e48aa2b749a91</act:id>
+  <act:type>EQUITY</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Resultat</act:description>
+  <act:parent type="new">1972cce2e2364f95b2b0bc014502661d</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Balanços d'obertura</act:name>
+  <act:id type="new">a0a622a30410f75eba35d2875a843da8</act:id>
+  <act:type>EQUITY</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Balanços d'obertura</act:description>
+  <act:parent type="new">3ab6a6d97b216c11333e48aa2b749a91</act:parent>
+</gnc:account>
+</gnc-account-example>
+
+<!-- Local variables: -->
+<!-- mode: xml        -->
+<!-- End:             -->
diff --git a/accounts/ca/acctchrt_currency.gnucash-xea b/accounts/ca/acctchrt_currency.gnucash-xea
new file mode 100644
index 0000000..4b5acca
--- /dev/null
+++ b/accounts/ca/acctchrt_currency.gnucash-xea
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="utf-8"?>
+<gnc-account-example>
+    <gnc-act:title>
+      Compte de conversió monetària
+    </gnc-act:title>
+    <gnc-act:short-description>
+      Compte per convertir i comerciar amb moneda estrangera
+    </gnc-act:short-description>
+    <gnc-act:long-description>
+    Hauríeu de seleccionar aquest joc de comptes si convertiu monedes estrangeres.
+    
+    Nota: El compte es troba en USD; editi el compte per modificar la moneda
+  </gnc-act:long-description>
+<gnc:account version="2.0.0">
+  <act:name>Root Account</act:name>
+  <act:id type="new">1972cce2e2364f95b2b0bc014502661d</act:id>
+  <act:type>ROOT</act:type>
+  <act:commodity-scu>0</act:commodity-scu>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Actiu</act:name>
+  <act:id type="new">b3c65be1c5d163746ddc0c506f3f4619</act:id>
+  <act:type>ASSET</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Actiu</act:description>
+  <act:parent type="new">1972cce2e2364f95b2b0bc014502661d</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Inversions</act:name>
+  <act:id type="new">d9c796b35784533aee4309e28a3cbfc5</act:id>
+  <act:type>ASSET</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Inversions</act:description>
+  <act:parent type="new">b3c65be1c5d163746ddc0c506f3f4619</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Comerç de monedes estrangeres</act:name>
+  <act:id type="new">9206632307989cb5b244ad5da5d3131b</act:id>
+  <act:type>CURRENCY</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>USD</cmdty:id>
+  </act:commodity>
+  <act:description>Comerç de monedes estrangeres</act:description>
+  <act:parent type="new">d9c796b35784533aee4309e28a3cbfc5</act:parent>
+</gnc:account>
+</gnc-account-example>
+
+<!-- Local variables: -->
+<!-- mode: xml        -->
+<!-- End:             -->
diff --git a/accounts/ca/acctchrt_eduloan.gnucash-xea b/accounts/ca/acctchrt_eduloan.gnucash-xea
new file mode 100644
index 0000000..c4f69f0
--- /dev/null
+++ b/accounts/ca/acctchrt_eduloan.gnucash-xea
@@ -0,0 +1,88 @@
+<?xml version="1.0" encoding="utf-8"?>
+<gnc-account-example>
+    <gnc-act:title>
+      Préstec per a l'educació
+    </gnc-act:title>
+    <gnc-act:short-description>
+      Comptes per a préstecs per estudis i interessos associats
+    </gnc-act:short-description>
+    <gnc-act:long-description>
+    Hauríeu de seleccionar aquest conjunt de comptes si posseïu un préstec per a l'educació (préstec per a l'educació, interessos de préstec per a l'educació)
+  </gnc-act:long-description>
+<gnc:account version="2.0.0">
+  <act:name>Root Account</act:name>
+  <act:id type="new">1972cce2e2364f95b2b0bc014502661d</act:id>
+  <act:type>ROOT</act:type>
+  <act:commodity-scu>0</act:commodity-scu>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Passiu</act:name>
+  <act:id type="new">4e7e8e39487ad4aba0b62c2232c577c5</act:id>
+  <act:type>LIABILITY</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Passiu</act:description>
+  <act:parent type="new">1972cce2e2364f95b2b0bc014502661d</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Préstecs</act:name>
+  <act:id type="new">c3219e37044b0531d66a7b64433b026d</act:id>
+  <act:type>LIABILITY</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Préstecs</act:description>
+  <act:parent type="new">4e7e8e39487ad4aba0b62c2232c577c5</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Préstec per a l'educació</act:name>
+  <act:id type="new">ddeba367199bd025e00420a19d6f9ae4</act:id>
+  <act:type>LIABILITY</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Préstec per a l'educació</act:description>
+  <act:parent type="new">c3219e37044b0531d66a7b64433b026d</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Despeses</act:name>
+  <act:id type="new">fdbf47b39f70e8818f325eee7931039a</act:id>
+  <act:type>EXPENSE</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Despeses</act:description>
+  <act:parent type="new">1972cce2e2364f95b2b0bc014502661d</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Interessos</act:name>
+  <act:id type="new">1cfcd30ea97b954ffb550ab87d561033</act:id>
+  <act:type>EXPENSE</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Interessos</act:description>
+  <act:parent type="new">fdbf47b39f70e8818f325eee7931039a</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Interessos de préstec per a l'educació</act:name>
+  <act:id type="new">04e3d970dc60d3920f40b93fce8924a2</act:id>
+  <act:type>EXPENSE</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Interessos de préstec per a l'educació</act:description>
+  <act:parent type="new">1cfcd30ea97b954ffb550ab87d561033</act:parent>
+</gnc:account>
+</gnc-account-example>
+
+<!-- Local variables: -->
+<!-- mode: xml        -->
+<!-- End:             -->
diff --git a/accounts/ca/acctchrt_fixedassets.gnucash-xea b/accounts/ca/acctchrt_fixedassets.gnucash-xea
new file mode 100644
index 0000000..d0bbe54
--- /dev/null
+++ b/accounts/ca/acctchrt_fixedassets.gnucash-xea
@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="utf-8"?>
+<gnc-account-example>
+    <gnc-act:title>
+      Actius fixos
+    </gnc-act:title>
+    <gnc-act:short-description>
+      Comptes per gestionar diferents actius fixos
+    </gnc-act:short-description>
+    <gnc-act:long-description>
+    Hauríeu de seleccionar aquest compte si teniu diferents actius fixos (casa, vehicle, casa de vacances, altres actius).
+  </gnc-act:long-description>
+<gnc:account version="2.0.0">
+  <act:name>Root Account</act:name>
+  <act:id type="new">1972cce2e2364f95b2b0bc014502661d</act:id>
+  <act:type>ROOT</act:type>
+  <act:commodity-scu>0</act:commodity-scu>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Actiu</act:name>
+  <act:id type="new">64b6276c060185131cecbd1ac6218440</act:id>
+  <act:type>ASSET</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Actiu</act:description>
+  <act:parent type="new">1972cce2e2364f95b2b0bc014502661d</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Actiu fix</act:name>
+  <act:id type="new">9b171f77000bf68dd1ebbaf58336656d</act:id>
+  <act:type>ASSET</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Actiu fix</act:description>
+  <act:parent type="new">64b6276c060185131cecbd1ac6218440</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Casa</act:name>
+  <act:id type="new">9205ad6b6482903e5a696602d491c8f5</act:id>
+  <act:type>ASSET</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Casa</act:description>
+  <act:parent type="new">9b171f77000bf68dd1ebbaf58336656d</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Altres actius</act:name>
+  <act:id type="new">ad3b239297277c9ef3840c0433cecb18</act:id>
+  <act:type>ASSET</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Altres actius</act:description>
+  <act:parent type="new">9b171f77000bf68dd1ebbaf58336656d</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Vehicle</act:name>
+  <act:id type="new">5913089ffc36df6f0a5d96a5d7a444c0</act:id>
+  <act:type>ASSET</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Vehicle</act:description>
+  <act:parent type="new">9b171f77000bf68dd1ebbaf58336656d</act:parent>
+</gnc:account>
+</gnc-account-example>
+
+<!-- Local variables: -->
+<!-- mode: xml        -->
+<!-- End:             -->
diff --git a/accounts/ca/acctchrt_homeloan.gnucash-xea b/accounts/ca/acctchrt_homeloan.gnucash-xea
new file mode 100644
index 0000000..c872aef
--- /dev/null
+++ b/accounts/ca/acctchrt_homeloan.gnucash-xea
@@ -0,0 +1,88 @@
+<?xml version="1.0" encoding="utf-8"?>
+<gnc-account-example>
+    <gnc-act:title>
+      Préstec hipotecari
+    </gnc-act:title>
+    <gnc-act:short-description>
+     Comptes per a préstec hipotecari i interès associat
+    </gnc-act:short-description>
+    <gnc-act:long-description>
+    Hauríeu d'escollir aquest joc de comptes si teniu contractat un préstec hipotecari (préstec hipotecari, interès hipoteca).
+  </gnc-act:long-description>
+<gnc:account version="2.0.0">
+  <act:name>Root Account</act:name>
+  <act:id type="new">1972cce2e2364f95b2b0bc014502661d</act:id>
+  <act:type>ROOT</act:type>
+  <act:commodity-scu>0</act:commodity-scu>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Passiu</act:name>
+  <act:id type="new">6664763bd1ea41462cba5ef856d9c00c</act:id>
+  <act:type>LIABILITY</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Passiu</act:description>
+  <act:parent type="new">1972cce2e2364f95b2b0bc014502661d</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Préstecs</act:name>
+  <act:id type="new">2e6e2d91551cff7b1fd8d6eb34c12117</act:id>
+  <act:type>LIABILITY</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Préstecs</act:description>
+  <act:parent type="new">6664763bd1ea41462cba5ef856d9c00c</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Préstec hipotecari</act:name>
+  <act:id type="new">4df1b393c218d9047dd22d33d2737e83</act:id>
+  <act:type>LIABILITY</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Préstec hipotecari</act:description>
+  <act:parent type="new">2e6e2d91551cff7b1fd8d6eb34c12117</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Despeses</act:name>
+  <act:id type="new">2f076f5ae073173a11d33420cd39fa4d</act:id>
+  <act:type>EXPENSE</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Despeses</act:description>
+  <act:parent type="new">1972cce2e2364f95b2b0bc014502661d</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Interessos</act:name>
+  <act:id type="new">3dc58d8a51b5deaa22e0c65d81e90346</act:id>
+  <act:type>EXPENSE</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Interessos</act:description>
+  <act:parent type="new">2f076f5ae073173a11d33420cd39fa4d</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Interès de la hipoteca</act:name>
+  <act:id type="new">c1e23fa813d3c8c4a8ea1228a7615b79</act:id>
+  <act:type>EXPENSE</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Interès de la hipoteca</act:description>
+  <act:parent type="new">3dc58d8a51b5deaa22e0c65d81e90346</act:parent>
+</gnc:account>
+</gnc-account-example>
+
+<!-- Local variables: -->
+<!-- mode: xml        -->
+<!-- End:             -->
diff --git a/accounts/ca/acctchrt_homeown.gnucash-xea b/accounts/ca/acctchrt_homeown.gnucash-xea
new file mode 100644
index 0000000..126c4f1
--- /dev/null
+++ b/accounts/ca/acctchrt_homeown.gnucash-xea
@@ -0,0 +1,88 @@
+<?xml version="1.0" encoding="utf-8"?>
+<gnc-account-example>
+    <gnc-act:title>
+      Despeses de propietari de casa
+    </gnc-act:title>
+    <gnc-act:short-description>
+      Despeses associades a la propietat d'una casa
+    </gnc-act:short-description>
+    <gnc-act:long-description>
+    Hauríeu de seleccionar aquest joc de comptes si posseïu una casa. Aquest joc us proporciona un grup de comptes per controlar les despeses domèstiques (assegurança, impostos, reparacions).
+  </gnc-act:long-description>
+<gnc:account version="2.0.0">
+  <act:name>Root Account</act:name>
+  <act:id type="new">1972cce2e2364f95b2b0bc014502661d</act:id>
+  <act:type>ROOT</act:type>
+  <act:commodity-scu>0</act:commodity-scu>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Despeses</act:name>
+  <act:id type="new">84732f5fdd27b6463d75bf958e3a4b06</act:id>
+  <act:type>EXPENSE</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Despeses</act:description>
+  <act:parent type="new">1972cce2e2364f95b2b0bc014502661d</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Reparacions domèstiques</act:name>
+  <act:id type="new">fa27de57090e107fa99fe1db53790f23</act:id>
+  <act:type>EXPENSE</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Reparacions domèstiques</act:description>
+  <act:parent type="new">84732f5fdd27b6463d75bf958e3a4b06</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Assegurances</act:name>
+  <act:id type="new">4677fe36914ebcf23758f3bf20686b4a</act:id>
+  <act:type>EXPENSE</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Assegurances</act:description>
+  <act:parent type="new">84732f5fdd27b6463d75bf958e3a4b06</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Assegurança de la llar</act:name>
+  <act:id type="new">3b5909f31bda0e0f76149fd600e0cb1d</act:id>
+  <act:type>EXPENSE</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Assegurança de la llar</act:description>
+  <act:parent type="new">4677fe36914ebcf23758f3bf20686b4a</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Impostos</act:name>
+  <act:id type="new">a931b8ffe2917ff9a069333623da96ca</act:id>
+  <act:type>EXPENSE</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Impostos</act:description>
+  <act:parent type="new">84732f5fdd27b6463d75bf958e3a4b06</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Contribució</act:name>
+  <act:id type="new">3994b8f5a6a8b2a0a48126fa955e03f7</act:id>
+  <act:type>EXPENSE</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Contribució</act:description>
+  <act:parent type="new">a931b8ffe2917ff9a069333623da96ca</act:parent>
+</gnc:account>
+</gnc-account-example>
+
+<!-- Local variables: -->
+<!-- mode: xml        -->
+<!-- End:             -->
diff --git a/accounts/ca/acctchrt_otherloan.gnucash-xea b/accounts/ca/acctchrt_otherloan.gnucash-xea
new file mode 100644
index 0000000..9959254
--- /dev/null
+++ b/accounts/ca/acctchrt_otherloan.gnucash-xea
@@ -0,0 +1,88 @@
+<?xml version="1.0" encoding="utf-8"?>
+<gnc-account-example>
+    <gnc-act:title>
+      Altres préstecs
+    </gnc-act:title>
+    <gnc-act:short-description>
+      Comptes per controlar altres préstecs, junt amb el seu interès associat
+    </gnc-act:short-description>
+    <gnc-act:long-description>
+    Desitjareu seleccionar aquest joc de comptes si teniu un préstec diferent a un préstec hipotecari (altres préstecs, interessos d'altres préstecs).
+  </gnc-act:long-description>
+<gnc:account version="2.0.0">
+  <act:name>Root Account</act:name>
+  <act:id type="new">1972cce2e2364f95b2b0bc014502661d</act:id>
+  <act:type>ROOT</act:type>
+  <act:commodity-scu>0</act:commodity-scu>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Passiu</act:name>
+  <act:id type="new">8ec79e80d9abf58d78ce3129d3fe3365</act:id>
+  <act:type>LIABILITY</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Passiu</act:description>
+  <act:parent type="new">1972cce2e2364f95b2b0bc014502661d</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Préstecs</act:name>
+  <act:id type="new">b5624a9d1a1b797b87b815774faccfe4</act:id>
+  <act:type>LIABILITY</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Préstecs</act:description>
+  <act:parent type="new">8ec79e80d9abf58d78ce3129d3fe3365</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Altres préstecs</act:name>
+  <act:id type="new">eb79670a4c9b0faab87485b7b2a4abe4</act:id>
+  <act:type>LIABILITY</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Altres préstecs</act:description>
+  <act:parent type="new">b5624a9d1a1b797b87b815774faccfe4</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Despeses</act:name>
+  <act:id type="new">565e52a122e8acc9a67a36e61357e2ae</act:id>
+  <act:type>EXPENSE</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Despeses</act:description>
+  <act:parent type="new">1972cce2e2364f95b2b0bc014502661d</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Interessos</act:name>
+  <act:id type="new">4a02c14e992ea79076837c164aa6fc8d</act:id>
+  <act:type>EXPENSE</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Interessos</act:description>
+  <act:parent type="new">565e52a122e8acc9a67a36e61357e2ae</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Altre interès</act:name>
+  <act:id type="new">f01de45e290ecc29b64d9cb8a733af68</act:id>
+  <act:type>EXPENSE</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Interès associat a un altre préstec</act:description>
+  <act:parent type="new">4a02c14e992ea79076837c164aa6fc8d</act:parent>
+</gnc:account>
+</gnc-account-example>
+
+<!-- Local variables: -->
+<!-- mode: xml        -->
+<!-- End:             -->
diff --git a/accounts/ca/acctchrt_renter.gnucash-xea b/accounts/ca/acctchrt_renter.gnucash-xea
new file mode 100644
index 0000000..d076ff4
--- /dev/null
+++ b/accounts/ca/acctchrt_renter.gnucash-xea
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="utf-8"?>
+<gnc-account-example>
+    <gnc-act:title>
+      Despeses d'inquilí
+    </gnc-act:title>
+    <gnc-act:short-description>
+      Despeses associades a llogar una casa
+    </gnc-act:short-description>
+    <gnc-act:long-description>
+    Voldreu escollir aquest joc de comptes si llogueu una casa o un apartament (lloguer, assegurança d'inquilí).
+  </gnc-act:long-description>
+<gnc:account version="2.0.0">
+  <act:name>Root Account</act:name>
+  <act:id type="new">1972cce2e2364f95b2b0bc014502661d</act:id>
+  <act:type>ROOT</act:type>
+  <act:commodity-scu>0</act:commodity-scu>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Despeses</act:name>
+  <act:id type="new">9a2b4520f113372f4e576f5b6dc129c6</act:id>
+  <act:type>EXPENSE</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Despeses</act:description>
+  <act:parent type="new">1972cce2e2364f95b2b0bc014502661d</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Assegurances</act:name>
+  <act:id type="new">b79b231807a98cd562c46cf0454e9f25</act:id>
+  <act:type>EXPENSE</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Assegurances</act:description>
+  <act:parent type="new">9a2b4520f113372f4e576f5b6dc129c6</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Assegurança de l'inquilí</act:name>
+  <act:id type="new">a4c93c964b8322d534e35b7054cbda4d</act:id>
+  <act:type>EXPENSE</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Assegurança de l'inquilí</act:description>
+  <act:parent type="new">b79b231807a98cd562c46cf0454e9f25</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Lloguer</act:name>
+  <act:id type="new">c1638a9a48d4d0e1b17d99219a18f34b</act:id>
+  <act:type>EXPENSE</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Lloguer</act:description>
+  <act:parent type="new">9a2b4520f113372f4e576f5b6dc129c6</act:parent>
+</gnc:account>
+</gnc-account-example>
+
+<!-- Local variables: -->
+<!-- mode: xml        -->
+<!-- End:             -->
diff --git a/accounts/ca/acctchrt_retiremt.gnucash-xea b/accounts/ca/acctchrt_retiremt.gnucash-xea
new file mode 100644
index 0000000..9e26790
--- /dev/null
+++ b/accounts/ca/acctchrt_retiremt.gnucash-xea
@@ -0,0 +1,105 @@
+<?xml version="1.0" encoding="utf-8"?>
+<gnc-account-example>
+    <gnc-act:title>
+      Comptes de jubilació
+    </gnc-act:title>
+    <gnc-act:short-description>
+      Compte de jubilació amb subcomptes d'inversions relacionades
+    </gnc-act:short-description>
+    <gnc-act:long-description>
+    Voldreu escollir aquest joc de comptes si teniu comptes de jubilació (d'accions, bons, fons d'inversió, fons d'índex).
+  </gnc-act:long-description>
+<gnc:account version="2.0.0">
+  <act:name>Root Account</act:name>
+  <act:id type="new">1972cce2e2364f95b2b0bc014502661d</act:id>
+  <act:type>ROOT</act:type>
+  <act:commodity-scu>0</act:commodity-scu>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Actiu</act:name>
+  <act:id type="new">e67ef2c52a4eaf3b9d37d317848a5812</act:id>
+  <act:type>ASSET</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Actiu</act:description>
+  <act:parent type="new">1972cce2e2364f95b2b0bc014502661d</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Inversions</act:name>
+  <act:id type="new">64cf99f6bafe0a539a5941ea713bdfcd</act:id>
+  <act:type>ASSET</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Inversions</act:description>
+  <act:parent type="new">e67ef2c52a4eaf3b9d37d317848a5812</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Jubilació</act:name>
+  <act:id type="new">4173f3047238f4b5595b11d6161b2f48</act:id>
+  <act:type>BANK</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Jubilació</act:description>
+  <act:slots>
+    <slot>
+      <slot:key>notes</slot:key>
+      <slot:value type="string">IRA, 401(k), o altres fons de jubilació</slot:value>
+    </slot>
+  </act:slots>
+  <act:parent type="new">64cf99f6bafe0a539a5941ea713bdfcd</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Bons</act:name>
+  <act:id type="new">9053199c1da747555d12272f48c719fd</act:id>
+  <act:type>STOCK</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Bons</act:description>
+  <act:parent type="new">4173f3047238f4b5595b11d6161b2f48</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Accions</act:name>
+  <act:id type="new">9bf53e9580991e323b297999fddff988</act:id>
+  <act:type>STOCK</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Accions</act:description>
+  <act:parent type="new">4173f3047238f4b5595b11d6161b2f48</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Fons d'índex</act:name>
+  <act:id type="new">2326b032fe4e8f434159310fccf17091</act:id>
+  <act:type>MUTUAL</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Fons d'índex</act:description>
+  <act:parent type="new">4173f3047238f4b5595b11d6161b2f48</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Fons d'inversió</act:name>
+  <act:id type="new">a62d804729117e74a6c880cecb818b56</act:id>
+  <act:type>MUTUAL</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Fons d'inversió</act:description>
+  <act:parent type="new">4173f3047238f4b5595b11d6161b2f48</act:parent>
+</gnc:account>
+</gnc-account-example>
+
+<!-- Local variables: -->
+<!-- mode: xml        -->
+<!-- End:             -->
diff --git a/accounts/ca/acctchrt_spouseinc.gnucash-xea b/accounts/ca/acctchrt_spouseinc.gnucash-xea
new file mode 100644
index 0000000..a02afd7
--- /dev/null
+++ b/accounts/ca/acctchrt_spouseinc.gnucash-xea
@@ -0,0 +1,121 @@
+<?xml version="1.0" encoding="utf-8"?>
+<gnc-account-example>
+    <gnc-act:title>
+      Ingressos de cònjuge
+    </gnc-act:title>
+    <gnc-act:short-description>
+     Comptes per controlar els ingressos del cònjuge de manera separada
+    </gnc-act:short-description>
+    <gnc-act:long-description>
+    Voldreu seleccionar aquest joc de comptes si el vostre cònjuge treballa (sou (cònjuge), impostos (cònjuge)).
+  </gnc-act:long-description>
+<gnc:account version="2.0.0">
+  <act:name>Root Account</act:name>
+  <act:id type="new">1972cce2e2364f95b2b0bc014502661d</act:id>
+  <act:type>ROOT</act:type>
+  <act:commodity-scu>0</act:commodity-scu>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Ingressos</act:name>
+  <act:id type="new">b4fadf6188d7f1ae7e7aa4fa27f5cc95</act:id>
+  <act:type>INCOME</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Ingressos</act:description>
+  <act:parent type="new">1972cce2e2364f95b2b0bc014502661d</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Sou (Cònjuge)</act:name>
+  <act:id type="new">7c4495ff132d100b0aa339ce683200dd</act:id>
+  <act:type>INCOME</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Sou (Cònjuge)</act:description>
+  <act:parent type="new">b4fadf6188d7f1ae7e7aa4fa27f5cc95</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Despeses</act:name>
+  <act:id type="new">1884bbd7394883ebafec8b9e2eb091a4</act:id>
+  <act:type>EXPENSE</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Despeses</act:description>
+  <act:parent type="new">1972cce2e2364f95b2b0bc014502661d</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Impostos (Cònjuge)</act:name>
+  <act:id type="new">3cd0ca7d6b0e5f44e4cde2851c3ff387</act:id>
+  <act:type>EXPENSE</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Impostos (Cònjuge)</act:description>
+  <act:parent type="new">1884bbd7394883ebafec8b9e2eb091a4</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>IRPF</act:name>
+  <act:id type="new">78df9cf06ee197272a695a4c3044f749</act:id>
+  <act:type>EXPENSE</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>IRPF</act:description>
+  <act:parent type="new">3cd0ca7d6b0e5f44e4cde2851c3ff387</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Retencions</act:name>
+  <act:id type="new">eba0c095658c7c3a4f4294db9c7392f3</act:id>
+  <act:type>EXPENSE</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Retencions</act:description>
+  <act:parent type="new">3cd0ca7d6b0e5f44e4cde2851c3ff387</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Altres impostos</act:name>
+  <act:id type="new">dea0cf67026749c9a5aa97be4e5cd052</act:id>
+  <act:type>EXPENSE</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Altres impostos</act:description>
+  <act:parent type="new">3cd0ca7d6b0e5f44e4cde2851c3ff387</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Seguretat Social</act:name>
+  <act:id type="new">9bd3abb2ed8c4c0d00f8e8ec36d2744d</act:id>
+  <act:type>EXPENSE</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Seguretat Social</act:description>
+  <act:parent type="new">3cd0ca7d6b0e5f44e4cde2851c3ff387</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Municipals</act:name>
+  <act:id type="new">aa14dbcd622024495a8a972b0f37d13a</act:id>
+  <act:type>EXPENSE</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Municipals</act:description>
+  <act:parent type="new">3cd0ca7d6b0e5f44e4cde2851c3ff387</act:parent>
+</gnc:account>
+</gnc-account-example>
+
+<!-- Local variables: -->
+<!-- mode: xml        -->
+<!-- End:             -->
diff --git a/accounts/ca/acctchrt_spouseretire.gnucash-xea b/accounts/ca/acctchrt_spouseretire.gnucash-xea
new file mode 100644
index 0000000..b5f1393
--- /dev/null
+++ b/accounts/ca/acctchrt_spouseretire.gnucash-xea
@@ -0,0 +1,105 @@
+<?xml version="1.0" encoding="utf-8"?>
+<gnc-account-example>
+    <gnc-act:title>
+      Comptes de jubilació de cònjuge
+    </gnc-act:title>
+    <gnc-act:short-description>
+     Compte de jubilació amb comptes d'inversió associats per a cònjuge
+    </gnc-act:short-description>
+    <gnc-act:long-description>
+    Voldreu seleccionar aquest joc de comptes si teniu inversions a nom del vostre cònjuge (accions, bons, fons d'inversió, fons d'índex, interessos, dividents).
+  </gnc-act:long-description>
+<gnc:account version="2.0.0">
+  <act:name>Root Account</act:name>
+  <act:id type="new">1972cce2e2364f95b2b0bc014502661d</act:id>
+  <act:type>ROOT</act:type>
+  <act:commodity-scu>0</act:commodity-scu>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Actiu</act:name>
+  <act:id type="new">96d9b17add59eb4c7edec7ed241af755</act:id>
+  <act:type>ASSET</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Actiu</act:description>
+  <act:parent type="new">1972cce2e2364f95b2b0bc014502661d</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Inversions</act:name>
+  <act:id type="new">f46c9f777b1730c6b5f4a1faf9e31708</act:id>
+  <act:type>ASSET</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Inversions</act:description>
+  <act:parent type="new">96d9b17add59eb4c7edec7ed241af755</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Jubilació de cònjuge</act:name>
+  <act:id type="new">4426b41837adc284f96b291c31022844</act:id>
+  <act:type>BANK</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Jubilació de cònjuge</act:description>
+  <act:slots>
+    <slot>
+      <slot:key>notes</slot:key>
+      <slot:value type="string">IRA, 401(k), or other retirement</slot:value>
+    </slot>
+  </act:slots>
+  <act:parent type="new">f46c9f777b1730c6b5f4a1faf9e31708</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Bons</act:name>
+  <act:id type="new">c8e7c315502547e51bfdd5a70b5cdd2e</act:id>
+  <act:type>STOCK</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Bons</act:description>
+  <act:parent type="new">4426b41837adc284f96b291c31022844</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Accions</act:name>
+  <act:id type="new">b8838eb77b9603e035e1f7b440d468ae</act:id>
+  <act:type>STOCK</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Accions</act:description>
+  <act:parent type="new">4426b41837adc284f96b291c31022844</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Fons d'índex</act:name>
+  <act:id type="new">0ec1a5b402ceea10d95445a2b31c41a1</act:id>
+  <act:type>MUTUAL</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Fons d'índex</act:description>
+  <act:parent type="new">4426b41837adc284f96b291c31022844</act:parent>
+</gnc:account>
+<gnc:account version="2.0.0">
+  <act:name>Fons d'inversió</act:name>
+  <act:id type="new">d9ed01f9b8f9845bc3f68f3e0afb021f</act:id>
+  <act:type>MUTUAL</act:type>
+  <act:commodity>
+    <cmdty:space>ISO4217</cmdty:space>
+    <cmdty:id>EUR</cmdty:id>
+  </act:commodity>
+  <act:description>Fons d'inversió</act:description>
+  <act:parent type="new">4426b41837adc284f96b291c31022844</act:parent>
+</gnc:account>
+</gnc-account-example>
+
+<!-- Local variables: -->
+<!-- mode: xml        -->
+<!-- End:             -->

commit 1a84b4a000cc242b463bcf32000d87492a2ed32b
Author: Geert Janssens <geert at kobaltwit.be>
Date:   Wed Sep 20 19:59:17 2017 +0200

    Properly ignore internal report options that are not on invisible option pages when opening the report options dialog

diff --git a/src/gnome-utils/dialog-options.c b/src/gnome-utils/dialog-options.c
index 60a8903..26362e4 100644
--- a/src/gnome-utils/dialog-options.c
+++ b/src/gnome-utils/dialog-options.c
@@ -1010,6 +1010,11 @@ gnc_option_set_ui_widget(GNCOption *option,
         LEAVE("bad type");
         return;
     }
+    else if (g_strcmp0 (type, "internal") == 0)
+    {
+        LEAVE("internal type");
+        return;
+    }
 
     raw_name = gnc_option_name(option);
     if (raw_name && *raw_name)

commit 350dd690fd97ae302a1878b035f8206bfa386c7d
Author: John Ralls <jralls at ceridwen.us>
Date:   Wed Sep 6 11:43:43 2017 -0700

    Install the current, 2015, and 2016 ChangeLogs.

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 94f74c1..2bee494 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -504,6 +504,8 @@ SET(gnucash_DOCS
     ChangeLog.2012
     ChangeLog.2013
     ChangeLog.2014
+    ChangeLog.2015
+    ChangeLog.2016
     DOCUMENTERS
     HACKING
     LICENSE
@@ -652,8 +654,10 @@ IF (BUILDING_FROM_VCS)
     COMMAND ${GIT_EXECUTABLE} log --format=\"%ad %aN %n%n%x09* %s%d%n\" --date=short --since=2016-01-01 > ${CMAKE_BINARY_DIR}/ChangeLog
     WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
   )
+  INSTALL(FILES ${CMAKE_BINARY_DIR}/ChangeLog DESTINATION share/doc/gnucash)
 ELSE()
   FILE(COPY ChangeLog DESTINATION ChangeLog)
+  INSTALL(FILES ChangeLog DESTINATION share/doc/gnucash)
 ENDIF()
 
 #Link LICENSE to COPYING so that people expecting to find it,



Summary of changes:
 configure.ac                                       |    1 +
 data/accounts/CMakeLists.txt                       |    4 +-
 data/accounts/Makefile.am                          |    1 +
 data/accounts/{cs => ca}/CMakeLists.txt            |    6 +-
 data/accounts/{sk => ca}/Makefile.am               |    3 +-
 .../{es_ES => ca}/acctchrt_brokerage.gnucash-xea   |   62 +-
 .../{es_ES => ca}/acctchrt_carloan.gnucash-xea     |   34 +-
 .../{es_MX => ca}/acctchrt_cdmoneymkt.gnucash-xea  |   42 +-
 .../{es_ES => ca}/acctchrt_childcare.gnucash-xea   |   17 +-
 .../{es_ES => ca}/acctchrt_common.gnucash-xea      |  252 ++-
 .../{es_ES => ca}/acctchrt_currency.gnucash-xea    |   26 +-
 .../{es_ES => ca}/acctchrt_eduloan.gnucash-xea     |   34 +-
 .../{es_MX => ca}/acctchrt_fixedassets.gnucash-xea |   25 +-
 .../{es_ES => ca}/acctchrt_homeloan.gnucash-xea    |   33 +-
 .../{es_ES => ca}/acctchrt_homeown.gnucash-xea     |   34 +-
 .../{es_MX => ca}/acctchrt_otherloan.gnucash-xea   |   34 +-
 .../{es_MX => ca}/acctchrt_renter.gnucash-xea      |   25 +-
 .../{es_MX => ca}/acctchrt_retiremt.gnucash-xea    |   40 +-
 .../{es_ES => ca}/acctchrt_spouseinc.gnucash-xea   |   41 +-
 .../acctchrt_spouseretire.gnucash-xea              |   38 +-
 gnucash/gnome-utils/dialog-options.c               |    5 +
 gnucash/report/standard-reports/CMakeLists.txt     |    1 +
 gnucash/report/standard-reports/Makefile.am        |    1 +
 .../standard-reports/income-gst-statement.scm      | 1804 ++++++++++++++++++++
 po/POTFILES.in                                     |    1 +
 25 files changed, 2178 insertions(+), 386 deletions(-)
 copy data/accounts/{cs => ca}/CMakeLists.txt (81%)
 copy data/accounts/{sk => ca}/Makefile.am (94%)
 copy data/accounts/{es_ES => ca}/acctchrt_brokerage.gnucash-xea (76%)
 copy data/accounts/{es_ES => ca}/acctchrt_carloan.gnucash-xea (73%)
 copy data/accounts/{es_MX => ca}/acctchrt_cdmoneymkt.gnucash-xea (73%)
 copy data/accounts/{es_ES => ca}/acctchrt_childcare.gnucash-xea (75%)
 copy data/accounts/{es_ES => ca}/acctchrt_common.gnucash-xea (79%)
 copy data/accounts/{es_ES => ca}/acctchrt_currency.gnucash-xea (71%)
 copy data/accounts/{es_ES => ca}/acctchrt_eduloan.gnucash-xea (73%)
 copy data/accounts/{es_MX => ca}/acctchrt_fixedassets.gnucash-xea (79%)
 copy data/accounts/{es_ES => ca}/acctchrt_homeloan.gnucash-xea (75%)
 copy data/accounts/{es_ES => ca}/acctchrt_homeown.gnucash-xea (73%)
 copy data/accounts/{es_MX => ca}/acctchrt_otherloan.gnucash-xea (74%)
 copy data/accounts/{es_MX => ca}/acctchrt_renter.gnucash-xea (75%)
 copy data/accounts/{es_MX => ca}/acctchrt_retiremt.gnucash-xea (74%)
 copy data/accounts/{es_ES => ca}/acctchrt_spouseinc.gnucash-xea (78%)
 copy data/accounts/{es_MX => ca}/acctchrt_spouseretire.gnucash-xea (75%)
 create mode 100644 gnucash/report/standard-reports/income-gst-statement.scm



More information about the gnucash-changes mailing list