gnucash master: Multiple changes pushed

John Ralls jralls at code.gnucash.org
Thu May 16 14:33:52 EDT 2019


Updated	 via  https://github.com/Gnucash/gnucash/commit/3ec00f52 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/539be984 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/aeb7e690 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/f779b817 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/0ecfc911 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/75a919b2 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/a63adac4 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/29f605bd (commit)
	 via  https://github.com/Gnucash/gnucash/commit/7cb4c1d7 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/fc567208 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/217418bb (commit)
	 via  https://github.com/Gnucash/gnucash/commit/f905467a (commit)
	 via  https://github.com/Gnucash/gnucash/commit/6b0f3ce6 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/e6c50357 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/8738644a (commit)
	 via  https://github.com/Gnucash/gnucash/commit/d4c524a9 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/7b1a262e (commit)
	 via  https://github.com/Gnucash/gnucash/commit/67830a0e (commit)
	 via  https://github.com/Gnucash/gnucash/commit/668b1f6b (commit)
	 via  https://github.com/Gnucash/gnucash/commit/c38c4557 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/a5609806 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/e76ebf4c (commit)
	 via  https://github.com/Gnucash/gnucash/commit/ea0982eb (commit)
	 via  https://github.com/Gnucash/gnucash/commit/35b3d6d1 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/d7b40c78 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/9504b706 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/1dc99f1f (commit)
	 via  https://github.com/Gnucash/gnucash/commit/29063fc9 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/bb49a177 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/bca3bd37 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/ac0eb001 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/b41cb2f5 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/e353804d (commit)
	 via  https://github.com/Gnucash/gnucash/commit/bfbf2c13 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/b05506ca (commit)
	 via  https://github.com/Gnucash/gnucash/commit/75632dae (commit)
	 via  https://github.com/Gnucash/gnucash/commit/2e105c94 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/aa5601b4 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/aab89065 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/94c5fe9f (commit)
	 via  https://github.com/Gnucash/gnucash/commit/e983d07c (commit)
	 via  https://github.com/Gnucash/gnucash/commit/101f8402 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/7345a4ad (commit)
	 via  https://github.com/Gnucash/gnucash/commit/1a40caee (commit)
	 via  https://github.com/Gnucash/gnucash/commit/3b73c49e (commit)
	 via  https://github.com/Gnucash/gnucash/commit/a26a7c59 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/58465432 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/d6248940 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/7b6b8600 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/48c3c8bc (commit)
	 via  https://github.com/Gnucash/gnucash/commit/810d283e (commit)
	 via  https://github.com/Gnucash/gnucash/commit/eec00c8a (commit)
	 via  https://github.com/Gnucash/gnucash/commit/f1fe106d (commit)
	 via  https://github.com/Gnucash/gnucash/commit/0cb60dd2 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/6e246ef8 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/6dd04cfa (commit)
	 via  https://github.com/Gnucash/gnucash/commit/1338162d (commit)
	 via  https://github.com/Gnucash/gnucash/commit/375013f9 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/e111c5bb (commit)
	 via  https://github.com/Gnucash/gnucash/commit/f2aacf94 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/fbcf4882 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/ce675eaa (commit)
	 via  https://github.com/Gnucash/gnucash/commit/b2dc906b (commit)
	 via  https://github.com/Gnucash/gnucash/commit/9ef2a2f3 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/91f3e9fe (commit)
	 via  https://github.com/Gnucash/gnucash/commit/76936bc6 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/8fb21116 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/24ac69d8 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/53e4e8a9 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/275463d3 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/8d71fcaf (commit)
	 via  https://github.com/Gnucash/gnucash/commit/38dfc6ec (commit)
	 via  https://github.com/Gnucash/gnucash/commit/c782e7a4 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/7c9f01ff (commit)
	 via  https://github.com/Gnucash/gnucash/commit/653d8cb5 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/ff3a3471 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/b87d693a (commit)
	 via  https://github.com/Gnucash/gnucash/commit/14b32559 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/29416292 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/c28196fb (commit)
	 via  https://github.com/Gnucash/gnucash/commit/126dc3a7 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/bfbb89f6 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/529a6cb0 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/d30cf25c (commit)
	 via  https://github.com/Gnucash/gnucash/commit/114efe59 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/1c1fa360 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/6b10c2f2 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/a7114971 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/e42c8113 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/3feb8646 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/6c7ccbd9 (commit)
	from  https://github.com/Gnucash/gnucash/commit/2c637a97 (commit)



commit 3ec00f527543ebd11a08c06b99a7131d5b5910de
Merge: 2c637a971 539be984e
Author: John Ralls <jralls at ceridwen.us>
Date:   Thu May 16 11:29:14 2019 -0700

    Merge branch 'maint'


commit 539be984e5c5d9f76be87bf0f95f9419fc9af91e
Author: Geert Janssens <geert at kobaltwit.be>
Date:   Thu May 16 19:01:19 2019 +0200

    Fix mnemonic behavior on business preferences page

diff --git a/gnucash/gtkbuilder/business-prefs.glade b/gnucash/gtkbuilder/business-prefs.glade
index de2e89473..1f5055918 100644
--- a/gnucash/gtkbuilder/business-prefs.glade
+++ b/gnucash/gtkbuilder/business-prefs.glade
@@ -296,7 +296,7 @@
           <object class="GtkLabel">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
-            <property name="label" translatable="yes">_Days in advance:</property>
+            <property name="label" translatable="yes">Days in ad_vance:</property>
             <property name="use_underline">True</property>
             <property name="mnemonic_widget">pref/dialogs.business.bill/days-in-advance</property>
           </object>
@@ -363,7 +363,7 @@
             <property name="can_focus">False</property>
             <property name="label" translatable="yes">_Days in advance:</property>
             <property name="use_underline">True</property>
-            <property name="mnemonic_widget">pref/dialogs.business.bill/days-in-advance</property>
+            <property name="mnemonic_widget">pref/dialogs.business.invoice/days-in-advance</property>
           </object>
           <packing>
             <property name="left_attach">1</property>

commit aeb7e690b537a4c6cb1cd469cb65f0d69f7814f8
Author: Frank H. Ellenberger <frank.h.ellenberger at gmail.com>
Date:   Thu May 16 17:37:28 2019 +0200

    Use standard buttons and add more mnenoics to Aqbanking dialogs
    
    Part of Bug 797232

diff --git a/gnucash/import-export/aqb/dialog-ab.glade b/gnucash/import-export/aqb/dialog-ab.glade
index bb2f0f861..274176362 100644
--- a/gnucash/import-export/aqb/dialog-ab.glade
+++ b/gnucash/import-export/aqb/dialog-ab.glade
@@ -26,13 +26,14 @@
             <property name="layout_style">end</property>
             <child>
               <object class="GtkButton" id="abort_button">
-                <property name="label">_Cancel</property>
+                <property name="label">gtk-cancel</property>
                 <property name="visible">True</property>
                 <property name="sensitive">False</property>
                 <property name="can_focus">True</property>
                 <property name="can_default">True</property>
                 <property name="receives_default">True</property>
                 <property name="use_underline">True</property>
+                <property name="use_stock">True</property>
                 <signal name="clicked" handler="ggg_abort_clicked_cb" swapped="no"/>
               </object>
               <packing>
@@ -43,12 +44,13 @@
             </child>
             <child>
               <object class="GtkButton" id="close_button">
-                <property name="label">C_lose</property>
+                <property name="label">gtk-close</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="can_default">True</property>
                 <property name="receives_default">True</property>
                 <property name="use_underline">True</property>
+                <property name="use_stock">True</property>
                 <signal name="clicked" handler="ggg_close_clicked_cb" swapped="no"/>
               </object>
               <packing>
@@ -205,8 +207,9 @@
                   <object class="GtkLabel" id="label8877444">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="label" translatable="yes"><b>Log Messages</b></property>
+                    <property name="label" translatable="yes"><b>_Log Messages</b></property>
                     <property name="use_markup">True</property>
+                    <property name="use_underline">True</property>
                     <property name="xalign">0</property>
                   </object>
                   <packing>
@@ -246,7 +249,7 @@
             </child>
             <child>
               <object class="GtkCheckButton" id="close_checkbutton">
-                <property name="label" translatable="yes">Close when finished</property>
+                <property name="label" translatable="yes">Close when _finished</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="receives_default">False</property>
@@ -297,12 +300,13 @@
             <property name="layout_style">end</property>
             <child>
               <object class="GtkButton" id="cancel_button1">
-                <property name="label">_Cancel</property>
+                <property name="label">gtk-cancel</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="can_default">True</property>
                 <property name="receives_default">True</property>
                 <property name="use_underline">True</property>
+                <property name="use_stock">True</property>
               </object>
               <packing>
                 <property name="expand">False</property>
@@ -312,12 +316,13 @@
             </child>
             <child>
               <object class="GtkButton" id="ok_button">
-                <property name="label">_OK</property>
+                <property name="label">gtk-ok</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="can_default">True</property>
                 <property name="receives_default">True</property>
                 <property name="use_underline">True</property>
+                <property name="use_stock">True</property>
               </object>
               <packing>
                 <property name="expand">False</property>
@@ -603,12 +608,13 @@
             <property name="layout_style">end</property>
             <child>
               <object class="GtkButton" id="cancelbutton2">
-                <property name="label">_Cancel</property>
+                <property name="label">gtk-cancel</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="can_default">True</property>
                 <property name="receives_default">True</property>
                 <property name="use_underline">True</property>
+                <property name="use_stock">True</property>
               </object>
               <packing>
                 <property name="expand">False</property>
@@ -618,12 +624,13 @@
             </child>
             <child>
               <object class="GtkButton" id="okbutton2">
-                <property name="label">_OK</property>
+                <property name="label">gtk-ok</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="can_default">True</property>
                 <property name="receives_default">True</property>
                 <property name="use_underline">True</property>
+                <property name="use_stock">True</property>
               </object>
               <packing>
                 <property name="expand">False</property>
@@ -670,7 +677,8 @@
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
                     <property name="halign">start</property>
-                    <property name="label" translatable="yes">Password:</property>
+                    <property name="label" translatable="yes">_Password:</property>
+                    <property name="use_underline">True</property>
                     <property name="xalign">0</property>
                   </object>
                   <packing>
@@ -683,7 +691,8 @@
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
                     <property name="halign">start</property>
-                    <property name="label" translatable="yes">Confirm Password:</property>
+                    <property name="label" translatable="yes">Con_firm Password:</property>
+                    <property name="use_underline">True</property>
                     <property name="xalign">0</property>
                   </object>
                   <packing>
@@ -721,13 +730,13 @@
                 </child>
                 <child>
                   <object class="GtkCheckButton" id="remember_pin">
-                    <property name="label" translatable="yes">Remember the _PIN in memory</property>
+                    <property name="label" translatable="yes">_Remember the PIN in memory</property>
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
                     <property name="receives_default">False</property>
                     <property name="has_tooltip">True</property>
                     <property name="tooltip_markup">If active, the PIN for HBCI/AqBanking actions will be remembered in memory during a session. Otherwise it will have to be entered again each time during a session when it is needed.</property>
-                    <property name="tooltip_text" translatable="yes">If active, the PIN for HBCI/AqBanking actions will be remembered in memory during a session. Otherwise it will have to be entered again each time during a session when it is needed.</property>
+                    <property name="tooltip_text" translatable="yes">If active, the PIN for FinTS/AqBanking actions will be remembered in memory during a session. Otherwise it will have to be entered again each time during a session when it is needed.</property>
                     <property name="halign">start</property>
                     <property name="use_underline">True</property>
                     <property name="draw_indicator">True</property>
@@ -779,12 +788,13 @@
             <property name="layout_style">end</property>
             <child>
               <object class="GtkButton" id="cancelbutton1">
-                <property name="label">_Cancel</property>
+                <property name="label">gtk-cancel</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="can_default">True</property>
                 <property name="receives_default">True</property>
                 <property name="use_underline">True</property>
+                <property name="use_stock">True</property>
               </object>
               <packing>
                 <property name="expand">False</property>
@@ -794,13 +804,14 @@
             </child>
             <child>
               <object class="GtkButton" id="okbutton1">
-                <property name="label">_OK</property>
+                <property name="label">gtk-ok</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="can_default">True</property>
                 <property name="has_default">True</property>
                 <property name="receives_default">True</property>
                 <property name="use_underline">True</property>
+                <property name="use_stock">True</property>
               </object>
               <packing>
                 <property name="expand">False</property>
@@ -827,7 +838,8 @@
               <object class="GtkLabel" id="label8877450">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
-                <property name="label" translatable="yes">Enter name for new template:</property>
+                <property name="label" translatable="yes"> _Name of the new template:</property>
+                <property name="use_underline">True</property>
               </object>
               <packing>
                 <property name="expand">False</property>
@@ -839,6 +851,7 @@
               <object class="GtkEntry" id="template_name">
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
+                <property name="tooltip_text" translatable="yes">Enter a unique name for the new template.</property>
                 <property name="max_length">250</property>
                 <property name="invisible_char">●</property>
                 <property name="activates_default">True</property>
@@ -900,12 +913,13 @@
             </child>
             <child>
               <object class="GtkButton" id="cancel_button">
-                <property name="label">_Cancel</property>
+                <property name="label">gtk-cancel</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="can_default">True</property>
                 <property name="receives_default">True</property>
                 <property name="use_underline">True</property>
+                <property name="use_stock">True</property>
               </object>
               <packing>
                 <property name="expand">False</property>
@@ -986,7 +1000,8 @@
                   <object class="GtkLabel" id="recp_account_heading">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="label" translatable="yes">Recipient Account Number</property>
+                    <property name="label" translatable="yes">Recipient Account _Number</property>
+                    <property name="use_underline">True</property>
                     <property name="xalign">0</property>
                   </object>
                   <packing>
@@ -1013,7 +1028,8 @@
                   <object class="GtkLabel" id="recp_bankcode_heading">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="label" translatable="yes">Recipient Bank Code</property>
+                    <property name="label" translatable="yes">Recipient _Bank Code</property>
+                    <property name="use_underline">True</property>
                     <property name="xalign">0</property>
                   </object>
                   <packing>
@@ -1041,7 +1057,8 @@
                   <object class="GtkLabel" id="recp_name_heading">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="label" translatable="yes">Recipient Name</property>
+                    <property name="label" translatable="yes">_Recipient Name</property>
+                    <property name="use_underline">True</property>
                     <property name="justify">center</property>
                     <property name="xalign">0</property>
                   </object>
@@ -1082,7 +1099,8 @@
                   <object class="GtkLabel" id="label8877434">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="label" translatable="yes">Amount</property>
+                    <property name="label" translatable="yes">_Amount</property>
+                    <property name="use_underline">True</property>
                     <property name="justify">center</property>
                     <property name="xalign">0</property>
                   </object>
@@ -1096,7 +1114,8 @@
                   <object class="GtkLabel" id="label8877433">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="label" translatable="yes">Payment Purpose (only for recipient)</property>
+                    <property name="label" translatable="yes">Payment _Purpose (only for recipient)</property>
+                    <property name="use_underline">True</property>
                     <property name="justify">center</property>
                     <property name="xalign">0</property>
                   </object>
@@ -1124,7 +1143,7 @@
                   <object class="GtkLabel" id="orig_name_heading">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="label" translatable="yes">Originator Name</property>
+                    <property name="label" translatable="yes">_Originator Name</property>
                     <property name="xalign">0</property>
                   </object>
                   <packing>
@@ -1486,7 +1505,8 @@
                   <object class="GtkLabel" id="label1">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="label" translatable="yes">Templates</property>
+                    <property name="label" translatable="yes">_Templates</property>
+                    <property name="use_underline">True</property>
                   </object>
                 </child>
               </object>

commit f779b81719d86ba6082389dff26e96d3a6e03437
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Thu May 16 18:25:58 2019 +0800

    [balsheet-pnl] unrealized-gain calculator bugfix
    
    The unrealized-gain calculator was flawed.
    
    The fixed function is copied from balance-sheet.scm and adapted to
    balsheet-pnl.scm vars.
    
    This fixed function matches unrealized-gains amounts from
    balance-sheet.scm

diff --git a/gnucash/report/standard-reports/balsheet-pnl.scm b/gnucash/report/standard-reports/balsheet-pnl.scm
index 08cb0d2a6..44795c88d 100644
--- a/gnucash/report/standard-reports/balsheet-pnl.scm
+++ b/gnucash/report/standard-reports/balsheet-pnl.scm
@@ -937,13 +937,16 @@ also show overall period profit & loss."))
                                     (else (list-ref report-dates col-idx))))
                             (asset-liability-balance
                              (list-ref asset-liability-balances col-idx))
-                            (latest (monetaries->exchanged
-                                     asset-liability-balance
-                                     common-currency price-source date))
-                            (avg-cost (monetaries->exchanged
-                                       asset-liability-balance
-                                       common-currency 'average-cost date)))
-                       (gnc:monetary+ latest (gnc:monetary-neg avg-cost))))))
+                            (asset-liability-basis
+                             (gnc:accounts-get-comm-total-assets
+                              (append asset-accounts liability-accounts)
+                              (lambda (acc)
+                                (gnc:account-get-comm-value-at-date acc date #f))))
+                            (unrealized (gnc:make-commodity-collector)))
+                       (unrealized 'merge asset-liability-basis #f)
+                       (unrealized 'minusmerge asset-liability-balance #f)
+                       (monetaries->exchanged
+                        unrealized common-currency price-source date)))))
              (retained-earnings-fn
               (lambda (col-idx)
                 (let* ((date (case price-source

commit 0ecfc911cae0d1987228c06d1bfaba23aca56e63
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Tue May 14 22:16:07 2019 +0800

    [balsheet-pnl] chart: set report-currency to most used currency
    
    This is a usability upgrade.
    
    This balsheet-pnl report does *not* enforce a report currency; it can
    print, process and multilevel-total monetary amounts in their original
    currency.
    
    But a linked chart needs one. By default it uses global
    report_currency which may not match the book's most used currencies.
    
    This commit will scan the accountlist, retrieve the most common
    currency used, and set it as the report-currency for the linked
    chart.
    
    The book-main-currency function *may* be upgraded to
    report-utilities.scm in the future.
    
    Case example:
    * set gnc_default_report_currency to USD
    * load book.gnucash with majority accounts in EUR, some in GBP
    * run balsheet-pnl.scm - shows EUR and GBP amounts and mixed totals.
    * click link to barchart - would not succeed because all amounts
      converted to USD0.00. this commit will ensure barchart's target
      currency is set to EUR thereby showing useful chart.

diff --git a/gnucash/report/standard-reports/balsheet-pnl.scm b/gnucash/report/standard-reports/balsheet-pnl.scm
index 8d493a3cf..08cb0d2a6 100644
--- a/gnucash/report/standard-reports/balsheet-pnl.scm
+++ b/gnucash/report/standard-reports/balsheet-pnl.scm
@@ -830,6 +830,21 @@ also show overall period profit & loss."))
                commodities)
               (gnc:make-html-table-cell/markup "number-cell" cell))))
 
+         ;; scan accounts' commodities, filter currencies only, create
+         ;; hash-map counter, convert to alist, sort descending tally,
+         ;; return first pair's car. result=most used currency. the
+         ;; (cons default-currency 0) avoids crash in an empty-book by
+         ;; ensuring there is at least 1 currency.
+         (book-main-currency
+          (let ((h (make-hash-table)))
+            (for-each
+             (lambda (curr)
+               (hash-set! h curr (1+ (hash-ref h curr 0))))
+             (filter gnc-commodity-is-currency (map xaccAccountGetCommodity accounts)))
+            (caar (sort! (cons (cons (gnc-default-report-currency) 0)
+                               (hash-map->list cons h))
+                         (lambda (a b) (> (cdr a) (cdr b)))))))
+
          ;; decompose the account list
          (show-foreign? (get-option pagename-commodities optname-show-foreign))
          (show-rates? (get-option pagename-commodities optname-show-rates))
@@ -953,8 +968,7 @@ also show overall period profit & loss."))
                           (list (list "General" "Start Date" (cons 'absolute startdate))
                                 (list "General" "End Date" (cons 'absolute enddate))
                                 (list "General" "Report's currency"
-                                      (or common-currency
-                                          (gnc-default-report-currency)))
+                                      (or common-currency book-main-currency))
                                 (list "General" "Step Size" incr)
                                 (list "General" "Price Source"
                                       (or price-source 'pricedb-nearest))
@@ -1120,8 +1134,7 @@ also show overall period profit & loss."))
                                 (list "General" "End Date"
                                       (cons 'absolute enddate))
                                 (list "General" "Report's currency"
-                                      (or common-currency
-                                          (gnc-default-report-currency)))
+                                      (or common-currency book-main-currency))
                                 (list "General" "Step Size" (or incr 'MonthDelta))
                                 (list "General" "Price Source"
                                       (or price-source 'pricedb-nearest))

commit 75a919b283a7621192030528061839b017c0e19b
Author: Mike Evans <mikee at saxicola.co.uk>
Date:   Wed May 15 07:08:54 2019 +0100

    Bug 751290 - Rethinking the invoice ledger view
    
    Fix indent and add a note for translators.

diff --git a/gnucash/gnome/dialog-invoice.c b/gnucash/gnome/dialog-invoice.c
index 3194f00ca..d1ae2447b 100644
--- a/gnucash/gnome/dialog-invoice.c
+++ b/gnucash/gnome/dialog-invoice.c
@@ -1936,8 +1936,9 @@ gnc_invoice_update_window (InvoiceWindow *iw, GtkWidget *widget)
         gtk_widget_set_sensitive (iw->notes_text, TRUE);
     }
 
+    /* Translators: This is a label to show whether the invoice is paid or not. */
     if(gncInvoiceIsPaid (invoice))
-            gtk_label_set_text(GTK_LABEL(iw->paid_label),  _("PAID"));
+        gtk_label_set_text(GTK_LABEL(iw->paid_label),  _("PAID"));
     else
         gtk_label_set_text(GTK_LABEL(iw->paid_label),  _("UNPAID"));
     

commit a63adac4c571dfea509d71a2a9ea318d58e3e6a3
Author: Frank H. Ellenberger <frank.h.ellenberger at gmail.com>
Date:   Wed May 15 00:13:20 2019 +0200

    Rise minimum required CMake version for Linux to 3.2
    
    This will allow us to use modules like FindIntl.
    https://lists.gnucash.org/logs/2019/05/14.html#T17:32:19

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 49ecded73..61cb22010 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -3,7 +3,7 @@
 if (WIN32 OR APPLE)
   cmake_minimum_required (VERSION 3.3.2)
 else()
-  cmake_minimum_required (VERSION 3.0)
+  cmake_minimum_required (VERSION 3.2)
 endif()
 
 project (gnucash)

commit 29f605bd1b72336616f03d3b4c76ebc20b9243c8
Author: Frank H. Ellenberger <frank.h.ellenberger at gmail.com>
Date:   Tue May 14 22:57:24 2019 +0200

    Move I18N modules in one section of CMakelists.txt

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0c292d95a..49ecded73 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -238,23 +238,21 @@ if (MSVC)
   add_definitions ( -DNOMINMAX )
 endif (MSVC)
 
-find_path (LIBINTL_INCLUDE_PATH NAMES libintl.h
-		  PATHS /usr/include /opt/gnome/include)
-find_library (LIBINTL_LIBRARY NAMES intl)
-
 find_path (LTDL_INCLUDE_PATH NAMES ltdl.h PATHS /usr/include)
-
 if(NOT LTDL_INCLUDE_PATH-NOTFOUND)
   set(HAVE_LTDL_H 1)
 endif()
 
-
-
 find_program(GLIB_COMPILE_SCHEMAS glib-compile-schemas HINTS ${CMAKE_PREFIX_PATH}/gnome/bin)
 if (NOT GLIB_COMPILE_SCHEMAS)
   message(SEND_ERROR "Can't find glib-compile-schemas program. Please set GLIB_COMPILE_SCHEMAS.")
 endif(NOT GLIB_COMPILE_SCHEMAS)
 
+find_path (REGEX_INCLUDE_PATH NAMES regex.h
+		  PATHS /usr/include /opt/gnome/include)
+find_library (REGEX_LIBRARY NAMES regex)
+
+# I18N
 if (ALLOW_OLD_GETTEXT)
     find_package (Gettext REQUIRED)
 else (ALLOW_OLD_GETTEXT)
@@ -273,9 +271,11 @@ if (${GETTEXT_VERSION_STRING} VERSION_LESS 0.19.6)
     message (WARNING "Got gettext version ${GETTEXT_VERSION_STRING}, however you need at least gettext version 0.19.6 in order to handle translation of the gnucash.appdata file. The build will be configured with an untranslated gnucash.appdata file.")
 endif ()
 
-find_path (REGEX_INCLUDE_PATH NAMES regex.h
+find_path (LIBINTL_INCLUDE_PATH NAMES libintl.h
 		  PATHS /usr/include /opt/gnome/include)
-find_library (REGEX_LIBRARY NAMES regex)
+find_library (LIBINTL_LIBRARY NAMES intl)
+
+# HELP
 if (WIN32)
   message(STATUS "Looking for htmlhelp.h and htmlhelp.a")
   find_path (HTMLHELP_INCLUDE_PATH NAMES htmlhelp.h)

commit 7cb4c1d7b1d8b6021e5037ff2c591c1a9ccc4c72
Author: Frank H. Ellenberger <frank.h.ellenberger at gmail.com>
Date:   Tue May 14 22:37:05 2019 +0200

    Cleanup of no longer used Gettext flags
    
    We don't need HAVE_GETTEXT conditional code

diff --git a/CMakeLists.txt b/CMakeLists.txt
index dd2ef68fb..0c292d95a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -697,9 +697,6 @@ endif(UNIX OR MINGW)
 endif(ENABLE_BINRELOC)
 
 if (UNIX OR MINGW)
-set (HAVE_BIND_TEXTDOMAIN_CODESET 1)
-set (HAVE_DCGETTEXT 1)
-set (HAVE_GETTEXT 1)
 set (HAVE_GETTIMEOFDAY 1)
 set (HAVE_GUILE 1)
 set (HAVE_LIBM 1)
diff --git a/common/config.h.cmake.in b/common/config.h.cmake.in
index 654737ea8..7a2ca2f51 100644
--- a/common/config.h.cmake.in
+++ b/common/config.h.cmake.in
@@ -78,9 +78,6 @@
 /* Don't use deprecated glib functions */
 #cmakedefine G_DISABLE_DEPRECATED 1
 
-/* Define to 1 if you have the `bind_textdomain_codeset' function. */
-#cmakedefine HAVE_BIND_TEXTDOMAIN_CODESET 1
-
 /* define if the Boost library is available */
 #cmakedefine HAVE_BOOST
 
@@ -93,9 +90,6 @@
 /* Define to 1 if you have the <dbi/dbi.h> header file. */
 #cmakedefine HAVE_DBI_DBI_H 1
 
-/* Define to 1 if you have the `dcgettext' function. */
-#cmakedefine HAVE_DCGETTEXT 1
-
 /* Define to 1 if you have the <dirent.h> header file. */
 #cmakedefine HAVE_DIRENT_H 1
 
@@ -120,9 +114,6 @@
 /* Define to 1 if you have the `getppid' function. */
 #cmakedefine HAVE_GETPPID 1
 
-/* Define if the GNU gettext() function is already present or preinstalled. */
-#cmakedefine HAVE_GETTEXT 1
-
 /* Define to 1 if you have the `gettimeofday' function. */
 #cmakedefine HAVE_GETTIMEOFDAY 1
 
diff --git a/gnucash/gnucash-bin.c b/gnucash/gnucash-bin.c
index c6bc3bd53..7d8902767 100644
--- a/gnucash/gnucash-bin.c
+++ b/gnucash/gnucash-bin.c
@@ -69,10 +69,8 @@ static QofLogModule log_module = GNC_MOD_GUI;
  */
 #define __MSWIN_CONSOLE__ 0
 
-#ifdef HAVE_GETTEXT
-#  include <libintl.h>
-#  include <locale.h>
-#endif
+#include <libintl.h>
+#include <locale.h>
 
 #ifdef MAC_INTEGRATION
 #  include <Foundation/Foundation.h>
@@ -848,6 +846,7 @@ redirect_stdout (void)
 int
 main(int argc, char ** argv)
 {
+    gchar *localedir = gnc_path_get_localedir();
 #if !defined(G_THREADS_ENABLED) || defined(G_THREADS_IMPL_NONE)
 #    error "No GLib thread implementation available!"
 #endif
@@ -883,17 +882,12 @@ main(int argc, char ** argv)
         g_setenv ("LC_ALL", "C", TRUE);
         setlocale (LC_ALL, "C");
       }
-#ifdef HAVE_GETTEXT
-    {
-        gchar *localedir = gnc_path_get_localedir();
-        bindtextdomain(GETTEXT_PACKAGE, localedir);
-	bindtextdomain("iso_4217", localedir); // For win32 to find currency name translations
-	bind_textdomain_codeset("iso_4217", "UTF-8");
-	textdomain(GETTEXT_PACKAGE);
-        bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
-        g_free(localedir);
-    }
-#endif
+    bindtextdomain(GETTEXT_PACKAGE, localedir);
+    bindtextdomain("iso_4217", localedir); // For win32 to find currency name translations
+    bind_textdomain_codeset("iso_4217", "UTF-8");
+    textdomain(GETTEXT_PACKAGE);
+    bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
+    g_free(localedir);
 
     gnc_parse_command_line(&argc, &argv);
     gnc_print_unstable_message();

commit fc567208f3400f26263582a4c10926e12fe108eb
Author: John Ralls <jralls at ceridwen.us>
Date:   Tue May 14 13:34:07 2019 -0700

    Bug 797233 - Balance Sheet, Chart of Accounts, and other reports...
    
    crash when involving foreign currency stocks.
    
    Scheme's inexact->exact function just converts the floating-point
    representation of a number into an exact rational (documented in the
    API Reference, Simple Generic Data Types, Numerical data types, Exact
    and Inexact Numbers), which isn't what we want.
    
    We want the number converted to exact directly from the string and to do
    that we have gnc-fq-helper preface it with #e.

diff --git a/libgnucash/quotes/gnc-fq-helper.in b/libgnucash/quotes/gnc-fq-helper.in
index 1e781913e..95e7210c5 100755
--- a/libgnucash/quotes/gnc-fq-helper.in
+++ b/libgnucash/quotes/gnc-fq-helper.in
@@ -186,7 +186,7 @@ sub schemify_num {
   if(!$numstr) { return "failed-conversion"; }
 
   if($numstr =~ /^\s*(\d+(\.\d+)?([eE][+-]?\d+)?)$/o) {
-    return $1;
+    return "#e" . $1;
   } else {
     return "failed-conversion";
   }
diff --git a/libgnucash/scm/price-quotes.scm b/libgnucash/scm/price-quotes.scm
index 812fcbb07..c12fa35e0 100644
--- a/libgnucash/scm/price-quotes.scm
+++ b/libgnucash/scm/price-quotes.scm
@@ -404,13 +404,7 @@
               (else #f)))
 
       (if price
-          ;; The second argument to inexact->exact is chosen to give reasonable values
-          ;; for prices between .12345e-9 and 12345678.87654
-          
-          ;; inexact->exact is probably not necessary but it can't hurt and is cheap.
-          (set! price
-                (gnc-scm-to-numeric 
-                  (rationalize (inexact->exact price) 1/1000000000000000))))
+          (set! price (gnc-scm-to-numeric price)))
       (if gnc-time
           (set! gnc-time (timestr->time64 gnc-time time-zone))
           (set! gnc-time (gnc:get-today)))

commit 217418bb8c30cea5921d4f2517460b7bafb6609a
Merge: 6b0f3ce64 f905467a4
Author: John Ralls <jralls at ceridwen.us>
Date:   Tue May 14 10:09:16 2019 -0700

    Merge Adrián Panella's  'numeric' into maint.


commit f905467a443f44897c60614e9f9149336f7eae3c
Author: Adrian Panella <ianchi74 at outlook.com>
Date:   Mon May 13 23:05:11 2019 -0500

    [numeric] Fix constructor from strings in range (0 ,1)
    
    Fix error that caused strings in the form 0.nnn to be
    converted to negative numerics.

diff --git a/libgnucash/engine/gnc-numeric.cpp b/libgnucash/engine/gnc-numeric.cpp
index a2e6c2a49..a2cbf6d1c 100644
--- a/libgnucash/engine/gnc-numeric.cpp
+++ b/libgnucash/engine/gnc-numeric.cpp
@@ -178,7 +178,7 @@ GncNumeric::GncNumeric(const std::string& str, bool autoround)
         GncInt128 high(stoll(m[1].str()));
         GncInt128 low(stoll(m[2].str()));
         int64_t d = powten(m[2].str().length());
-        GncInt128 n = high * d + (high > 0 ? low : -low);
+        GncInt128 n = high * d + (high >= 0 ? low : -low);
         if (!autoround && n.isBig())
         {
             std::ostringstream errmsg;

commit 6b0f3ce641e1a5125e761f8abbe076abd5dedca0
Author: Frank H. Ellenberger <frank.h.ellenberger at gmail.com>
Date:   Tue May 14 04:21:55 2019 +0200

    Unify optionally required Python version - PR #481 supplement

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 23eb5e9ed..dd2ef68fb 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -474,8 +474,8 @@ if (WITH_PYTHON)
     message(SEND_ERROR "Python support enabled, but Python interpreter not found.")
   endif()
 
-  if (PYTHON_VERSION_STRING VERSION_LESS "2.4.0")
-    message(SEND_ERROR "Found python version ${PYTHON_VERSION_STRING}, but it's too old. Need python >= 2.4.0")
+  if (PYTHON_VERSION_STRING VERSION_LESS "3.2.0")
+    message(SEND_ERROR "Found python version ${PYTHON_VERSION_STRING}, but it's too old. Need python >= 3.2.0")
   endif()
 
   find_package(PythonLibs 3)
diff --git a/README.dependencies b/README.dependencies
index db0ea9ec2..42b28344c 100644
--- a/README.dependencies
+++ b/README.dependencies
@@ -94,7 +94,7 @@ Libraries/Deps
 
   libofx		0.9.0			 OFX/QFX import
 
-  python		3.4.0			 python bindings; headers
+  python		3.2.0			 python bindings; headers
 						 required, not just binaries.
 
   makeinfo                                       Not really needed, it

commit e6c50357bbff398cdba76213d7d1620ca8f6bd34
Author: John Ralls <jralls at ceridwen.us>
Date:   Mon May 13 15:19:19 2019 -0700

    Fix test error string to match actual error.

diff --git a/libgnucash/engine/test/utest-gnc-pricedb.c b/libgnucash/engine/test/utest-gnc-pricedb.c
index 670bf6f5e..5d1aec75f 100644
--- a/libgnucash/engine/test/utest-gnc-pricedb.c
+++ b/libgnucash/engine/test/utest-gnc-pricedb.c
@@ -1071,7 +1071,7 @@ gnc_pricedb_lookup_day_t64(GNCPriceDB *db,// C: 4 in 2 SCM: 2 in 1 Local: 1:0:0
 static void
 test_gnc_pricedb_lookup_day_t64 (PriceDBFixture *fixture, gconstpointer pData)
 {
-    gchar *msg1 = "[gnc_dmy2timespec_internal()] Date computation error from Y-M-D 12-11-18: Year is out of valid range: 1400..10000";
+    gchar *msg1 = "[gnc_dmy2time64_internal()] Date computation error from Y-M-D 12-11-18: Year is out of valid range: 1400..9999";
     gint loglevel = G_LOG_LEVEL_WARNING | G_LOG_FLAG_FATAL;
     gchar *logdomain = "qof.engine";
     TestErrorStruct check = {loglevel, logdomain, msg1, 0};

commit 8738644af0dc70914c2f128ee985246a7e068f8d
Merge: d4c524a9e aab89065d
Author: John Ralls <jralls at ceridwen.us>
Date:   Mon May 13 15:13:52 2019 -0700

    Merge David Palma's fix-division into maint.


commit d4c524a9ef6d369e2ce3d41e480f89871d89fac3
Author: Geert Janssens <geert at kobaltwit.be>
Date:   Mon May 13 19:42:36 2019 +0200

    Fix test dependency issue

diff --git a/libgnucash/scm/test/CMakeLists.txt b/libgnucash/scm/test/CMakeLists.txt
index eb5858239..677d6124a 100644
--- a/libgnucash/scm/test/CMakeLists.txt
+++ b/libgnucash/scm/test/CMakeLists.txt
@@ -6,6 +6,7 @@ set(GUILE_DEPENDS
   scm-gnc-module
   scm-app-utils
   scm-scm scm-engine
+  scm-srfi64-extras
   )
 
 if (HAVE_SRFI64)

commit 7b1a262eea619dfea7126c3ef5dbd3e252a65f1a
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Fri May 10 23:50:14 2019 +0800

    [balsheet-pnl] refinements to barchart
    
    * barchart should inherit the period selected. this requires
      redefining the periodlist - we need the exact symbol to set the
      barchart's period option.
    
    * balsheet: disable barchart if period is disabled - it makes no sense
      to create link to networth barchart for single-date balsheet
    
    * reorder some options for better usability
    
    * note this may affect saved-reports / saved-tabs but only those
      running bleeding edge maint. I do not intend to make any further
      options changes on this report.

diff --git a/gnucash/report/standard-reports/balsheet-pnl.scm b/gnucash/report/standard-reports/balsheet-pnl.scm
index 1c37c0e6e..8d493a3cf 100644
--- a/gnucash/report/standard-reports/balsheet-pnl.scm
+++ b/gnucash/report/standard-reports/balsheet-pnl.scm
@@ -129,37 +129,30 @@ also show overall period profit & loss."))
 (define periodlist
   (list
    (list #f
-         (cons 'delta #f)
          (cons 'text (_ "Disabled"))
          (cons 'tip (_ "Disabled")))
 
-   (list 'year
-         (cons 'delta YearDelta)
+   (list 'YearDelta
          (cons 'text (_ "Year"))
          (cons 'tip (_ "One year.")))
 
-   (list 'halfyear
-         (cons 'delta HalfYearDelta)
+   (list 'HalfYearDelta
          (cons 'text (_ "Half Year"))
          (cons 'tip (_ "Half Year.")))
 
-   (list 'quarter
-         (cons 'delta QuarterDelta)
+   (list 'QuarterDelta
          (cons 'text (_ "Quarter"))
          (cons 'tip (_ "One Quarter.")))
 
-   (list 'month
-         (cons 'delta MonthDelta)
+   (list 'MonthDelta
          (cons 'text (_ "Month"))
          (cons 'tip (_ "One Month.")))
 
-   (list 'twoweek
-         (cons 'delta TwoWeekDelta)
+   (list 'TwoWeekDelta
          (cons 'text (_ "2Week"))
          (cons 'tip (_ "Two Weeks.")))
 
-   (list 'week
-         (cons 'delta WeekDelta)
+   (list 'WeekDelta
          (cons 'text (_ "Week"))
          (cons 'tip (_ "One Week.")))))
 
@@ -203,13 +196,17 @@ also show overall period profit & loss."))
          options
          gnc:pagename-general optname-dual-columns
          (not x))
-        (gnc-option-db-set-option-selectable-by-name
-         options
-         gnc:pagename-general
-         (case report-type
-           ((balsheet) optname-startdate)
-           ((pnl) optname-include-overall-period))
-         x))))
+        (case report-type
+          ((balsheet)
+           (gnc-option-db-set-option-selectable-by-name
+            options gnc:pagename-general optname-include-chart x)
+
+           (gnc-option-db-set-option-selectable-by-name
+            options gnc:pagename-general optname-startdate x))
+
+          ((pnl)
+           (gnc-option-db-set-option-selectable-by-name
+            options gnc:pagename-general optname-include-overall-period x))))))
 
     (add-option
      (gnc:make-simple-boolean-option
@@ -219,7 +216,7 @@ also show overall period profit & loss."))
     (add-option
      (gnc:make-simple-boolean-option
       gnc:pagename-general optname-include-chart
-      "d" opthelp-include-chart #f))
+      "c5" opthelp-include-chart #f))
 
     (add-option
      (gnc:make-simple-boolean-option
@@ -339,7 +336,7 @@ also show overall period profit & loss."))
       (add-option
        (gnc:make-simple-boolean-option
         gnc:pagename-general optname-include-overall-period
-        "e" opthelp-include-overall-period #f))
+        "c6" opthelp-include-overall-period #f))
 
       ;; closing entry match criteria
       (add-option
@@ -717,9 +714,7 @@ also show overall period profit & loss."))
                                optname-enddate)))
          (disable-account-indent? (get-option gnc:pagename-display
                                               optname-account-full-name))
-         (incr (let ((period (get-option gnc:pagename-general optname-period)))
-                 (and period
-                      (keylist-get-info periodlist period 'delta))))
+         (incr (get-option gnc:pagename-general optname-period))
          (disable-amount-indent? (and (not incr)
                                       (get-option gnc:pagename-general
                                                   optname-disable-amount-indent)))
@@ -770,7 +765,8 @@ also show overall period profit & loss."))
                                 gnc:time64-end-day-time
                                 gnc:time64-start-day-time)
                             (if incr
-                                (gnc:make-date-list startdate enddate incr)
+                                (gnc:make-date-list
+                                 startdate enddate (gnc:deltasym-to-delta incr))
                                 (if (eq? report-type 'balsheet)
                                     (list enddate)
                                     (list startdate enddate)))))
@@ -951,7 +947,7 @@ also show overall period profit & loss."))
                       (map
                        gnc:monetary-neg
                        (income-expense-balance 'format gnc:make-gnc-monetary #f))))))
-             (chart (and include-chart?
+             (chart (and include-chart? incr
                          (gnc:make-report-anchor
                           networth-barchart-uuid report-obj
                           (list (list "General" "Start Date" (cons 'absolute startdate))
@@ -959,6 +955,7 @@ also show overall period profit & loss."))
                                 (list "General" "Report's currency"
                                       (or common-currency
                                           (gnc-default-report-currency)))
+                                (list "General" "Step Size" incr)
                                 (list "General" "Price Source"
                                       (or price-source 'pricedb-nearest))
                                 (list "Accounts" "Accounts"
@@ -1039,7 +1036,7 @@ also show overall period profit & loss."))
                           #:show-accounts? #f
                           #:show-total? #f))
 
-        (if include-chart?
+        (if (and include-chart? incr)
             (gnc:html-document-add-object!
              doc
              (gnc:make-html-text
@@ -1125,6 +1122,7 @@ also show overall period profit & loss."))
                                 (list "General" "Report's currency"
                                       (or common-currency
                                           (gnc-default-report-currency)))
+                                (list "General" "Step Size" (or incr 'MonthDelta))
                                 (list "General" "Price Source"
                                       (or price-source 'pricedb-nearest))
                                 (list "Accounts" "Accounts"

commit 67830a0e35ef479d436ba90cad2043ad48a3e05a
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Sun May 12 00:13:39 2019 +0800

    [report-gnome] compact functions
    
    * inline single-use functions
    * use srfi-1 list processing functions
    * minimise set! calls

diff --git a/gnucash/report/report-gnome/report-gnome.scm b/gnucash/report/report-gnome/report-gnome.scm
index a837ddb00..94af04771 100644
--- a/gnucash/report/report-gnome/report-gnome.scm
+++ b/gnucash/report/report-gnome/report-gnome.scm
@@ -45,54 +45,30 @@
 (define (gnc:add-report-template-menu-items)
   (define *template-items* '())
 
-  (define (add-template-menu-item name template)
-    (if (gnc:report-template-in-menu? template)
-        (let ((title (string-append (_ "Report") ": " (_ name)))
-              (menu-path (gnc:report-template-menu-path template))
-              (menu-tip (gnc:report-template-menu-tip template))
-              (item #f))
+  (gnc:report-templates-for-each
+   (lambda (report-guid template)
+     (let ((name (or (gnc:report-template-menu-name template)
+                     (gnc:report-template-name template))))
+       (set! *template-items* (cons (cons name template) *template-items*)))))
 
-          ;;(if (not menu-path)
-              ;;(set! menu-path '(""))
-              ;;(set! menu-path
-              ;; (append menu-path '(""))))
-
-          (if (not menu-path)
-              (set! menu-path '()))
-
-          (set! menu-path (append (list gnc:menuname-reports) menu-path))
-
-          (if (not menu-tip)
-              (set! menu-tip
-                    (format #f (_ "Display the ~a report") (_ name))))
-
-          (set! item
-                (gnc:make-menu-item
-                 name
-                 (gnc:report-template-report-guid template)
-                 menu-tip
-                 menu-path
-                 (lambda (window)
-                   (let ((report (gnc:make-report
-                                  (gnc:report-template-report-guid template))))
-                     (gnc-main-window-open-report report window)))))
-          (gnc-add-scm-extension item))))
-
-  (define (add-template report-guid template)
-    (let ((name (gnc:report-template-name template))
-	  (menu-name (gnc:report-template-menu-name template)))
-      (if menu-name (set! name menu-name))
-      (set! *template-items* (cons (cons name template) *template-items*))))
-
-  (define (sort-templates a b)
-    (string>? (car a) (car b)))
-
-  (gnc:report-templates-for-each add-template)
   (for-each
    (lambda (item)
-     (add-template-menu-item (car item) (cdr item)))
-   (sort *template-items* sort-templates)))
-
+     (let* ((menu-name (car item))
+            (template (cdr item))
+            (report-guid (gnc:report-template-report-guid template))
+            (menu-tip (or (gnc:report-template-menu-tip template)
+                          (format #f (_ "Display the ~a report") (_ menu-name))))
+            (menu-path (append (list gnc:menuname-reports)
+                               (or (gnc:report-template-menu-path template)
+                                   '()))))
+       (gnc-add-scm-extension
+        (gnc:make-menu-item
+         menu-name report-guid menu-tip menu-path
+         (lambda (window)
+           (gnc-main-window-open-report
+            (gnc:make-report report-guid) window))))))
+   (sort (filter (compose gnc:report-template-in-menu? cdr) *template-items*)
+         (lambda (a b) (string>? (car a) (car b))))))
 
 (define (gnc:report-menu-setup)
   (define asset-liability-menu
@@ -142,10 +118,4 @@
     (N_ "Welcome-to-GnuCash report screen")
     (list gnc:menuname-reports gnc:menuname-utility "")
     (lambda (window)
-      (gnc-main-window-open-report (gnc:make-welcome-report) window))))
-  
-)
-
-(define (gnc:spawn-custom-report-dialog window)
-  (gnc:debug "called into custom report dialog, window is " window)
-  (gnc-ui-custom-report window))
+      (gnc-main-window-open-report (gnc:make-welcome-report) window)))))

commit 668b1f6b7be36fa6e2ad781c2ba87f740e4417a2
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Sun May 12 00:12:43 2019 +0800

    [report-gnome] fix whitespace

diff --git a/gnucash/gnome-utils/gnome-utils.scm b/gnucash/gnome-utils/gnome-utils.scm
index b903e4596..7d5e56edb 100644
--- a/gnucash/gnome-utils/gnome-utils.scm
+++ b/gnucash/gnome-utils/gnome-utils.scm
@@ -19,12 +19,12 @@
 
 (define-module (gnucash gnome-utils))
 
-(use-modules (gnucash utilities)) 
+(use-modules (gnucash utilities))
 (use-modules (gnucash gnc-module))
 
-(eval-when
-      (compile load eval expand)
-      (load-extension "libgncmod-gnome-utils" "scm_init_sw_gnome_utils_module"))
+(eval-when (compile load eval expand)
+  (load-extension "libgncmod-gnome-utils" "scm_init_sw_gnome_utils_module"))
+
 (use-modules (sw_gnome_utils))
 (gnc:module-load "gnucash/app-utils" 0)
 
diff --git a/gnucash/report/report-gnome/report-gnome.scm b/gnucash/report/report-gnome/report-gnome.scm
index 6d6748bc0..a837ddb00 100644
--- a/gnucash/report/report-gnome/report-gnome.scm
+++ b/gnucash/report/report-gnome/report-gnome.scm
@@ -25,16 +25,15 @@
 
 
 (define-module (gnucash report report-gnome))
-(use-modules (gnucash utilities)) 
+(use-modules (gnucash utilities))
 (use-modules (gnucash gnc-module))
 (use-modules (gnucash gnome-utils))
 (use-modules (gnucash gettext))
 (use-modules (gnucash report utility-reports))
 
-(eval-when
-      (compile load eval expand)
-      (load-extension "libgncmod-gnome-utils" "scm_init_sw_gnome_utils_module")
-      (load-extension "libgncmod-report-gnome" "scm_init_sw_report_gnome_module"))
+(eval-when (compile load eval expand)
+  (load-extension "libgncmod-gnome-utils" "scm_init_sw_gnome_utils_module")
+  (load-extension "libgncmod-report-gnome" "scm_init_sw_report_gnome_module"))
 (use-modules (sw_report_gnome))
 
 (gnc:module-load "gnucash/gnome-utils" 0)
@@ -106,19 +105,20 @@
     (gnc:make-menu gnc:menuname-utility (list gnc:menuname-reports)))
   (define experimental-menu
     (gnc:make-menu gnc:menuname-experimental (list gnc:menuname-reports)))
-  (define tax-menu 
+  (define tax-menu
     (gnc:make-menu gnc:menuname-taxes (list gnc:menuname-reports)))
-  (define business-menu 
+  (define business-menu
     (gnc:make-menu gnc:menuname-business-reports (list gnc:menuname-reports)))
 
-  (gnc-add-scm-extension 
+  (gnc-add-scm-extension
    (gnc:make-menu-item
-   (N_ "Saved Report Configurations")
-   "4d3dcdc8890b11df99dd94cddfd72085"
-   (N_ "Manage and run saved report configurations")
-   (list "Reports/SavedReportConfigs")
-   (lambda (window)
-     (gnc:spawn-custom-report-dialog window))))
+    (N_ "Saved Report Configurations")
+    "4d3dcdc8890b11df99dd94cddfd72085"
+    (N_ "Manage and run saved report configurations")
+    (list "Reports/SavedReportConfigs")
+    (lambda (window)
+      (gnc:debug "called into custom report dialog, window is " window)
+      (gnc-ui-custom-report window))))
 
   ;; (gnc-add-scm-extension tax-menu)
   (gnc-add-scm-extension income-expense-menu)
@@ -136,7 +136,7 @@
 
   ;; the Welcome to GnuCash "extravaganza" report
   (gnc-add-scm-extension
-   (gnc:make-menu-item 
+   (gnc:make-menu-item
     (N_ "Welcome Sample Report")
     "ad80271c890b11dfa79f2dcedfd72085"
     (N_ "Welcome-to-GnuCash report screen")

commit c38c4557a56370a51236903e326f4429fd5b2caf
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Sun May 12 11:36:51 2019 +0100

    Bug 797051 - Change Overwrite price confirmation
    
    Change when you cancel the overwrite price confirmation so that you
    return back to the 'Price Editor' instead of closing it.

diff --git a/gnucash/gnome/dialog-price-editor.c b/gnucash/gnome/dialog-price-editor.c
index 202c7df66..6f792fc14 100644
--- a/gnucash/gnome/dialog-price-editor.c
+++ b/gnucash/gnome/dialog-price-editor.c
@@ -330,39 +330,37 @@ pedit_dialog_response_cb (GtkDialog *dialog, gint response, gpointer data)
     PriceEditDialog *pedit_dialog = data;
     GNCPrice *new_price = NULL;
     const char *error_str;
-    gboolean price_is_ok = TRUE;
 
     if ((response == GTK_RESPONSE_OK) || (response == GTK_RESPONSE_APPLY))
     {
         error_str = gui_to_price (pedit_dialog);
-        if (g_strcmp0 (error_str, "CANCEL") == 0)
-            price_is_ok = FALSE;
-        else if (error_str)
+        if (g_strcmp0 (error_str, "CANCEL") == 0) // cancel from replace price dialog
+        {
+            // set the ok and cancel buttons sensitivity
+            gnc_prices_set_changed (pedit_dialog, FALSE);
+            return;
+        }
+        else if (error_str) // error string from gui
         {
             gnc_warning_dialog (GTK_WINDOW (pedit_dialog->dialog), "%s", error_str);
             return;
         }
-
+        // set the ok and cancel buttons sensitivity
         gnc_prices_set_changed (pedit_dialog, FALSE);
-        if (price_is_ok)
-        {
-            if (pedit_dialog->is_new)
-                gnc_pricedb_add_price (pedit_dialog->price_db, pedit_dialog->price);
 
-            gnc_gui_refresh_all ();
-        }
+        if (pedit_dialog->is_new)
+            gnc_pricedb_add_price (pedit_dialog->price_db, pedit_dialog->price);
+
+        gnc_gui_refresh_all ();
     }
 
     if (response == GTK_RESPONSE_APPLY)
     {
-        if (price_is_ok)
-        {
-            new_price = gnc_price_clone (pedit_dialog->price, pedit_dialog->book);
-            pedit_dialog->is_new = TRUE;
+        new_price = gnc_price_clone (pedit_dialog->price, pedit_dialog->book);
+        pedit_dialog->is_new = TRUE;
 
-            gnc_price_unref (pedit_dialog->price);
-            pedit_dialog->price = new_price;
-        }
+        gnc_price_unref (pedit_dialog->price);
+        pedit_dialog->price = new_price;
     }
     else
     {

commit a560980617d6e7bc6d8ec1a24c6cc5bcacc0d3e1
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Sat May 11 15:23:54 2019 +0100

    Remove some obsolete code
    
    Remove some code that was used in the old transaction import assistant
    to do with embedding an account picker dialog in an assistant.

diff --git a/gnucash/gtkbuilder/dialog-import.glade b/gnucash/gtkbuilder/dialog-import.glade
index 84f6c6ac6..3aebe4943 100644
--- a/gnucash/gtkbuilder/dialog-import.glade
+++ b/gnucash/gtkbuilder/dialog-import.glade
@@ -82,6 +82,32 @@
             <property name="position">0</property>
           </packing>
         </child>
+        <child>
+          <object class="GtkLabel" id="label847715">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="label" translatable="yes">Please select or create an appropriate GnuCash account for:</property>
+            <property name="justify">center</property>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkLabel" id="online_id_label">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="label" translatable="yes">Online account ID here...</property>
+            <property name="justify">center</property>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
         <child>
           <object class="GtkBox" id="placeholder_warning_hbox">
             <property name="can_focus">False</property>
@@ -121,6 +147,20 @@
             <property name="position">2</property>
           </packing>
         </child>
+        <child>
+          <object class="GtkScrolledWindow" id="account_tree_sw">
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <child>
+              <placeholder/>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">True</property>
+            <property name="fill">True</property>
+            <property name="position">4</property>
+          </packing>
+        </child>
       </object>
     </child>
     <action-widgets>
@@ -129,51 +169,6 @@
       <action-widget response="-5">okbutton</action-widget>
     </action-widgets>
   </object>
-  <object class="GtkBox" id="account_picker_content">
-    <property name="visible">True</property>
-    <property name="can_focus">False</property>
-    <property name="orientation">vertical</property>
-    <child>
-      <object class="GtkLabel" id="label847715">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="label" translatable="yes">Please select or create an appropriate GnuCash account for:</property>
-        <property name="justify">center</property>
-      </object>
-      <packing>
-        <property name="expand">False</property>
-        <property name="fill">False</property>
-        <property name="position">0</property>
-      </packing>
-    </child>
-    <child>
-      <object class="GtkLabel" id="online_id_label">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="label" translatable="yes">Online account ID here...</property>
-        <property name="justify">center</property>
-      </object>
-      <packing>
-        <property name="expand">False</property>
-        <property name="fill">False</property>
-        <property name="position">1</property>
-      </packing>
-    </child>
-    <child>
-      <object class="GtkScrolledWindow" id="account_tree_sw">
-        <property name="visible">True</property>
-        <property name="can_focus">True</property>
-        <child>
-          <placeholder/>
-        </child>
-      </object>
-      <packing>
-        <property name="expand">True</property>
-        <property name="fill">True</property>
-        <property name="position">2</property>
-      </packing>
-    </child>
-  </object>
   <object class="GtkAdjustment" id="atm_fee_adj">
     <property name="upper">1000</property>
     <property name="value">2</property>
diff --git a/gnucash/import-export/import-account-matcher.c b/gnucash/import-export/import-account-matcher.c
index 704cffa84..8674e832e 100644
--- a/gnucash/import-export/import-account-matcher.c
+++ b/gnucash/import-export/import-account-matcher.c
@@ -62,7 +62,6 @@ static AccountPickerDialog* gnc_import_new_account_picker(void)
 {
     AccountPickerDialog* picker = g_new(AccountPickerDialog, 1);
     picker->dialog = NULL;
-    picker->assistant = NULL;
     picker->account_tree = NULL;
     picker->account_tree_sw = NULL;
     picker->auto_create = TRUE;
@@ -151,8 +150,6 @@ gnc_import_add_account(GtkWidget *button, AccountPickerDialog *picker)
 
     if (picker->dialog != NULL)
         parent = GTK_WINDOW (picker->dialog);
-    else
-        parent = GTK_WINDOW (picker->assistant);
 
     /*DEBUG("Begin");  */
     if (picker->new_account_default_type != ACCT_TYPE_NONE)
@@ -228,50 +225,7 @@ account_tree_row_activated_cb(GtkTreeView *view, GtkTreePath *path,
                               GtkTreeViewColumn *column,
                               AccountPickerDialog *picker)
 {
-    const gchar *retval_name = NULL;
-    Account *old_id_acc;
-
-    /* See if we have a dialog, if not we are an assistant */
-    if (picker->dialog == NULL)
-    {
-        GtkAssistant *assistant = GTK_ASSISTANT(picker->assistant);
-        gint num = gtk_assistant_get_current_page (assistant);
-        GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
-
-        picker->retAccount = gnc_tree_view_account_get_selected_account(picker->account_tree);
-        if (picker->retAccount)
-            retval_name = xaccAccountGetName(picker->retAccount);
-        if (!retval_name)
-            retval_name = "(null)";
-        DEBUG("Selected account %p, %s", picker->retAccount, retval_name);
-
-        /* See if the selected account is a placeholder. */
-        if (picker->retAccount && xaccAccountGetPlaceholder (picker->retAccount))
-        {
-             show_placeholder_warning (picker, retval_name);
-        }
-        else if ( picker->account_online_id_value != NULL)
-        {
-            /* find the old account for this on line id value and reset it */
-            old_id_acc =
-                gnc_account_foreach_descendant_until(gnc_get_current_root_account (),
-                        test_acct_online_id_match,
-                        /* This argument will only be used as a "const char*" */
-                        (void*)picker->account_online_id_value);
-
-            if (old_id_acc != NULL)
-                gnc_import_set_acc_online_id(old_id_acc, "");
-
-            gnc_import_set_acc_online_id(picker->retAccount, picker->account_online_id_value);
-            gtk_assistant_set_page_complete (assistant, page, TRUE);
-        }
-        else
-            gtk_assistant_set_page_complete (assistant, page, TRUE);
-    }
-    else
-    {
-        gtk_dialog_response(GTK_DIALOG(picker->dialog), GTK_RESPONSE_OK);
-    }
+    gtk_dialog_response(GTK_DIALOG(picker->dialog), GTK_RESPONSE_OK);
 }
 
 
@@ -296,7 +250,7 @@ Account * gnc_import_select_account(GtkWidget *parent,
     const gchar *retval_name = NULL;
     GtkBuilder *builder;
     GtkTreeSelection *selection;
-    GtkWidget * online_id_label, *box, *pbox;
+    GtkWidget * online_id_label;
     gchar account_description_text[ACCOUNT_DESCRIPTION_MAX_SIZE + 1] = "";
     gboolean ok_pressed_retval = FALSE;
 
@@ -352,7 +306,6 @@ Account * gnc_import_select_account(GtkWidget *parent,
         builder = gtk_builder_new();
         gnc_builder_add_from_file (builder, "dialog-import.glade", "account_new_icon");
         gnc_builder_add_from_file (builder, "dialog-import.glade", "account_picker_dialog");
-        gnc_builder_add_from_file (builder, "dialog-import.glade", "account_picker_content");
         /* connect the signals in the interface */
         if (builder == NULL)
         {
@@ -370,11 +323,6 @@ Account * gnc_import_select_account(GtkWidget *parent,
         gnc_restore_window_size (GNC_PREFS_GROUP,
                                  GTK_WINDOW(picker->dialog), GTK_WINDOW (parent));
 
-        /* Pack the content into the dialog vbox */
-        pbox = GTK_WIDGET(gtk_builder_get_object (builder, "account_picker_vbox"));
-        box = GTK_WIDGET(gtk_builder_get_object (builder, "account_picker_content"));
-        gtk_box_pack_start( GTK_BOX(pbox), box, TRUE, TRUE, 0);
-
         picker->account_tree_sw = GTK_WIDGET(gtk_builder_get_object (builder, "account_tree_sw"));
         online_id_label = GTK_WIDGET(gtk_builder_get_object (builder, "online_id_label"));
 
@@ -474,131 +422,4 @@ Account * gnc_import_select_account(GtkWidget *parent,
     return retval;
 }
 
-
-/**********************************************************************
- * These are the routines for use with an Assistant page
- **********************************************************************/
-
-/*******************************************************
- * gnc_import_account_assist_setup
- *
- * Main call for page setup in an assistant
- *******************************************************/
-AccountPickerDialog* gnc_import_account_assist_setup(GtkWidget *parent)
-{
-    AccountPickerDialog * picker;
-    GtkBuilder *builder;
-    GtkWidget  *box, *h_box;
-
-    /* Init the account picker structure */
-    picker = gnc_import_new_account_picker();
-
-    /* load the interface */
-    builder = gtk_builder_new();
-    gnc_builder_add_from_file (builder, "dialog-import.glade", "account_picker_content");
-    /* connect the signals in the interface */
-    if (builder == NULL)
-    {
-        PERR("Error opening the glade builder interface");
-    }
-
-    picker->assistant = gtk_widget_get_parent(parent);
-    /* Pack content into Assistant page widget */
-    box = GTK_WIDGET(gtk_builder_get_object (builder, "account_picker_content"));
-    gtk_box_pack_start( GTK_BOX(parent), box, TRUE, TRUE, 6);
-
-    picker->account_tree_sw = GTK_WIDGET(gtk_builder_get_object (builder, "account_tree_sw"));
-    picker->account_online_id_label = GTK_WIDGET(gtk_builder_get_object (builder, "online_id_label"));
-
-    /* Add the New Account Button */
-    picker->new_button = gtk_button_new_with_mnemonic (_("_New Account"));
-
-    h_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
-    gtk_box_set_homogeneous (GTK_BOX (h_box), TRUE);
-
-    gtk_box_pack_start(GTK_BOX(h_box), picker->new_button, FALSE, FALSE, 0);
-    gtk_box_pack_start( GTK_BOX(box), h_box, FALSE, FALSE, 6);
-    gtk_widget_show (picker->new_button);
-    g_signal_connect(picker->new_button, "clicked",
-                     G_CALLBACK(gnc_import_add_account), picker);
-
-    build_acct_tree(picker);
-
-    g_signal_connect(picker->account_tree, "row-activated",
-                     G_CALLBACK(account_tree_row_activated_cb), picker);
-
-    g_object_unref(G_OBJECT(builder));
-    return picker;
-}
-
-
-/*******************************************************
- * gnc_import_account_assist_disable
- *
- * disables account picker input.
- *******************************************************/
-void
-gnc_import_account_assist_disable (AccountPickerDialog *picker, gboolean disable)
-{
-    gtk_widget_set_sensitive (picker->account_tree_sw, !disable);
-    gtk_widget_set_sensitive (picker->new_button, !disable);
-}
-
-
-/*******************************************************
- * gnc_import_account_assist_update
- *
- * updates the page and returns account found.
- *******************************************************/
-Account * gnc_import_account_assist_update (AccountPickerDialog *picker)
-{
-#define ACCOUNT_DESCRIPTION_MAX_SIZE 255
-
-    const gchar *retval_name = NULL;
-    gchar account_description_text[ACCOUNT_DESCRIPTION_MAX_SIZE + 1] = "";
-
-    ENTER("Default commodity received: %s", gnc_commodity_get_fullname( picker->new_account_default_commodity));
-    DEBUG("Default account type received: %s", xaccAccountGetTypeStr( picker->new_account_default_type));
-
-    /*DEBUG("Looking for account with online_id: %s", picker->account_online_id_value);*/
-    if (picker->account_online_id_value != NULL)
-    {
-        picker->retAccount =
-            gnc_account_foreach_descendant_until(gnc_get_current_root_account (),
-                    test_acct_online_id_match,
-                    /* This argument will only be used as a "const char*" */
-                    (void*)picker->account_online_id_value);
-    }
-
-    if (picker->account_human_description != NULL)
-    {
-        strncat(account_description_text, picker->account_human_description,
-                ACCOUNT_DESCRIPTION_MAX_SIZE - strlen(account_description_text));
-        strncat(account_description_text, "\n",
-                ACCOUNT_DESCRIPTION_MAX_SIZE - strlen(account_description_text));
-    }
-    if (picker->account_online_id_value != NULL)
-    {
-        strncat(account_description_text, _("(Full account ID: "),
-                ACCOUNT_DESCRIPTION_MAX_SIZE - strlen(account_description_text));
-        strncat(account_description_text, picker->account_online_id_value,
-                ACCOUNT_DESCRIPTION_MAX_SIZE - strlen(account_description_text));
-        strncat(account_description_text, ")",
-                ACCOUNT_DESCRIPTION_MAX_SIZE - strlen(account_description_text));
-    }
-    gtk_label_set_text(GTK_LABEL( picker->account_online_id_label), account_description_text);
-
-    if (picker->default_account == NULL)
-        gnc_tree_view_account_set_selected_account(picker->account_tree, picker->retAccount);
-    else
-        gnc_tree_view_account_set_selected_account(picker->account_tree, picker->default_account);
-
-    /*FIXME: DEBUG("WRITEME: Here we should check if an account type is compatible, currency matches, etc.\n"); */
-
-    /*DEBUG("Return value: %p%s%s%s",picker->retAccount,", account name:",xaccAccountGetName(picker->retAccount),"\n");*/
-    retval_name = picker->retAccount ? xaccAccountGetName(picker->retAccount) : NULL;
-    LEAVE("Selected account %p, %s", picker->retAccount, retval_name ? retval_name : "(null)");
-    return picker->retAccount;
-}
-
 /**@}*/
diff --git a/gnucash/import-export/import-account-matcher.h b/gnucash/import-export/import-account-matcher.h
index 17c99976a..d53f0b8f6 100644
--- a/gnucash/import-export/import-account-matcher.h
+++ b/gnucash/import-export/import-account-matcher.h
@@ -38,7 +38,6 @@
 typedef struct
 {
     GtkWidget           *dialog;                         /* Dialog Widget */
-    GtkWidget           *assistant;                      /* assistant Widget */
     GtkWidget           *new_button;                     /* new account button Widget */
     GtkWidget           *ok_button;                      /* ok button Widget */
     GncTreeViewAccount  *account_tree;                   /* Account tree */
@@ -126,39 +125,5 @@ Account * gnc_import_select_account(GtkWidget *parent,
                                     gboolean * ok_pressed
                                    );
 
-
-/**  Must be called with the parent widget, ie. a vbox that the
-     account picker dialog will be packed into. The data structure
-     AccountPickerDialog is initialised and default values populated.
-
-  @param parent The parent widget. This is the place the account picker dialog will
-  be packed into.
-
-  @return A pointer to the AccountPickerDialog which has been setup.
-*/
-AccountPickerDialog * gnc_import_account_assist_setup (GtkWidget *parent);
-
-
-/**  Must be called with an AccountPickerDialog structure allready setup.
-     If an account with a matching online_id is found, which is
-     allready present in the dialog structure, the function returns with a
-     pointer to that account or NULL if not found.
-
-  @param Account picker Dialog structure, AccountPickerDialog
-
-  @return A pointer to the found account, or NULL if account not found.
-*/
-Account * gnc_import_account_assist_update (AccountPickerDialog *picker);
-
-
-/**  Must be called with an AccountPickerDialog structure allready setup.
-     Set the sensitivity of the account picker to disable input.
-
-  @param Account picker Dialog structure, AccountPickerDialog
-
-  @param TRUE to make picker insensitve.
-*/
-void gnc_import_account_assist_disable (AccountPickerDialog *picker, gboolean disable);
-
 #endif
 /**@}*/

commit e76ebf4c60cd845e60d07ce596ab57044ae73e73
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Sat May 11 14:44:37 2019 +0100

    Change the Placeholder warning in the Account picker
    
    When an account is selected it is checked for being a placeholder and
    if it is a warning dialog was created. This was pointed out as being
    disruptive so this change controls the sensitivity of the OK button and
    displays a warning in the account picker dialog.

diff --git a/gnucash/gtkbuilder/dialog-import.glade b/gnucash/gtkbuilder/dialog-import.glade
index 59ed257be..84f6c6ac6 100644
--- a/gnucash/gtkbuilder/dialog-import.glade
+++ b/gnucash/gtkbuilder/dialog-import.glade
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.20.4 -->
+<!-- Generated with glade 3.22.1 -->
 <interface>
   <requires lib="gtk+" version="3.10"/>
   <object class="GtkImage" id="account_new_icon">
@@ -14,6 +14,9 @@
     <property name="default_height">600</property>
     <property name="type_hint">dialog</property>
     <signal name="map" handler="gnc_ui_generic_account_picker_map_cb" swapped="no"/>
+    <child>
+      <placeholder/>
+    </child>
     <child internal-child="vbox">
       <object class="GtkBox" id="account_picker_vbox">
         <property name="visible">True</property>
@@ -80,16 +83,43 @@
           </packing>
         </child>
         <child>
-          <placeholder/>
-        </child>
-        <child>
-          <placeholder/>
-        </child>
-        <child>
-          <placeholder/>
-        </child>
-        <child>
-          <placeholder/>
+          <object class="GtkBox" id="placeholder_warning_hbox">
+            <property name="can_focus">False</property>
+            <property name="margin_left">6</property>
+            <property name="margin_right">6</property>
+            <property name="margin_top">6</property>
+            <property name="spacing">6</property>
+            <child>
+              <object class="GtkImage" id="placeholder_warning_image">
+                <property name="can_focus">False</property>
+                <property name="halign">start</property>
+                <property name="stock">gtk-dialog-warning</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLabel" id="placeholder_warning_label">
+                <property name="can_focus">False</property>
+                <property name="halign">start</property>
+                <property name="wrap">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">2</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="pack_type">end</property>
+            <property name="position">2</property>
+          </packing>
         </child>
       </object>
     </child>
@@ -165,7 +195,6 @@
     <property name="page_increment">10</property>
   </object>
   <object class="GtkDialog" id="format_picker_dialog">
-    <property name="visible">False</property>
     <property name="can_focus">False</property>
     <property name="title" translatable="yes">Choose a format</property>
     <property name="resizable">False</property>
@@ -173,6 +202,9 @@
     <property name="default_width">600</property>
     <property name="default_height">400</property>
     <property name="type_hint">dialog</property>
+    <child>
+      <placeholder/>
+    </child>
     <child internal-child="vbox">
       <object class="GtkBox" id="dialog-vbox16">
         <property name="visible">True</property>
@@ -301,6 +333,9 @@
     <property name="visible">True</property>
     <property name="can_focus">False</property>
     <property name="title" translatable="yes">Preferences</property>
+    <child>
+      <placeholder/>
+    </child>
     <child>
       <object class="GtkGrid" id="matcher_prefs">
         <property name="visible">True</property>
@@ -554,6 +589,9 @@
     <property name="default_width">600</property>
     <property name="default_height">400</property>
     <property name="type_hint">dialog</property>
+    <child>
+      <placeholder/>
+    </child>
     <child internal-child="vbox">
       <object class="GtkBox" id="dialog-vbox14">
         <property name="visible">True</property>
@@ -726,6 +764,9 @@
     <property name="resizable">False</property>
     <property name="type_hint">dialog</property>
     <signal name="close" handler="on_matcher_help_close_clicked" swapped="no"/>
+    <child>
+      <placeholder/>
+    </child>
     <child internal-child="vbox">
       <object class="GtkBox" id="dialog-vbox18">
         <property name="visible">True</property>
@@ -1119,9 +1160,6 @@
         <property name="position">1</property>
       </packing>
     </child>
-    <child>
-      <placeholder/>
-    </child>
     <child>
       <object class="GtkCheckButton" id="show_source_account_button">
         <property name="label" translatable="yes">Show the Source Account column</property>
@@ -1145,6 +1183,9 @@
     <property name="default_height">400</property>
     <property name="type_hint">dialog</property>
     <signal name="close" handler="on_matcher_cancel_clicked" swapped="no"/>
+    <child>
+      <placeholder/>
+    </child>
     <child internal-child="vbox">
       <object class="GtkBox" id="transaction_matcher_vbox">
         <property name="visible">True</property>
diff --git a/gnucash/import-export/import-account-matcher.c b/gnucash/import-export/import-account-matcher.c
index 02546621a..704cffa84 100644
--- a/gnucash/import-export/import-account-matcher.c
+++ b/gnucash/import-export/import-account-matcher.c
@@ -171,6 +171,53 @@ gnc_import_add_account(GtkWidget *button, AccountPickerDialog *picker)
 }
 
 
+/***********************************************************
+ * show_placeholder_warning
+ *
+ * show the warning when account is a place holder and disable
+ * OK button
+ ************************************************************/
+static void
+show_placeholder_warning (AccountPickerDialog *picker, const gchar *name)
+{
+    gchar *text = g_strdup_printf (_("The account %s is a placeholder account and does not allow "
+                                     "transactions. Please choose a different account."), name);
+
+    gtk_label_set_text (GTK_LABEL(picker->pwarning), text);
+    gnc_label_set_alignment (picker->pwarning, 0.0, 0.5);
+    gtk_widget_show_all (GTK_WIDGET(picker->pwhbox));
+    g_free (text);
+
+    gtk_widget_set_sensitive (picker->ok_button, FALSE); // disable OK button
+}
+
+
+/*******************************************************
+ * account_tree_row_changed_cb
+ *
+ * Callback for when user selects a different row
+ *******************************************************/
+static void
+account_tree_row_changed_cb (GtkTreeSelection *selection,
+                             AccountPickerDialog *picker)
+{
+
+    Account *sel_account = gnc_tree_view_account_get_selected_account (picker->account_tree);
+
+    gtk_widget_set_sensitive (picker->ok_button, TRUE); // enable OK button
+
+    /* See if the selected account is a placeholder. */
+    if (sel_account && xaccAccountGetPlaceholder (sel_account))
+    {
+        const gchar *retval_name = xaccAccountGetName (sel_account);
+
+        show_placeholder_warning (picker, retval_name);
+    }
+    else
+        gtk_widget_hide (GTK_WIDGET(picker->pwhbox)); // hide the placeholder warning
+}
+
+
 /*******************************************************
  * account_tree_row_activated_cb
  *
@@ -201,10 +248,7 @@ account_tree_row_activated_cb(GtkTreeView *view, GtkTreePath *path,
         /* See if the selected account is a placeholder. */
         if (picker->retAccount && xaccAccountGetPlaceholder (picker->retAccount))
         {
-            gnc_error_dialog (GTK_WINDOW (picker->dialog),
-                              _("The account %s is a placeholder account and does not allow "
-                                "transactions. Please choose a different account."),
-                              retval_name);
+             show_placeholder_warning (picker, retval_name);
         }
         else if ( picker->account_online_id_value != NULL)
         {
@@ -251,6 +295,7 @@ Account * gnc_import_select_account(GtkWidget *parent,
     Account * retval = NULL;
     const gchar *retval_name = NULL;
     GtkBuilder *builder;
+    GtkTreeSelection *selection;
     GtkWidget * online_id_label, *box, *pbox;
     gchar account_description_text[ACCOUNT_DESCRIPTION_MAX_SIZE + 1] = "";
     gboolean ok_pressed_retval = FALSE;
@@ -314,6 +359,10 @@ Account * gnc_import_select_account(GtkWidget *parent,
             PERR("Error opening the glade builder interface");
         }
         picker->dialog = GTK_WIDGET(gtk_builder_get_object (builder, "account_picker_dialog"));
+        picker->pwhbox = GTK_WIDGET(gtk_builder_get_object (builder, "placeholder_warning_hbox"));
+        picker->pwarning = GTK_WIDGET(gtk_builder_get_object (builder, "placeholder_warning_label"));
+        picker->ok_button = GTK_WIDGET(gtk_builder_get_object (builder, "okbutton"));
+
         if (parent)
             gtk_window_set_transient_for (GTK_WINDOW (picker->dialog),
                                           GTK_WINDOW (parent));
@@ -349,11 +398,17 @@ Account * gnc_import_select_account(GtkWidget *parent,
         }
         gtk_label_set_text((GtkLabel*)online_id_label, account_description_text);
         build_acct_tree(picker);
-        gnc_tree_view_account_set_selected_account(picker->account_tree, default_selection);
 
         gtk_window_set_modal(GTK_WINDOW(picker->dialog), TRUE);
         g_signal_connect(picker->account_tree, "row-activated",
                          G_CALLBACK(account_tree_row_activated_cb), picker);
+
+        selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(picker->account_tree));
+        g_signal_connect(selection, "changed",
+                         G_CALLBACK(account_tree_row_changed_cb), picker);
+
+        gnc_tree_view_account_set_selected_account(picker->account_tree, default_selection);
+
         do
         {
             response = gtk_dialog_run(GTK_DIALOG(picker->dialog));
@@ -380,11 +435,7 @@ Account * gnc_import_select_account(GtkWidget *parent,
                 /* See if the selected account is a placeholder. */
                 if (retval && xaccAccountGetPlaceholder (retval))
                 {
-                    gnc_error_dialog
-                    (GTK_WINDOW (picker->dialog),
-                     _("The account %s is a placeholder account and does not allow "
-                       "transactions. Please choose a different account."),
-                     retval_name);
+                    show_placeholder_warning (picker, retval_name);
                     response = GNC_RESPONSE_NEW;
                     break;
                 }
diff --git a/gnucash/import-export/import-account-matcher.h b/gnucash/import-export/import-account-matcher.h
index 986e75908..17c99976a 100644
--- a/gnucash/import-export/import-account-matcher.h
+++ b/gnucash/import-export/import-account-matcher.h
@@ -40,6 +40,7 @@ typedef struct
     GtkWidget           *dialog;                         /* Dialog Widget */
     GtkWidget           *assistant;                      /* assistant Widget */
     GtkWidget           *new_button;                     /* new account button Widget */
+    GtkWidget           *ok_button;                      /* ok button Widget */
     GncTreeViewAccount  *account_tree;                   /* Account tree */
     GtkWidget           *account_tree_sw;                /* Scroll Window for Account tree */
     gboolean             auto_create;                    /* Auto create retAccount, can be used to step over this stage */
@@ -50,6 +51,8 @@ typedef struct
     GNCAccountType       new_account_default_type;       /* new account default type, incoming */
     Account             *default_account;                /* default account for selection, incoming */
     Account             *retAccount;                     /* Account value returned to caller */
+    GtkWidget           *pwhbox;                         /* Placeholder Warning HBox */
+    GtkWidget           *pwarning;                       /* Placeholder Warning Label */
 } AccountPickerDialog;
 
 /**  Must be called with a string containing a unique identifier for the

commit ea0982eb3367ad267124e5bf90deab48411aceca
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Tue May 7 15:52:09 2019 +0100

    Stop some errors when cancelling the QIF import
    
    The imported_account_tree variable is only set when the 'start import'
    button is pressed on assistant page 'QIF import' so only process the
    undo from there.

diff --git a/gnucash/import-export/qif-imp/assistant-qif-import.c b/gnucash/import-export/qif-imp/assistant-qif-import.c
index e7cb53f20..edc448bcb 100644
--- a/gnucash/import-export/qif-imp/assistant-qif-import.c
+++ b/gnucash/import-export/qif-imp/assistant-qif-import.c
@@ -1110,7 +1110,8 @@ gnc_ui_qif_import_convert_undo (QIFImportWindow * wind)
     gnc_set_busy_cursor (NULL, TRUE);
 
     /* Undo the conversion. */
-    gfec_apply (undo, wind->imported_account_tree, _gfec_error_handler);
+    if (wind->imported_account_tree != SCM_BOOL_F)
+        gfec_apply (undo, wind->imported_account_tree, _gfec_error_handler);
 
     /* There's no imported account tree any more. */
     scm_gc_unprotect_object (wind->imported_account_tree);

commit 35b3d6d1871fdb7c3093aac00173f31b8467abe8
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Tue May 7 15:51:25 2019 +0100

    Bug 668349 - Scroll to selected accounts in QIF import tree views

diff --git a/gnucash/import-export/qif-imp/assistant-qif-import.c b/gnucash/import-export/qif-imp/assistant-qif-import.c
index bebc9cc41..e7cb53f20 100644
--- a/gnucash/import-export/qif-imp/assistant-qif-import.c
+++ b/gnucash/import-export/qif-imp/assistant-qif-import.c
@@ -288,7 +288,6 @@ static void
 update_account_picker_page (QIFImportWindow * wind, SCM make_display,
                             GtkWidget *view, SCM map_info, SCM * display_info)
 {
-
     SCM  get_qif_name = scm_c_eval_string ("qif-map-entry:qif-name");
     SCM  get_gnc_name = scm_c_eval_string ("qif-map-entry:gnc-name");
     SCM  get_new      = scm_c_eval_string ("qif-map-entry:new-acct?");
@@ -339,20 +338,19 @@ update_account_picker_page (QIFImportWindow * wind, SCM make_display,
 
     /* move to the old selected row */
     prev_row = GPOINTER_TO_INT(g_object_get_data (G_OBJECT(store), PREV_ROW));
+    selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(view));
+
     if (prev_row != -1)
-    {
-        selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(view));
         path = gtk_tree_path_new_from_indices (prev_row, -1);
-        gtk_tree_selection_select_path (selection, path);
-        gtk_tree_path_free (path);
-    }
     else
-    {
-        selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(view));
         path = gtk_tree_path_new_from_indices (0, -1);
-        gtk_tree_selection_select_path (selection, path);
-        gtk_tree_path_free (path);
-    }
+
+    gtk_tree_selection_select_path (selection, path);
+
+    /* scroll the tree view so the selection is visable if there are rows */
+    if (gtk_tree_model_iter_n_children (GTK_TREE_MODEL(store), NULL) > 0)
+        gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW(view), path, NULL, TRUE, 0.5, 0.0);
+    gtk_tree_path_free (path);
 }
 
 
diff --git a/gnucash/import-export/qif-imp/dialog-account-picker.c b/gnucash/import-export/qif-imp/dialog-account-picker.c
index 7e2e72bcf..96fc1372d 100644
--- a/gnucash/import-export/qif-imp/dialog-account-picker.c
+++ b/gnucash/import-export/qif-imp/dialog-account-picker.c
@@ -202,6 +202,8 @@ build_acct_tree(QIFAccountPickerDialog * picker, QIFImportWindow * import)
         {
             gtk_tree_view_expand_to_path(picker->treeview, path);
             gtk_tree_selection_select_path(selection, path);
+            gtk_tree_view_scroll_to_cell (picker->treeview, path,
+                                          NULL, TRUE, 0.5, 0.0);
             gtk_tree_path_free(path);
         }
         gtk_tree_row_reference_free(reference);

commit d7b40c788b9aaaf1a29cf16462ab22cc03a4ecae
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Tue May 7 15:50:37 2019 +0100

    Bug 754710 - Add column sorting to Qif import Match views

diff --git a/gnucash/import-export/qif-imp/assistant-qif-import.c b/gnucash/import-export/qif-imp/assistant-qif-import.c
index 9a75cf0c2..bebc9cc41 100644
--- a/gnucash/import-export/qif-imp/assistant-qif-import.c
+++ b/gnucash/import-export/qif-imp/assistant-qif-import.c
@@ -529,6 +529,14 @@ create_account_picker_view (GtkWidget *widget,
                                 G_TYPE_STRING, G_TYPE_BOOLEAN,
                                 PANGO_TYPE_ELLIPSIZE_MODE);
     gtk_tree_view_set_model (view, GTK_TREE_MODEL(store));
+
+    /* prevent the rows being dragged to a different order */
+    gtk_tree_view_set_reorderable (view, FALSE);
+
+    /* default sort order */
+    gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE(store),
+                                          ACCOUNT_COL_QIF_NAME,
+                                          GTK_SORT_ASCENDING);
     g_object_unref (store);
 
     renderer = gtk_cell_renderer_text_new ();
@@ -539,9 +547,12 @@ create_account_picker_view (GtkWidget *widget,
              "ellipsize",
              ACCOUNT_COL_ELLIPSIZE,
              NULL);
-    g_object_set (column, "expand", TRUE, NULL);
-    gtk_tree_view_column_set_resizable (column, TRUE);
+
+    g_object_set (G_OBJECT(column), "expand", TRUE, "reorderable",
+                  TRUE, "resizable", TRUE, NULL);
+
     gtk_tree_view_append_column (view, column);
+    gtk_tree_view_column_set_sort_column_id (column, ACCOUNT_COL_QIF_NAME);
 
     renderer = gtk_cell_renderer_text_new ();
     column = gtk_tree_view_column_new_with_attributes (_("GnuCash account name"),
@@ -552,9 +563,11 @@ create_account_picker_view (GtkWidget *widget,
              ACCOUNT_COL_ELLIPSIZE,
              NULL);
 
-    g_object_set (column, "expand", TRUE, NULL);
-    gtk_tree_view_column_set_resizable (column, TRUE);
+    g_object_set (G_OBJECT(column), "expand", TRUE, "reorderable",
+                  TRUE, "resizable", TRUE, NULL);
+
     gtk_tree_view_append_column (view, column);
+    gtk_tree_view_column_set_sort_column_id (column, ACCOUNT_COL_GNC_NAME);
 
     renderer = gtk_cell_renderer_toggle_new ();
     g_object_set(renderer, "activatable", FALSE, NULL);

commit 9504b7067de74782c1f432c280e4c421fc4880fc
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Tue May 7 15:49:52 2019 +0100

    Bug 728873 - In Qif importer use the enter on account entry
    
    Focus is already on the account entry so enable the use of the enter
    key to proceed to the next page when you are finished changing the
    account name for a qif file.

diff --git a/gnucash/gtkbuilder/assistant-qif-import.glade b/gnucash/gtkbuilder/assistant-qif-import.glade
index af71d2047..c566847db 100644
--- a/gnucash/gtkbuilder/assistant-qif-import.glade
+++ b/gnucash/gtkbuilder/assistant-qif-import.glade
@@ -381,6 +381,7 @@ Please enter a name for the account. If the file was exported from another accou
                 <property name="primary_icon_activatable">False</property>
                 <property name="secondary_icon_activatable">False</property>
                 <signal name="changed" handler="gnc_ui_qif_import_acct_valid_cb" swapped="no"/>
+                <signal name="activate" handler="gnc_ui_qif_import_acct_enter_cb" swapped="no"/>
               </object>
               <packing>
                 <property name="expand">True</property>
diff --git a/gnucash/import-export/qif-imp/assistant-qif-import.c b/gnucash/import-export/qif-imp/assistant-qif-import.c
index 5505e3ce0..9a75cf0c2 100644
--- a/gnucash/import-export/qif-imp/assistant-qif-import.c
+++ b/gnucash/import-export/qif-imp/assistant-qif-import.c
@@ -237,6 +237,7 @@ void gnc_ui_qif_import_date_valid_cb (GtkWidget *widget, gpointer user_data);
 
 void gnc_ui_qif_import_account_prepare (GtkAssistant *assistant, gpointer user_data);
 void gnc_ui_qif_import_acct_valid_cb (GtkWidget *widget, gpointer user_data);
+void gnc_ui_qif_import_acct_enter_cb (GtkWidget * widget, gpointer user_data);
 
 void gnc_ui_qif_import_loaded_files_prepare (GtkAssistant *assistant, gpointer user_data);
 void gnc_ui_qif_import_load_another_cb (GtkButton *button, gpointer user_data);
@@ -2134,10 +2135,41 @@ gnc_ui_qif_import_account_prepare (GtkAssistant  *assistant, gpointer user_data)
 }
 
 
+/********************************************************************
+ * gnc_ui_qif_import_acct_enter_cb
+ *
+ * Invoked when the "enter" button is clicked on the acct entry.
+ ********************************************************************/
+void
+gnc_ui_qif_import_acct_enter_cb (GtkWidget * widget,
+                                 gpointer user_data)
+{
+    QIFImportWindow * wind = user_data;
+
+    GtkAssistant *assistant = GTK_ASSISTANT(wind->window);
+    gint num = gtk_assistant_get_current_page (assistant);
+    GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
+
+    const gchar * acct_name = gtk_entry_get_text (GTK_ENTRY(wind->acct_entry));
+
+    if (!acct_name || acct_name[0] == 0)
+    {
+        /* Disable the assistant "Next" Button */
+        gtk_assistant_set_page_complete (assistant, page, FALSE);
+    }
+    else
+    {
+        /* Enable the assistant "Next" Button and proceed */
+        gtk_assistant_set_page_complete (assistant, page, TRUE);
+        gtk_assistant_set_current_page (assistant, num + 1);
+    }
+}
+
+
 /********************************************************************
  * gnc_ui_qif_import_acct_valid_cb
  *
- * Invoked when the "next" button is clicked on the default acct page.
+ * Change signal for the acct entry to enable "Next" button.
  ********************************************************************/
 void
 gnc_ui_qif_import_acct_valid_cb (GtkWidget * widget,

commit 1dc99f1fa64c9d69a3a1a3441beee7033f47d1ca
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Tue May 7 15:49:12 2019 +0100

    Going back from 'Qif files you have loaded' crashes
    
    Once you have unloaded all files on the above page and go back Gnucash
    will crash as it was using an invalid file, check for selected_file in
    the ...import_account_prepare function.

diff --git a/gnucash/import-export/qif-imp/assistant-qif-import.c b/gnucash/import-export/qif-imp/assistant-qif-import.c
index 1fd99afbc..5505e3ce0 100644
--- a/gnucash/import-export/qif-imp/assistant-qif-import.c
+++ b/gnucash/import-export/qif-imp/assistant-qif-import.c
@@ -2104,21 +2104,32 @@ gnc_ui_qif_import_account_prepare (GtkAssistant  *assistant, gpointer user_data)
 
     if (wind->ask_date_format && wind->date_format)
         qif_import_reparse_dates (wind);
-   /* Determine the next page to display. */
-    if (scm_call_1 (check_from_acct, wind->selected_file) != SCM_BOOL_T)
-    {
-        /* There is an account name missing. Ask the user to provide one. */
-        SCM default_acct = scm_c_eval_string ("qif-file:path-to-accountname");
-        gchar * default_acctname = NULL;
 
-        default_acctname = gnc_scm_call_1_to_string (default_acct, wind->selected_file);
-        gtk_entry_set_text (GTK_ENTRY(wind->acct_entry), default_acctname);
-        g_free (default_acctname);
+    /* make sure there is a file selected, may of come back */
+    if (wind->selected_file == SCM_BOOL_F)
+    {
+        GtkAssistant *assistant = GTK_ASSISTANT(wind->window);
+        gtk_entry_set_text (GTK_ENTRY(wind->filename_entry), "");
+        gtk_assistant_set_current_page (assistant, 1);
     }
     else
     {
-        /* Skip ahead to the "loaded files" page. */
-        gtk_assistant_set_current_page (assistant, num + 1);
+        /* Determine the next page to display. */
+        if (scm_call_1 (check_from_acct, wind->selected_file) != SCM_BOOL_T)
+        {
+            /* There is an account name missing. Ask the user to provide one. */
+            SCM default_acct = scm_c_eval_string ("qif-file:path-to-accountname");
+            gchar * default_acctname = NULL;
+
+            default_acctname = gnc_scm_call_1_to_string (default_acct, wind->selected_file);
+            gtk_entry_set_text (GTK_ENTRY(wind->acct_entry), default_acctname);
+            g_free (default_acctname);
+        }
+        else
+        {
+            /* Skip ahead to the "loaded files" page. */
+            gtk_assistant_set_current_page (assistant, num + 1);
+        }
     }
 }
 

commit 29063fc9d27703d0c60e6019fdf031590d5b87c9
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Tue May 7 15:48:32 2019 +0100

    With no files in the Qif importer it is possible to proceed
    
    On the page 'Qif files you have loaded' it is possible to unload files
    and if all files are unloaded it was still possible to proceed so
    disable the next button if no files are in the list.

diff --git a/gnucash/import-export/qif-imp/assistant-qif-import.c b/gnucash/import-export/qif-imp/assistant-qif-import.c
index 6f71ac594..1fd99afbc 100644
--- a/gnucash/import-export/qif-imp/assistant-qif-import.c
+++ b/gnucash/import-export/qif-imp/assistant-qif-import.c
@@ -2101,6 +2101,7 @@ gnc_ui_qif_import_account_prepare (GtkAssistant  *assistant, gpointer user_data)
     gint num = gtk_assistant_get_current_page (assistant);
 
     SCM  check_from_acct = scm_c_eval_string ("qif-file:check-from-acct");
+
     if (wind->ask_date_format && wind->date_format)
         qif_import_reparse_dates (wind);
    /* Determine the next page to display. */
@@ -2251,12 +2252,19 @@ update_file_page (QIFImportWindow * wind)
     GtkTreePath *path;
     GtkTreeRowReference *reference = NULL;
 
+    GtkAssistant *assistant = GTK_ASSISTANT(wind->window);
+    gint num = gtk_assistant_get_current_page (assistant);
+    GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
+    gint num_of_files = 0;
+
     /* clear the list */
     view = GTK_TREE_VIEW(wind->selected_file_view);
     store = GTK_LIST_STORE(gtk_tree_view_get_model (view));
     gtk_list_store_clear (store);
     qif_file_path = scm_c_eval_string ("qif-file:path");
 
+    gtk_assistant_set_page_complete (assistant, page, FALSE);
+
     while (!scm_is_null (loaded_file_list))
     {
         gchar *row_text    = NULL;
@@ -2292,6 +2300,12 @@ update_file_page (QIFImportWindow * wind)
         }
         gtk_tree_row_reference_free (reference);
     }
+
+    /* get the number of files in the list */
+    num_of_files = gtk_tree_model_iter_n_children (GTK_TREE_MODEL(store), NULL);
+
+    if (num_of_files > 0)
+        gtk_assistant_set_page_complete (assistant, page, TRUE);
 }
 
 

commit bb49a177cfa226f8c9a630d5bf367912cf5a50d1
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Tue May 7 15:47:53 2019 +0100

    Bug 583277 - Ask for confirmation for cancelling QIF import

diff --git a/gnucash/import-export/qif-imp/assistant-qif-import.c b/gnucash/import-export/qif-imp/assistant-qif-import.c
index 2efd56743..6f71ac594 100644
--- a/gnucash/import-export/qif-imp/assistant-qif-import.c
+++ b/gnucash/import-export/qif-imp/assistant-qif-import.c
@@ -1352,6 +1352,7 @@ gnc_ui_qif_import_cancel_cb (GtkAssistant *gtkassistant, gpointer user_data)
     gint currentpage = gtk_assistant_get_current_page (gtkassistant);
     GtkWidget *mypage = gtk_assistant_get_nth_page (gtkassistant, currentpage);
     const char *pagename = gtk_buildable_get_name (GTK_BUILDABLE(mypage));
+    const char *fmt = _("Are you sure you want to cancel?");
 
     if (!g_strcmp0 (pagename, "summary_page"))
     {
@@ -1359,16 +1360,22 @@ gnc_ui_qif_import_cancel_cb (GtkAssistant *gtkassistant, gpointer user_data)
            invoke a cancel action. The import has finised at that point. */
         gnc_ui_qif_import_close_cb (gtkassistant, user_data);
     }
-    else if (wind->busy)
+    else
     {
-        /* Cancel any long-running Scheme operation. */
-        scm_c_eval_string ("(qif-import:cancel)");
+        if (!gnc_verify_dialog (GTK_WINDOW(gtkassistant), FALSE, "%s", fmt))
+            return;
+
+        if (wind->busy)
+        {
+            /* Cancel any long-running Scheme operation. */
+            scm_c_eval_string ("(qif-import:cancel)");
 
-        /* Wait for the busy flag to be lowered. */
-        g_timeout_add (200, cancel_timeout_cb, user_data);
+            /* Wait for the busy flag to be lowered. */
+            g_timeout_add (200, cancel_timeout_cb, user_data);
+        }
+        else
+            do_cancel (wind);
     }
-    else
-        do_cancel (wind);
 }
 
 

commit bca3bd379ed7d0e4e55ab95d06d23cce089f7a6a
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Tue May 7 15:47:04 2019 +0100

    Bug 642824 - Check for Placeholder Accounts in Qif Import
    
    Placeholder accounts do not allow transactions so when the account
    picker dialog is presented, add an error dialog for placeholder
    selection and a column to display that the account is a placeholder.

diff --git a/gnucash/gtkbuilder/dialog-account-picker.glade b/gnucash/gtkbuilder/dialog-account-picker.glade
index 6144047e4..545878147 100644
--- a/gnucash/gtkbuilder/dialog-account-picker.glade
+++ b/gnucash/gtkbuilder/dialog-account-picker.glade
@@ -1,11 +1,14 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.20.0 -->
+<!-- Generated with glade 3.22.1 -->
 <interface>
   <requires lib="gtk+" version="3.10"/>
   <object class="GtkWindow" id="preferences_window">
     <property name="visible">True</property>
     <property name="can_focus">False</property>
     <property name="title" translatable="yes">Preferences</property>
+    <child>
+      <placeholder/>
+    </child>
     <child>
       <object class="GtkGrid" id="prefs_table">
         <property name="visible">True</property>
@@ -141,6 +144,9 @@
     <property name="default_width">300</property>
     <property name="default_height">400</property>
     <property name="type_hint">dialog</property>
+    <child>
+      <placeholder/>
+    </child>
     <child internal-child="vbox">
       <object class="GtkBox" id="dialog-vbox1">
         <property name="visible">True</property>
@@ -248,6 +254,44 @@
                 <property name="position">1</property>
               </packing>
             </child>
+            <child>
+              <object class="GtkBox" id="placeholder_warning_hbox">
+                <property name="can_focus">False</property>
+                <property name="margin_left">6</property>
+                <property name="margin_right">6</property>
+                <property name="margin_top">6</property>
+                <property name="spacing">6</property>
+                <child>
+                  <object class="GtkImage" id="placeholder_warning_image">
+                    <property name="can_focus">False</property>
+                    <property name="halign">start</property>
+                    <property name="stock">gtk-dialog-warning</property>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">True</property>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="placeholder_warning_label">
+                    <property name="can_focus">False</property>
+                    <property name="halign">start</property>
+                    <property name="wrap">True</property>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">True</property>
+                    <property name="position">2</property>
+                  </packing>
+                </child>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">2</property>
+              </packing>
+            </child>
           </object>
           <packing>
             <property name="expand">True</property>
diff --git a/gnucash/import-export/qif-imp/dialog-account-picker.c b/gnucash/import-export/qif-imp/dialog-account-picker.c
index 88e4912b9..7e2e72bcf 100644
--- a/gnucash/import-export/qif-imp/dialog-account-picker.c
+++ b/gnucash/import-export/qif-imp/dialog-account-picker.c
@@ -45,6 +45,7 @@ enum account_cols
 {
     ACCOUNT_COL_NAME = 0,
     ACCOUNT_COL_FULLNAME,
+    ACCOUNT_COL_PLACEHOLDER,
     ACCOUNT_COL_CHECK,
     NUM_ACCOUNT_COLS
 };
@@ -53,8 +54,11 @@ struct _accountpickerdialog
 {
     GtkWidget       * dialog;
     GtkTreeView     * treeview;
+    GtkWidget       * pwhbox;
+    GtkWidget       * pwarning;
+    GtkWidget       * ok_button;
     QIFImportWindow * qif_wind;
-    SCM             map_entry;
+    SCM               map_entry;
     gchar           * selected_name;
 };
 
@@ -83,9 +87,11 @@ acct_tree_add_accts(SCM accts,
     gboolean     leafnode;
     SCM          current;
     gboolean     checked;
+    Account      * account;
 
     while (!scm_is_null(accts))
     {
+        gboolean placeholder = FALSE;
         current = SCM_CAR(accts);
 
         if (scm_is_null(current))
@@ -122,10 +128,15 @@ acct_tree_add_accts(SCM accts,
 
         checked = (SCM_CADR(current) == SCM_BOOL_T);
 
+        account = gnc_account_lookup_by_full_name (gnc_get_current_root_account(), acctname);
+        if (account)
+            placeholder = xaccAccountGetPlaceholder (account);
+
         gtk_tree_store_append(store, &iter, parent);
         gtk_tree_store_set(store, &iter,
                            ACCOUNT_COL_NAME, compname,
                            ACCOUNT_COL_FULLNAME, acctname,
+                           ACCOUNT_COL_PLACEHOLDER, placeholder,
                            ACCOUNT_COL_CHECK, checked,
                            -1);
 
@@ -267,15 +278,34 @@ gnc_ui_qif_account_picker_changed_cb(GtkTreeSelection *selection,
     SCM name_setter = scm_c_eval_string("qif-map-entry:set-gnc-name!");
     GtkTreeModel *model;
     GtkTreeIter iter;
+    gboolean placeholder;
+
+    gtk_widget_set_sensitive (wind->ok_button, TRUE); // enable OK button
 
     g_free(wind->selected_name);
     if (gtk_tree_selection_get_selected(selection, &model, &iter))
     {
         gtk_tree_model_get(model, &iter,
+                           ACCOUNT_COL_PLACEHOLDER, &placeholder,
                            ACCOUNT_COL_FULLNAME, &wind->selected_name,
                            -1);
         scm_call_2(name_setter, wind->map_entry,
                    wind->selected_name ? scm_from_utf8_string(wind->selected_name) : SCM_BOOL_F);
+
+        if (placeholder)
+        {
+            gchar *text = g_strdup_printf (_("The account %s is a placeholder account and does not allow "
+                                             "transactions. Please choose a different account."), wind->selected_name);
+
+            gtk_label_set_text (GTK_LABEL(wind->pwarning), text);
+            gnc_label_set_alignment (wind->pwarning, 0.0, 0.5);
+            gtk_widget_show_all (GTK_WIDGET(wind->pwhbox));
+            g_free (text);
+
+            gtk_widget_set_sensitive (wind->ok_button, FALSE); // disable OK button
+        }
+        else
+            gtk_widget_hide (GTK_WIDGET(wind->pwhbox)); // hide the placeholder warning
     }
     else
     {
@@ -318,6 +348,31 @@ gnc_ui_qif_account_picker_map_cb(GtkWidget * w, gpointer user_data)
 }
 
 
+/****************************************************************
+ * dialog_response_cb
+ *
+ ****************************************************************/
+static void
+dialog_response_cb (GtkDialog *dialog, gint response_id, gpointer user_data)
+{
+    QIFAccountPickerDialog * wind = user_data;
+    GtkTreeModel *model;
+    GtkTreeIter iter;
+    gboolean placeholder;
+
+    if (gtk_tree_selection_get_selected (gtk_tree_view_get_selection
+                                        (wind->treeview), &model, &iter))
+        gtk_tree_model_get (model, &iter,
+                            ACCOUNT_COL_PLACEHOLDER, &placeholder, -1);
+
+    if (response_id == GTK_RESPONSE_OK)
+    {
+        if (placeholder)
+            g_signal_stop_emission_by_name (dialog, "response");
+    }
+}
+
+
 /****************************************************************
  * qif_account_picker_dialog
  *
@@ -354,18 +409,21 @@ qif_account_picker_dialog(GtkWindow *parent, QIFImportWindow * qif_wind, SCM map
 
     wind->dialog     = GTK_WIDGET(gtk_builder_get_object (builder, "qif_import_account_picker_dialog"));
     wind->treeview   = GTK_TREE_VIEW(gtk_builder_get_object (builder, "account_tree"));
+    wind->pwhbox     = GTK_WIDGET(gtk_builder_get_object (builder, "placeholder_warning_hbox"));
+    wind->pwarning   = GTK_WIDGET(gtk_builder_get_object (builder, "placeholder_warning_label"));
+    wind->ok_button  = GTK_WIDGET(gtk_builder_get_object (builder, "okbutton"));
     wind->qif_wind   = qif_wind;
 
     gtk_window_set_transient_for (GTK_WINDOW (wind->dialog), parent);
 
     {
+        GtkTreeSelection *selection;
         GtkTreeStore *store;
         GtkCellRenderer *renderer;
         GtkTreeViewColumn *column;
-        GtkTreeSelection *selection;
 
         store = gtk_tree_store_new(NUM_ACCOUNT_COLS, G_TYPE_STRING, G_TYPE_STRING,
-                                   G_TYPE_BOOLEAN);
+                                   G_TYPE_BOOLEAN, G_TYPE_BOOLEAN);
         gtk_tree_view_set_model(wind->treeview, GTK_TREE_MODEL(store));
         g_object_unref(store);
 
@@ -378,6 +436,15 @@ qif_account_picker_dialog(GtkWindow *parent, QIFImportWindow * qif_wind, SCM map
         g_object_set(column, "expand", TRUE, NULL);
         gtk_tree_view_append_column(wind->treeview, column);
 
+        renderer = gtk_cell_renderer_toggle_new();
+        g_object_set(renderer, "activatable", FALSE, NULL);
+        column = gtk_tree_view_column_new_with_attributes(_("Placeholder?"),
+                 renderer,
+                 "active",
+                 ACCOUNT_COL_PLACEHOLDER,
+                 NULL);
+        gtk_tree_view_append_column(wind->treeview, column);
+
         renderer = gtk_cell_renderer_toggle_new();
         g_object_set(renderer, "activatable", FALSE, NULL);
         column = gtk_tree_view_column_new_with_attributes(_("New?"),
@@ -406,6 +473,9 @@ qif_account_picker_dialog(GtkWindow *parent, QIFImportWindow * qif_wind, SCM map
      * again after the window is mapped. */
     build_acct_tree(wind, wind->qif_wind);
 
+    g_signal_connect (wind->dialog, "response",
+                      G_CALLBACK (dialog_response_cb), wind);
+
     do
     {
         response = gtk_dialog_run(GTK_DIALOG(wind->dialog));

commit ac0eb0014132a7c29c8446dedbd4a591a78469c6
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Tue May 7 15:46:17 2019 +0100

    Bug 397927 - Save the window size/position for Qif Account picker dialog

diff --git a/gnucash/gschemas/org.gnucash.dialogs.import.generic.gschema.xml.in b/gnucash/gschemas/org.gnucash.dialogs.import.generic.gschema.xml.in
index 719ec4359..b9c75ae1e 100644
--- a/gnucash/gschemas/org.gnucash.dialogs.import.generic.gschema.xml.in
+++ b/gnucash/gschemas/org.gnucash.dialogs.import.generic.gschema.xml.in
@@ -42,6 +42,7 @@
     </key>
     <child name="match-picker" schema="org.gnucash.dialogs.import.generic.match-picker"/>
     <child name="transaction-list" schema="org.gnucash.dialogs.import.generic.transaction-list"/>
+    <child name="account-picker" schema="org.gnucash.dialogs.import.generic.account-picker"/>
   </schema>
 
   <schema id="org.gnucash.dialogs.import.generic.match-picker" path="/org/gnucash/dialogs/import/generic/match-picker/">
@@ -59,6 +60,16 @@
    </key>
   </schema>
 
+  <schema id="org.gnucash.dialogs.import.generic.account-picker" path="/org/gnucash/dialogs/import/generic/account-picker/">
+    <key name="last-geometry" type="(iiii)">
+      <default>(-1,-1,-1,-1)</default>
+      <summary>Last window position and size</summary>
+      <description>This setting describes the size and position of the window when it was last closed.
+        The numbers are the X and Y coordinates of the top left corner of the window
+        followed by the width and height of the window.</description>
+    </key>
+  </schema>
+
   <schema id="org.gnucash.dialogs.import.generic.transaction-list" path="/org/gnucash/dialogs/import/generic/transaction-list/">
     <key name="last-geometry" type="(iiii)">
       <default>(-1,-1,-1,-1)</default>
diff --git a/gnucash/gschemas/org.gnucash.dialogs.import.qif.gschema.xml.in b/gnucash/gschemas/org.gnucash.dialogs.import.qif.gschema.xml.in
index 8456bfe00..14f2cb14c 100644
--- a/gnucash/gschemas/org.gnucash.dialogs.import.qif.gschema.xml.in
+++ b/gnucash/gschemas/org.gnucash.dialogs.import.qif.gschema.xml.in
@@ -32,5 +32,16 @@
       <summary>Show documentation</summary>
       <description>Show some documentation-only pages in QIF Import assistant.</description>
     </key>
+    <child name="account-picker" schema="org.gnucash.dialogs.import.qif.account-picker"/>
+  </schema>
+
+  <schema id="org.gnucash.dialogs.import.qif.account-picker" path="/org/gnucash/dialogs/import/qif/account-picker/">
+    <key name="last-geometry" type="(iiii)">
+      <default>(-1,-1,-1,-1)</default>
+      <summary>Last window position and size</summary>
+      <description>This setting describes the size and position of the window when it was last closed.
+        The numbers are the X and Y coordinates of the top left corner of the window
+        followed by the width and height of the window.</description>
+    </key>
   </schema>
 </schemalist>
diff --git a/gnucash/import-export/import-account-matcher.c b/gnucash/import-export/import-account-matcher.c
index 6ee4e90a4..02546621a 100644
--- a/gnucash/import-export/import-account-matcher.c
+++ b/gnucash/import-export/import-account-matcher.c
@@ -40,6 +40,7 @@
 
 #include "gnc-commodity.h"
 #include "gnc-engine.h"
+#include "gnc-prefs.h"
 #include "gnc-tree-view-account.h"
 #include "gnc-ui.h"
 
@@ -47,6 +48,9 @@ static QofLogModule log_module = GNC_MOD_IMPORT;
 
 #define STATE_SECTION "dialogs/import/generic_matcher/account_matcher"
 
+#define GNC_PREFS_GROUP "dialogs.import.generic.account-picker"
+
+
 /*-******************************************************************\
  * Functions needed by gnc_import_select_account
  *
@@ -314,6 +318,9 @@ Account * gnc_import_select_account(GtkWidget *parent,
             gtk_window_set_transient_for (GTK_WINDOW (picker->dialog),
                                           GTK_WINDOW (parent));
 
+        gnc_restore_window_size (GNC_PREFS_GROUP,
+                                 GTK_WINDOW(picker->dialog), GTK_WINDOW (parent));
+
         /* Pack the content into the dialog vbox */
         pbox = GTK_WIDGET(gtk_builder_get_object (builder, "account_picker_vbox"));
         box = GTK_WIDGET(gtk_builder_get_object (builder, "account_picker_content"));
@@ -397,6 +404,7 @@ Account * gnc_import_select_account(GtkWidget *parent,
         while (response == GNC_RESPONSE_NEW);
 
         g_object_unref(G_OBJECT(builder));
+        gnc_save_window_size (GNC_PREFS_GROUP, GTK_WINDOW(picker->dialog));
         gtk_widget_destroy(picker->dialog);
     }
     else
diff --git a/gnucash/import-export/qif-imp/dialog-account-picker.c b/gnucash/import-export/qif-imp/dialog-account-picker.c
index d6def51f6..88e4912b9 100644
--- a/gnucash/import-export/qif-imp/dialog-account-picker.c
+++ b/gnucash/import-export/qif-imp/dialog-account-picker.c
@@ -33,11 +33,14 @@
 #include "dialog-utils.h"
 #include "assistant-qif-import.h"
 #include "gnc-gui-query.h"
+#include "gnc-prefs.h"
 #include "gnc-ui-util.h"
 #include "guile-mappings.h"
 #include "gnc-guile-utils.h"
 #include "gnc-ui.h" /* for GNC_RESPONSE_NEW */
 
+#define GNC_PREFS_GROUP   "dialogs.import.qif.account-picker"
+
 enum account_cols
 {
     ACCOUNT_COL_NAME = 0,
@@ -396,6 +399,9 @@ qif_account_picker_dialog(GtkWindow *parent, QIFImportWindow * qif_wind, SCM map
                            G_CALLBACK(gnc_ui_qif_account_picker_map_cb),
                            wind);
 
+    gnc_restore_window_size (GNC_PREFS_GROUP,
+                             GTK_WINDOW(wind->dialog), parent);
+
     /* this is to get the checkmarks set up right.. it will get called
      * again after the window is mapped. */
     build_acct_tree(wind, wind->qif_wind);
@@ -405,6 +411,7 @@ qif_account_picker_dialog(GtkWindow *parent, QIFImportWindow * qif_wind, SCM map
         response = gtk_dialog_run(GTK_DIALOG(wind->dialog));
     }
     while (response == GNC_RESPONSE_NEW);
+    gnc_save_window_size (GNC_PREFS_GROUP, GTK_WINDOW(wind->dialog));
     gtk_widget_destroy(wind->dialog);
     g_object_unref(G_OBJECT(builder));
 

commit b41cb2f5c20d4ebb688005c821f6b635d51a9ac8
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Tue May 7 15:45:34 2019 +0100

    Bug 797215 - Add sorting to QIF duplicates page

diff --git a/gnucash/gtkbuilder/assistant-qif-import.glade b/gnucash/gtkbuilder/assistant-qif-import.glade
index b5e469a41..af71d2047 100644
--- a/gnucash/gtkbuilder/assistant-qif-import.glade
+++ b/gnucash/gtkbuilder/assistant-qif-import.glade
@@ -1252,7 +1252,7 @@ Click "Next" to review the possible matches.</property>
             <property name="visible">True</property>
             <property name="can_focus">False</property>
             <property name="orientation">vertical</property>
-            <property name="spacing">2</property>
+            <property name="spacing">6</property>
             <child>
               <object class="GtkFrame" id="frame45">
                 <property name="visible">True</property>
diff --git a/gnucash/import-export/qif-imp/assistant-qif-import.c b/gnucash/import-export/qif-imp/assistant-qif-import.c
index 0166691fe..2efd56743 100644
--- a/gnucash/import-export/qif-imp/assistant-qif-import.c
+++ b/gnucash/import-export/qif-imp/assistant-qif-import.c
@@ -90,12 +90,18 @@ enum account_cols
     NUM_ACCOUNT_COLS
 };
 
+/* to simplify sorting and hence use the default sort function
+ * we store the date as an int64 and convert the gnc_numeric
+ * to a double which can be stored in the liststore.
+ */
 enum qif_trans_cols
 {
     QIF_TRANS_COL_INDEX = 0,
     QIF_TRANS_COL_DATE,
+    QIF_TRANS_COL_DATE_INT64, // used only for sorting
     QIF_TRANS_COL_DESCRIPTION,
     QIF_TRANS_COL_AMOUNT,
+    QIF_TRANS_COL_AMOUNT_DOUBLE, // used only for sorting
     QIF_TRANS_COL_CHECKED,
     NUM_QIF_TRANS_COLS
 };
@@ -1141,6 +1147,7 @@ refresh_old_transactions (QIFImportWindow * wind, int selection)
 
         while (!scm_is_null (possible_matches))
         {
+            gdouble amount_gd = 0;
             char datebuff [MAX_DATE_LENGTH + 1];
             memset (datebuff, 0, sizeof (datebuff));
             current_xtn = SCM_CAR(possible_matches);
@@ -1161,6 +1168,7 @@ refresh_old_transactions (QIFImportWindow * wind, int selection)
                     xaccPrintAmount (gnc_numeric_abs (xaccSplitGetValue (gnc_split)),
                                      gnc_account_print_info
                                      (xaccSplitGetAccount (gnc_split), TRUE));
+                amount_gd = gnc_numeric_to_double (xaccSplitGetValue(gnc_split));
             }
 
             gtk_list_store_append (store, &iter);
@@ -1170,8 +1178,10 @@ refresh_old_transactions (QIFImportWindow * wind, int selection)
             (store, &iter,
              QIF_TRANS_COL_INDEX, rownum++,
              QIF_TRANS_COL_DATE, datebuff,
+             QIF_TRANS_COL_DATE_INT64, xaccTransRetDatePosted(gnc_xtn), // used for sorting
              QIF_TRANS_COL_DESCRIPTION, xaccTransGetDescription (gnc_xtn),
              QIF_TRANS_COL_AMOUNT, amount_str,
+             QIF_TRANS_COL_AMOUNT_DOUBLE, amount_gd, // used for sorting
              QIF_TRANS_COL_CHECKED, selected != SCM_BOOL_F,
              -1);
 
@@ -3214,6 +3224,7 @@ gnc_ui_qif_import_duplicates_match_prepare (GtkAssistant *assistant,
         duplicates = wind->match_transactions;
         while (!scm_is_null (duplicates))
         {
+            gdouble amount_gd = 0;
             time64 send_time = 0;
             char datebuff [MAX_DATE_LENGTH + 1];
             memset (datebuff, 0, sizeof (datebuff));
@@ -3231,6 +3242,7 @@ gnc_ui_qif_import_duplicates_match_prepare (GtkAssistant *assistant,
                     xaccPrintAmount (gnc_numeric_abs (xaccSplitGetValue (gnc_split)),
                                      gnc_account_print_info
                                      (xaccSplitGetAccount (gnc_split), TRUE));
+                amount_gd = gnc_numeric_to_double (xaccSplitGetValue(gnc_split));
             }
             gtk_list_store_append (store, &iter);
             send_time = xaccTransRetDatePosted (gnc_xtn);
@@ -3238,10 +3250,11 @@ gnc_ui_qif_import_duplicates_match_prepare (GtkAssistant *assistant,
             gtk_list_store_set
             (store, &iter,
              QIF_TRANS_COL_INDEX, rownum++,
-             QIF_TRANS_COL_DATE,
-             datebuff,
+             QIF_TRANS_COL_DATE, datebuff,
+             QIF_TRANS_COL_DATE_INT64, send_time, // used for sorting
              QIF_TRANS_COL_DESCRIPTION, xaccTransGetDescription (gnc_xtn),
              QIF_TRANS_COL_AMOUNT, amount_str,
+             QIF_TRANS_COL_AMOUNT_DOUBLE, amount_gd, // used for sorting
              -1);
 
             duplicates = SCM_CDR(duplicates);
@@ -3591,18 +3604,28 @@ build_views (QIFImportWindow *wind)
 
     /* Set up the new transaction view */
     view = GTK_TREE_VIEW(wind->new_transaction_view);
-    store = gtk_list_store_new (NUM_QIF_TRANS_COLS, G_TYPE_INT, G_TYPE_STRING,
-                                G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN);
+    store = gtk_list_store_new (NUM_QIF_TRANS_COLS, G_TYPE_INT, G_TYPE_STRING, G_TYPE_INT64,
+                                G_TYPE_STRING, G_TYPE_STRING, G_TYPE_DOUBLE, G_TYPE_BOOLEAN);
     gtk_tree_view_set_model (view, GTK_TREE_MODEL(store));
+
+    /* default sort order */
+    gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE(store),
+                                          QIF_TRANS_COL_DATE_INT64,
+                                          GTK_SORT_ASCENDING);
     g_object_unref (store);
 
+    /* prevent the rows being dragged to a different order */
+    gtk_tree_view_set_reorderable (view, FALSE);
+
     renderer = gtk_cell_renderer_text_new ();
     column = gtk_tree_view_column_new_with_attributes (_("Date"),
              renderer,
              "text",
              QIF_TRANS_COL_DATE,
              NULL);
+    g_object_set (G_OBJECT(column), "reorderable", TRUE, "resizable", TRUE, NULL);
     gtk_tree_view_append_column (view, column);
+    gtk_tree_view_column_set_sort_column_id (column, QIF_TRANS_COL_DATE_INT64);
 
     renderer = gtk_cell_renderer_text_new ();
     column = gtk_tree_view_column_new_with_attributes (_("Description"),
@@ -3610,8 +3633,10 @@ build_views (QIFImportWindow *wind)
              "text",
              QIF_TRANS_COL_DESCRIPTION,
              NULL);
+    g_object_set (G_OBJECT(column), "reorderable", TRUE, "resizable", TRUE, NULL);
     gtk_tree_view_append_column (view, column);
     gtk_tree_view_column_set_expand(column, TRUE);
+    gtk_tree_view_column_set_sort_column_id (column, QIF_TRANS_COL_DESCRIPTION);
 
     renderer = gtk_cell_renderer_text_new ();
     column = gtk_tree_view_column_new_with_attributes (_("Amount"),
@@ -3619,7 +3644,9 @@ build_views (QIFImportWindow *wind)
              "text",
              QIF_TRANS_COL_AMOUNT,
              NULL);
+    g_object_set (G_OBJECT(column), "reorderable", TRUE, "resizable", TRUE, NULL);
     gtk_tree_view_append_column (view, column);
+    gtk_tree_view_column_set_sort_column_id (column, QIF_TRANS_COL_AMOUNT_DOUBLE);
 
     selection = gtk_tree_view_get_selection (view);
     g_signal_connect (selection, "changed",
@@ -3628,18 +3655,28 @@ build_views (QIFImportWindow *wind)
 
     /* Set up the old transaction view */
     view = GTK_TREE_VIEW(wind->old_transaction_view);
-    store = gtk_list_store_new (NUM_QIF_TRANS_COLS, G_TYPE_INT, G_TYPE_STRING,
-                                G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN);
+    store = gtk_list_store_new (NUM_QIF_TRANS_COLS, G_TYPE_INT, G_TYPE_STRING, G_TYPE_INT64,
+                                G_TYPE_STRING, G_TYPE_STRING, G_TYPE_DOUBLE, G_TYPE_BOOLEAN);
     gtk_tree_view_set_model (view, GTK_TREE_MODEL(store));
+
+    /* default sort order */
+    gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE(store),
+                                          QIF_TRANS_COL_DATE_INT64,
+                                          GTK_SORT_ASCENDING);
     g_object_unref (store);
 
+    /* prevent the rows being dragged to a different order */
+    gtk_tree_view_set_reorderable (view, FALSE);
+
     renderer = gtk_cell_renderer_text_new ();
     column = gtk_tree_view_column_new_with_attributes (_("Date"),
              renderer,
              "text",
              QIF_TRANS_COL_DATE,
              NULL);
+    g_object_set (G_OBJECT(column), "reorderable", TRUE, "resizable", TRUE, NULL);
     gtk_tree_view_append_column (view, column);
+    gtk_tree_view_column_set_sort_column_id (column, QIF_TRANS_COL_DATE_INT64);
 
     renderer = gtk_cell_renderer_text_new ();
     column = gtk_tree_view_column_new_with_attributes (_("Description"),
@@ -3647,8 +3684,10 @@ build_views (QIFImportWindow *wind)
              "text",
              QIF_TRANS_COL_DESCRIPTION,
              NULL);
+    g_object_set (G_OBJECT(column), "reorderable", TRUE, "resizable", TRUE, NULL);
     gtk_tree_view_append_column (view, column);
     gtk_tree_view_column_set_expand (column, TRUE);
+    gtk_tree_view_column_set_sort_column_id (column, QIF_TRANS_COL_DESCRIPTION);
 
     renderer = gtk_cell_renderer_text_new ();
     column = gtk_tree_view_column_new_with_attributes (_("Amount"),
@@ -3656,7 +3695,9 @@ build_views (QIFImportWindow *wind)
              "text",
              QIF_TRANS_COL_AMOUNT,
              NULL);
+    g_object_set (G_OBJECT(column), "reorderable", TRUE, "resizable", TRUE, NULL);
     gtk_tree_view_append_column (view, column);
+    gtk_tree_view_column_set_sort_column_id (column, QIF_TRANS_COL_AMOUNT_DOUBLE);
 
     renderer = gtk_cell_renderer_toggle_new ();
     column = gtk_tree_view_column_new_with_attributes (_("Match?"),

commit e353804d64e1fef93c9d13da860adff6d3058656
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Tue May 7 15:44:51 2019 +0100

    Rename some variables to be more notebook specific in previous assistant-qif-import.c change

diff --git a/gnucash/import-export/qif-imp/assistant-qif-import.c b/gnucash/import-export/qif-imp/assistant-qif-import.c
index e03412d68..0166691fe 100644
--- a/gnucash/import-export/qif-imp/assistant-qif-import.c
+++ b/gnucash/import-export/qif-imp/assistant-qif-import.c
@@ -147,6 +147,7 @@ struct _qifimportwindow
     /* Widgets on the commodity page. */
     gint        num_new_pages;
     GtkWidget * commodity_notebook;
+    GList     * commodity_notebook_pages;
     gint        timeout_id;
 
     /* Conversion progress page. */
@@ -162,8 +163,6 @@ struct _qifimportwindow
     /* Widgets on the summary page. */
     GtkWidget * summary_text;
 
-    GList     * commodity_pages;
-
     gboolean  show_doc_pages;
     gboolean  ask_date_format;
     gboolean  busy;
@@ -197,9 +196,9 @@ struct _qifimportwindow
     gchar    *date_format;
 };
 
-struct _qifassistantpage
+struct _qifnotebookpage
 {
-    GtkWidget     *page;
+    GtkWidget     *notebook_page;
     GtkWidget     *namespace_combo;
     GtkWidget     *name_entry;
     GtkWidget     *mnemonic_entry;
@@ -208,7 +207,7 @@ struct _qifassistantpage
     SCM            hash_key;
 };
 
-typedef struct _qifassistantpage QIFAssistantPage;
+typedef struct _qifnotebookpage QIFCommNotebookPage;
 
 static void gnc_ui_qif_import_assistant_destroy (GtkWidget *object, gpointer user_data);
 static void gnc_ui_qif_import_assistant_close_handler (gpointer user_data);
@@ -404,25 +403,25 @@ update_memo_page (QIFImportWindow * wind)
 static void
 gnc_ui_qif_import_commodity_destroy (QIFImportWindow * wind)
 {
-    GList              *pageptr;
-    GtkWidget          *gtkpage;
-    QIFAssistantPage   *page;
+    GList               *pageptr;
+    GtkWidget           *notebook_page;
+    QIFCommNotebookPage *comm_nb_page;
 
-    for (pageptr = wind->commodity_pages; pageptr; pageptr = pageptr->next)
+    for (pageptr = wind->commodity_notebook_pages; pageptr; pageptr = pageptr->next)
     {
-        gtkpage   = pageptr->data;
-        page      = g_object_get_data (G_OBJECT(gtkpage), "page_struct");
+        notebook_page = pageptr->data;
+        comm_nb_page  = g_object_get_data (G_OBJECT(notebook_page), "page_struct");
 
         /* Unprotect the Scheme hash key. */
-        scm_gc_unprotect_object (page->hash_key);
+        scm_gc_unprotect_object (comm_nb_page->hash_key);
 
         /* Free the memory allocated for the page's struct. */
-        g_free (page);
+        g_free (comm_nb_page);
     }
 
     /* Free the list of pages. */
-    g_list_free (wind->commodity_pages);
-    wind->commodity_pages = NULL;
+    g_list_free (wind->commodity_notebook_pages);
+    wind->commodity_notebook_pages = NULL;
 }
 
 
@@ -828,17 +827,16 @@ gnc_ui_qif_import_memo_select_cb (GtkTreeSelection *selection,
 /*********************************************
  * new_security_notebook_page
  *********************************************/
-static QIFAssistantPage *
+static QIFCommNotebookPage *
 new_security_notebook_page (SCM security_hash_key, gnc_commodity *comm, QIFImportWindow *wind)
 {
-
-    QIFAssistantPage *retval = g_new0 (QIFAssistantPage, 1);
+    QIFCommNotebookPage *comm_nb_page = g_new0(QIFCommNotebookPage, 1);
     GtkListStore *store;
     GtkWidget    *table;
     GtkWidget    *label;
     gchar        *title = NULL;
     const char   *str;
-    GtkWidget    *page;
+    GtkWidget    *notebook_page;
     GtkWidget    *notebook_label;
     GtkWidget    *entry;
     char         *name_tooltip =
@@ -853,15 +851,15 @@ new_security_notebook_page (SCM security_hash_key, gnc_commodity *comm, QIFImpor
           " enter a new one.");
 
     /* Make the page widget. */
-    page = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
-    gtk_box_set_homogeneous (GTK_BOX(page), FALSE);
-    retval->page = page;
-    g_object_set_data (G_OBJECT(retval->page), "page_struct", retval);
+    notebook_page = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
+    gtk_box_set_homogeneous (GTK_BOX (notebook_page), FALSE);
+    comm_nb_page->notebook_page = notebook_page;
+    g_object_set_data (G_OBJECT(notebook_page), "page_struct", comm_nb_page);
 
     /* Save the commodity and the hash table key. */
-    retval->commodity = comm;
-    retval->hash_key = security_hash_key;
-    scm_gc_protect_object (retval->hash_key);
+    comm_nb_page->commodity = comm;
+    comm_nb_page->hash_key = security_hash_key;
+    scm_gc_protect_object (comm_nb_page->hash_key);
 
     /* Set the page title. */
     str = gnc_commodity_get_mnemonic (comm);
@@ -872,11 +870,11 @@ new_security_notebook_page (SCM security_hash_key, gnc_commodity *comm, QIFImpor
     notebook_label = gtk_label_new (title);
     gnc_label_set_alignment (notebook_label, 0.0, 0.5);
     gtk_notebook_append_page (GTK_NOTEBOOK(wind->commodity_notebook),
-                              page, notebook_label);
+                              notebook_page, notebook_label);
     g_free (title);
 
-   /* set the page complete flag as on creation all fields will be OK */
-    retval->page_complete = TRUE;
+    /* set the page complete flag as on creation all fields will be OK */
+    comm_nb_page->page_complete = TRUE;
 
     /* Add all the widgets to the page. */
     table = gtk_grid_new ();
@@ -884,15 +882,15 @@ new_security_notebook_page (SCM security_hash_key, gnc_commodity *comm, QIFImpor
     gtk_grid_set_column_spacing (GTK_GRID(table), 12);
 
     /* Name entry */
-    retval->name_entry = gtk_entry_new ();
-    gtk_entry_set_text (GTK_ENTRY(retval->name_entry),
+    comm_nb_page->name_entry = gtk_entry_new ();
+    gtk_entry_set_text (GTK_ENTRY(comm_nb_page->name_entry),
                         gnc_commodity_get_fullname (comm));
     label = gtk_label_new_with_mnemonic (_("_Name or description:"));
-    gtk_label_set_mnemonic_widget (GTK_LABEL(label), retval->name_entry);
+    gtk_label_set_mnemonic_widget (GTK_LABEL(label), comm_nb_page->name_entry);
     gnc_label_set_alignment (label, 0, 0.5);
 
     gtk_widget_set_tooltip_text (label, name_tooltip);
-    gtk_widget_set_tooltip_text (retval->name_entry, name_tooltip);
+    gtk_widget_set_tooltip_text (comm_nb_page->name_entry, name_tooltip);
 
     gtk_grid_attach (GTK_GRID(table), label, 0, 0, 1, 1);
     gtk_widget_set_halign (label, GTK_ALIGN_FILL);
@@ -901,22 +899,22 @@ new_security_notebook_page (SCM security_hash_key, gnc_commodity *comm, QIFImpor
     gtk_widget_set_vexpand (label, FALSE);
     g_object_set (label, "margin", 0, NULL);
 
-    gtk_grid_attach (GTK_GRID(table), retval->name_entry, 1, 0, 1, 1);
+    gtk_grid_attach (GTK_GRID(table), comm_nb_page->name_entry, 1, 0, 1, 1);
 
-    g_signal_connect (retval->name_entry, "changed",
+    g_signal_connect (comm_nb_page->name_entry, "changed",
                       G_CALLBACK(gnc_ui_qif_import_comm_changed_cb), wind);
 
     /* Mnemonic entry */
-    retval->mnemonic_entry = gtk_entry_new ();
-    gtk_entry_set_text (GTK_ENTRY(retval->mnemonic_entry),
+    comm_nb_page->mnemonic_entry = gtk_entry_new ();
+    gtk_entry_set_text (GTK_ENTRY(comm_nb_page->mnemonic_entry),
                        gnc_commodity_get_mnemonic (comm));
     label = gtk_label_new_with_mnemonic (
                 _("_Ticker symbol or other abbreviation:"));
-    gtk_label_set_mnemonic_widget (GTK_LABEL(label), retval->mnemonic_entry);
+    gtk_label_set_mnemonic_widget (GTK_LABEL(label), comm_nb_page->mnemonic_entry);
     gnc_label_set_alignment (label, 0, 0.5);
 
     gtk_widget_set_tooltip_text (label, mnemonic_tooltip);
-    gtk_widget_set_tooltip_text (retval->mnemonic_entry, mnemonic_tooltip);
+    gtk_widget_set_tooltip_text (comm_nb_page->mnemonic_entry, mnemonic_tooltip);
 
     gtk_grid_attach (GTK_GRID(table), label, 0, 1, 1, 1);
     gtk_widget_set_halign (label, GTK_ALIGN_FILL);
@@ -925,32 +923,32 @@ new_security_notebook_page (SCM security_hash_key, gnc_commodity *comm, QIFImpor
     gtk_widget_set_vexpand (label, FALSE);
     g_object_set (label, "margin", 0, NULL);
 
-    gtk_grid_attach (GTK_GRID(table), retval->mnemonic_entry, 1, 1, 1, 1);
+    gtk_grid_attach (GTK_GRID(table), comm_nb_page->mnemonic_entry, 1, 1, 1, 1);
 
-    g_signal_connect (retval->mnemonic_entry, "changed",
+    g_signal_connect (comm_nb_page->mnemonic_entry, "changed",
                       G_CALLBACK(gnc_ui_qif_import_comm_changed_cb), wind);
 
     /* Namespace entry */
     store = gtk_list_store_new (1, G_TYPE_STRING);
-    retval->namespace_combo = gtk_combo_box_new_with_model_and_entry (GTK_TREE_MODEL(store));
+    comm_nb_page->namespace_combo = gtk_combo_box_new_with_model_and_entry (GTK_TREE_MODEL(store));
     g_object_unref (store);
 
-    entry = gtk_bin_get_child (GTK_BIN(retval->namespace_combo));
+    entry = gtk_bin_get_child (GTK_BIN(comm_nb_page->namespace_combo));
     gtk_widget_set_events (GTK_WIDGET(entry), GDK_FOCUS_CHANGE_MASK);
     g_signal_connect (G_OBJECT (entry), "changed",
                       G_CALLBACK(gnc_ui_qif_import_comm_namespace_changed_cb), wind);
 
     /* Set the column for the text */
-    gtk_combo_box_set_entry_text_column (GTK_COMBO_BOX(retval->namespace_combo), 0);
+    gtk_combo_box_set_entry_text_column (GTK_COMBO_BOX(comm_nb_page->namespace_combo), 0);
 
-    gnc_cbwe_add_completion (GTK_COMBO_BOX(retval->namespace_combo));
+    gnc_cbwe_add_completion (GTK_COMBO_BOX(comm_nb_page->namespace_combo));
     label = gtk_label_new_with_mnemonic (
                 _("_Exchange or abbreviation type:"));
-    gtk_label_set_mnemonic_widget (GTK_LABEL(label), retval->namespace_combo);
+    gtk_label_set_mnemonic_widget (GTK_LABEL(label), comm_nb_page->namespace_combo);
     gnc_label_set_alignment (label, 0, 0.5);
 
     gtk_widget_set_tooltip_text (label, namespace_tooltip);
-    gtk_widget_set_tooltip_text (retval->namespace_combo, namespace_tooltip);
+    gtk_widget_set_tooltip_text (comm_nb_page->namespace_combo, namespace_tooltip);
 
     gtk_grid_attach (GTK_GRID(table), label, 0, 2, 1, 1);
     gtk_widget_set_halign (label, GTK_ALIGN_FILL);
@@ -959,14 +957,11 @@ new_security_notebook_page (SCM security_hash_key, gnc_commodity *comm, QIFImpor
     gtk_widget_set_vexpand (label, FALSE);
     g_object_set (label, "margin", 0, NULL);
 
-    gtk_grid_attach (GTK_GRID(table), retval->namespace_combo, 1, 2, 1, 1);
-
-    gtk_container_set_border_width (GTK_CONTAINER(page), 12);
-
-    gtk_box_pack_start (GTK_BOX(page), table, FALSE, FALSE, 12);
-
+    gtk_grid_attach (GTK_GRID(table), comm_nb_page->namespace_combo, 1, 2, 1, 1);
+    gtk_container_set_border_width (GTK_CONTAINER(notebook_page), 12);
+    gtk_box_pack_start (GTK_BOX(notebook_page), table, FALSE, FALSE, 12);
     gtk_widget_show_all (GTK_WIDGET(wind->commodity_notebook));
-    return retval;
+    return comm_nb_page;
 }
 
 
@@ -982,16 +977,16 @@ prepare_security_pages (QIFImportWindow * wind)
     SCM   securities;
     SCM   comm_ptr_token;
 
-    GList              * current;
-    gnc_commodity      * commodity;
-    QIFAssistantPage   * new_page;
+    GList               * current;
+    gnc_commodity       * commodity;
+    QIFCommNotebookPage * new_comm_nb_page;
 
     /*
      * Make assistant pages for each new QIF security.
      */
     gnc_set_busy_cursor (NULL, TRUE);
     securities = wind->new_securities;
-    current = wind->commodity_pages;
+    current = wind->commodity_notebook_pages;
     while (!scm_is_null (securities) && (securities != SCM_BOOL_F))
     {
         if (current)
@@ -1012,13 +1007,13 @@ prepare_security_pages (QIFImportWindow * wind)
 #undef FUNC_NAME
 
             /* Build a new security notebook page. */
-            new_page = new_security_notebook_page (SCM_CAR(securities), commodity, wind);
+            new_comm_nb_page = new_security_notebook_page (SCM_CAR(securities), commodity, wind);
 
-            /* Add it to the list of security pages. */
-            wind->commodity_pages = g_list_append (wind->commodity_pages,
-                                                   new_page->page);
+            /* Add it to the list of security notebook pages. */
+            wind->commodity_notebook_pages = g_list_append (wind->commodity_notebook_pages,
+                                                            new_comm_nb_page->notebook_page);
 
-            gtk_widget_show_all (new_page->page);
+            gtk_widget_show_all (new_comm_nb_page->notebook_page);
         }
         wind->num_new_pages = wind->num_new_pages + 1;
         securities = SCM_CDR(securities);
@@ -1037,41 +1032,41 @@ prepare_security_pages (QIFImportWindow * wind)
 static void
 gnc_ui_qif_import_commodity_update (QIFImportWindow * wind)
 {
-    GList              *pageptr;
-    GtkWidget          *gtkpage;
-    QIFAssistantPage   *page;
-    const gchar        *mnemonic = NULL;
-    gchar              *name_space = NULL;
-    const gchar        *fullname = NULL;
-    gnc_commodity      *tab_commodity;
+    GList               *pageptr;
+    GtkWidget           *notebook_page;
+    QIFCommNotebookPage *comm_nb_page;
+    const gchar         *mnemonic = NULL;
+    gchar               *name_space = NULL;
+    const gchar         *fullname = NULL;
+    gnc_commodity       *tab_commodity;
 
-    for (pageptr = wind->commodity_pages; pageptr; pageptr = pageptr->next)
+    for (pageptr = wind->commodity_notebook_pages; pageptr; pageptr = pageptr->next)
     {
-        gtkpage   = pageptr->data;
-        page      = g_object_get_data (G_OBJECT(gtkpage), "page_struct");
+        notebook_page = pageptr->data;
+        comm_nb_page  = g_object_get_data (G_OBJECT(notebook_page), "page_struct");
 
         /* Get any changes from the commodity page. */
-        mnemonic  = gtk_entry_get_text (GTK_ENTRY(page->mnemonic_entry));
-        name_space = gnc_ui_namespace_picker_ns (page->namespace_combo);
-        fullname  = gtk_entry_get_text (GTK_ENTRY(page->name_entry));
+        mnemonic  = gtk_entry_get_text (GTK_ENTRY(comm_nb_page->mnemonic_entry));
+        name_space = gnc_ui_namespace_picker_ns (comm_nb_page->namespace_combo);
+        fullname  = gtk_entry_get_text (GTK_ENTRY(comm_nb_page->name_entry));
 
         /* Update the commodity with the new values. */
-        gnc_commodity_set_namespace (page->commodity, name_space);
-        gnc_commodity_set_fullname (page->commodity, fullname);
-        gnc_commodity_set_mnemonic (page->commodity, mnemonic);
+        gnc_commodity_set_namespace (comm_nb_page->commodity, name_space);
+        gnc_commodity_set_fullname (comm_nb_page->commodity, fullname);
+        gnc_commodity_set_mnemonic (comm_nb_page->commodity, mnemonic);
 
         /* Add the commodity to the commodity table (if it isn't a duplicate). */
-        tab_commodity = gnc_commodity_table_lookup (gnc_get_current_commodities (),
+        tab_commodity = gnc_commodity_table_lookup (gnc_get_current_commodities(),
                         name_space, mnemonic);
-        if (!tab_commodity || tab_commodity == page->commodity)
-            tab_commodity = gnc_commodity_table_insert (gnc_get_current_commodities (),
-                            page->commodity);
+        if (!tab_commodity || tab_commodity == comm_nb_page->commodity)
+            tab_commodity = gnc_commodity_table_insert (gnc_get_current_commodities(),
+                                                        comm_nb_page->commodity);
 
         /* Update the security hash table. */
         scm_hash_set_x (wind->security_hash,
-                       page->hash_key,
-                       SWIG_NewPointerObj (tab_commodity,
-                                           SWIG_TypeQuery ("_p_gnc_commodity"), 0));
+                        comm_nb_page->hash_key,
+                        SWIG_NewPointerObj (tab_commodity,
+                                            SWIG_TypeQuery("_p_gnc_commodity"), 0));
 
         g_free (name_space);
     }
@@ -1277,8 +1272,8 @@ static void
 do_cancel (QIFImportWindow * wind)
 {
     GList                *pageptr;
-    GtkWidget            *gtkpage;
-    QIFAssistantPage     *page;
+    GtkWidget            *notebook_page;
+    QIFCommNotebookPage  *comm_nb_page;
     gnc_commodity_table  *table;
 
     gnc_set_busy_cursor (NULL, TRUE);
@@ -1287,11 +1282,11 @@ do_cancel (QIFImportWindow * wind)
     gnc_ui_qif_import_convert_undo (wind);
 
     /* Remove any commodities created for assistant pages. */
-    for (pageptr = wind->commodity_pages; pageptr; pageptr = pageptr->next)
+    for (pageptr = wind->commodity_notebook_pages; pageptr; pageptr = pageptr->next)
     {
-        gtkpage   = pageptr->data;
-        page      = g_object_get_data (G_OBJECT(gtkpage), "page_struct");
-        gnc_commodity_destroy (page->commodity);
+        notebook_page = pageptr->data;
+        comm_nb_page = g_object_get_data (G_OBJECT(notebook_page), "page_struct");
+        gnc_commodity_destroy (comm_nb_page->commodity);
     }
 
     /* Remove any namespaces created by the user. */
@@ -2631,10 +2626,10 @@ gnc_ui_qif_import_commodity_notebook_update_combos (QIFImportWindow * wind, gboo
 {
     GList               *pageptr;
     GtkWidget           *notebook_page;
-    QIFAssistantPage    *comm_nb_page;
+    QIFCommNotebookPage *comm_nb_page;
     gboolean             pages_complete = TRUE;
 
-    for (pageptr = wind->commodity_pages; pageptr; pageptr = pageptr->next)
+    for (pageptr = wind->commodity_notebook_pages; pageptr; pageptr = pageptr->next)
     {
         const gchar *ns;
 
@@ -2673,10 +2668,10 @@ gnc_ui_qif_import_commodity_all_notebook_pages_complete (QIFImportWindow * wind)
 {
     GList               *pageptr;
     GtkWidget           *notebook_page;
-    QIFAssistantPage    *comm_nb_page;
+    QIFCommNotebookPage *comm_nb_page;
     gboolean             pages_complete = TRUE;
 
-    for (pageptr = wind->commodity_pages; pageptr; pageptr = pageptr->next)
+    for (pageptr = wind->commodity_notebook_pages; pageptr; pageptr = pageptr->next)
     {
         notebook_page = pageptr->data;
         comm_nb_page  = g_object_get_data (G_OBJECT(notebook_page), "page_struct");
@@ -2694,10 +2689,11 @@ gnc_ui_qif_import_commodity_all_notebook_pages_complete (QIFImportWindow * wind)
 void
 gnc_ui_qif_import_commodity_prepare (GtkAssistant *assistant, gpointer user_data)
 {
-    QIFImportWindow * wind = user_data;
-    gint num = gtk_assistant_get_current_page (assistant);
-    GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
-    gint total = gtk_assistant_get_n_pages (assistant);
+    QIFImportWindow *wind = user_data;
+    gint              num = gtk_assistant_get_current_page (assistant);
+    GtkWidget       *page = gtk_assistant_get_nth_page (assistant, num);
+    gint            total = gtk_assistant_get_n_pages (assistant);
+
     gtk_assistant_update_buttons_state (assistant);
 
     PINFO ("Total Number of Assistant Pages is %d", gtk_assistant_get_n_pages (assistant));
@@ -2736,34 +2732,34 @@ gnc_ui_qif_import_comm_valid (GtkAssistant *assistant, gpointer user_data)
     QIFImportWindow *    wind = user_data;
     gint                  num = gtk_notebook_get_current_page (GTK_NOTEBOOK(wind->commodity_notebook));
     GtkWidget * notebook_page = gtk_notebook_get_nth_page (GTK_NOTEBOOK(wind->commodity_notebook), num);
-    QIFAssistantPage   *qpage = g_object_get_data (G_OBJECT(notebook_page), "page_struct");
+    QIFCommNotebookPage * comm_nb_page = g_object_get_data (G_OBJECT(notebook_page), "page_struct");
 
     QofBook                 *book;
     gnc_commodity_table     *table;
     gnc_commodity_namespace *newns;
 
-    gchar       *name_space = gnc_ui_namespace_picker_ns (qpage->namespace_combo);
-    const gchar *name      = gtk_entry_get_text (GTK_ENTRY(qpage->name_entry));
-    const gchar *mnemonic  = gtk_entry_get_text (GTK_ENTRY(qpage->mnemonic_entry));
+    gchar       *name_space = gnc_ui_namespace_picker_ns (comm_nb_page->namespace_combo);
+    const gchar *name       = gtk_entry_get_text (GTK_ENTRY(comm_nb_page->name_entry));
+    const gchar *mnemonic   = gtk_entry_get_text (GTK_ENTRY(comm_nb_page->mnemonic_entry));
 
     /* set the page complete flag to TRUE to start with */
-    qpage->page_complete = TRUE;
+    comm_nb_page->page_complete = TRUE;
 
     if (!name || (name[0] == 0))
     {
-        qpage->page_complete = FALSE;
+        comm_nb_page->page_complete = FALSE;
         g_free (name_space);
         return FALSE;
     }
     else if (!mnemonic || (mnemonic[0] == 0))
     {
-        qpage->page_complete = FALSE;
+        comm_nb_page->page_complete = FALSE;
         g_free (name_space);
         return FALSE;
     }
     else if (!name_space || (name_space[0] == 0))
     {
-        qpage->page_complete = FALSE;
+        comm_nb_page->page_complete = FALSE;
         if (name_space)
             g_free (name_space);
         return FALSE;
@@ -2783,7 +2779,7 @@ gnc_ui_qif_import_comm_valid (GtkAssistant *assistant, gpointer user_data)
                             _("You must enter an existing national "
                               "currency or enter a different type."));
 
-        qpage->page_complete = FALSE;
+        comm_nb_page->page_complete = FALSE;
         g_free (name_space);
         return FALSE;
     }

commit bfbf2c1396b59ec6096b425621adecf9b96d7c87
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Tue May 7 15:44:04 2019 +0100

    Bug 797204 - Qif import Tradable commodities page
    
    This bug has two elements, the first is that when you have a large
    number of tradable commodities you get an assistant page for each one
    and if too many you loose site of the assistant buttons. To fix this a
    notebook was added to the tradable commodities assistant page with the
    individual commodities being added to notebook pages.
    
    The second part was that when editing these an intrusive dialogue was
    being raised that displayed the same information as the tooltip which
    blocked input. These were removed and the assistant next button enabled
    when all entries are valid.

diff --git a/gnucash/gtkbuilder/assistant-qif-import.glade b/gnucash/gtkbuilder/assistant-qif-import.glade
index b8ae01fbb..b5e469a41 100644
--- a/gnucash/gtkbuilder/assistant-qif-import.glade
+++ b/gnucash/gtkbuilder/assistant-qif-import.glade
@@ -32,6 +32,9 @@
     <signal name="cancel" handler="gnc_ui_qif_import_cancel_cb" swapped="no"/>
     <signal name="close" handler="gnc_ui_qif_import_close_cb" swapped="no"/>
     <signal name="prepare" handler="gnc_ui_qif_import_prepare_cb" swapped="no"/>
+    <child>
+      <placeholder/>
+    </child>
     <child>
       <object class="GtkLabel" id="start_page">
         <property name="visible">True</property>
@@ -983,25 +986,78 @@ In the following page, you will see the text that appears in the Payee and Memo
       </packing>
     </child>
     <child>
-      <object class="GtkBox" id="commodity_doc_page">
+      <object class="GtkBox" id="commodity_page">
         <property name="visible">True</property>
         <property name="can_focus">False</property>
         <property name="border_width">12</property>
         <property name="orientation">vertical</property>
         <child>
-          <object class="GtkLabel" id="label833">
+          <object class="GtkBox">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
-            <property name="label" translatable="yes">In the following pages you will be asked to provide information about stocks, mutual funds, and other investments that appear in the QIF file(s) you are importing. GnuCash needs some additional details about these investments that the QIF format does not provide. 
-
+            <property name="orientation">vertical</property>
+            <property name="spacing">6</property>
+            <child>
+              <object class="GtkLabel" id="label833">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="margin_bottom">12</property>
+                <property name="label" translatable="yes">Below you are asked to provide information about stocks, mutual funds, and other investments that appear in the QIF file(s) you are importing. GnuCash needs some additional details about these investments that the QIF format does not provide. 
+ 
 Each stock, mutual fund, or other investment must have a name and an abbreviation, such as a stock symbol. Because some unrelated investments have the same abbreviation, you also need to indicate what type of abbreviation you have entered. For example, you could select the exchange that assigned the symbol (NASDAQ, NYSE, etc.), or select an investment type.
 
 If you don't see your exchange listed, or none of the available choices are appropriate, you can enter a new one.</property>
-            <property name="wrap">True</property>
+                <property name="wrap">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLabel" id="label834">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="halign">start</property>
+                <property name="label" translatable="yes">Enter Information about...</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkNotebook" id="commodity_notebook">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="tab_pos">left</property>
+                <property name="scrollable">True</property>
+              </object>
+              <packing>
+                <property name="expand">True</property>
+                <property name="fill">True</property>
+                <property name="position">2</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLabel" id="label835">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="halign">start</property>
+                <property name="label" translatable="yes">All fields must be complete to continue...</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">3</property>
+              </packing>
+            </child>
           </object>
           <packing>
-            <property name="expand">False</property>
-            <property name="fill">False</property>
+            <property name="expand">True</property>
+            <property name="fill">True</property>
             <property name="position">0</property>
           </packing>
         </child>
diff --git a/gnucash/import-export/qif-imp/assistant-qif-import.c b/gnucash/import-export/qif-imp/assistant-qif-import.c
index 95b42c68c..e03412d68 100644
--- a/gnucash/import-export/qif-imp/assistant-qif-import.c
+++ b/gnucash/import-export/qif-imp/assistant-qif-import.c
@@ -146,6 +146,8 @@ struct _qifimportwindow
 
     /* Widgets on the commodity page. */
     gint        num_new_pages;
+    GtkWidget * commodity_notebook;
+    gint        timeout_id;
 
     /* Conversion progress page. */
     GtkWidget * convert_pause;
@@ -202,6 +204,7 @@ struct _qifassistantpage
     GtkWidget     *name_entry;
     GtkWidget     *mnemonic_entry;
     gnc_commodity *commodity;
+    gboolean       page_complete;
     SCM            hash_key;
 };
 
@@ -250,9 +253,9 @@ void gnc_ui_qif_import_memo_rematch_cb (GtkButton *button, gpointer user_data);
 
 void gnc_ui_qif_import_currency_prepare (GtkAssistant *assistant, gpointer user_data);
 
-void gnc_ui_qif_import_commodity_new_prepare (GtkAssistant *assistant, gpointer user_data);
-void gnc_ui_qif_import_commodity_doc_prepare (GtkAssistant *assistant, gpointer user_data);
+void gnc_ui_qif_import_commodity_prepare (GtkAssistant *assistant, gpointer user_data);
 void gnc_ui_qif_import_comm_changed_cb (GtkWidget *widget, gpointer user_data);
+void gnc_ui_qif_import_comm_namespace_changed_cb (GtkWidget *widget, gpointer user_data);
 
 void gnc_ui_qif_import_convert_progress_prepare (GtkAssistant *assistant, gpointer user_data);
 void gnc_ui_qif_import_convert_progress_pause_cb (GtkButton * button, gpointer user_data);
@@ -823,10 +826,10 @@ gnc_ui_qif_import_memo_select_cb (GtkTreeSelection *selection,
 
 
 /*********************************************
- * new_security_page
+ * new_security_notebook_page
  *********************************************/
 static QIFAssistantPage *
-new_security_page (SCM security_hash_key, gnc_commodity *comm, QIFImportWindow *wind)
+new_security_notebook_page (SCM security_hash_key, gnc_commodity *comm, QIFImportWindow *wind)
 {
 
     QIFAssistantPage *retval = g_new0 (QIFAssistantPage, 1);
@@ -836,6 +839,8 @@ new_security_page (SCM security_hash_key, gnc_commodity *comm, QIFImportWindow *
     gchar        *title = NULL;
     const char   *str;
     GtkWidget    *page;
+    GtkWidget    *notebook_label;
+    GtkWidget    *entry;
     char         *name_tooltip =
         _("Enter a name or short description, such as \"Red Hat Stock\".");
     char         *mnemonic_tooltip =
@@ -852,13 +857,6 @@ new_security_page (SCM security_hash_key, gnc_commodity *comm, QIFImportWindow *
     gtk_box_set_homogeneous (GTK_BOX(page), FALSE);
     retval->page = page;
     g_object_set_data (G_OBJECT(retval->page), "page_struct", retval);
-    page = retval->page;
-
-    /* Insert the new page */
-    gtk_assistant_insert_page (GTK_ASSISTANT(wind->window), page, 14);
-    gtk_assistant_set_page_type (GTK_ASSISTANT(wind->window), page, GTK_ASSISTANT_PAGE_PROGRESS);
-    gtk_assistant_set_page_complete (GTK_ASSISTANT(wind->window), page, TRUE);
-    gtk_assistant_update_buttons_state (GTK_ASSISTANT(wind->window));
 
     /* Save the commodity and the hash table key. */
     retval->commodity = comm;
@@ -868,14 +866,19 @@ new_security_page (SCM security_hash_key, gnc_commodity *comm, QIFImportWindow *
     /* Set the page title. */
     str = gnc_commodity_get_mnemonic (comm);
     str = str ? str : "";
-    title = _("Enter information about");
-    title =  g_strdup_printf ("%s \"%s\"", title, str);
-    gtk_assistant_set_page_title (GTK_ASSISTANT(wind->window), page, title);
+    title =  g_strdup_printf ("\"%s\"", str);
+
+    /* Insert the new notebook page */
+    notebook_label = gtk_label_new (title);
+    gnc_label_set_alignment (notebook_label, 0.0, 0.5);
+    gtk_notebook_append_page (GTK_NOTEBOOK(wind->commodity_notebook),
+                              page, notebook_label);
     g_free (title);
 
-    /*
-     * Add all the widgets to the page.
-     */
+   /* set the page complete flag as on creation all fields will be OK */
+    retval->page_complete = TRUE;
+
+    /* Add all the widgets to the page. */
     table = gtk_grid_new ();
     gtk_grid_set_row_spacing (GTK_GRID(table), 6);
     gtk_grid_set_column_spacing (GTK_GRID(table), 12);
@@ -932,6 +935,11 @@ new_security_page (SCM security_hash_key, gnc_commodity *comm, QIFImportWindow *
     retval->namespace_combo = gtk_combo_box_new_with_model_and_entry (GTK_TREE_MODEL(store));
     g_object_unref (store);
 
+    entry = gtk_bin_get_child (GTK_BIN(retval->namespace_combo));
+    gtk_widget_set_events (GTK_WIDGET(entry), GDK_FOCUS_CHANGE_MASK);
+    g_signal_connect (G_OBJECT (entry), "changed",
+                      G_CALLBACK(gnc_ui_qif_import_comm_namespace_changed_cb), wind);
+
     /* Set the column for the text */
     gtk_combo_box_set_entry_text_column (GTK_COMBO_BOX(retval->namespace_combo), 0);
 
@@ -957,6 +965,7 @@ new_security_page (SCM security_hash_key, gnc_commodity *comm, QIFImportWindow *
 
     gtk_box_pack_start (GTK_BOX(page), table, FALSE, FALSE, 12);
 
+    gtk_widget_show_all (GTK_WIDGET(wind->commodity_notebook));
     return retval;
 }
 
@@ -996,13 +1005,14 @@ prepare_security_pages (QIFImportWindow * wind)
             comm_ptr_token = scm_call_2 (hash_ref,
                                          wind->security_hash,
                                          SCM_CAR(securities));
-#define FUNC_NAME "new_security_page"
+
+#define FUNC_NAME "new_security_notebook_page"
             commodity = SWIG_MustGetPtr (comm_ptr_token,
                                          SWIG_TypeQuery ("_p_gnc_commodity"), 1, 0);
 #undef FUNC_NAME
 
-            /* Build a new security page. */
-            new_page = new_security_page (SCM_CAR(securities), commodity, wind);
+            /* Build a new security notebook page. */
+            new_page = new_security_notebook_page (SCM_CAR(securities), commodity, wind);
 
             /* Add it to the list of security pages. */
             wind->commodity_pages = g_list_append (wind->commodity_pages,
@@ -2565,7 +2575,7 @@ gnc_ui_qif_import_currency_prepare (GtkAssistant *assistant, gpointer user_data)
 
 
 /**************************************************
- * Page 13 - Commodity Doc. Page Procedures
+ * Page 13 - Commodity Page Procedures
  **************************************************/
 
 /****************************************************************
@@ -2611,11 +2621,78 @@ gnc_ui_qif_import_new_securities (QIFImportWindow * wind)
 
 
 /********************************************************************
- * gnc_ui_qif_import_commodity_doc_prepare
+ * gnc_ui_qif_import_commodity_notebook_update_combos
+ *
+ * Scans all commodity notebook pages to make sure all the name space
+ * combos are in sync
+ ********************************************************************/
+static void
+gnc_ui_qif_import_commodity_notebook_update_combos (QIFImportWindow * wind, gboolean init_combos)
+{
+    GList               *pageptr;
+    GtkWidget           *notebook_page;
+    QIFAssistantPage    *comm_nb_page;
+    gboolean             pages_complete = TRUE;
+
+    for (pageptr = wind->commodity_pages; pageptr; pageptr = pageptr->next)
+    {
+        const gchar *ns;
+
+        notebook_page = pageptr->data;
+        comm_nb_page = g_object_get_data (G_OBJECT(notebook_page), "page_struct");
+
+        /* Get any entered namespace. */
+        ns = gnc_ui_namespace_picker_ns (comm_nb_page->namespace_combo);
+
+        /* Update the namespaces available to select. */
+        if (!ns || !ns[0])
+        {
+            gnc_ui_update_namespace_picker (
+                comm_nb_page->namespace_combo,
+                gnc_commodity_get_namespace (comm_nb_page->commodity),
+                DIAG_COMM_ALL);
+
+            if(!init_combos)
+                gtk_entry_set_text (GTK_ENTRY(gtk_bin_get_child (
+                                    GTK_BIN(comm_nb_page->namespace_combo))), "");
+        }
+        else
+            gnc_ui_update_namespace_picker (comm_nb_page->namespace_combo, ns, DIAG_COMM_ALL);
+    }
+}
+
+
+/********************************************************************
+ * gnc_ui_qif_import_commodity_all_notebook_pages_complete
+ *
+ * Scans all commodity notebook pages for the page_complete flag and
+ * return TRUE if they are all complete
+ ********************************************************************/
+static gboolean
+gnc_ui_qif_import_commodity_all_notebook_pages_complete (QIFImportWindow * wind)
+{
+    GList               *pageptr;
+    GtkWidget           *notebook_page;
+    QIFAssistantPage    *comm_nb_page;
+    gboolean             pages_complete = TRUE;
+
+    for (pageptr = wind->commodity_pages; pageptr; pageptr = pageptr->next)
+    {
+        notebook_page = pageptr->data;
+        comm_nb_page  = g_object_get_data (G_OBJECT(notebook_page), "page_struct");
+
+        if (!comm_nb_page->page_complete)
+            pages_complete = FALSE;
+    }
+    return pages_complete;
+}
+
+
+/********************************************************************
++ * gnc_ui_qif_import_commodity_prepare
  ********************************************************************/
 void
-gnc_ui_qif_import_commodity_doc_prepare (GtkAssistant *assistant,
-        gpointer user_data)
+gnc_ui_qif_import_commodity_prepare (GtkAssistant *assistant, gpointer user_data)
 {
     QIFImportWindow * wind = user_data;
     gint num = gtk_assistant_get_current_page (assistant);
@@ -2626,7 +2703,8 @@ gnc_ui_qif_import_commodity_doc_prepare (GtkAssistant *assistant,
     PINFO ("Total Number of Assistant Pages is %d", gtk_assistant_get_n_pages (assistant));
 
     /* Enable the Assistant "Next" Button */
-    gtk_assistant_set_page_complete (assistant, page, TRUE);
+    gtk_assistant_set_page_complete (assistant, page,
+                                     gnc_ui_qif_import_commodity_all_notebook_pages_complete (wind));
 
     /* Jump to Summary page if load_stop TRUE */
     if (wind->load_stop)
@@ -2634,47 +2712,18 @@ gnc_ui_qif_import_commodity_doc_prepare (GtkAssistant *assistant,
 
     /* If there are new securities, prepare the security pages. */
     if (gnc_ui_qif_import_new_securities (wind))
-        prepare_security_pages(wind);
-    else
-        /* If there are no securities, jump the doc page */
-        gtk_assistant_set_current_page (assistant, num + 1);
-
-    /* Jump over doc page if show_doc_pages FALSE */
-    if (!wind->show_doc_pages)
-        gtk_assistant_set_current_page (assistant, num + 1);
-}
-
-
-/********************************************
- * Page xx - Commodity New Pages Procedures
- ********************************************/
-
-/********************************************
- * gnc_ui_qif_import_commodity_new_prepare
- *******************************************/
-void
-gnc_ui_qif_import_commodity_new_prepare (GtkAssistant *assistant,
-        gpointer user_data)
-{
-    gint num = gtk_assistant_get_current_page (assistant);
-    GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
-
-    QIFAssistantPage    *qpage = g_object_get_data (G_OBJECT(page), "page_struct");
-    const gchar         *ns;
-
-    g_return_if_fail (qpage != NULL);
+    {
+        wind->timeout_id = 0;
 
-    /* Get any entered namespace. */
-    ns = gnc_ui_namespace_picker_ns (qpage->namespace_combo);
+        /* add the commodity notebook pages */
+        prepare_security_pages (wind);
 
-    /* Update the namespaces available to select. */
-    if (!ns || !ns[0])
-        gnc_ui_update_namespace_picker (
-            qpage->namespace_combo,
-            gnc_commodity_get_namespace (qpage->commodity),
-            DIAG_COMM_ALL);
+        /* make sure all the namespace combos are in sync */
+        gnc_ui_qif_import_commodity_notebook_update_combos (wind, TRUE);
+    }
     else
-        gnc_ui_update_namespace_picker (qpage->namespace_combo, ns, DIAG_COMM_ALL);
+        /* If there are no securities, jump the commodity page */
+        gtk_assistant_set_current_page (assistant, num + 1);
 }
 
 
@@ -2684,10 +2733,10 @@ gnc_ui_qif_import_commodity_new_prepare (GtkAssistant *assistant,
 static gboolean
 gnc_ui_qif_import_comm_valid (GtkAssistant *assistant, gpointer user_data)
 {
-    QIFImportWindow *wind = user_data;
-    gint num = gtk_assistant_get_current_page (GTK_ASSISTANT(wind->window));
-    GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
-    QIFAssistantPage    *qpage = g_object_get_data (G_OBJECT(page), "page_struct");
+    QIFImportWindow *    wind = user_data;
+    gint                  num = gtk_notebook_get_current_page (GTK_NOTEBOOK(wind->commodity_notebook));
+    GtkWidget * notebook_page = gtk_notebook_get_nth_page (GTK_NOTEBOOK(wind->commodity_notebook), num);
+    QIFAssistantPage   *qpage = g_object_get_data (G_OBJECT(notebook_page), "page_struct");
 
     QofBook                 *book;
     gnc_commodity_table     *table;
@@ -2697,28 +2746,24 @@ gnc_ui_qif_import_comm_valid (GtkAssistant *assistant, gpointer user_data)
     const gchar *name      = gtk_entry_get_text (GTK_ENTRY(qpage->name_entry));
     const gchar *mnemonic  = gtk_entry_get_text (GTK_ENTRY(qpage->mnemonic_entry));
 
+    /* set the page complete flag to TRUE to start with */
+    qpage->page_complete = TRUE;
+
     if (!name || (name[0] == 0))
     {
-        gnc_warning_dialog (GTK_WINDOW(assistant), "%s",
-                            _("Enter a name or short description, such as \"Red Hat Stock\"."));
+        qpage->page_complete = FALSE;
         g_free (name_space);
         return FALSE;
     }
     else if (!mnemonic || (mnemonic[0] == 0))
     {
-        gnc_warning_dialog (GTK_WINDOW(assistant), "%s",
-                            _("Enter the ticker symbol or other well known abbreviation, such as"
-                              " \"RHT\". If there isn't one, or you don't know it, create your own."));
+        qpage->page_complete = FALSE;
         g_free (name_space);
         return FALSE;
     }
     else if (!name_space || (name_space[0] == 0))
     {
-        gnc_warning_dialog (GTK_WINDOW(assistant), "%s",
-                            _("Select the exchange on which the symbol is traded, or select the"
-                              " type of investment (such as FUND for mutual funds.) If you don't"
-                              " see your exchange or an appropriate investment type, you can"
-                              " enter a new one."));
+        qpage->page_complete = FALSE;
         if (name_space)
             g_free (name_space);
         return FALSE;
@@ -2738,6 +2783,7 @@ gnc_ui_qif_import_comm_valid (GtkAssistant *assistant, gpointer user_data)
                             _("You must enter an existing national "
                               "currency or enter a different type."));
 
+        qpage->page_complete = FALSE;
         g_free (name_space);
         return FALSE;
     }
@@ -2760,7 +2806,10 @@ gnc_ui_qif_import_comm_valid (GtkAssistant *assistant, gpointer user_data)
     else
         g_free (name_space);
 
-    return TRUE;
+    /* make sure all the namespace combos are in sync */
+    gnc_ui_qif_import_commodity_notebook_update_combos (wind, FALSE);
+
+    return gnc_ui_qif_import_commodity_all_notebook_pages_complete (wind);
 }
 
 
@@ -2775,7 +2824,42 @@ gnc_ui_qif_import_comm_changed_cb (GtkWidget *widget, gpointer user_data)
     gint num = gtk_assistant_get_current_page (assistant);
     GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
 
-    gtk_assistant_set_page_complete (assistant, page, gnc_ui_qif_import_comm_valid (assistant, user_data));
+    gtk_assistant_set_page_complete (assistant, page,
+                                     gnc_ui_qif_import_comm_valid (assistant, user_data));
+}
+
+
+static gboolean
+do_page_check (gpointer user_data)
+{
+    QIFImportWindow *wind = user_data;
+    GtkAssistant *assistant = GTK_ASSISTANT(wind->window);
+    gint num = gtk_assistant_get_current_page (assistant);
+    GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
+
+    gtk_assistant_set_page_complete (assistant, page,
+                                     gnc_ui_qif_import_comm_valid (GTK_ASSISTANT(wind->assistant), wind));
+
+    wind->timeout_id = 0;
+    return FALSE;
+}
+
+
+/**********************************************
+ * gnc_ui_qif_import_comm_namespace_changed_cb
+ **********************************************/
+void
+gnc_ui_qif_import_comm_namespace_changed_cb (GtkWidget *widget, gpointer user_data)
+{
+    QIFImportWindow *wind = user_data;
+
+    if (wind->timeout_id)
+        g_source_remove (wind->timeout_id);
+
+    /* delay the page check while typing in the combo entry, this should
+     * reduce the number of false entries as new name spaces are typed, its
+     * not really a problem as name spaces created but not used do not get imported. */
+    wind->timeout_id = g_timeout_add (500, (GSourceFunc)do_page_check, wind);
 }
 
 
@@ -3363,15 +3447,10 @@ void gnc_ui_qif_import_prepare_cb (GtkAssistant  *assistant, GtkWidget *page,
         /* Current page is Currency page */
         gnc_ui_qif_import_currency_prepare (assistant, user_data);
     }
-    else if (!g_strcmp0 (pagename, "commodity_doc_page"))
-    {
-        /* Current page is Commodity Doc. page */
-        gnc_ui_qif_import_commodity_doc_prepare (assistant, user_data);
-    }
     else if (!g_strcmp0 (pagename, "commodity_page"))
     {
         /* Current page is Commodity page */
-        /* gnc_ui_qif_import_commodity_prepare (assistant, user_data); */
+        gnc_ui_qif_import_commodity_prepare (assistant, user_data);
     }
     else if (!g_strcmp0 (pagename, "convert_progress_page"))
     {
@@ -3398,11 +3477,6 @@ void gnc_ui_qif_import_prepare_cb (GtkAssistant  *assistant, GtkWidget *page,
         /* Current page is the summary page */
         gnc_ui_qif_import_summary_page_prepare (assistant, user_data);
     }
-    else
-    {
-        /* Current page is a new commodity page */
-        gnc_ui_qif_import_commodity_new_prepare (assistant, user_data);
-    }
 }
 
 
@@ -3435,6 +3509,7 @@ get_assistant_widgets (QIFImportWindow *wind, GtkBuilder *builder)
     wind->currency_picker    = GTK_WIDGET(gtk_builder_get_object (builder, "currency_comboboxentry"));
     wind->book_option_label  = GTK_WIDGET(gtk_builder_get_object (builder, "book_option_label"));
     wind->book_option_message = GTK_WIDGET(gtk_builder_get_object (builder, "book_option_message_label"));
+    wind->commodity_notebook = GTK_WIDGET(gtk_builder_get_object (builder, "commodity_notebook"));
     wind->acct_view          = GTK_WIDGET(gtk_builder_get_object (builder, "account_page_view"));
     wind->acct_view_count    = GTK_WIDGET(gtk_builder_get_object (builder, "account_page_count"));
     wind->acct_view_btn      = GTK_WIDGET(gtk_builder_get_object (builder, "account_page_change"));

commit b05506ca7242f1ab501c6e5f84464bae63a33acc
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Tue May 7 15:43:21 2019 +0100

    Reformat assistant-qif-import.c source file part4/4

diff --git a/gnucash/import-export/qif-imp/assistant-qif-import.c b/gnucash/import-export/qif-imp/assistant-qif-import.c
index 18bc3a4ec..95b42c68c 100644
--- a/gnucash/import-export/qif-imp/assistant-qif-import.c
+++ b/gnucash/import-export/qif-imp/assistant-qif-import.c
@@ -2845,7 +2845,8 @@ gnc_ui_qif_import_convert_progress_start_cb (GtkButton * button,
                                        0);
 
     /* The default currency. */
-    const gchar *currname = gtk_entry_get_text (GTK_ENTRY(gtk_bin_get_child (GTK_BIN(GTK_COMBO_BOX(wind->currency_picker)))));
+    const gchar *currname = gtk_entry_get_text (GTK_ENTRY(gtk_bin_get_child (
+                                                GTK_BIN(GTK_COMBO_BOX(wind->currency_picker)))));
 
     /* Raise the busy flag so the assistant can't be canceled unexpectedly. */
     wind->busy = TRUE;
@@ -3023,7 +3024,7 @@ gnc_ui_qif_import_convert_progress_start_cb (GtkButton * button,
  * Prepare the data conversion progress page for display.
  ********************************************************************/
 void
-gnc_ui_qif_import_convert_progress_prepare(GtkAssistant *assistant,
+gnc_ui_qif_import_convert_progress_prepare (GtkAssistant *assistant,
         gpointer user_data)
 {
     QIFImportWindow   *wind = user_data;
@@ -3031,19 +3032,21 @@ gnc_ui_qif_import_convert_progress_prepare(GtkAssistant *assistant,
     GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
 
     /* Recompute assistant Buttons */
-    gtk_assistant_update_buttons_state( assistant );
+    gtk_assistant_update_buttons_state (assistant);
 
     /* Reset the progress display. */
-    gnc_progress_dialog_set_primary(wind->convert_progress, "");
-    gnc_progress_dialog_set_secondary(wind->convert_progress,
-                                      _("When you press the Start Button, GnuCash will import your QIF data. If there are no errors or warnings, you will automatically proceed to the next step. Otherwise, the details will be shown below for your review."));
-    gnc_progress_dialog_set_sub(wind->convert_progress, " ");
-    gnc_progress_dialog_reset_value(wind->convert_progress);
-    gnc_progress_dialog_reset_log(wind->convert_progress);
+    gnc_progress_dialog_set_primary (wind->convert_progress, "");
+    gnc_progress_dialog_set_secondary (wind->convert_progress,
+            _("When you press the Start Button, GnuCash will import your QIF data. "
+              "If there are no errors or warnings, you will automatically proceed to "
+              "the next step. Otherwise, the details will be shown below for your review."));
+    gnc_progress_dialog_set_sub (wind->convert_progress, " ");
+    gnc_progress_dialog_reset_value (wind->convert_progress);
+    gnc_progress_dialog_reset_log (wind->convert_progress);
 
     /* Set Pause and Start buttons */
-    gtk_widget_set_sensitive(wind->convert_pause, FALSE);
-    gtk_widget_set_sensitive(wind->convert_start, TRUE);
+    gtk_widget_set_sensitive (wind->convert_pause, FALSE);
+    gtk_widget_set_sensitive (wind->convert_start, TRUE);
 
     /* Disable the assistant "Next" button */
     gtk_assistant_set_page_complete (assistant, page, FALSE);
@@ -3051,7 +3054,7 @@ gnc_ui_qif_import_convert_progress_prepare(GtkAssistant *assistant,
     /* Before creating transactions, if this is a new book, let user specify
      * book options, since they affect how transactions are created */
     if (wind->new_book)
-        wind->new_book = gnc_new_book_option_display(wind->window);
+        wind->new_book = gnc_new_book_option_display (wind->window);
 }
 
 
@@ -3072,22 +3075,22 @@ gnc_ui_qif_import_duplicates_doc_prepare (GtkAssistant *assistant,
     gint total = gtk_assistant_get_n_pages (assistant);
     gtk_assistant_update_buttons_state (assistant);
 
-    PINFO("Total Number of Assistant Pages is %d", gtk_assistant_get_n_pages (assistant));
+    PINFO ("Total Number of Assistant Pages is %d", gtk_assistant_get_n_pages (assistant));
 
     /* Enable the Assistant "Next" Button */
     gtk_assistant_set_page_complete (assistant, page, TRUE);
 
     /* Jump to Summary page if load_stop TRUE */
     if (wind->load_stop)
-        gtk_assistant_set_current_page (assistant, total - 1 );
+        gtk_assistant_set_current_page (assistant, total - 1);
 
     /* Jump over doc page if show_doc_pages FALSE */
     if (!wind->show_doc_pages)
-        gtk_assistant_set_current_page (assistant, num + 1 );
+        gtk_assistant_set_current_page (assistant, num + 1);
 
     /* Don't show doc page if there are no duplicates */
-    if (scm_is_null(wind->match_transactions))
-        gtk_assistant_set_current_page (assistant, num + 1 );
+    if (scm_is_null (wind->match_transactions))
+        gtk_assistant_set_current_page (assistant, num + 1);
 }
 
 
@@ -3118,58 +3121,58 @@ gnc_ui_qif_import_duplicates_match_prepare (GtkAssistant *assistant,
     const gchar      *amount_str;
     int               rownum = 0;
 
-    if (!scm_is_null(wind->match_transactions))
+    if (!scm_is_null (wind->match_transactions))
     {
         view = GTK_TREE_VIEW(wind->new_transaction_view);
-        store = GTK_LIST_STORE(gtk_tree_view_get_model(view));
-        gtk_list_store_clear(store);
+        store = GTK_LIST_STORE(gtk_tree_view_get_model (view));
+        gtk_list_store_clear (store);
 
-        if (!scm_is_list(wind->match_transactions))
+        if (!scm_is_list (wind->match_transactions))
             return;
 
         /* Loop through the list of new, potentially duplicate transactions. */
         duplicates = wind->match_transactions;
-        while (!scm_is_null(duplicates))
+        while (!scm_is_null (duplicates))
         {
             time64 send_time = 0;
-            char datebuff[MAX_DATE_LENGTH + 1];
-            memset (datebuff, 0, sizeof(datebuff));
+            char datebuff [MAX_DATE_LENGTH + 1];
+            memset (datebuff, 0, sizeof (datebuff));
             current_xtn = SCM_CAAR(duplicates);
 #define FUNC_NAME "xaccTransCountSplits"
-            gnc_xtn = SWIG_MustGetPtr(current_xtn,
-                                      SWIG_TypeQuery("_p_Transaction"), 1, 0);
+            gnc_xtn = SWIG_MustGetPtr (current_xtn,
+                                       SWIG_TypeQuery ("_p_Transaction"), 1, 0);
 #undef FUNC_NAME
-            if (xaccTransCountSplits(gnc_xtn) > 2)
+            if (xaccTransCountSplits (gnc_xtn) > 2)
                 amount_str = _("(split)");
             else
             {
-                gnc_split = xaccTransGetSplit(gnc_xtn, 0);
+                gnc_split = xaccTransGetSplit (gnc_xtn, 0);
                 amount_str =
-                    xaccPrintAmount(gnc_numeric_abs(xaccSplitGetValue(gnc_split)),
-                                    gnc_account_print_info
-                                    (xaccSplitGetAccount(gnc_split), TRUE));
+                    xaccPrintAmount (gnc_numeric_abs (xaccSplitGetValue (gnc_split)),
+                                     gnc_account_print_info
+                                     (xaccSplitGetAccount (gnc_split), TRUE));
             }
-            gtk_list_store_append(store, &iter);
-            send_time = xaccTransRetDatePosted(gnc_xtn);
-            qof_print_date_buff (datebuff, sizeof(datebuff), send_time);
+            gtk_list_store_append (store, &iter);
+            send_time = xaccTransRetDatePosted (gnc_xtn);
+            qof_print_date_buff (datebuff, sizeof (datebuff), send_time);
             gtk_list_store_set
             (store, &iter,
              QIF_TRANS_COL_INDEX, rownum++,
              QIF_TRANS_COL_DATE,
              datebuff,
-             QIF_TRANS_COL_DESCRIPTION, xaccTransGetDescription(gnc_xtn),
+             QIF_TRANS_COL_DESCRIPTION, xaccTransGetDescription (gnc_xtn),
              QIF_TRANS_COL_AMOUNT, amount_str,
              -1);
 
             duplicates = SCM_CDR(duplicates);
         }
-        selection = gtk_tree_view_get_selection(view);
-        path = gtk_tree_path_new_from_indices(0, -1);
-        gtk_tree_selection_select_path(selection, path);
-        gtk_tree_path_free(path);
+        selection = gtk_tree_view_get_selection (view);
+        path = gtk_tree_path_new_from_indices (0, -1);
+        gtk_tree_selection_select_path (selection, path);
+        gtk_tree_path_free (path);
     }
     else
-        gtk_assistant_set_current_page (assistant, num + 1 );
+        gtk_assistant_set_current_page (assistant, num + 1);
 
     /* Enable the Assistant "Next" Button */
     gtk_assistant_set_page_complete (assistant, page, TRUE);
@@ -3206,48 +3209,48 @@ gnc_ui_qif_import_finish_cb (GtkAssistant *assistant,
 {
     QIFImportWindow * wind = user_data;
 
-    SCM save_map_prefs = scm_c_eval_string("qif-import:save-map-prefs");
-    SCM cat_and_merge = scm_c_eval_string("gnc:account-tree-catenate-and-merge");
-    SCM prune_xtns = scm_c_eval_string("gnc:prune-matching-transactions");
+    SCM save_map_prefs = scm_c_eval_string ("qif-import:save-map-prefs");
+    SCM cat_and_merge = scm_c_eval_string ("gnc:account-tree-catenate-and-merge");
+    SCM prune_xtns = scm_c_eval_string ("gnc:prune-matching-transactions");
     SCM scm_result;
 
     GncPluginPage *page;
     gboolean acct_tree_found = FALSE;
 
-    gnc_suspend_gui_refresh();
+    gnc_suspend_gui_refresh ();
 
     /* Prune any imported transactions that were determined to be duplicates. */
     if (wind->match_transactions != SCM_BOOL_F)
-        scm_call_1(prune_xtns, wind->match_transactions);
+        scm_call_1 (prune_xtns, wind->match_transactions);
 
     /* Merge the imported account tree with the existing one. */
     if (wind->imported_account_tree != SCM_BOOL_F)
-        scm_call_2(cat_and_merge,
-                   scm_c_eval_string("(gnc-get-current-root-account)"),
+        scm_call_2 (cat_and_merge,
+                   scm_c_eval_string ("(gnc-get-current-root-account)"),
                    wind->imported_account_tree);
 
-    gnc_resume_gui_refresh();
+    gnc_resume_gui_refresh ();
 
     /* Save the user's mapping preferences. */
-    scm_result = scm_apply(save_map_prefs,
-                           SCM_LIST5(wind->acct_map_info, wind->cat_map_info,
-                                     wind->memo_map_info, wind->security_hash,
-                                     wind->security_prefs),
-                           SCM_EOL);
+    scm_result = scm_apply (save_map_prefs,
+                            SCM_LIST5 (wind->acct_map_info, wind->cat_map_info,
+                                      wind->memo_map_info, wind->security_hash,
+                                      wind->security_prefs),
+                            SCM_EOL);
 
     if (scm_result == SCM_BOOL_F)
-        gnc_warning_dialog(GTK_WINDOW (assistant), "%s",
-                           _("GnuCash was unable to save your mapping preferences."));
+        gnc_warning_dialog (GTK_WINDOW(assistant), "%s",
+                            _("GnuCash was unable to save your mapping preferences."));
 
     /* Open an account tab in the main window if one doesn't exist already. */
-    gnc_main_window_foreach_page(gnc_ui_qif_import_check_acct_tree,
-                                 &acct_tree_found);
+    gnc_main_window_foreach_page (gnc_ui_qif_import_check_acct_tree,
+                                  &acct_tree_found);
 
     wind->acct_tree_found = acct_tree_found;
     if (!acct_tree_found)
     {
-        page = gnc_plugin_page_account_tree_new();
-        gnc_main_window_open_page(NULL, page);
+        page = gnc_plugin_page_account_tree_new ();
+        gnc_main_window_open_page (NULL, page);
     }
 }
 
@@ -3270,13 +3273,13 @@ gnc_ui_qif_import_summary_page_prepare (GtkAssistant *assistant,
     gchar *text;
 
     if (wind->load_stop)
-        text = g_strdup_printf(_("There was a problem with the import."));
+        text = g_strdup_printf (_("There was a problem with the import."));
     else
-        text = g_strdup_printf(_("QIF Import Completed."));
+        text = g_strdup_printf (_("QIF Import Completed."));
 
-    gtk_label_set_markup(GTK_LABEL(wind->summary_text), g_strdup_printf("<span size=\"large\"><b>%s</b></span>", text));
+    gtk_label_set_markup (GTK_LABEL(wind->summary_text), g_strdup_printf ("<span size=\"large\"><b>%s</b></span>", text));
 
-    g_free(text);
+    g_free (text);
 
     /* Enable the Assistant "Next" Button */
     gtk_assistant_set_page_complete (assistant, page, TRUE);
@@ -3289,11 +3292,11 @@ gnc_ui_qif_import_summary_page_prepare (GtkAssistant *assistant,
 void gnc_ui_qif_import_prepare_cb (GtkAssistant  *assistant, GtkWidget *page,
                                    gpointer user_data)
 {
-    gint currentpage = gtk_assistant_get_current_page(assistant);
+    gint currentpage = gtk_assistant_get_current_page (assistant);
     GtkWidget *mypage = gtk_assistant_get_nth_page (assistant, currentpage);
-    const char *pagename = gtk_buildable_get_name(GTK_BUILDABLE(mypage));
+    const char *pagename = gtk_buildable_get_name (GTK_BUILDABLE(mypage));
 
-    PINFO("Builder Page Name is %s", gtk_buildable_get_name(GTK_BUILDABLE(mypage)));
+    PINFO ("Builder Page Name is %s", gtk_buildable_get_name (GTK_BUILDABLE(mypage)));
 
     if (!g_strcmp0 (pagename, "start_page"))
     {
@@ -3409,17 +3412,17 @@ void gnc_ui_qif_import_prepare_cb (GtkAssistant  *assistant, GtkWidget *page,
  * Get all builder-defined widgets that need to be actively managed.
  ********************************************************************/
 static void
-get_assistant_widgets(QIFImportWindow *wind, GtkBuilder *builder)
+get_assistant_widgets (QIFImportWindow *wind, GtkBuilder *builder)
 {
-    g_return_if_fail(wind);
-    g_return_if_fail(builder);
+    g_return_if_fail (wind);
+    g_return_if_fail (builder);
 
     wind->window             = GTK_WIDGET(gtk_builder_get_object (builder, "qif_import_assistant"));
     wind->filename_entry     = GTK_WIDGET(gtk_builder_get_object (builder, "qif_filename_entry"));
     wind->load_pause         = GTK_WIDGET(gtk_builder_get_object (builder, "load_progress_pause"));
     wind->load_start         = GTK_WIDGET(gtk_builder_get_object (builder, "load_progress_start"));
     wind->load_log           = GTK_WIDGET(gtk_builder_get_object (builder, "load_progress_log"));
-    wind->load_progress      = gnc_progress_dialog_custom(
+    wind->load_progress      = gnc_progress_dialog_custom (
                                    GTK_LABEL(gtk_builder_get_object (builder, "load_progress_primary")),
                                    GTK_LABEL(gtk_builder_get_object (builder, "load_progress_secondary")),
                                    GTK_PROGRESS_BAR(gtk_builder_get_object (builder, "load_progress_bar")),
@@ -3444,7 +3447,7 @@ get_assistant_widgets(QIFImportWindow *wind, GtkBuilder *builder)
     wind->convert_pause      = GTK_WIDGET(gtk_builder_get_object (builder, "convert_progress_pause"));
     wind->convert_start      = GTK_WIDGET(gtk_builder_get_object (builder, "convert_progress_start"));
     wind->convert_log        = GTK_WIDGET(gtk_builder_get_object (builder, "convert_progress_log"));
-    wind->convert_progress   = gnc_progress_dialog_custom(
+    wind->convert_progress   = gnc_progress_dialog_custom (
                                    GTK_LABEL(gtk_builder_get_object (builder, "convert_progress_primary")),
                                    GTK_LABEL(gtk_builder_get_object (builder, "convert_progress_secondary")),
                                    GTK_PROGRESS_BAR(gtk_builder_get_object (builder, "convert_progress_bar")),
@@ -3468,7 +3471,7 @@ get_assistant_widgets(QIFImportWindow *wind, GtkBuilder *builder)
  * Build the details of all GtkTreeView widgets.
  ********************************************************************/
 static void
-build_views(QIFImportWindow *wind)
+build_views (QIFImportWindow *wind)
 {
     GtkTreeView *view;
     GtkListStore *store;
@@ -3476,126 +3479,126 @@ build_views(QIFImportWindow *wind)
     GtkTreeViewColumn *column;
     GtkTreeSelection *selection;
 
-    g_return_if_fail(wind);
+    g_return_if_fail (wind);
 
     /* Set up the selected file view */
     view = GTK_TREE_VIEW(wind->selected_file_view);
-    store = gtk_list_store_new(NUM_FILENAME_COLS, G_TYPE_INT, G_TYPE_STRING);
-    gtk_tree_view_set_model(view, GTK_TREE_MODEL(store));
-    g_object_unref(store);
+    store = gtk_list_store_new (NUM_FILENAME_COLS, 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("unused",
+    renderer = gtk_cell_renderer_text_new ();
+    column = gtk_tree_view_column_new_with_attributes ("unused",
              renderer,
              "text",
              FILENAME_COL_NAME,
              NULL);
-    gtk_tree_view_append_column(view, column);
+    gtk_tree_view_append_column (view, column);
 
-    selection = gtk_tree_view_get_selection(view);
-    g_signal_connect(selection, "changed",
-                     G_CALLBACK(gnc_ui_qif_import_select_loaded_file_cb),
-                     wind);
+    selection = gtk_tree_view_get_selection (view);
+    g_signal_connect (selection, "changed",
+                      G_CALLBACK(gnc_ui_qif_import_select_loaded_file_cb),
+                      wind);
 
     /* Set up the QIF account to GnuCash account matcher. */
-    create_account_picker_view(wind->acct_view, _("QIF account name"),
-                               G_CALLBACK(gnc_ui_qif_import_account_activate_cb),
-                               G_CALLBACK(gnc_ui_qif_import_account_select_cb),
-                               wind);
+    create_account_picker_view (wind->acct_view, _("QIF account name"),
+                                G_CALLBACK(gnc_ui_qif_import_account_activate_cb),
+                                G_CALLBACK(gnc_ui_qif_import_account_select_cb),
+                                wind);
 
     /* Set up the QIF category to GnuCash account matcher. */
-    create_account_picker_view(wind->cat_view,  _("QIF category name"),
-                               G_CALLBACK(gnc_ui_qif_import_category_activate_cb),
-                               G_CALLBACK(gnc_ui_qif_import_category_select_cb),
-                               wind);
+    create_account_picker_view (wind->cat_view,  _("QIF category name"),
+                                G_CALLBACK(gnc_ui_qif_import_category_activate_cb),
+                                G_CALLBACK(gnc_ui_qif_import_category_select_cb),
+                                wind);
 
     /* Set up the QIF payee/memo to GnuCash account matcher. */
-    create_account_picker_view(wind->memo_view, _("QIF payee/memo"),
-                               G_CALLBACK(gnc_ui_qif_import_memo_activate_cb),
-                               G_CALLBACK(gnc_ui_qif_import_memo_select_cb),
-                               wind);
+    create_account_picker_view (wind->memo_view, _("QIF payee/memo"),
+                                G_CALLBACK(gnc_ui_qif_import_memo_activate_cb),
+                                G_CALLBACK(gnc_ui_qif_import_memo_select_cb),
+                                wind);
 
     /* Set up the new transaction view */
     view = GTK_TREE_VIEW(wind->new_transaction_view);
-    store = gtk_list_store_new(NUM_QIF_TRANS_COLS, G_TYPE_INT, G_TYPE_STRING,
-                               G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN);
-    gtk_tree_view_set_model(view, GTK_TREE_MODEL(store));
-    g_object_unref(store);
+    store = gtk_list_store_new (NUM_QIF_TRANS_COLS, G_TYPE_INT, G_TYPE_STRING,
+                                G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN);
+    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(_("Date"),
+    renderer = gtk_cell_renderer_text_new ();
+    column = gtk_tree_view_column_new_with_attributes (_("Date"),
              renderer,
              "text",
              QIF_TRANS_COL_DATE,
              NULL);
-    gtk_tree_view_append_column(view, column);
+    gtk_tree_view_append_column (view, column);
 
-    renderer = gtk_cell_renderer_text_new();
-    column = gtk_tree_view_column_new_with_attributes(_("Description"),
+    renderer = gtk_cell_renderer_text_new ();
+    column = gtk_tree_view_column_new_with_attributes (_("Description"),
              renderer,
              "text",
              QIF_TRANS_COL_DESCRIPTION,
              NULL);
-    gtk_tree_view_append_column(view, column);
+    gtk_tree_view_append_column (view, column);
     gtk_tree_view_column_set_expand(column, TRUE);
 
-    renderer = gtk_cell_renderer_text_new();
-    column = gtk_tree_view_column_new_with_attributes(_("Amount"),
+    renderer = gtk_cell_renderer_text_new ();
+    column = gtk_tree_view_column_new_with_attributes (_("Amount"),
              renderer,
              "text",
              QIF_TRANS_COL_AMOUNT,
              NULL);
-    gtk_tree_view_append_column(view, column);
+    gtk_tree_view_append_column (view, column);
 
-    selection = gtk_tree_view_get_selection(view);
-    g_signal_connect(selection, "changed",
-                     G_CALLBACK(gnc_ui_qif_import_duplicate_new_select_cb),
-                     wind);
+    selection = gtk_tree_view_get_selection (view);
+    g_signal_connect (selection, "changed",
+                      G_CALLBACK(gnc_ui_qif_import_duplicate_new_select_cb),
+                      wind);
 
     /* Set up the old transaction view */
     view = GTK_TREE_VIEW(wind->old_transaction_view);
-    store = gtk_list_store_new(NUM_QIF_TRANS_COLS, G_TYPE_INT, G_TYPE_STRING,
-                               G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN);
-    gtk_tree_view_set_model(view, GTK_TREE_MODEL(store));
-    g_object_unref(store);
+    store = gtk_list_store_new (NUM_QIF_TRANS_COLS, G_TYPE_INT, G_TYPE_STRING,
+                                G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN);
+    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(_("Date"),
+    renderer = gtk_cell_renderer_text_new ();
+    column = gtk_tree_view_column_new_with_attributes (_("Date"),
              renderer,
              "text",
              QIF_TRANS_COL_DATE,
              NULL);
-    gtk_tree_view_append_column(view, column);
+    gtk_tree_view_append_column (view, column);
 
-    renderer = gtk_cell_renderer_text_new();
-    column = gtk_tree_view_column_new_with_attributes(_("Description"),
+    renderer = gtk_cell_renderer_text_new ();
+    column = gtk_tree_view_column_new_with_attributes (_("Description"),
              renderer,
              "text",
              QIF_TRANS_COL_DESCRIPTION,
              NULL);
-    gtk_tree_view_append_column(view, column);
-    gtk_tree_view_column_set_expand(column, TRUE);
+    gtk_tree_view_append_column (view, column);
+    gtk_tree_view_column_set_expand (column, TRUE);
 
-    renderer = gtk_cell_renderer_text_new();
-    column = gtk_tree_view_column_new_with_attributes(_("Amount"),
+    renderer = gtk_cell_renderer_text_new ();
+    column = gtk_tree_view_column_new_with_attributes (_("Amount"),
              renderer,
              "text",
              QIF_TRANS_COL_AMOUNT,
              NULL);
-    gtk_tree_view_append_column(view, column);
+    gtk_tree_view_append_column (view, column);
 
-    renderer = gtk_cell_renderer_toggle_new();
-    column = gtk_tree_view_column_new_with_attributes(_("Match?"),
+    renderer = gtk_cell_renderer_toggle_new ();
+    column = gtk_tree_view_column_new_with_attributes (_("Match?"),
              renderer,
              "active",
              QIF_TRANS_COL_CHECKED,
              NULL);
-    gtk_tree_view_append_column(view, column);
+    gtk_tree_view_append_column (view, column);
 
-    selection = gtk_tree_view_get_selection(view);
-    g_signal_connect(selection, "changed",
-                     G_CALLBACK(gnc_ui_qif_import_duplicate_old_select_cb),
-                     wind);
+    selection = gtk_tree_view_get_selection (view);
+    g_signal_connect (selection, "changed",
+                      G_CALLBACK(gnc_ui_qif_import_duplicate_old_select_cb),
+                      wind);
 }
 
 
@@ -3605,12 +3608,12 @@ build_views(QIFImportWindow *wind)
  * Build a new QIF import assistant.
  ********************************************************************/
 static GtkWidget *
-gnc_ui_qif_import_assistant_make(QIFImportWindow *qif_win)
+gnc_ui_qif_import_assistant_make (QIFImportWindow *qif_win)
 {
     GtkBuilder        *builder;
     GtkWidget         *box;
 
-    builder = gtk_builder_new();
+    builder = gtk_builder_new ();
     gnc_builder_add_from_file (builder, "assistant-qif-import.glade", "currency_liststore");
     gnc_builder_add_from_file (builder, "assistant-qif-import.glade", "date_format_liststore");
     gnc_builder_add_from_file (builder, "assistant-qif-import.glade", "qif_import_assistant");
@@ -3620,45 +3623,45 @@ gnc_ui_qif_import_assistant_make(QIFImportWindow *qif_win)
     qif_win->busy                 = FALSE;
     /* In order to include a book options display on the creation of a new book,
      * we need to detect when we are dealing with a new book. */
-    qif_win->new_book = gnc_is_new_book();
+    qif_win->new_book = gnc_is_new_book ();
 
     /* Get all user preferences related to QIF importing. */
-    get_preferences(qif_win);
+    get_preferences (qif_win);
 
     /* Set up the Scheme side of things. Note that if a session/book did not
      * exist prior to this function, it is created within scheme function
      * "qif-import:load-map-prefs", so we need to have set the flag previously */
-    initialize_scheme(qif_win);
+    initialize_scheme (qif_win);
 
     /* Get all interesting builder-defined widgets. */
-    get_assistant_widgets(qif_win, builder);
+    get_assistant_widgets (qif_win, builder);
 
     /* Make this window stay on top */
-    gtk_window_set_transient_for (GTK_WINDOW (qif_win->window), gnc_ui_get_main_window(NULL));
+    gtk_window_set_transient_for (GTK_WINDOW(qif_win->window), gnc_ui_get_main_window (NULL));
 
     /* Build the details of all GtkTreeView widgets. */
-    build_views(qif_win);
+    build_views (qif_win);
 
     /* Currency Page */
     /* Set a default currency for new accounts */
-    qif_win->currency_picker = gnc_currency_edit_new();
-    gnc_currency_edit_set_currency (GNC_CURRENCY_EDIT(qif_win->currency_picker), gnc_default_currency());
+    qif_win->currency_picker = gnc_currency_edit_new ();
+    gnc_currency_edit_set_currency (GNC_CURRENCY_EDIT(qif_win->currency_picker), gnc_default_currency ());
     gtk_widget_show (qif_win->currency_picker);
     box = GTK_WIDGET(gtk_builder_get_object (builder, "currency_picker_hbox"));
-    gtk_box_pack_start(GTK_BOX(box), qif_win->currency_picker, TRUE, TRUE, 0);
+    gtk_box_pack_start (GTK_BOX(box), qif_win->currency_picker, TRUE, TRUE, 0);
 
     gnc_restore_window_size (GNC_PREFS_GROUP,
-                             GTK_WINDOW(qif_win->window), gnc_ui_get_main_window(NULL));
+                             GTK_WINDOW(qif_win->window), gnc_ui_get_main_window (NULL));
 
-    g_signal_connect( qif_win->window, "destroy",
-                      G_CALLBACK(gnc_ui_qif_import_assistant_destroy), qif_win );
+    g_signal_connect (qif_win->window, "destroy",
+                      G_CALLBACK(gnc_ui_qif_import_assistant_destroy), qif_win);
 
-    gtk_builder_connect_signals(builder, qif_win);
+    gtk_builder_connect_signals (builder, qif_win);
 
-    g_object_unref(G_OBJECT(builder));
+    g_object_unref (G_OBJECT(builder));
 
-    gtk_widget_show_all(qif_win->window);
-    gtk_window_present(GTK_WINDOW(qif_win->window));
+    gtk_widget_show_all (qif_win->window);
+    gtk_window_present (GTK_WINDOW(qif_win->window));
 
     return qif_win->window;
 }
@@ -3668,12 +3671,12 @@ gnc_ui_qif_import_assistant_make(QIFImportWindow *qif_win)
  * gnc_ui_qif_import_assistant_close_handler
  ********************************************/
 static void
-gnc_ui_qif_import_assistant_close_handler( gpointer user_data )
+gnc_ui_qif_import_assistant_close_handler (gpointer user_data)
 {
     QIFImportWindow *qif_win = user_data;
 
-    gnc_save_window_size(GNC_PREFS_GROUP, GTK_WINDOW(qif_win->window));
-    gtk_widget_destroy( qif_win->window );
+    gnc_save_window_size (GNC_PREFS_GROUP, GTK_WINDOW(qif_win->window));
+    gtk_widget_destroy (qif_win->window);
 }
 
 
@@ -3681,7 +3684,7 @@ gnc_ui_qif_import_assistant_close_handler( gpointer user_data )
  * gnc_file_qif_import
  ********************************************/
 void
-gnc_file_qif_import(void)
+gnc_file_qif_import (void)
 {
     QIFImportWindow *qif_win;
     gint component_id;
@@ -3689,7 +3692,7 @@ gnc_file_qif_import(void)
     qif_win = g_new0 (QIFImportWindow, 1);
 
     /* pop up the QIF File Import dialog box */
-    gnc_ui_qif_import_assistant_make(qif_win);
+    gnc_ui_qif_import_assistant_make (qif_win);
 
     component_id = gnc_register_gui_component (ASSISTANT_QIF_IMPORT_CM_CLASS,
                    NULL, gnc_ui_qif_import_assistant_close_handler,

commit 75632dae57fe1c4d35e935dd13125ce8f6f94228
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Tue May 7 15:42:49 2019 +0100

    Reformat assistant-qif-import.c source file part3/4

diff --git a/gnucash/import-export/qif-imp/assistant-qif-import.c b/gnucash/import-export/qif-imp/assistant-qif-import.c
index 49deecb8b..18bc3a4ec 100644
--- a/gnucash/import-export/qif-imp/assistant-qif-import.c
+++ b/gnucash/import-export/qif-imp/assistant-qif-import.c
@@ -2003,7 +2003,7 @@ gnc_ui_qif_import_load_progress_prepare (GtkAssistant  *assistant, gpointer user
  * Determine if we need the date page and what is next page.
  ********************************************************************/
 void
-gnc_ui_qif_import_date_format_prepare (GtkAssistant  *assistant, gpointer user_data)
+gnc_ui_qif_import_date_format_prepare (GtkAssistant *assistant, gpointer user_data)
 
 {
     QIFImportWindow *wind = user_data;
@@ -2038,13 +2038,13 @@ gnc_ui_qif_import_date_valid_cb (GtkWidget *widget, gpointer user_data)
     GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
 
     /* Get the selected date format. */
-    model = gtk_combo_box_get_model(GTK_COMBO_BOX (wind->date_format_combo));
-    gtk_combo_box_get_active_iter (GTK_COMBO_BOX (wind->date_format_combo), &iter);
+    model = gtk_combo_box_get_model (GTK_COMBO_BOX(wind->date_format_combo));
+    gtk_combo_box_get_active_iter (GTK_COMBO_BOX(wind->date_format_combo), &iter);
     gtk_tree_model_get (model, &iter, 0, &wind->date_format, -1);
 
     if (!wind->date_format)
     {
-        g_critical("QIF import: BUG DETECTED in gnc_ui_qif_import_date_valid_cb. Format is NULL.");
+        g_critical ("QIF import: BUG DETECTED in gnc_ui_qif_import_date_valid_cb. Format is NULL.");
     }
 
     gtk_assistant_set_page_complete (assistant, page, TRUE);
@@ -2078,18 +2078,18 @@ gnc_ui_qif_import_account_prepare (GtkAssistant  *assistant, gpointer user_data)
     QIFImportWindow * wind = user_data;
     gint num = gtk_assistant_get_current_page (assistant);
 
-    SCM  check_from_acct = scm_c_eval_string("qif-file:check-from-acct");
+    SCM  check_from_acct = scm_c_eval_string ("qif-file:check-from-acct");
     if (wind->ask_date_format && wind->date_format)
         qif_import_reparse_dates (wind);
    /* Determine the next page to display. */
-    if (scm_call_1(check_from_acct, wind->selected_file) != SCM_BOOL_T)
+    if (scm_call_1 (check_from_acct, wind->selected_file) != SCM_BOOL_T)
     {
         /* There is an account name missing. Ask the user to provide one. */
-        SCM default_acct = scm_c_eval_string("qif-file:path-to-accountname");
+        SCM default_acct = scm_c_eval_string ("qif-file:path-to-accountname");
         gchar * default_acctname = NULL;
 
-        default_acctname = gnc_scm_call_1_to_string(default_acct, wind->selected_file);
-        gtk_entry_set_text(GTK_ENTRY(wind->acct_entry), default_acctname);
+        default_acctname = gnc_scm_call_1_to_string (default_acct, wind->selected_file);
+        gtk_entry_set_text (GTK_ENTRY(wind->acct_entry), default_acctname);
         g_free (default_acctname);
     }
     else
@@ -2106,8 +2106,8 @@ gnc_ui_qif_import_account_prepare (GtkAssistant  *assistant, gpointer user_data)
  * Invoked when the "next" button is clicked on the default acct page.
  ********************************************************************/
 void
-gnc_ui_qif_import_acct_valid_cb(GtkWidget * widget,
-                                gpointer user_data)
+gnc_ui_qif_import_acct_valid_cb (GtkWidget * widget,
+                                 gpointer user_data)
 {
     QIFImportWindow * wind = user_data;
 
@@ -2115,7 +2115,7 @@ gnc_ui_qif_import_acct_valid_cb(GtkWidget * widget,
     gint num = gtk_assistant_get_current_page (assistant);
     GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
 
-    const gchar * acct_name = gtk_entry_get_text(GTK_ENTRY(wind->acct_entry));
+    const gchar * acct_name = gtk_entry_get_text (GTK_ENTRY(wind->acct_entry));
 
     if (!acct_name || acct_name[0] == 0)
     {
@@ -2148,17 +2148,17 @@ gnc_ui_qif_import_loaded_files_prepare (GtkAssistant *assistant,
     gint num = gtk_assistant_get_current_page (assistant);
     GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
 
-    const gchar * acct_name = gtk_entry_get_text(GTK_ENTRY(wind->acct_entry));
-    SCM    fix_default = scm_c_eval_string("qif-import:fix-from-acct");
+    const gchar * acct_name = gtk_entry_get_text (GTK_ENTRY(wind->acct_entry));
+    SCM    fix_default = scm_c_eval_string ("qif-import:fix-from-acct");
     SCM    scm_name;
 
-    scm_name = scm_from_utf8_string(acct_name ? acct_name : "");
-    scm_call_2(fix_default, wind->selected_file, scm_name);
+    scm_name = scm_from_utf8_string (acct_name ? acct_name : "");
+    scm_call_2 (fix_default, wind->selected_file, scm_name);
 
     /* Enable the assistant "Next" Button */
     gtk_assistant_set_page_complete (assistant, page, TRUE);
 
-    update_file_page(wind);
+    update_file_page (wind);
 }
 
 
@@ -2168,8 +2168,8 @@ gnc_ui_qif_import_loaded_files_prepare (GtkAssistant *assistant,
  * files page.
  ********************************************************************/
 void
-gnc_ui_qif_import_load_another_cb(GtkButton * button,
-                                  gpointer user_data)
+gnc_ui_qif_import_load_another_cb (GtkButton * button,
+                                   gpointer user_data)
 {
     QIFImportWindow * wind = user_data;
     GtkAssistant *assistant = GTK_ASSISTANT(wind->window);
@@ -2186,28 +2186,28 @@ gnc_ui_qif_import_load_another_cb(GtkButton * button,
  * page.
  ********************************************************************/
 void
-gnc_ui_qif_import_unload_file_cb(GtkButton * button,
-                                 gpointer user_data)
+gnc_ui_qif_import_unload_file_cb (GtkButton * button,
+                                  gpointer user_data)
 {
     QIFImportWindow * wind = user_data;
 
-    SCM unload_qif_file = scm_c_eval_string("qif-dialog:unload-qif-file");
+    SCM unload_qif_file = scm_c_eval_string ("qif-dialog:unload-qif-file");
     SCM imported_files;
 
     if (wind->selected_file != SCM_BOOL_F)
     {
         imported_files =
-            scm_call_2(unload_qif_file, wind->selected_file, wind->imported_files);
+            scm_call_2 (unload_qif_file, wind->selected_file, wind->imported_files);
 
-        scm_gc_unprotect_object(wind->imported_files);
+        scm_gc_unprotect_object (wind->imported_files);
         wind->imported_files = imported_files;
-        scm_gc_protect_object(wind->imported_files);
+        scm_gc_protect_object (wind->imported_files);
 
-        scm_gc_unprotect_object(wind->selected_file);
+        scm_gc_unprotect_object (wind->selected_file);
         wind->selected_file = SCM_BOOL_F;
-        scm_gc_protect_object(wind->selected_file);
+        scm_gc_protect_object (wind->selected_file);
 
-        update_file_page(wind);
+        update_file_page (wind);
     }
 }
 
@@ -2218,7 +2218,7 @@ gnc_ui_qif_import_unload_file_cb(GtkButton * button,
  * Update the list of loaded files.
  ********************************************************************/
 static void
-update_file_page(QIFImportWindow * wind)
+update_file_page (QIFImportWindow * wind)
 {
     SCM       loaded_file_list = wind->imported_files;
     SCM       qif_file_path;
@@ -2231,44 +2231,44 @@ update_file_page(QIFImportWindow * wind)
 
     /* clear the list */
     view = GTK_TREE_VIEW(wind->selected_file_view);
-    store = GTK_LIST_STORE(gtk_tree_view_get_model(view));
-    gtk_list_store_clear(store);
-    qif_file_path = scm_c_eval_string("qif-file:path");
+    store = GTK_LIST_STORE(gtk_tree_view_get_model (view));
+    gtk_list_store_clear (store);
+    qif_file_path = scm_c_eval_string ("qif-file:path");
 
-    while (!scm_is_null(loaded_file_list))
+    while (!scm_is_null (loaded_file_list))
     {
         gchar *row_text    = NULL;
         SCM    scm_qiffile = SCM_BOOL_F;
 
         scm_qiffile = SCM_CAR(loaded_file_list);
-        row_text = gnc_scm_call_1_to_string(qif_file_path, scm_qiffile);
+        row_text = gnc_scm_call_1_to_string (qif_file_path, scm_qiffile);
 
-        gtk_list_store_append(store, &iter);
-        gtk_list_store_set(store, &iter,
-                           FILENAME_COL_INDEX, row++,
-                           FILENAME_COL_NAME, row_text,
-                           -1);
+        gtk_list_store_append (store, &iter);
+        gtk_list_store_set (store, &iter,
+                            FILENAME_COL_INDEX, row++,
+                            FILENAME_COL_NAME, row_text,
+                            -1);
         g_free (row_text);
 
         if (scm_qiffile == wind->selected_file)
         {
-            path = gtk_tree_model_get_path(GTK_TREE_MODEL(store), &iter);
-            reference = gtk_tree_row_reference_new(GTK_TREE_MODEL(store), path);
-            gtk_tree_path_free(path);
+            path = gtk_tree_model_get_path (GTK_TREE_MODEL(store), &iter);
+            reference = gtk_tree_row_reference_new (GTK_TREE_MODEL(store), path);
+            gtk_tree_path_free (path);
         }
         loaded_file_list = SCM_CDR(loaded_file_list);
     }
 
     if (reference)
     {
-        GtkTreeSelection* selection = gtk_tree_view_get_selection(view);
-        path = gtk_tree_row_reference_get_path(reference);
+        GtkTreeSelection* selection = gtk_tree_view_get_selection (view);
+        path = gtk_tree_row_reference_get_path (reference);
         if (path)
         {
-            gtk_tree_selection_select_path(selection, path);
-            gtk_tree_path_free(path);
+            gtk_tree_selection_select_path (selection, path);
+            gtk_tree_path_free (path);
         }
-        gtk_tree_row_reference_free(reference);
+        gtk_tree_row_reference_free (reference);
     }
 }
 
@@ -2290,18 +2290,18 @@ gnc_ui_qif_import_account_doc_prepare (GtkAssistant *assistant,
     gint total = gtk_assistant_get_n_pages (assistant);
     gtk_assistant_update_buttons_state (assistant);
 
-    PINFO("Total Number of Assistant Pages is %d", gtk_assistant_get_n_pages (assistant));
+    PINFO ("Total Number of Assistant Pages is %d", gtk_assistant_get_n_pages (assistant));
 
     /* Enable the Assistant "Next" Button */
     gtk_assistant_set_page_complete (assistant, page, TRUE);
 
     /* Jump to Summary page if load_stop TRUE */
     if (wind->load_stop)
-        gtk_assistant_set_current_page (assistant, total - 1 );
+        gtk_assistant_set_current_page (assistant, total - 1);
 
     /* Jump over doc page if show_doc_pages FALSE */
     if (!wind->show_doc_pages)
-        gtk_assistant_set_current_page (assistant, num + 1 );
+        gtk_assistant_set_current_page (assistant, num + 1);
 }
 
 
@@ -2315,19 +2315,19 @@ gnc_ui_qif_import_account_doc_prepare (GtkAssistant *assistant,
  * Get the matching pages ready for viewing.
  ********************************************************************/
 void
-gnc_ui_qif_import_account_match_prepare(GtkAssistant *assistant,
-                                        gpointer user_data)
+gnc_ui_qif_import_account_match_prepare (GtkAssistant *assistant,
+                                         gpointer user_data)
 {
     QIFImportWindow * wind = user_data;
     gint num = gtk_assistant_get_current_page (assistant);
     GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
 
     /* Prepare the matching pages. */
-    gnc_set_busy_cursor(NULL, TRUE);
-    update_account_page(wind);
-    update_category_page(wind);
-    update_memo_page(wind);
-    gnc_unset_busy_cursor(NULL);
+    gnc_set_busy_cursor (NULL, TRUE);
+    update_account_page (wind);
+    update_category_page (wind);
+    update_memo_page (wind);
+    gnc_unset_busy_cursor (NULL);
 
     /* Enable the Assistant "Next" Button */
     gtk_assistant_set_page_complete (assistant, page, TRUE);
@@ -2342,17 +2342,17 @@ gnc_ui_qif_import_account_match_prepare(GtkAssistant *assistant,
  * button is an alternative to double-clicking a row.
  ****************************************************************/
 void
-gnc_ui_qif_import_account_rematch_cb(GtkButton *button, gpointer user_data)
+gnc_ui_qif_import_account_rematch_cb (GtkButton *button, gpointer user_data)
 {
     QIFImportWindow  *wind = user_data;
 
-    g_return_if_fail(wind);
+    g_return_if_fail (wind);
 
-    rematch_line(wind,
-                 gtk_tree_view_get_selection(GTK_TREE_VIEW(wind->acct_view)),
-                 wind->acct_display_info,
-                 wind->acct_map_info,
-                 update_account_page);
+    rematch_line (wind,
+                  gtk_tree_view_get_selection (GTK_TREE_VIEW(wind->acct_view)),
+                  wind->acct_display_info,
+                  wind->acct_map_info,
+                  update_account_page);
 }
 
 
@@ -2373,21 +2373,21 @@ gnc_ui_qif_import_catagory_doc_prepare (GtkAssistant *assistant,
     gint total = gtk_assistant_get_n_pages (assistant);
     gtk_assistant_update_buttons_state (assistant);
 
-    PINFO("Total Number of Assistant Pages is %d", gtk_assistant_get_n_pages (assistant));
+    PINFO ("Total Number of Assistant Pages is %d", gtk_assistant_get_n_pages (assistant));
 
     /* Enable the Assistant "Next" Button */
     gtk_assistant_set_page_complete (assistant, page, TRUE);
 
     /* Jump to Summary page if load_stop TRUE */
     if (wind->load_stop)
-        gtk_assistant_set_current_page (assistant, total - 1 );
+        gtk_assistant_set_current_page (assistant, total - 1);
 
     /* Jump over doc page if show_doc_pages FALSE */
     if (!wind->show_doc_pages)
-        gtk_assistant_set_current_page (assistant, num + 1 );
+        gtk_assistant_set_current_page (assistant, num + 1);
 
     /* If there are no category mappings, jump the doc page. */
-    if (scm_is_list(wind->cat_display_info) && scm_is_null(wind->cat_display_info))
+    if (scm_is_list (wind->cat_display_info) && scm_is_null (wind->cat_display_info))
         gtk_assistant_set_current_page (assistant, num + 1);
 }
 
@@ -2403,7 +2403,7 @@ gnc_ui_qif_import_catagory_doc_prepare (GtkAssistant *assistant,
  * category or payee/memo mappings to be dealt with.
  ****************************************************************/
 void
-gnc_ui_qif_import_catagory_match_prepare(GtkAssistant *assistant,
+gnc_ui_qif_import_catagory_match_prepare (GtkAssistant *assistant,
         gpointer user_data)
 {
     QIFImportWindow * wind = user_data;
@@ -2414,7 +2414,7 @@ gnc_ui_qif_import_catagory_match_prepare(GtkAssistant *assistant,
     gtk_assistant_set_page_complete (assistant, page, TRUE);
 
     /* If there are no category mappings, jump this step. */
-    if (scm_is_list(wind->cat_display_info) && scm_is_null(wind->cat_display_info))
+    if (scm_is_list (wind->cat_display_info) && scm_is_null (wind->cat_display_info))
         gtk_assistant_set_current_page (assistant, num + 1);
 }
 
@@ -2427,17 +2427,17 @@ gnc_ui_qif_import_catagory_match_prepare(GtkAssistant *assistant,
  * button is an alternative to double-clicking a row.
  ****************************************************************/
 void
-gnc_ui_qif_import_category_rematch_cb(GtkButton *button, gpointer user_data)
+gnc_ui_qif_import_category_rematch_cb (GtkButton *button, gpointer user_data)
 {
     QIFImportWindow  *wind = user_data;
 
-    g_return_if_fail(wind);
+    g_return_if_fail (wind);
 
-    rematch_line(wind,
-                 gtk_tree_view_get_selection(GTK_TREE_VIEW(wind->cat_view)),
-                 wind->cat_display_info,
-                 wind->cat_map_info,
-                 update_category_page);
+    rematch_line (wind,
+                  gtk_tree_view_get_selection (GTK_TREE_VIEW(wind->cat_view)),
+                  wind->cat_display_info,
+                  wind->cat_map_info,
+                  update_category_page);
 }
 
 
@@ -2449,8 +2449,7 @@ gnc_ui_qif_import_category_rematch_cb(GtkButton *button, gpointer user_data)
  * gnc_ui_qif_import_memo_doc_prepare
  ********************************************************************/
 void
-gnc_ui_qif_import_memo_doc_prepare (GtkAssistant *assistant,
-                                    gpointer user_data)
+gnc_ui_qif_import_memo_doc_prepare (GtkAssistant *assistant, gpointer user_data)
 {
     QIFImportWindow * wind = user_data;
     gint num = gtk_assistant_get_current_page (assistant);
@@ -2458,21 +2457,21 @@ gnc_ui_qif_import_memo_doc_prepare (GtkAssistant *assistant,
     gint total = gtk_assistant_get_n_pages (assistant);
     gtk_assistant_update_buttons_state (assistant);
 
-    PINFO("Total Number of Assistant Pages is %d", gtk_assistant_get_n_pages (assistant));
+    PINFO ("Total Number of Assistant Pages is %d", gtk_assistant_get_n_pages (assistant));
 
     /* Enable the Assistant "Next" Button */
     gtk_assistant_set_page_complete (assistant, page, TRUE);
 
     /* Jump to Summary page if load_stop TRUE */
     if (wind->load_stop)
-        gtk_assistant_set_current_page (assistant, total - 1 );
+        gtk_assistant_set_current_page (assistant, total - 1);
 
     /* Jump over doc page if show_doc_pages FALSE */
     if (!wind->show_doc_pages)
-        gtk_assistant_set_current_page (assistant, num + 1 );
+        gtk_assistant_set_current_page (assistant, num + 1);
 
     /* If there are no memo mappings, jump the doc page. */
-    if (scm_is_list(wind->memo_display_info) && scm_is_null(wind->memo_display_info))
+    if (scm_is_list (wind->memo_display_info) && scm_is_null (wind->memo_display_info))
         gtk_assistant_set_current_page (assistant, num + 1);
 }
 
@@ -2488,8 +2487,7 @@ gnc_ui_qif_import_memo_doc_prepare (GtkAssistant *assistant,
  * category or payee/memo mappings to be dealt with.
  ****************************************************************/
 void
-gnc_ui_qif_import_memo_match_prepare (GtkAssistant *assistant,
-                                      gpointer user_data)
+gnc_ui_qif_import_memo_match_prepare (GtkAssistant *assistant, gpointer user_data)
 {
     QIFImportWindow * wind = user_data;
     gint num = gtk_assistant_get_current_page (assistant);
@@ -2499,7 +2497,7 @@ gnc_ui_qif_import_memo_match_prepare (GtkAssistant *assistant,
     gtk_assistant_set_page_complete (assistant, page, TRUE);
 
     /* If there are no memo mappings, jump this step. */
-    if (scm_is_list(wind->memo_display_info) && scm_is_null(wind->memo_display_info))
+    if (scm_is_list (wind->memo_display_info) && scm_is_null (wind->memo_display_info))
         gtk_assistant_set_current_page (assistant, num + 1);
 }
 
@@ -2512,17 +2510,17 @@ gnc_ui_qif_import_memo_match_prepare (GtkAssistant *assistant,
  * button is an alternative to double-clicking a row.
  ****************************************************************/
 void
-gnc_ui_qif_import_memo_rematch_cb(GtkButton *button, gpointer user_data)
+gnc_ui_qif_import_memo_rematch_cb (GtkButton *button, gpointer user_data)
 {
-    QIFImportWindow  *wind = user_data;
+    QIFImportWindow * wind = user_data;
 
-    g_return_if_fail(wind);
+    g_return_if_fail (wind);
 
-    rematch_line(wind,
-                 gtk_tree_view_get_selection(GTK_TREE_VIEW(wind->memo_view)),
-                 wind->memo_display_info,
-                 wind->memo_map_info,
-                 update_memo_page);
+    rematch_line (wind,
+                  gtk_tree_view_get_selection (GTK_TREE_VIEW(wind->memo_view)),
+                  wind->memo_display_info,
+                  wind->memo_map_info,
+                  update_memo_page);
 }
 
 
@@ -2537,14 +2535,13 @@ gnc_ui_qif_import_memo_rematch_cb(GtkButton *button, gpointer user_data)
  * category or payee/memo mappings to be dealt with.
  ****************************************************************/
 void
-gnc_ui_qif_import_currency_prepare(GtkAssistant *assistant,
-                                   gpointer user_data)
+gnc_ui_qif_import_currency_prepare (GtkAssistant *assistant, gpointer user_data)
 {
     gint num = gtk_assistant_get_current_page (assistant);
     GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
     QIFImportWindow  *wind = user_data;
 
-    g_return_if_fail(wind);
+    g_return_if_fail (wind);
 
     /* Only display Book Option data if new book */
     if (wind->new_book)
@@ -2580,28 +2577,28 @@ gnc_ui_qif_import_currency_prepare(GtkAssistant *assistant,
  * Otherwise, FALSE is returned.
  ****************************************************************/
 static gboolean
-gnc_ui_qif_import_new_securities(QIFImportWindow * wind)
+gnc_ui_qif_import_new_securities (QIFImportWindow * wind)
 {
     SCM updates;
-    SCM update_securities = scm_c_eval_string("qif-import:update-security-hash");
+    SCM update_securities = scm_c_eval_string ("qif-import:update-security-hash");
 
     /* Get a list of any new QIF securities since the previous call. */
-    updates = scm_call_4(update_securities,
-                         wind->security_hash,
-                         wind->ticker_map,
-                         wind->acct_map_info,
-                         wind->security_prefs);
+    updates = scm_call_4 (update_securities,
+                          wind->security_hash,
+                          wind->ticker_map,
+                          wind->acct_map_info,
+                          wind->security_prefs);
     if (updates != SCM_BOOL_F)
     {
         /* A list of new QIF securities was returned. Save it. */
-        scm_gc_unprotect_object(wind->new_securities);
+        scm_gc_unprotect_object (wind->new_securities);
         if (wind->new_securities != SCM_BOOL_F)
             /* There is an existing list, so append the new list. */
-            wind->new_securities = scm_append(scm_list_2(wind->new_securities,
-                                              updates));
+            wind->new_securities = scm_append (scm_list_2 (wind->new_securities,
+                                               updates));
         else
             wind->new_securities = updates;
-        scm_gc_protect_object(wind->new_securities);
+        scm_gc_protect_object (wind->new_securities);
 
         return TRUE;
     }
@@ -2626,25 +2623,25 @@ gnc_ui_qif_import_commodity_doc_prepare (GtkAssistant *assistant,
     gint total = gtk_assistant_get_n_pages (assistant);
     gtk_assistant_update_buttons_state (assistant);
 
-    PINFO("Total Number of Assistant Pages is %d", gtk_assistant_get_n_pages (assistant));
+    PINFO ("Total Number of Assistant Pages is %d", gtk_assistant_get_n_pages (assistant));
 
     /* Enable the Assistant "Next" Button */
     gtk_assistant_set_page_complete (assistant, page, TRUE);
 
     /* Jump to Summary page if load_stop TRUE */
     if (wind->load_stop)
-        gtk_assistant_set_current_page (assistant, total - 1 );
+        gtk_assistant_set_current_page (assistant, total - 1);
 
     /* If there are new securities, prepare the security pages. */
-    if (gnc_ui_qif_import_new_securities(wind))
+    if (gnc_ui_qif_import_new_securities (wind))
         prepare_security_pages(wind);
     else
         /* If there are no securities, jump the doc page */
-        gtk_assistant_set_current_page (assistant, num + 1 );
+        gtk_assistant_set_current_page (assistant, num + 1);
 
     /* Jump over doc page if show_doc_pages FALSE */
     if (!wind->show_doc_pages)
-        gtk_assistant_set_current_page (assistant, num + 1 );
+        gtk_assistant_set_current_page (assistant, num + 1);
 }
 
 
@@ -2662,7 +2659,7 @@ gnc_ui_qif_import_commodity_new_prepare (GtkAssistant *assistant,
     gint num = gtk_assistant_get_current_page (assistant);
     GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
 
-    QIFAssistantPage    *qpage = g_object_get_data(G_OBJECT(page), "page_struct");
+    QIFAssistantPage    *qpage = g_object_get_data (G_OBJECT(page), "page_struct");
     const gchar         *ns;
 
     g_return_if_fail (qpage != NULL);
@@ -2672,12 +2669,12 @@ gnc_ui_qif_import_commodity_new_prepare (GtkAssistant *assistant,
 
     /* Update the namespaces available to select. */
     if (!ns || !ns[0])
-        gnc_ui_update_namespace_picker(
+        gnc_ui_update_namespace_picker (
             qpage->namespace_combo,
-            gnc_commodity_get_namespace(qpage->commodity),
+            gnc_commodity_get_namespace (qpage->commodity),
             DIAG_COMM_ALL);
     else
-        gnc_ui_update_namespace_picker(qpage->namespace_combo, ns, DIAG_COMM_ALL);
+        gnc_ui_update_namespace_picker (qpage->namespace_combo, ns, DIAG_COMM_ALL);
 }
 
 
@@ -2685,46 +2682,45 @@ gnc_ui_qif_import_commodity_new_prepare (GtkAssistant *assistant,
  * gnc_ui_qif_import_comm_valid
  ********************************/
 static gboolean
-gnc_ui_qif_import_comm_valid (GtkAssistant *assistant,
-                              gpointer user_data)
+gnc_ui_qif_import_comm_valid (GtkAssistant *assistant, gpointer user_data)
 {
     QIFImportWindow *wind = user_data;
     gint num = gtk_assistant_get_current_page (GTK_ASSISTANT(wind->window));
     GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
-    QIFAssistantPage    *qpage = g_object_get_data(G_OBJECT(page), "page_struct");
+    QIFAssistantPage    *qpage = g_object_get_data (G_OBJECT(page), "page_struct");
 
     QofBook                 *book;
     gnc_commodity_table     *table;
     gnc_commodity_namespace *newns;
 
-    gchar       *name_space = gnc_ui_namespace_picker_ns(qpage->namespace_combo);
-    const gchar *name      = gtk_entry_get_text(GTK_ENTRY(qpage->name_entry));
-    const gchar *mnemonic  = gtk_entry_get_text(GTK_ENTRY(qpage->mnemonic_entry));
+    gchar       *name_space = gnc_ui_namespace_picker_ns (qpage->namespace_combo);
+    const gchar *name      = gtk_entry_get_text (GTK_ENTRY(qpage->name_entry));
+    const gchar *mnemonic  = gtk_entry_get_text (GTK_ENTRY(qpage->mnemonic_entry));
 
     if (!name || (name[0] == 0))
     {
-        gnc_warning_dialog(GTK_WINDOW (assistant), "%s",
-                           _("Enter a name or short description, such as \"Red Hat Stock\"."));
-        g_free(name_space);
+        gnc_warning_dialog (GTK_WINDOW(assistant), "%s",
+                            _("Enter a name or short description, such as \"Red Hat Stock\"."));
+        g_free (name_space);
         return FALSE;
     }
     else if (!mnemonic || (mnemonic[0] == 0))
     {
-        gnc_warning_dialog(GTK_WINDOW (assistant), "%s",
-                           _("Enter the ticker symbol or other well known abbreviation, such as"
-                             " \"RHT\". If there isn't one, or you don't know it, create your own."));
-        g_free(name_space);
+        gnc_warning_dialog (GTK_WINDOW(assistant), "%s",
+                            _("Enter the ticker symbol or other well known abbreviation, such as"
+                              " \"RHT\". If there isn't one, or you don't know it, create your own."));
+        g_free (name_space);
         return FALSE;
     }
     else if (!name_space || (name_space[0] == 0))
     {
-        gnc_warning_dialog(GTK_WINDOW (assistant), "%s",
-                           _("Select the exchange on which the symbol is traded, or select the"
-                             " type of investment (such as FUND for mutual funds.) If you don't"
-                             " see your exchange or an appropriate investment type, you can"
-                             " enter a new one."));
+        gnc_warning_dialog (GTK_WINDOW(assistant), "%s",
+                            _("Select the exchange on which the symbol is traded, or select the"
+                              " type of investment (such as FUND for mutual funds.) If you don't"
+                              " see your exchange or an appropriate investment type, you can"
+                              " enter a new one."));
         if (name_space)
-            g_free(name_space);
+            g_free (name_space);
         return FALSE;
     }
 
@@ -2733,36 +2729,36 @@ gnc_ui_qif_import_comm_valid (GtkAssistant *assistant,
      *        the existing one, or go back and change what they've entered.
      */
 
-    book = gnc_get_current_book();
-    table = gnc_commodity_table_get_table(book);
-    if (gnc_commodity_namespace_is_iso(name_space) &&
-            !gnc_commodity_table_lookup(table, name_space, mnemonic))
+    book = gnc_get_current_book ();
+    table = gnc_commodity_table_get_table (book);
+    if (gnc_commodity_namespace_is_iso (name_space) &&
+            !gnc_commodity_table_lookup (table, name_space, mnemonic))
     {
-        gnc_warning_dialog(GTK_WINDOW (assistant), "%s",
-                           _("You must enter an existing national "
-                             "currency or enter a different type."));
+        gnc_warning_dialog (GTK_WINDOW(assistant), "%s",
+                            _("You must enter an existing national "
+                              "currency or enter a different type."));
 
-        g_free(name_space);
+        g_free (name_space);
         return FALSE;
     }
 
     /* Is the namespace a new one? */
-    if (!gnc_commodity_table_has_namespace(table, name_space))
+    if (!gnc_commodity_table_has_namespace (table, name_space))
     {
         /* Register it so that it will appear as an option on other pages. */
-        newns = gnc_commodity_table_add_namespace(table, name_space, book);
+        newns = gnc_commodity_table_add_namespace (table, name_space, book);
 
         /* Remember it so it can be removed if the import gets canceled. */
         if (newns)
-            wind->new_namespaces = g_list_prepend(wind->new_namespaces, name_space);
+            wind->new_namespaces = g_list_prepend (wind->new_namespaces, name_space);
         else
         {
-            g_warning("QIF import: Couldn't create namespace %s", name_space);
-            g_free(name_space);
+            g_warning ("QIF import: Couldn't create namespace %s", name_space);
+            g_free (name_space);
         }
     }
     else
-        g_free(name_space);
+        g_free (name_space);
 
     return TRUE;
 }
@@ -2793,34 +2789,34 @@ gnc_ui_qif_import_comm_changed_cb (GtkWidget *widget, gpointer user_data)
  * Invoked when the "Pause" button is clicked.
  ********************************************************************/
 void
-gnc_ui_qif_import_convert_progress_pause_cb(GtkButton * button,
+gnc_ui_qif_import_convert_progress_pause_cb (GtkButton * button,
         gpointer user_data)
 {
     QIFImportWindow *wind = user_data;
-    SCM toggle_pause      = scm_c_eval_string("qif-import:toggle-pause");
+    SCM toggle_pause      = scm_c_eval_string ("qif-import:toggle-pause");
     SCM progress;
 
     if (!wind->busy)
         return;
 
     /* Create SCM for the progress helper. */
-    progress = SWIG_NewPointerObj(wind->convert_progress,
-                                  SWIG_TypeQuery("_p__GNCProgressDialog"),
-                                  0);
+    progress = SWIG_NewPointerObj (wind->convert_progress,
+                                   SWIG_TypeQuery ("_p__GNCProgressDialog"),
+                                   0);
 
     /* Pause (or resume) the currently running operation. */
-    scm_call_1(toggle_pause, progress);
+    scm_call_1 (toggle_pause, progress);
 
     /* Swap the button label between pause and resume. */
-    if (strcmp(gtk_button_get_label(button), _("_Resume")))
+    if (strcmp (gtk_button_get_label (button), _("_Resume")))
     {
-        gtk_button_set_use_underline(button, TRUE);
-        gtk_button_set_label(button, _("_Resume"));
+        gtk_button_set_use_underline (button, TRUE);
+        gtk_button_set_label (button, _("_Resume"));
     }
     else
     {
-        gtk_button_set_use_underline(button, FALSE);
-        gtk_button_set_label(button, _("P_ause"));
+        gtk_button_set_use_underline (button, FALSE);
+        gtk_button_set_label (button, _("P_ause"));
     }
 }
 
@@ -2831,36 +2827,36 @@ gnc_ui_qif_import_convert_progress_pause_cb(GtkButton * button,
  * Invoked when the "Start" button is clicked.
  ********************************************************************/
 void
-gnc_ui_qif_import_convert_progress_start_cb(GtkButton * button,
+gnc_ui_qif_import_convert_progress_start_cb (GtkButton * button,
         gpointer user_data)
 {
     QIFImportWindow   *wind = user_data;
-    GtkAssistant *assistant = GTK_ASSISTANT (wind->window);
+    GtkAssistant *assistant = GTK_ASSISTANT(wind->window);
     gint num = gtk_assistant_get_current_page (assistant);
     GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
 
-    SCM qif_to_gnc      = scm_c_eval_string("qif-import:qif-to-gnc");
-    SCM find_duplicates = scm_c_eval_string("gnc:account-tree-find-duplicates");
+    SCM qif_to_gnc      = scm_c_eval_string ("qif-import:qif-to-gnc");
+    SCM find_duplicates = scm_c_eval_string ("gnc:account-tree-find-duplicates");
     SCM retval;
 
     /* SCM for the progress dialog. */
-    SCM progress = SWIG_NewPointerObj(wind->convert_progress,
-                                      SWIG_TypeQuery("_p__GNCProgressDialog"),
-                                      0);
+    SCM progress = SWIG_NewPointerObj (wind->convert_progress,
+                                       SWIG_TypeQuery ("_p__GNCProgressDialog"),
+                                       0);
 
     /* The default currency. */
-    const gchar *currname = gtk_entry_get_text( GTK_ENTRY( gtk_bin_get_child( GTK_BIN( GTK_COMBO_BOX(wind->currency_picker)))));
+    const gchar *currname = gtk_entry_get_text (GTK_ENTRY(gtk_bin_get_child (GTK_BIN(GTK_COMBO_BOX(wind->currency_picker)))));
 
     /* Raise the busy flag so the assistant can't be canceled unexpectedly. */
     wind->busy = TRUE;
-    gtk_widget_set_sensitive(wind->convert_pause, TRUE);
-    gtk_widget_set_sensitive(wind->convert_start, FALSE);
+    gtk_widget_set_sensitive (wind->convert_pause, TRUE);
+    gtk_widget_set_sensitive (wind->convert_start, FALSE);
 
     /* Clear any previous pause or cancel state. */
-    scm_c_eval_string("(qif-import:reset-cancel-pause)");
+    scm_c_eval_string ("(qif-import:reset-cancel-pause)");
 
     /* Update the commodities. */
-    gnc_ui_qif_import_commodity_update(wind);
+    gnc_ui_qif_import_commodity_update (wind);
 
     /*
      * Convert the QIF data into GnuCash data.
@@ -2872,33 +2868,33 @@ gnc_ui_qif_import_convert_progress_start_cb(GtkButton * button,
      */
 
     /* This step will fill 70% of the bar. */
-    gnc_progress_dialog_push(wind->convert_progress, 0.7);
-    retval = scm_apply(qif_to_gnc,
+    gnc_progress_dialog_push (wind->convert_progress, 0.7);
+    retval = scm_apply (qif_to_gnc,
                        SCM_LIST8(wind->imported_files,
                                  wind->acct_map_info,
                                  wind->cat_map_info,
                                  wind->memo_map_info,
                                  wind->security_hash,
-                                 scm_from_utf8_string(currname ? currname : ""),
+                                 scm_from_utf8_string (currname ? currname : ""),
                                  wind->transaction_status,
                                  progress),
                        SCM_EOL);
-    gnc_progress_dialog_pop(wind->convert_progress);
+    gnc_progress_dialog_pop (wind->convert_progress);
 
     if (retval == SCM_BOOL_T)
     {
         /* Canceled by the user. */
 
         /* Disable the pause button. */
-        gtk_widget_set_sensitive(wind->convert_pause, FALSE);
+        gtk_widget_set_sensitive (wind->convert_pause, FALSE);
 
         /* Remove any converted data. */
-        gnc_progress_dialog_set_sub(wind->convert_progress, _("Cleaning up"));
-        gnc_ui_qif_import_convert_undo(wind);
+        gnc_progress_dialog_set_sub (wind->convert_progress, _("Cleaning up"));
+        gnc_ui_qif_import_convert_undo (wind);
 
         /* Inform the user. */
-        gnc_progress_dialog_set_sub(wind->convert_progress, _("Canceled"));
-        gnc_progress_dialog_reset_value(wind->convert_progress);
+        gnc_progress_dialog_set_sub (wind->convert_progress, _("Canceled"));
+        gnc_progress_dialog_reset_value (wind->convert_progress);
 
         wind->busy = FALSE;
         wind->load_stop = TRUE;
@@ -2908,38 +2904,38 @@ gnc_ui_qif_import_convert_progress_start_cb(GtkButton * button,
         /* An bug was encountered during conversion. */
 
         /* Disable the pause button. */
-        gtk_widget_set_sensitive(wind->convert_pause, FALSE);
+        gtk_widget_set_sensitive (wind->convert_pause, FALSE);
 
         /* Remove any converted data. */
-        gnc_progress_dialog_set_sub(wind->convert_progress, _("Cleaning up"));
-        gnc_ui_qif_import_convert_undo(wind);
+        gnc_progress_dialog_set_sub (wind->convert_progress, _("Cleaning up"));
+        gnc_ui_qif_import_convert_undo (wind);
 
         /* Inform the user. */
-        gnc_progress_dialog_append_log(wind->convert_progress,
-                                       _( "A bug was detected while converting the QIF data."));
-        gnc_progress_dialog_set_sub(wind->convert_progress, _("Failed"));
-        gnc_progress_dialog_reset_value(wind->convert_progress);
-        gnc_error_dialog (GTK_WINDOW (assistant), "%s",
-                          _( "A bug was detected while converting the QIF data."));
+        gnc_progress_dialog_append_log (wind->convert_progress,
+                                        _("A bug was detected while converting the QIF data."));
+        gnc_progress_dialog_set_sub (wind->convert_progress, _("Failed"));
+        gnc_progress_dialog_reset_value (wind->convert_progress);
+        gnc_error_dialog (GTK_WINDOW(assistant), "%s",
+                          _("A bug was detected while converting the QIF data."));
         /* FIXME: How should we request that the user report this problem? */
 
         wind->busy = FALSE;
         wind->load_stop = TRUE;
     }
-    else if (scm_is_symbol(retval))
+    else if (scm_is_symbol (retval))
     {
         /* An error was encountered during conversion. */
 
         /* Disable the pause button. */
-        gtk_widget_set_sensitive(wind->convert_pause, FALSE);
+        gtk_widget_set_sensitive (wind->convert_pause, FALSE);
 
         /* Remove any converted data. */
-        gnc_progress_dialog_set_sub(wind->convert_progress, _("Cleaning up"));
-        gnc_ui_qif_import_convert_undo(wind);
+        gnc_progress_dialog_set_sub (wind->convert_progress, _("Cleaning up"));
+        gnc_ui_qif_import_convert_undo (wind);
 
         /* Inform the user. */
-        gnc_progress_dialog_set_sub(wind->convert_progress, _("Failed"));
-        gnc_progress_dialog_reset_value(wind->convert_progress);
+        gnc_progress_dialog_set_sub (wind->convert_progress, _("Failed"));
+        gnc_progress_dialog_reset_value (wind->convert_progress);
 
         wind->busy = FALSE;
         wind->load_stop = TRUE;
@@ -2947,31 +2943,31 @@ gnc_ui_qif_import_convert_progress_start_cb(GtkButton * button,
     if (wind->load_stop == FALSE)
     {
         /* Save the imported account tree. */
-        scm_gc_unprotect_object(wind->imported_account_tree);
+        scm_gc_unprotect_object (wind->imported_account_tree);
         wind->imported_account_tree = retval;
-        scm_gc_protect_object(wind->imported_account_tree);
+        scm_gc_protect_object (wind->imported_account_tree);
 
         /*
          * Detect potentially duplicated transactions.
          */
 
         /* This step will fill the remainder of the bar. */
-        gnc_progress_dialog_push(wind->convert_progress, 1);
-        retval = scm_call_3(find_duplicates,
-                            scm_c_eval_string("(gnc-get-current-root-account)"),
-                            wind->imported_account_tree, progress);
-        gnc_progress_dialog_pop(wind->convert_progress);
+        gnc_progress_dialog_push (wind->convert_progress, 1);
+        retval = scm_call_3 (find_duplicates,
+                             scm_c_eval_string ("(gnc-get-current-root-account)"),
+                             wind->imported_account_tree, progress);
+        gnc_progress_dialog_pop (wind->convert_progress);
 
         /* Save the results. */
-        scm_gc_unprotect_object(wind->match_transactions);
+        scm_gc_unprotect_object (wind->match_transactions);
         wind->match_transactions = retval;
-        scm_gc_protect_object(wind->match_transactions);
+        scm_gc_protect_object (wind->match_transactions);
 
         if (retval == SCM_BOOL_T)
         {
             /* Canceled by the user. */
-            gtk_widget_set_sensitive(wind->convert_pause, FALSE);
-            gnc_progress_dialog_set_sub(wind->convert_progress, _("Canceling"));
+            gtk_widget_set_sensitive (wind->convert_pause, FALSE);
+            gnc_progress_dialog_set_sub (wind->convert_progress, _("Canceling"));
             wind->busy = FALSE;
             wind->load_stop = TRUE;
         }
@@ -2980,19 +2976,19 @@ gnc_ui_qif_import_convert_progress_start_cb(GtkButton * button,
             /* An error occurred during duplicate checking. */
 
             /* Remove any converted data. */
-            gnc_progress_dialog_set_sub(wind->convert_progress, _("Cleaning up"));
-            gnc_ui_qif_import_convert_undo(wind);
+            gnc_progress_dialog_set_sub (wind->convert_progress, _("Cleaning up"));
+            gnc_ui_qif_import_convert_undo (wind);
 
             /* Inform the user. */
-            gnc_progress_dialog_append_log(wind->convert_progress,
-                                           _( "A bug was detected while detecting duplicates."));
-            gnc_progress_dialog_set_sub(wind->convert_progress, _("Failed"));
-            gnc_progress_dialog_reset_value(wind->convert_progress);
-            gnc_error_dialog (GTK_WINDOW (assistant), "%s",
-                              _( "A bug was detected while detecting duplicates."));
+            gnc_progress_dialog_append_log (wind->convert_progress,
+                                            _("A bug was detected while detecting duplicates."));
+            gnc_progress_dialog_set_sub (wind->convert_progress, _("Failed"));
+            gnc_progress_dialog_reset_value (wind->convert_progress);
+            gnc_error_dialog (GTK_WINDOW(assistant), "%s",
+                              _("A bug was detected while detecting duplicates."));
             /* FIXME: How should we request that the user report this problem? */
 
-            gtk_widget_set_sensitive(wind->convert_pause, FALSE);
+            gtk_widget_set_sensitive (wind->convert_pause, FALSE);
             wind->busy = FALSE;
             wind->load_stop = TRUE;
         }
@@ -3001,21 +2997,21 @@ gnc_ui_qif_import_convert_progress_start_cb(GtkButton * button,
     gtk_assistant_set_page_complete (assistant, page, TRUE);
 
     /* Set Pause and Start buttons */
-    gtk_widget_set_sensitive(wind->convert_pause, FALSE);
-    gtk_widget_set_sensitive(wind->convert_start, FALSE);
+    gtk_widget_set_sensitive (wind->convert_pause, FALSE);
+    gtk_widget_set_sensitive (wind->convert_start, FALSE);
 
     if (wind->load_stop == FALSE)
     {
         /* The conversion completed successfully. */
-        gnc_progress_dialog_set_sub(wind->convert_progress,
-                                    _("Conversion completed"));
-        gnc_progress_dialog_set_value(wind->convert_progress, 1);
+        gnc_progress_dialog_set_sub (wind->convert_progress,
+                                     _("Conversion completed"));
+        gnc_progress_dialog_set_value (wind->convert_progress, 1);
 
-        gtk_widget_set_sensitive(wind->convert_pause, FALSE);
+        gtk_widget_set_sensitive (wind->convert_pause, FALSE);
         wind->busy = FALSE;
 
         /* If the log is empty, move on to the next page automatically. */
-        if (gtk_text_buffer_get_char_count(gtk_text_view_get_buffer(GTK_TEXT_VIEW(wind->convert_log))) == 0)
+        if (gtk_text_buffer_get_char_count (gtk_text_view_get_buffer (GTK_TEXT_VIEW(wind->convert_log))) == 0)
             gtk_assistant_set_current_page (assistant, num + 1);
     }
 }

commit 2e105c94e71ac927ff6b0ae24b1ad04925901d96
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Tue May 7 15:42:16 2019 +0100

    Reformat assistant-qif-import.c source file part2/4

diff --git a/gnucash/import-export/qif-imp/assistant-qif-import.c b/gnucash/import-export/qif-imp/assistant-qif-import.c
index 1bc34f72e..49deecb8b 100644
--- a/gnucash/import-export/qif-imp/assistant-qif-import.c
+++ b/gnucash/import-export/qif-imp/assistant-qif-import.c
@@ -1080,26 +1080,26 @@ _gfec_error_handler (const char *message)
  * any imported accounts and transactions.
  ****************************************************************/
 static void
-gnc_ui_qif_import_convert_undo(QIFImportWindow * wind)
+gnc_ui_qif_import_convert_undo (QIFImportWindow * wind)
 {
-    SCM undo = scm_c_eval_string("qif-import:qif-to-gnc-undo");
+    SCM undo = scm_c_eval_string ("qif-import:qif-to-gnc-undo");
 
-    gnc_set_busy_cursor(NULL, TRUE);
+    gnc_set_busy_cursor (NULL, TRUE);
 
     /* Undo the conversion. */
-    gfec_apply(undo, wind->imported_account_tree, _gfec_error_handler);
+    gfec_apply (undo, wind->imported_account_tree, _gfec_error_handler);
 
     /* There's no imported account tree any more. */
-    scm_gc_unprotect_object(wind->imported_account_tree);
+    scm_gc_unprotect_object (wind->imported_account_tree);
     wind->imported_account_tree = SCM_BOOL_F;
-    scm_gc_protect_object(wind->imported_account_tree);
+    scm_gc_protect_object (wind->imported_account_tree);
 
     /* Get rid of the list of matched transactions. */
-    scm_gc_unprotect_object(wind->match_transactions);
+    scm_gc_unprotect_object (wind->match_transactions);
     wind->match_transactions = SCM_BOOL_F;
-    scm_gc_protect_object(wind->match_transactions);
+    scm_gc_protect_object (wind->match_transactions);
 
-    gnc_unset_busy_cursor(NULL);
+    gnc_unset_busy_cursor (NULL);
 }
 
 
@@ -1110,7 +1110,7 @@ gnc_ui_qif_import_convert_undo(QIFImportWindow * wind)
  * the old transactions.
  ****************************************************************/
 static void
-refresh_old_transactions(QIFImportWindow * wind, int selection)
+refresh_old_transactions (QIFImportWindow * wind, int selection)
 {
     SCM          possible_matches;
     SCM          current_xtn;
@@ -1124,28 +1124,28 @@ refresh_old_transactions(QIFImportWindow * wind, int selection)
     GtkTreeIter iter;
 
     view = GTK_TREE_VIEW(wind->old_transaction_view);
-    store = GTK_LIST_STORE(gtk_tree_view_get_model(view));
-    gtk_list_store_clear(store);
+    store = GTK_LIST_STORE(gtk_tree_view_get_model (view));
+    gtk_list_store_clear (store);
 
     if (wind->match_transactions != SCM_BOOL_F)
     {
-        possible_matches = SCM_CDR(scm_list_ref(wind->match_transactions,
-                                                scm_from_int (wind->selected_transaction)));
-        scm_call_2(scm_c_eval_string("qif-import:refresh-match-selection"),
-                   possible_matches, scm_from_int (selection));
+        possible_matches = SCM_CDR(scm_list_ref (wind->match_transactions,
+                                                 scm_from_int (wind->selected_transaction)));
+        scm_call_2 (scm_c_eval_string ("qif-import:refresh-match-selection"),
+                    possible_matches, scm_from_int (selection));
 
-        while (!scm_is_null(possible_matches))
+        while (!scm_is_null (possible_matches))
         {
-            char datebuff[MAX_DATE_LENGTH + 1];
-            memset(datebuff, 0, sizeof(datebuff));
+            char datebuff [MAX_DATE_LENGTH + 1];
+            memset (datebuff, 0, sizeof (datebuff));
             current_xtn = SCM_CAR(possible_matches);
 #define FUNC_NAME "xaccTransCountSplits"
-            gnc_xtn     = SWIG_MustGetPtr(SCM_CAR(current_xtn),
-                                          SWIG_TypeQuery("_p_Transaction"), 1, 0);
+            gnc_xtn     = SWIG_MustGetPtr (SCM_CAR(current_xtn),
+                                           SWIG_TypeQuery ("_p_Transaction"), 1, 0);
 #undef FUNC_NAME
             selected    = SCM_CDR(current_xtn);
 
-            if (xaccTransCountSplits(gnc_xtn) > 2)
+            if (xaccTransCountSplits (gnc_xtn) > 2)
             {
                 amount_str = _("(split)");
             }
@@ -1153,19 +1153,19 @@ refresh_old_transactions(QIFImportWindow * wind, int selection)
             {
                 gnc_split = xaccTransGetSplit(gnc_xtn, 0);
                 amount_str =
-                    xaccPrintAmount(gnc_numeric_abs(xaccSplitGetValue(gnc_split)),
-                                    gnc_account_print_info
-                                    (xaccSplitGetAccount(gnc_split), TRUE));
+                    xaccPrintAmount (gnc_numeric_abs (xaccSplitGetValue (gnc_split)),
+                                     gnc_account_print_info
+                                     (xaccSplitGetAccount (gnc_split), TRUE));
             }
 
-            gtk_list_store_append(store, &iter);
-            qof_print_date_buff(datebuff, sizeof(datebuff),
-                               xaccTransRetDatePosted(gnc_xtn));
+            gtk_list_store_append (store, &iter);
+            qof_print_date_buff (datebuff, sizeof (datebuff),
+                                xaccTransRetDatePosted (gnc_xtn));
             gtk_list_store_set
             (store, &iter,
              QIF_TRANS_COL_INDEX, rownum++,
              QIF_TRANS_COL_DATE, datebuff,
-             QIF_TRANS_COL_DESCRIPTION, xaccTransGetDescription(gnc_xtn),
+             QIF_TRANS_COL_DESCRIPTION, xaccTransGetDescription (gnc_xtn),
              QIF_TRANS_COL_AMOUNT, amount_str,
              QIF_TRANS_COL_CHECKED, selected != SCM_BOOL_F,
              -1);
@@ -1182,17 +1182,16 @@ refresh_old_transactions(QIFImportWindow * wind, int selection)
  * This function is the call back for duplicate transactions.
  ****************************************************************/
 static void
-gnc_ui_qif_import_duplicate_new_select_cb(GtkTreeSelection *selection,
+gnc_ui_qif_import_duplicate_new_select_cb (GtkTreeSelection *selection,
         QIFImportWindow  *wind)
 {
     GtkTreeModel *model;
     GtkTreeIter iter;
 
-    if (gtk_tree_selection_get_selected(selection, &model, &iter))
-        gtk_tree_model_get(model, &iter,
-                           QIF_TRANS_COL_INDEX, &wind->selected_transaction,
-                           -1);
-    refresh_old_transactions(wind, -1);
+    if (gtk_tree_selection_get_selected (selection, &model, &iter))
+        gtk_tree_model_get (model, &iter, QIF_TRANS_COL_INDEX,
+                            &wind->selected_transaction, -1);
+    refresh_old_transactions (wind, -1);
 }
 
 
@@ -1200,7 +1199,7 @@ gnc_ui_qif_import_duplicate_new_select_cb(GtkTreeSelection *selection,
  * reset_ignore_old_select
  ****************************************************************/
 static gboolean
-reset_ignore_old_select(gboolean *ignore)
+reset_ignore_old_select (gboolean *ignore)
 {
     *ignore = FALSE;
     return FALSE;
@@ -1213,7 +1212,7 @@ reset_ignore_old_select(gboolean *ignore)
  * This function is the call back for duplicate transactions.
  ****************************************************************/
 static void
-gnc_ui_qif_import_duplicate_old_select_cb(GtkTreeSelection *selection,
+gnc_ui_qif_import_duplicate_old_select_cb (GtkTreeSelection *selection,
         QIFImportWindow  *wind)
 {
     GtkTreeModel *model;
@@ -1223,9 +1222,9 @@ gnc_ui_qif_import_duplicate_old_select_cb(GtkTreeSelection *selection,
 
     /* Get the current selection then clear it.  We're about to clear
      * the entire list store and rebuild it so this prevents errors. */
-    if (!gtk_tree_selection_get_selected(selection, &model, &iter))
+    if (!gtk_tree_selection_get_selected (selection, &model, &iter))
         return;
-    gtk_tree_selection_unselect_all(selection);
+    gtk_tree_selection_unselect_all (selection);
 
     /* Getting a weird double call the first time a line is clicked.
      * Once via gtk_tree_view_button_press and then again via
@@ -1233,14 +1232,12 @@ gnc_ui_qif_import_duplicate_old_select_cb(GtkTreeSelection *selection,
     if (ignore_old_select)
         return;
     ignore_old_select = TRUE;
-    g_idle_add((GSourceFunc)reset_ignore_old_select, &ignore_old_select);
+    g_idle_add ((GSourceFunc)reset_ignore_old_select, &ignore_old_select);
 
     /* Get the row the user clicked on and update the scheme
      * code/rebuild the list store.  */
-    gtk_tree_model_get(model, &iter,
-                       QIF_TRANS_COL_INDEX, &row,
-                       -1);
-    refresh_old_transactions(wind, row);
+    gtk_tree_model_get (model, &iter, QIF_TRANS_COL_INDEX, &row, -1);
+    refresh_old_transactions (wind, row);
 }
 
 
@@ -1252,7 +1249,7 @@ gnc_ui_qif_import_duplicate_old_select_cb(GtkTreeSelection *selection,
  * window. The parameter user_data must point to a gboolean.
  ********************************************************************/
 static void
-gnc_ui_qif_import_check_acct_tree(GncPluginPage *page, gpointer user_data)
+gnc_ui_qif_import_check_acct_tree (GncPluginPage *page, gpointer user_data)
 {
     gboolean *found = user_data;
 
@@ -1267,41 +1264,41 @@ gnc_ui_qif_import_check_acct_tree(GncPluginPage *page, gpointer user_data)
  * Clears out any imported data and shuts down the importer.
  ****************************************************************/
 static void
-do_cancel(QIFImportWindow * wind)
+do_cancel (QIFImportWindow * wind)
 {
     GList                *pageptr;
     GtkWidget            *gtkpage;
     QIFAssistantPage     *page;
     gnc_commodity_table  *table;
 
-    gnc_set_busy_cursor(NULL, TRUE);
+    gnc_set_busy_cursor (NULL, TRUE);
 
     /* Remove any converted data. */
-    gnc_ui_qif_import_convert_undo(wind);
+    gnc_ui_qif_import_convert_undo (wind);
 
     /* Remove any commodities created for assistant pages. */
     for (pageptr = wind->commodity_pages; pageptr; pageptr = pageptr->next)
     {
         gtkpage   = pageptr->data;
-        page      = g_object_get_data(G_OBJECT(gtkpage), "page_struct");
-        gnc_commodity_destroy(page->commodity);
+        page      = g_object_get_data (G_OBJECT(gtkpage), "page_struct");
+        gnc_commodity_destroy (page->commodity);
     }
 
     /* Remove any namespaces created by the user. */
-    table = gnc_get_current_commodities();
+    table = gnc_get_current_commodities ();
     while (wind->new_namespaces)
     {
-        gnc_commodity_table_delete_namespace(table, (gchar *) wind->new_namespaces->data);
+        gnc_commodity_table_delete_namespace (table, (gchar *) wind->new_namespaces->data);
 
         /* Free the data and the list element. */
-        g_free(wind->new_namespaces->data);
-        wind->new_namespaces = g_list_delete_link(wind->new_namespaces,
+        g_free (wind->new_namespaces->data);
+        wind->new_namespaces = g_list_delete_link (wind->new_namespaces,
                                wind->new_namespaces);
     }
-    gnc_unset_busy_cursor(NULL);
+    gnc_unset_busy_cursor (NULL);
 
     /* Destroy the assistant. */
-    gnc_close_gui_component_by_data(ASSISTANT_QIF_IMPORT_CM_CLASS, wind);
+    gnc_close_gui_component_by_data (ASSISTANT_QIF_IMPORT_CM_CLASS, wind);
 }
 
 
@@ -1312,7 +1309,7 @@ do_cancel(QIFImportWindow * wind)
  * has been cleared before acting to cancel the import.
  ****************************************************************/
 static gboolean
-cancel_timeout_cb(gpointer data)
+cancel_timeout_cb (gpointer data)
 {
     QIFImportWindow *wind = data;
 
@@ -1321,7 +1318,7 @@ cancel_timeout_cb(gpointer data)
         return TRUE;
 
     /* The busy flag was lowered. Perform the cancel. */
-    do_cancel(wind);
+    do_cancel (wind);
 
     /* Cancel the timer. */
     return FALSE;
@@ -1334,29 +1331,29 @@ cancel_timeout_cb(gpointer data)
  * Invoked when the "Cancel" button is clicked.
  ****************************************************************/
 void
-gnc_ui_qif_import_cancel_cb(GtkAssistant *gtkassistant, gpointer user_data)
+gnc_ui_qif_import_cancel_cb (GtkAssistant *gtkassistant, gpointer user_data)
 {
     QIFImportWindow  *wind = user_data;
-    gint currentpage = gtk_assistant_get_current_page(gtkassistant);
+    gint currentpage = gtk_assistant_get_current_page (gtkassistant);
     GtkWidget *mypage = gtk_assistant_get_nth_page (gtkassistant, currentpage);
-    const char *pagename = gtk_buildable_get_name(GTK_BUILDABLE(mypage));
+    const char *pagename = gtk_buildable_get_name (GTK_BUILDABLE(mypage));
 
     if (!g_strcmp0 (pagename, "summary_page"))
     {
         /* Hitting the window close button on the summary page should not
            invoke a cancel action. The import has finised at that point. */
-        gnc_ui_qif_import_close_cb(gtkassistant, user_data);
+        gnc_ui_qif_import_close_cb (gtkassistant, user_data);
     }
     else if (wind->busy)
     {
         /* Cancel any long-running Scheme operation. */
-        scm_c_eval_string("(qif-import:cancel)");
+        scm_c_eval_string ("(qif-import:cancel)");
 
         /* Wait for the busy flag to be lowered. */
-        g_timeout_add(200, cancel_timeout_cb, user_data);
+        g_timeout_add (200, cancel_timeout_cb, user_data);
     }
     else
-        do_cancel(wind);
+        do_cancel (wind);
 }
 
 
@@ -1366,18 +1363,18 @@ gnc_ui_qif_import_cancel_cb(GtkAssistant *gtkassistant, gpointer user_data)
  * Invoked when the "Close" button is clicked.
  ****************************************************************/
 void
-gnc_ui_qif_import_close_cb(GtkAssistant *gtkassistant, gpointer user_data)
+gnc_ui_qif_import_close_cb (GtkAssistant *gtkassistant, gpointer user_data)
 {
     QIFImportWindow  *wind = user_data;
 
     /* If We did not have an account tree, lets save it */
     if (!wind->acct_tree_found)
     {
-        qof_book_mark_session_dirty(gnc_get_current_book());
-        gnc_ui_file_access_for_save_as (gnc_ui_get_main_window (GTK_WIDGET (gtkassistant)));
+        qof_book_mark_session_dirty (gnc_get_current_book ());
+        gnc_ui_file_access_for_save_as (gnc_ui_get_main_window (GTK_WIDGET(gtkassistant)));
     }
 
-    gnc_close_gui_component_by_data( ASSISTANT_QIF_IMPORT_CM_CLASS, wind );
+    gnc_close_gui_component_by_data (ASSISTANT_QIF_IMPORT_CM_CLASS, wind);
 }
 
 
@@ -1387,7 +1384,7 @@ gnc_ui_qif_import_close_cb(GtkAssistant *gtkassistant, gpointer user_data)
  * SCM get mappings.
  ****************************************************************/
 SCM
-gnc_ui_qif_import_assistant_get_mappings(QIFImportWindow * w)
+gnc_ui_qif_import_assistant_get_mappings (QIFImportWindow * w)
 {
     return SCM_LIST3(w->acct_map_info,
                      w->cat_map_info,
@@ -1407,11 +1404,11 @@ gnc_ui_qif_import_assistant_get_mappings(QIFImportWindow * w)
  * Get all user preferences related to QIF import.
  ********************************************************************/
 static void
-get_preferences(QIFImportWindow *wind)
+get_preferences (QIFImportWindow *wind)
 {
     gchar tmp_transaction_status = 'n';
 
-    g_return_if_fail(wind);
+    g_return_if_fail (wind);
 
     /* Get the user's preference for showing documentation pages. */
     wind->show_doc_pages =
@@ -1433,13 +1430,13 @@ get_preferences(QIFImportWindow *wind)
  * Initialize all Scheme-controlled objects.
  ********************************************************************/
 static void
-initialize_scheme(QIFImportWindow *wind)
+initialize_scheme (QIFImportWindow *wind)
 {
     SCM  load_map_prefs;
     SCM  mapping_info;
     SCM  create_ticker_map;
 
-    g_return_if_fail(wind);
+    g_return_if_fail (wind);
 
     /* Initialize Scheme variables. */
     wind->imported_files        = SCM_EOL;
@@ -1460,35 +1457,35 @@ initialize_scheme(QIFImportWindow *wind)
 
     /* Get the saved state of mappings from Quicken accounts and
      * categories to GnuCash accounts. */
-    load_map_prefs = scm_c_eval_string("qif-import:load-map-prefs");
-    mapping_info = scm_call_0(load_map_prefs); /* <- gets/creates session/book */
-    wind->gnc_acct_info         = scm_list_ref(mapping_info, scm_from_int (0));
-    wind->acct_map_info         = scm_list_ref(mapping_info, scm_from_int (1));
-    wind->cat_map_info          = scm_list_ref(mapping_info, scm_from_int (2));
-    wind->memo_map_info         = scm_list_ref(mapping_info, scm_from_int (3));
-    wind->security_hash         = scm_list_ref(mapping_info, scm_from_int (4));
-    wind->security_prefs        = scm_list_ref(mapping_info, scm_from_int (5));
+    load_map_prefs = scm_c_eval_string ("qif-import:load-map-prefs");
+    mapping_info = scm_call_0 (load_map_prefs); /* <- gets/creates session/book */
+    wind->gnc_acct_info         = scm_list_ref (mapping_info, scm_from_int (0));
+    wind->acct_map_info         = scm_list_ref (mapping_info, scm_from_int (1));
+    wind->cat_map_info          = scm_list_ref (mapping_info, scm_from_int (2));
+    wind->memo_map_info         = scm_list_ref (mapping_info, scm_from_int (3));
+    wind->security_hash         = scm_list_ref (mapping_info, scm_from_int (4));
+    wind->security_prefs        = scm_list_ref (mapping_info, scm_from_int (5));
 
     /* Get the initial ticker map. */
-    create_ticker_map = scm_c_eval_string("make-ticker-map");
-    wind->ticker_map            = scm_call_0(create_ticker_map);
+    create_ticker_map = scm_c_eval_string ("make-ticker-map");
+    wind->ticker_map            = scm_call_0 (create_ticker_map);
 
     /* Protect our data from garbage collection. */
-    scm_gc_protect_object(wind->imported_files);
-    scm_gc_protect_object(wind->selected_file);
-    scm_gc_protect_object(wind->gnc_acct_info);
-    scm_gc_protect_object(wind->cat_display_info);
-    scm_gc_protect_object(wind->cat_map_info);
-    scm_gc_protect_object(wind->memo_display_info);
-    scm_gc_protect_object(wind->memo_map_info);
-    scm_gc_protect_object(wind->acct_display_info);
-    scm_gc_protect_object(wind->acct_map_info);
-    scm_gc_protect_object(wind->security_hash);
-    scm_gc_protect_object(wind->security_prefs);
-    scm_gc_protect_object(wind->new_securities);
-    scm_gc_protect_object(wind->ticker_map);
-    scm_gc_protect_object(wind->imported_account_tree);
-    scm_gc_protect_object(wind->match_transactions);
+    scm_gc_protect_object (wind->imported_files);
+    scm_gc_protect_object (wind->selected_file);
+    scm_gc_protect_object (wind->gnc_acct_info);
+    scm_gc_protect_object (wind->cat_display_info);
+    scm_gc_protect_object (wind->cat_map_info);
+    scm_gc_protect_object (wind->memo_display_info);
+    scm_gc_protect_object (wind->memo_map_info);
+    scm_gc_protect_object (wind->acct_display_info);
+    scm_gc_protect_object (wind->acct_map_info);
+    scm_gc_protect_object (wind->security_hash);
+    scm_gc_protect_object (wind->security_prefs);
+    scm_gc_protect_object (wind->new_securities);
+    scm_gc_protect_object (wind->ticker_map);
+    scm_gc_protect_object (wind->imported_account_tree);
+    scm_gc_protect_object (wind->match_transactions);
 }
 
 
@@ -1505,21 +1502,21 @@ void
 gnc_ui_qif_import_intro_prepare (GtkAssistant  *assistant, gpointer user_data)
 {
     QIFImportWindow   *wind = user_data;
-    SCM unload = scm_c_eval_string("qif-dialog:unload-qif-file");
+    SCM unload = scm_c_eval_string ("qif-dialog:unload-qif-file");
     SCM files_list;
 
     /* Set load stop to FALSE */
     wind->load_stop = FALSE;
 
-    files_list = scm_call_2(unload, wind->selected_file, wind->imported_files);
+    files_list = scm_call_2 (unload, wind->selected_file, wind->imported_files);
 
-    scm_gc_unprotect_object(wind->imported_files);
+    scm_gc_unprotect_object (wind->imported_files);
     wind->imported_files = files_list;
-    scm_gc_protect_object(wind->imported_files);
+    scm_gc_protect_object (wind->imported_files);
 
-    scm_gc_unprotect_object(wind->selected_file);
+    scm_gc_unprotect_object (wind->selected_file);
     wind->selected_file = SCM_BOOL_F;
-    scm_gc_protect_object(wind->selected_file);
+    scm_gc_protect_object (wind->selected_file);
 }
 
 
@@ -1540,13 +1537,13 @@ gnc_ui_qif_import_load_file_complete (GtkAssistant  *assistant,
     const gchar * path_to_load;
 
     /* Get the file name. */
-    path_to_load = gtk_entry_get_text(GTK_ENTRY(wind->filename_entry));
+    path_to_load = gtk_entry_get_text (GTK_ENTRY(wind->filename_entry));
 
     /* Validate the chosen filename. */
-    if (strlen(path_to_load) == 0)
-        gnc_error_dialog (GTK_WINDOW (assistant), "%s", _("Please select a file to load."));
-    else if (g_access(path_to_load, R_OK) < 0)
-        gnc_error_dialog (GTK_WINDOW (assistant), "%s",
+    if (strlen (path_to_load) == 0)
+        gnc_error_dialog (GTK_WINDOW(assistant), "%s", _("Please select a file to load."));
+    else if (g_access (path_to_load, R_OK) < 0)
+        gnc_error_dialog (GTK_WINDOW(assistant), "%s",
                           _("File not found or read permission denied. "
                             "Please select another file."));
     else
@@ -1554,10 +1551,10 @@ gnc_ui_qif_import_load_file_complete (GtkAssistant  *assistant,
         SCM qif_file_loaded = scm_c_eval_string("qif-dialog:qif-file-loaded?");
 
         /* See if the file is already loaded. */
-        if (scm_call_2(qif_file_loaded,
-                       scm_from_locale_string(path_to_load ? path_to_load : ""),
-                       wind->imported_files) == SCM_BOOL_T)
-            gnc_error_dialog (GTK_WINDOW (assistant), "%s",
+        if (scm_call_2 (qif_file_loaded,
+                        scm_from_locale_string (path_to_load ? path_to_load : ""),
+                        wind->imported_files) == SCM_BOOL_T)
+            gnc_error_dialog (GTK_WINDOW(assistant), "%s",
                               _("That QIF file is already loaded. "
                                 "Please select another file."));
         else
@@ -1566,7 +1563,6 @@ gnc_ui_qif_import_load_file_complete (GtkAssistant  *assistant,
             return TRUE;
         }
     }
-
     /* Stay on this page. */
     return FALSE;
 }
@@ -1578,7 +1574,7 @@ gnc_ui_qif_import_load_file_complete (GtkAssistant  *assistant,
  * Prepare the load file page for display.
  ********************************************************************/
 void
-gnc_ui_qif_import_load_file_prepare (GtkAssistant  *assistant, gpointer user_data)
+gnc_ui_qif_import_load_file_prepare (GtkAssistant *assistant, gpointer user_data)
 {
     QIFImportWindow * wind = user_data;
     const gchar * path_to_load;
@@ -1588,12 +1584,12 @@ gnc_ui_qif_import_load_file_prepare (GtkAssistant  *assistant, gpointer user_dat
     GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
 
     /* Get the file name. */
-    path_to_load = gtk_entry_get_text(GTK_ENTRY(wind->filename_entry));
+    path_to_load = gtk_entry_get_text (GTK_ENTRY(wind->filename_entry));
 
     /* Calculate status for the Assistant "Next" Button */
-    if (strlen(path_to_load) != 0)
+    if (strlen (path_to_load) != 0)
     {
-       page_status = gnc_ui_qif_import_load_file_complete(assistant, user_data);
+       page_status = gnc_ui_qif_import_load_file_complete (assistant, user_data);
     }
     gtk_assistant_set_page_complete (assistant, page, page_status);
 }
@@ -1607,8 +1603,8 @@ gnc_ui_qif_import_load_file_prepare (GtkAssistant  *assistant, gpointer user_dat
  * fields describing how to parse the file.
  ********************************************************************/
 void
-gnc_ui_qif_import_select_file_cb(GtkButton * button,
-                                 gpointer user_data)
+gnc_ui_qif_import_select_file_cb (GtkButton * button,
+                                  gpointer user_data)
 {
     QIFImportWindow * wind = user_data;
 
@@ -1621,40 +1617,40 @@ gnc_ui_qif_import_select_file_cb(GtkButton * button,
     char *file_name, *default_dir;
 
     /* Default to whatever's already present */
-    default_dir = gnc_get_default_directory(GNC_PREFS_GROUP);
+    default_dir = gnc_get_default_directory (GNC_PREFS_GROUP);
 
-    filter = gtk_file_filter_new();
-    gtk_file_filter_set_name(filter, "*.qif");
-    gtk_file_filter_add_pattern(filter, "*.[Qq][Ii][Ff]");
-    new_file_name = gnc_file_dialog(gnc_ui_get_gtk_window (GTK_WIDGET (button)),
-                                    _("Select QIF File"),
-                                    g_list_prepend (NULL, filter),
-                                    default_dir,
-                                    GNC_FILE_DIALOG_IMPORT);
+    filter = gtk_file_filter_new ();
+    gtk_file_filter_set_name (filter, "*.qif");
+    gtk_file_filter_add_pattern (filter, "*.[Qq][Ii][Ff]");
+    new_file_name = gnc_file_dialog (gnc_ui_get_gtk_window (GTK_WIDGET(button)),
+                                     _("Select QIF File"),
+                                     g_list_prepend (NULL, filter),
+                                     default_dir,
+                                     GNC_FILE_DIALOG_IMPORT);
 
     /* Insure valid data, and something that can be freed. */
     if (new_file_name == NULL)
     {
-        file_name = g_strdup(default_dir);
+        file_name = g_strdup (default_dir);
     }
-    else if (!g_path_is_absolute(new_file_name))
+    else if (!g_path_is_absolute (new_file_name))
     {
-        file_name = g_build_filename(default_dir, new_file_name, NULL);
-        g_free(new_file_name);
+        file_name = g_build_filename (default_dir, new_file_name, NULL);
+        g_free (new_file_name);
     }
     else
     {
         file_name = new_file_name;
         /* Update the working directory */
-        g_free(default_dir);
-        default_dir = g_path_get_dirname(file_name);
-        gnc_set_default_directory(GNC_PREFS_GROUP, default_dir);
+        g_free (default_dir);
+        default_dir = g_path_get_dirname (file_name);
+        gnc_set_default_directory (GNC_PREFS_GROUP, default_dir);
     }
-    g_free(default_dir);
+    g_free (default_dir);
 
     /* set the filename entry for what was selected */
-    gtk_entry_set_text(GTK_ENTRY(wind->filename_entry), file_name);
-    g_free(file_name);
+    gtk_entry_set_text (GTK_ENTRY(wind->filename_entry), file_name);
+    g_free (file_name);
 
     gtk_assistant_set_page_complete (assistant, page,
                                      gnc_ui_qif_import_load_file_complete (assistant, user_data));
@@ -1671,34 +1667,34 @@ gnc_ui_qif_import_select_file_cb(GtkButton * button,
  * Invoked when the "Pause" button is clicked.
  ********************************************************************/
 void
-gnc_ui_qif_import_load_progress_pause_cb(GtkButton * button,
+gnc_ui_qif_import_load_progress_pause_cb (GtkButton * button,
         gpointer user_data)
 {
     QIFImportWindow *wind = user_data;
-    SCM toggle_pause      = scm_c_eval_string("qif-import:toggle-pause");
+    SCM toggle_pause      = scm_c_eval_string ("qif-import:toggle-pause");
     SCM progress;
 
     if (!wind->busy)
         return;
 
     /* Create SCM for the progress helper. */
-    progress = SWIG_NewPointerObj(wind->load_progress,
-                                  SWIG_TypeQuery("_p__GNCProgressDialog"),
+    progress = SWIG_NewPointerObj (wind->load_progress,
+                                  SWIG_TypeQuery ("_p__GNCProgressDialog"),
                                   0);
 
     /* Pause (or resume) the currently running operation. */
-    scm_call_1(toggle_pause, progress);
+    scm_call_1 (toggle_pause, progress);
 
     /* Swap the button label between pause and resume. */
-    if (strcmp(gtk_button_get_label(button), _("_Resume")))
+    if (strcmp (gtk_button_get_label (button), _("_Resume")))
     {
-        gtk_button_set_use_underline(button, TRUE);
-        gtk_button_set_label(button, _("_Resume"));
+        gtk_button_set_use_underline (button, TRUE);
+        gtk_button_set_label (button, _("_Resume"));
     }
     else
     {
-        gtk_button_set_use_underline(button, FALSE);
-        gtk_button_set_label(button, _("P_ause"));
+        gtk_button_set_use_underline (button, FALSE);
+        gtk_button_set_label (button, _("P_ause"));
     }
 }
 
@@ -1709,7 +1705,7 @@ gnc_ui_qif_import_load_progress_pause_cb(GtkButton * button,
  * Invoked when the "Start" button is clicked.
  ********************************************************************/
 void
-gnc_ui_qif_import_load_progress_start_cb(GtkButton * button,
+gnc_ui_qif_import_load_progress_start_cb (GtkButton * button,
         gpointer user_data)
 {
     QIFImportWindow   *wind = user_data;
@@ -1719,11 +1715,11 @@ gnc_ui_qif_import_load_progress_start_cb(GtkButton * button,
 
     const gchar * path_to_load;
 
-    SCM make_qif_file   = scm_c_eval_string("make-qif-file");
-    SCM qif_file_load   = scm_c_eval_string("qif-file:read-file");
-    SCM qif_file_parse  = scm_c_eval_string("qif-file:parse-fields");
-    SCM unload_qif_file = scm_c_eval_string("qif-dialog:unload-qif-file");
-    SCM parse_results   = scm_c_eval_string("qif-file:parse-fields-results");
+    SCM make_qif_file   = scm_c_eval_string ("make-qif-file");
+    SCM qif_file_load   = scm_c_eval_string ("qif-file:read-file");
+    SCM qif_file_parse  = scm_c_eval_string ("qif-file:parse-fields");
+    SCM unload_qif_file = scm_c_eval_string ("qif-dialog:unload-qif-file");
+    SCM parse_results   = scm_c_eval_string ("qif-file:parse-fields-results");
     SCM scm_qiffile;
     SCM imported_files = SCM_EOL;
     SCM load_return = SCM_BOOL_F, parse_return = SCM_BOOL_F;
@@ -1731,25 +1727,25 @@ gnc_ui_qif_import_load_progress_start_cb(GtkButton * button,
 
     /* Raise the busy flag so the assistant can't be canceled unexpectedly. */
     wind->busy = TRUE;
-    gtk_widget_set_sensitive(wind->load_pause, TRUE);
+    gtk_widget_set_sensitive (wind->load_pause, TRUE);
 
     /* Get the file name. */
-    path_to_load = gtk_entry_get_text(GTK_ENTRY(wind->filename_entry));
+    path_to_load = gtk_entry_get_text (GTK_ENTRY(wind->filename_entry));
 
     /* Create the <qif-file> object. */
-    scm_qiffile          = scm_call_0(make_qif_file);
-    scm_gc_unprotect_object(wind->selected_file);
+    scm_qiffile          = scm_call_0 (make_qif_file);
+    scm_gc_unprotect_object (wind->selected_file);
     wind->selected_file  = scm_qiffile;
-    scm_gc_protect_object(wind->selected_file);
-    imported_files       = scm_cons(scm_qiffile, wind->imported_files);
+    scm_gc_protect_object (wind->selected_file);
+    imported_files       = scm_cons (scm_qiffile, wind->imported_files);
 
     /* Create SCM for the progress helper. */
-    progress = SWIG_NewPointerObj(wind->load_progress,
-                                  SWIG_TypeQuery("_p__GNCProgressDialog"),
-                                  0);
+    progress = SWIG_NewPointerObj (wind->load_progress,
+                                   SWIG_TypeQuery ("_p__GNCProgressDialog"),
+                                   0);
 
     /* Clear any previous pause or cancel state. */
-    scm_c_eval_string("(qif-import:reset-cancel-pause)");
+    scm_c_eval_string ("(qif-import:reset-cancel-pause)");
 
     /*
      * Load the file.
@@ -1763,58 +1759,58 @@ gnc_ui_qif_import_load_progress_start_cb(GtkButton * button,
      */
 
     /* This step will fill 70% of the bar. */
-    gnc_progress_dialog_push(wind->load_progress, 0.7);
-    load_return = scm_call_4(qif_file_load,
-                             SCM_CAR(imported_files),
-                             scm_from_locale_string(path_to_load ? path_to_load : ""),
-                             wind->ticker_map,
-                             progress);
-    gnc_progress_dialog_pop(wind->load_progress);
+    gnc_progress_dialog_push (wind->load_progress, 0.7);
+    load_return = scm_call_4 (qif_file_load,
+                              SCM_CAR(imported_files),
+                              scm_from_locale_string (path_to_load ? path_to_load : ""),
+                              wind->ticker_map,
+                              progress);
+    gnc_progress_dialog_pop (wind->load_progress);
     if (load_return == SCM_BOOL_T)
     {
         /* Canceled by the user. */
 
         /* Disable the pause button. */
-        gtk_widget_set_sensitive(wind->load_pause, FALSE);
+        gtk_widget_set_sensitive (wind->load_pause, FALSE);
 
         /* Inform the user. */
-        gnc_progress_dialog_set_sub(wind->load_progress, _("Canceled"));
+        gnc_progress_dialog_set_sub (wind->load_progress, _("Canceled"));
 
         wind->busy = FALSE;
         wind->load_stop = TRUE;
     }
-    else if (load_return == SCM_BOOL_F || !scm_is_list(load_return))
+    else if (load_return == SCM_BOOL_F || !scm_is_list (load_return))
     {
         /* A bug was detected. */
 
         /* Disable the pause button. */
-        gtk_widget_set_sensitive(wind->load_pause, FALSE);
+        gtk_widget_set_sensitive (wind->load_pause, FALSE);
 
         /* Inform the user. */
-        gnc_progress_dialog_append_log(wind->load_progress,
-                                       _( "An error occurred while loading the QIF file."));
-        gnc_progress_dialog_set_sub(wind->load_progress, _("Failed"));
-        gnc_progress_dialog_reset_value(wind->load_progress);
-        gnc_error_dialog (GTK_WINDOW (assistant), "%s",
-                          _( "An error occurred while loading the QIF file."));
+        gnc_progress_dialog_append_log (wind->load_progress,
+                                        _("An error occurred while loading the QIF file."));
+        gnc_progress_dialog_set_sub (wind->load_progress, _("Failed"));
+        gnc_progress_dialog_reset_value (wind->load_progress);
+        gnc_error_dialog (GTK_WINDOW(assistant), "%s",
+                          _("An error occurred while loading the QIF file."));
         /* FIXME: How should we request that the user report this problem? */
 
         wind->busy = FALSE;
         wind->load_stop = TRUE;
     }
-    else if (!scm_is_null(load_return))
+    else if (!scm_is_null (load_return))
     {
         if (SCM_CAR(load_return) == SCM_BOOL_F)
         {
-            imported_files = scm_call_2(unload_qif_file, scm_qiffile, imported_files);
-            scm_gc_unprotect_object(wind->imported_files);
+            imported_files = scm_call_2 (unload_qif_file, scm_qiffile, imported_files);
+            scm_gc_unprotect_object (wind->imported_files);
             wind->imported_files = imported_files;
-            scm_gc_protect_object(wind->imported_files);
+            scm_gc_protect_object (wind->imported_files);
 
-            gnc_progress_dialog_set_sub(wind->load_progress, _("Failed"));
-            gnc_progress_dialog_reset_value(wind->load_progress);
+            gnc_progress_dialog_set_sub (wind->load_progress, _("Failed"));
+            gnc_progress_dialog_reset_value (wind->load_progress);
 
-            gtk_widget_set_sensitive(wind->load_pause, FALSE);
+            gtk_widget_set_sensitive (wind->load_pause, FALSE);
             wind->busy = FALSE;
             wind->load_stop = TRUE;
         }
@@ -1834,26 +1830,26 @@ gnc_ui_qif_import_load_progress_start_cb(GtkButton * button,
     /* This step will fill the remainder of the bar. */
     if (!wind->load_stop)
     {
-	gnc_progress_dialog_push(wind->load_progress, 1);
-	parse_return = scm_call_2(qif_file_parse, SCM_CAR(imported_files),
-				  progress);
-	gnc_progress_dialog_pop(wind->load_progress);
-	wind->ask_date_format = FALSE;
-	wind->date_format = NULL;
+    gnc_progress_dialog_push (wind->load_progress, 1);
+    parse_return = scm_call_2 (qif_file_parse, SCM_CAR(imported_files),
+                   progress);
+    gnc_progress_dialog_pop (wind->load_progress);
+    wind->ask_date_format = FALSE;
+    wind->date_format = NULL;
     }
     if (parse_return == SCM_BOOL_T)
     {
         /* Canceled by the user. */
 
         /* Disable the pause button. */
-        gtk_widget_set_sensitive(wind->load_pause, FALSE);
+        gtk_widget_set_sensitive (wind->load_pause, FALSE);
 
         /* Unload the file. */
-        gnc_progress_dialog_set_sub(wind->load_progress, _("Cleaning up"));
-        imported_files = scm_call_2(unload_qif_file, scm_qiffile, imported_files);
+        gnc_progress_dialog_set_sub (wind->load_progress, _("Cleaning up"));
+        imported_files = scm_call_2 (unload_qif_file, scm_qiffile, imported_files);
 
         /* Inform the user. */
-        gnc_progress_dialog_set_sub(wind->load_progress, _("Canceled"));
+        gnc_progress_dialog_set_sub (wind->load_progress, _("Canceled"));
 
         wind->busy = FALSE;
         wind->load_stop = TRUE;
@@ -1863,25 +1859,25 @@ gnc_ui_qif_import_load_progress_start_cb(GtkButton * button,
         /* A bug was detected. */
 
         /* Disable the pause button. */
-        gtk_widget_set_sensitive(wind->load_pause, FALSE);
+        gtk_widget_set_sensitive (wind->load_pause, FALSE);
 
         /* Unload the file. */
-        gnc_progress_dialog_set_sub(wind->load_progress, _("Cleaning up"));
-        imported_files = scm_call_2(unload_qif_file, scm_qiffile, imported_files);
+        gnc_progress_dialog_set_sub (wind->load_progress, _("Cleaning up"));
+        imported_files = scm_call_2 (unload_qif_file, scm_qiffile, imported_files);
 
         /* Inform the user. */
-        gnc_progress_dialog_append_log(wind->load_progress,
-                                       _( "A bug was detected while parsing the QIF file."));
-        gnc_progress_dialog_set_sub(wind->load_progress, _("Failed"));
-        gnc_progress_dialog_reset_value(wind->load_progress);
-        gnc_error_dialog (GTK_WINDOW (assistant), "%s",
-                          _( "A bug was detected while parsing the QIF file."));
+        gnc_progress_dialog_append_log (wind->load_progress,
+                                        _("A bug was detected while parsing the QIF file."));
+        gnc_progress_dialog_set_sub (wind->load_progress, _("Failed"));
+        gnc_progress_dialog_reset_value (wind->load_progress);
+        gnc_error_dialog (GTK_WINDOW(assistant), "%s",
+                          _("A bug was detected while parsing the QIF file."));
         /* FIXME: How should we request that the user report this problem? */
 
         wind->busy = FALSE;
         wind->load_stop = TRUE;
     }
-    else if (!scm_is_null(parse_return))
+    else if (!scm_is_null (parse_return))
     {
         /* Are there only warnings? */
         if (SCM_CAR(parse_return) == SCM_BOOL_T)
@@ -1891,35 +1887,35 @@ gnc_ui_qif_import_load_progress_start_cb(GtkButton * button,
             /* A warning means that (potentially) the date format is
              * ambiguous.  So search the results for the "date" type and if
              * it's found, set up the format selector page. */
-            if ((date_formats = scm_call_2(parse_results,
-                                           SCM_CDR(parse_return),
-                                           scm_from_locale_symbol ("date"))) != SCM_BOOL_F)
+            if ((date_formats = scm_call_2 (parse_results,
+                                            SCM_CDR(parse_return),
+                                            scm_from_locale_symbol ("date"))) != SCM_BOOL_F)
             {
                 GtkComboBox *combo_box;
                 GtkTreeModel *model;
                 GtkTreeIter iter;
 
                 /* Block the date call back */
-                g_signal_handlers_block_by_func( wind->date_format_combo, gnc_ui_qif_import_date_valid_cb, wind );
+                g_signal_handlers_block_by_func (wind->date_format_combo, gnc_ui_qif_import_date_valid_cb, wind);
 
                 /* Clear the date format combo box. */
                 combo_box = GTK_COMBO_BOX(wind->date_format_combo);
-                model = gtk_combo_box_get_model(combo_box);
-                gtk_list_store_clear(GTK_LIST_STORE(model));
+                model = gtk_combo_box_get_model (combo_box);
+                gtk_list_store_clear (GTK_LIST_STORE(model));
 
-                gtk_combo_box_set_active(GTK_COMBO_BOX(wind->date_format_combo), -1);
+                gtk_combo_box_set_active (GTK_COMBO_BOX(wind->date_format_combo), -1);
 
                 /* Add the formats for the user to select from. */
-                while (scm_is_list(date_formats) && !scm_is_null(date_formats))
+                while (scm_is_list (date_formats) && !scm_is_null (date_formats))
                 {
-                    gtk_list_store_append(GTK_LIST_STORE(model), &iter);
-                    gtk_list_store_set (GTK_LIST_STORE(model), &iter, 0, gnc_scm_symbol_to_locale_string(SCM_CAR(date_formats)), -1);
+                    gtk_list_store_append (GTK_LIST_STORE(model), &iter);
+                    gtk_list_store_set (GTK_LIST_STORE(model), &iter, 0, gnc_scm_symbol_to_locale_string (SCM_CAR(date_formats)), -1);
 
                     date_formats = SCM_CDR(date_formats);
                 }
 
                 /* Unblock the date call back */
-                g_signal_handlers_unblock_by_func( wind->date_format_combo, gnc_ui_qif_import_date_valid_cb, wind );
+                g_signal_handlers_unblock_by_func (wind->date_format_combo, gnc_ui_qif_import_date_valid_cb, wind);
 
                 wind->ask_date_format = TRUE;
             }
@@ -1928,11 +1924,11 @@ gnc_ui_qif_import_load_progress_start_cb(GtkButton * button,
         else
         {
             /* Parsing failed. */
-            imported_files = scm_call_2(unload_qif_file, scm_qiffile, imported_files);
-            gnc_progress_dialog_set_sub(wind->load_progress, _("Failed"));
-            gnc_progress_dialog_reset_value(wind->load_progress);
+            imported_files = scm_call_2 (unload_qif_file, scm_qiffile, imported_files);
+            gnc_progress_dialog_set_sub (wind->load_progress, _("Failed"));
+            gnc_progress_dialog_reset_value (wind->load_progress);
 
-            gtk_widget_set_sensitive(wind->load_pause, FALSE);
+            gtk_widget_set_sensitive (wind->load_pause, FALSE);
             wind->busy = FALSE;
             wind->load_stop = TRUE;
         }
@@ -1942,23 +1938,22 @@ gnc_ui_qif_import_load_progress_start_cb(GtkButton * button,
     gtk_assistant_set_page_complete (assistant, page, TRUE);
 
     /* Set Pause and Start buttons */
-    gtk_widget_set_sensitive(wind->load_pause, FALSE);
-    gtk_widget_set_sensitive(wind->load_start, FALSE);
+    gtk_widget_set_sensitive (wind->load_pause, FALSE);
+    gtk_widget_set_sensitive (wind->load_start, FALSE);
 
     /* The file was loaded successfully. */
-    gnc_progress_dialog_set_sub(wind->load_progress, _("Loading completed"));
-    gnc_progress_dialog_set_value(wind->load_progress, 1);
+    gnc_progress_dialog_set_sub (wind->load_progress, _("Loading completed"));
+    gnc_progress_dialog_set_value (wind->load_progress, 1);
 
-    scm_gc_unprotect_object(wind->imported_files);
+    scm_gc_unprotect_object (wind->imported_files);
     wind->imported_files = imported_files;
-    scm_gc_protect_object(wind->imported_files);
+    scm_gc_protect_object (wind->imported_files);
 
-    gtk_widget_set_sensitive(wind->load_pause, FALSE);
+    gtk_widget_set_sensitive (wind->load_pause, FALSE);
     wind->busy = FALSE;
 
     if (wind->load_stop == FALSE)
     {
-
         /* Auto step to next page */
         gtk_assistant_set_current_page (assistant, num + 1);
     }
@@ -1982,16 +1977,16 @@ gnc_ui_qif_import_load_progress_prepare (GtkAssistant  *assistant, gpointer user
     GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
 
     /* Reset the progress display. */
-    gnc_progress_dialog_set_primary(wind->load_progress, "");
-    gnc_progress_dialog_set_secondary(wind->load_progress,
-                                      _("When you press the Start Button, GnuCash will load your QIF file. If there are no errors or warnings, you will automatically proceed to the next step. Otherwise, the details will be shown below for your review."));
-    gnc_progress_dialog_set_sub(wind->load_progress, " ");
-    gnc_progress_dialog_reset_value(wind->load_progress);
-    gnc_progress_dialog_reset_log(wind->load_progress);
+    gnc_progress_dialog_set_primary (wind->load_progress, "");
+    gnc_progress_dialog_set_secondary (wind->load_progress,
+                                       _("When you press the Start Button, GnuCash will load your QIF file. If there are no errors or warnings, you will automatically proceed to the next step. Otherwise, the details will be shown below for your review."));
+    gnc_progress_dialog_set_sub (wind->load_progress, " ");
+    gnc_progress_dialog_reset_value (wind->load_progress);
+    gnc_progress_dialog_reset_log (wind->load_progress);
 
     /* Set Pause and Start buttons */
-    gtk_widget_set_sensitive(wind->load_pause, FALSE);
-    gtk_widget_set_sensitive(wind->load_start, TRUE);
+    gtk_widget_set_sensitive (wind->load_pause, FALSE);
+    gtk_widget_set_sensitive (wind->load_start, TRUE);
 
     /* Disable the assistant "Next" button */
     gtk_assistant_set_page_complete (assistant, page, FALSE);

commit aa5601b432305da9771e9e8fc31eb7bfa0a6d81c
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Tue May 7 15:41:38 2019 +0100

    Reformat assistant-qif-import.c source file part1/4

diff --git a/gnucash/import-export/qif-imp/assistant-qif-import.c b/gnucash/import-export/qif-imp/assistant-qif-import.c
index 693d77b96..1bc34f72e 100644
--- a/gnucash/import-export/qif-imp/assistant-qif-import.c
+++ b/gnucash/import-export/qif-imp/assistant-qif-import.c
@@ -62,10 +62,10 @@
 #include "guile-mappings.h"
 #include <gfec.h>
 
-#define ASSISTANT_QIF_IMPORT_CM_CLASS "assistant-qif-import"
-#define GNC_PREFS_GROUP   "dialogs.import.qif"
-#define GNC_PREF_SHOW_DOC "show-doc"
-#define GNC_PREF_DEFAULT_TRANS_STATUS_CLEARED "default-status-cleared"
+#define ASSISTANT_QIF_IMPORT_CM_CLASS            "assistant-qif-import"
+#define GNC_PREFS_GROUP                          "dialogs.import.qif"
+#define GNC_PREF_SHOW_DOC                        "show-doc"
+#define GNC_PREF_DEFAULT_TRANS_STATUS_CLEARED    "default-status-cleared"
 #define GNC_PREF_DEFAULT_TRANS_STATUS_NOTCLEARED "default-status-notcleared"
 #define GNC_PREF_DEFAULT_TRANS_STATUS_RECONCILED "default-status-reconciled"
 
@@ -208,14 +208,14 @@ struct _qifassistantpage
 typedef struct _qifassistantpage QIFAssistantPage;
 
 static void gnc_ui_qif_import_assistant_destroy (GtkWidget *object, gpointer user_data);
-static void gnc_ui_qif_import_assistant_close_handler (gpointer user_data );
+static void gnc_ui_qif_import_assistant_close_handler (gpointer user_data);
 
 void gnc_ui_qif_import_cancel_cb (GtkAssistant *gtkassistant, gpointer user_data);
 void gnc_ui_qif_import_prepare_cb (GtkAssistant *assistant, GtkWidget *page, gpointer user_data);
 void gnc_ui_qif_import_finish_cb (GtkAssistant *gtkassistant, gpointer user_data);
 void gnc_ui_qif_import_close_cb (GtkAssistant *gtkassistant, gpointer user_data);
 
-void gnc_ui_qif_import_intro_prepare (GtkAssistant  *assistant, gpointer user_data);
+void gnc_ui_qif_import_intro_prepare (GtkAssistant *assistant, gpointer user_data);
 
 void gnc_ui_qif_import_load_file_prepare (GtkAssistant *assistant, gpointer user_data);
 void gnc_ui_qif_import_select_file_cb (GtkButton *button, gpointer user_data);
@@ -256,7 +256,7 @@ void gnc_ui_qif_import_comm_changed_cb (GtkWidget *widget, gpointer user_data);
 
 void gnc_ui_qif_import_convert_progress_prepare (GtkAssistant *assistant, gpointer user_data);
 void gnc_ui_qif_import_convert_progress_pause_cb (GtkButton * button, gpointer user_data);
-void gnc_ui_qif_import_convert_progress_start_cb(GtkButton * button, gpointer user_data);
+void gnc_ui_qif_import_convert_progress_start_cb (GtkButton * button, gpointer user_data);
 
 void gnc_ui_qif_import_duplicates_match_prepare (GtkAssistant *assistant, gpointer user_data);
 void gnc_ui_qif_import_duplicates_doc_prepare (GtkAssistant *assistant, gpointer user_data);
@@ -276,13 +276,13 @@ void gnc_ui_qif_import_summary_page_prepare (GtkAssistant *assistant, gpointer u
  * translation in the Accounts page view (acount picker list).
  ****************************************************************/
 static void
-update_account_picker_page(QIFImportWindow * wind, SCM make_display,
-                           GtkWidget *view, SCM map_info, SCM * display_info)
+update_account_picker_page (QIFImportWindow * wind, SCM make_display,
+                            GtkWidget *view, SCM map_info, SCM * display_info)
 {
 
-    SCM  get_qif_name = scm_c_eval_string("qif-map-entry:qif-name");
-    SCM  get_gnc_name = scm_c_eval_string("qif-map-entry:gnc-name");
-    SCM  get_new      = scm_c_eval_string("qif-map-entry:new-acct?");
+    SCM  get_qif_name = scm_c_eval_string ("qif-map-entry:qif-name");
+    SCM  get_gnc_name = scm_c_eval_string ("qif-map-entry:gnc-name");
+    SCM  get_new      = scm_c_eval_string ("qif-map-entry:new-acct?");
     SCM  accts_left;
     gchar *qif_name = NULL;
     gchar *gnc_name = NULL;
@@ -294,55 +294,55 @@ update_account_picker_page(QIFImportWindow * wind, SCM make_display,
     GtkTreePath *path;
     GtkTreeSelection *selection;
 
-    store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(view)));
+    store = GTK_LIST_STORE(gtk_tree_view_get_model (GTK_TREE_VIEW(view)));
 
     /* now get the list of strings to display in the gtk_list_store widget */
-    accts_left = scm_call_3(make_display,
-                            wind->imported_files,
-                            map_info,
-                            wind->gnc_acct_info);
+    accts_left = scm_call_3 (make_display,
+                             wind->imported_files,
+                             map_info,
+                             wind->gnc_acct_info);
 
-    scm_gc_unprotect_object(*display_info);
+    scm_gc_unprotect_object (*display_info);
     *display_info = accts_left;
-    scm_gc_protect_object(*display_info);
+    scm_gc_protect_object (*display_info);
 
     /* clear the list */
-    gtk_list_store_clear(store);
-
-    while (!scm_is_null(accts_left))
-    {
-        qif_name = gnc_scm_call_1_to_string(get_qif_name, SCM_CAR(accts_left));
-        gnc_name = gnc_scm_call_1_to_string(get_gnc_name, SCM_CAR(accts_left));
-        checked  = (scm_call_1(get_new, SCM_CAR(accts_left)) == SCM_BOOL_T);
-
-        gtk_list_store_append(store, &iter);
-        gtk_list_store_set(store, &iter,
-                           ACCOUNT_COL_INDEX,     row++,
-                           ACCOUNT_COL_QIF_NAME,  qif_name,
-                           ACCOUNT_COL_GNC_NAME,  gnc_name,
-                           ACCOUNT_COL_NEW,       checked,
-                           ACCOUNT_COL_ELLIPSIZE, PANGO_ELLIPSIZE_START,
-                           -1);
+    gtk_list_store_clear (store);
+
+    while (!scm_is_null (accts_left))
+    {
+        qif_name = gnc_scm_call_1_to_string (get_qif_name, SCM_CAR(accts_left));
+        gnc_name = gnc_scm_call_1_to_string (get_gnc_name, SCM_CAR(accts_left));
+        checked  = (scm_call_1 (get_new, SCM_CAR(accts_left)) == SCM_BOOL_T);
+
+        gtk_list_store_append (store, &iter);
+        gtk_list_store_set (store, &iter,
+                            ACCOUNT_COL_INDEX,     row++,
+                            ACCOUNT_COL_QIF_NAME,  qif_name,
+                            ACCOUNT_COL_GNC_NAME,  gnc_name,
+                            ACCOUNT_COL_NEW,       checked,
+                            ACCOUNT_COL_ELLIPSIZE, PANGO_ELLIPSIZE_START,
+                            -1);
         accts_left = SCM_CDR(accts_left);
         g_free (qif_name);
         g_free (gnc_name);
     }
 
     /* move to the old selected row */
-    prev_row = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(store), PREV_ROW));
+    prev_row = GPOINTER_TO_INT(g_object_get_data (G_OBJECT(store), PREV_ROW));
     if (prev_row != -1)
     {
-        selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
-        path = gtk_tree_path_new_from_indices(prev_row, -1);
-        gtk_tree_selection_select_path(selection, path);
-        gtk_tree_path_free(path);
+        selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(view));
+        path = gtk_tree_path_new_from_indices (prev_row, -1);
+        gtk_tree_selection_select_path (selection, path);
+        gtk_tree_path_free (path);
     }
     else
     {
-        selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
-        path = gtk_tree_path_new_from_indices( 0, -1);
-        gtk_tree_selection_select_path(selection, path);
-        gtk_tree_path_free(path);
+        selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(view));
+        path = gtk_tree_path_new_from_indices (0, -1);
+        gtk_tree_selection_select_path (selection, path);
+        gtk_tree_path_free (path);
     }
 }
 
@@ -353,13 +353,13 @@ update_account_picker_page(QIFImportWindow * wind, SCM make_display,
  * update the QIF account -> GNC Account picker
  ****************************************************************/
 static void
-update_account_page(QIFImportWindow * wind)
+update_account_page (QIFImportWindow * wind)
 {
 
-    SCM  make_account_display = scm_c_eval_string("qif-dialog:make-account-display");
+    SCM  make_account_display = scm_c_eval_string ("qif-dialog:make-account-display");
 
-    update_account_picker_page(wind, make_account_display, wind->acct_view,
-                               wind->acct_map_info, &(wind->acct_display_info));
+    update_account_picker_page (wind, make_account_display, wind->acct_view,
+                                wind->acct_map_info, &(wind->acct_display_info));
 }
 
 
@@ -369,12 +369,12 @@ update_account_page(QIFImportWindow * wind)
  * update the QIF category -> GNC Account picker
  ****************************************************************/
 static void
-update_category_page(QIFImportWindow * wind)
+update_category_page (QIFImportWindow * wind)
 {
-    SCM  make_category_display = scm_c_eval_string("qif-dialog:make-category-display");
+    SCM  make_category_display = scm_c_eval_string ("qif-dialog:make-category-display");
 
-    update_account_picker_page(wind, make_category_display, wind->cat_view,
-                               wind->cat_map_info, &(wind->cat_display_info));
+    update_account_picker_page (wind, make_category_display, wind->cat_view,
+                                wind->cat_map_info, &(wind->cat_display_info));
 }
 
 
@@ -384,12 +384,12 @@ update_category_page(QIFImportWindow * wind)
  * update the QIF memo -> GNC Account picker
  ****************************************************************/
 static void
-update_memo_page(QIFImportWindow * wind)
+update_memo_page (QIFImportWindow * wind)
 {
-    SCM  make_memo_display = scm_c_eval_string("qif-dialog:make-memo-display");
+    SCM  make_memo_display = scm_c_eval_string ("qif-dialog:make-memo-display");
 
-    update_account_picker_page(wind, make_memo_display, wind->memo_view,
-                               wind->memo_map_info, &(wind->memo_display_info));
+    update_account_picker_page (wind, make_memo_display, wind->memo_view,
+                                wind->memo_map_info, &(wind->memo_display_info));
 }
 
 
@@ -399,7 +399,7 @@ update_memo_page(QIFImportWindow * wind)
  * This function destroys any commodity pages.
  ****************************************************************/
 static void
-gnc_ui_qif_import_commodity_destroy(QIFImportWindow * wind)
+gnc_ui_qif_import_commodity_destroy (QIFImportWindow * wind)
 {
     GList              *pageptr;
     GtkWidget          *gtkpage;
@@ -408,17 +408,17 @@ gnc_ui_qif_import_commodity_destroy(QIFImportWindow * wind)
     for (pageptr = wind->commodity_pages; pageptr; pageptr = pageptr->next)
     {
         gtkpage   = pageptr->data;
-        page      = g_object_get_data(G_OBJECT(gtkpage), "page_struct");
+        page      = g_object_get_data (G_OBJECT(gtkpage), "page_struct");
 
         /* Unprotect the Scheme hash key. */
-        scm_gc_unprotect_object(page->hash_key);
+        scm_gc_unprotect_object (page->hash_key);
 
         /* Free the memory allocated for the page's struct. */
-        g_free(page);
+        g_free (page);
     }
 
     /* Free the list of pages. */
-    g_list_free(wind->commodity_pages);
+    g_list_free (wind->commodity_pages);
     wind->commodity_pages = NULL;
 }
 
@@ -428,37 +428,37 @@ gnc_ui_qif_import_commodity_destroy(QIFImportWindow * wind)
  * close the QIF Import assistant window
  **********************************************/
 static void
-gnc_ui_qif_import_assistant_destroy(GtkWidget *object, gpointer user_data)
+gnc_ui_qif_import_assistant_destroy (GtkWidget *object, gpointer user_data)
 {
     QIFImportWindow * wind = user_data;
 
     /* Destroy the progress dialog helpers. */
-    gnc_progress_dialog_destroy(wind->load_progress);
+    gnc_progress_dialog_destroy (wind->load_progress);
 
     /* Destroy any commodity pages. */
-    gnc_ui_qif_import_commodity_destroy(wind);
+    gnc_ui_qif_import_commodity_destroy (wind);
 
-    gnc_unregister_gui_component_by_data(ASSISTANT_QIF_IMPORT_CM_CLASS, wind);
+    gnc_unregister_gui_component_by_data (ASSISTANT_QIF_IMPORT_CM_CLASS, wind);
 
-    gtk_widget_destroy(wind->window);
+    gtk_widget_destroy (wind->window);
 
-    scm_gc_unprotect_object(wind->imported_files);
-    scm_gc_unprotect_object(wind->selected_file);
-    scm_gc_unprotect_object(wind->gnc_acct_info);
-    scm_gc_unprotect_object(wind->cat_display_info);
-    scm_gc_unprotect_object(wind->cat_map_info);
-    scm_gc_unprotect_object(wind->memo_display_info);
-    scm_gc_unprotect_object(wind->memo_map_info);
-    scm_gc_unprotect_object(wind->acct_display_info);
-    scm_gc_unprotect_object(wind->acct_map_info);
-    scm_gc_unprotect_object(wind->security_hash);
-    scm_gc_unprotect_object(wind->security_prefs);
-    scm_gc_unprotect_object(wind->new_securities);
-    scm_gc_unprotect_object(wind->ticker_map);
-    scm_gc_unprotect_object(wind->imported_account_tree);
-    scm_gc_unprotect_object(wind->match_transactions);
+    scm_gc_unprotect_object (wind->imported_files);
+    scm_gc_unprotect_object (wind->selected_file);
+    scm_gc_unprotect_object (wind->gnc_acct_info);
+    scm_gc_unprotect_object (wind->cat_display_info);
+    scm_gc_unprotect_object (wind->cat_map_info);
+    scm_gc_unprotect_object (wind->memo_display_info);
+    scm_gc_unprotect_object (wind->memo_map_info);
+    scm_gc_unprotect_object (wind->acct_display_info);
+    scm_gc_unprotect_object (wind->acct_map_info);
+    scm_gc_unprotect_object (wind->security_hash);
+    scm_gc_unprotect_object (wind->security_prefs);
+    scm_gc_unprotect_object (wind->new_securities);
+    scm_gc_unprotect_object (wind->ticker_map);
+    scm_gc_unprotect_object (wind->imported_account_tree);
+    scm_gc_unprotect_object (wind->match_transactions);
 
-    g_free(wind);
+    g_free (wind);
 }
 
 
@@ -467,8 +467,8 @@ gnc_ui_qif_import_assistant_destroy(GtkWidget *object, gpointer user_data)
  * callback when a file is clicked in the "loaded files" page
  ****************************************************************/
 static void
-gnc_ui_qif_import_select_loaded_file_cb(GtkTreeSelection *selection,
-                                        gpointer          user_data)
+gnc_ui_qif_import_select_loaded_file_cb (GtkTreeSelection *selection,
+                                         gpointer  user_data)
 {
     QIFImportWindow * wind = user_data;
     GtkTreeModel *model;
@@ -477,25 +477,25 @@ gnc_ui_qif_import_select_loaded_file_cb(GtkTreeSelection *selection,
     GtkWidget *button;
 
     button = (wind->unload_file_btn);
-    if (gtk_tree_selection_get_selected(selection, &model, &iter))
+    if (gtk_tree_selection_get_selected (selection, &model, &iter))
     {
-        gtk_tree_model_get(model, &iter, FILENAME_COL_INDEX, &row, -1);
-        if (scm_is_list(wind->imported_files) &&
-                (scm_ilength(wind->imported_files) > row))
+        gtk_tree_model_get (model, &iter, FILENAME_COL_INDEX, &row, -1);
+        if (scm_is_list (wind->imported_files) &&
+                (scm_ilength (wind->imported_files) > row))
         {
-            scm_gc_unprotect_object(wind->selected_file);
-            wind->selected_file = scm_list_ref(wind->imported_files,
-                                               scm_from_int (row));
-            scm_gc_protect_object(wind->selected_file);
-            g_object_set(button, "sensitive", TRUE, (gchar*)NULL);
+            scm_gc_unprotect_object (wind->selected_file);
+            wind->selected_file = scm_list_ref (wind->imported_files,
+                                                scm_from_int (row));
+            scm_gc_protect_object (wind->selected_file);
+            g_object_set (button, "sensitive", TRUE, (gchar*)NULL);
         }
     }
     else
     {
-        scm_gc_unprotect_object(wind->selected_file);
+        scm_gc_unprotect_object (wind->selected_file);
         wind->selected_file = SCM_BOOL_F;
-        scm_gc_protect_object(wind->selected_file);
-        g_object_set(button, "sensitive", FALSE, (gchar*)NULL);
+        scm_gc_protect_object (wind->selected_file);
+        g_object_set (button, "sensitive", FALSE, (gchar*)NULL);
     }
 }
 
@@ -504,38 +504,38 @@ gnc_ui_qif_import_select_loaded_file_cb(GtkTreeSelection *selection,
  * create_account_picker_view
  ****************************************************/
 static void
-create_account_picker_view(GtkWidget *widget,
-                           const gchar *col_name,
-                           GCallback activate_cb,
-                           GCallback select_cb,
-                           gpointer user_data)
+create_account_picker_view (GtkWidget *widget,
+                            const gchar *col_name,
+                            GCallback activate_cb,
+                            GCallback select_cb,
+                            gpointer user_data)
 {
     GtkTreeView *view = GTK_TREE_VIEW(widget);
-    GtkTreeSelection *selection = gtk_tree_view_get_selection(view);
+    GtkTreeSelection *selection = gtk_tree_view_get_selection (view);
     GtkListStore *store;
     GtkCellRenderer *renderer;
     GtkTreeViewColumn *column;
 
-    store = gtk_list_store_new(NUM_ACCOUNT_COLS, G_TYPE_INT, G_TYPE_STRING,
-                               G_TYPE_STRING, G_TYPE_BOOLEAN,
-                               PANGO_TYPE_ELLIPSIZE_MODE);
-    gtk_tree_view_set_model(view, GTK_TREE_MODEL(store));
-    g_object_unref(store);
+    store = gtk_list_store_new (NUM_ACCOUNT_COLS, G_TYPE_INT, G_TYPE_STRING,
+                                G_TYPE_STRING, G_TYPE_BOOLEAN,
+                                PANGO_TYPE_ELLIPSIZE_MODE);
+    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(col_name,
+    renderer = gtk_cell_renderer_text_new ();
+    column = gtk_tree_view_column_new_with_attributes (col_name,
              renderer,
              "text",
              ACCOUNT_COL_QIF_NAME,
              "ellipsize",
              ACCOUNT_COL_ELLIPSIZE,
              NULL);
-    g_object_set(column, "expand", TRUE, NULL);
-    gtk_tree_view_column_set_resizable(column, TRUE);
-    gtk_tree_view_append_column(view, column);
+    g_object_set (column, "expand", TRUE, NULL);
+    gtk_tree_view_column_set_resizable (column, TRUE);
+    gtk_tree_view_append_column (view, column);
 
-    renderer = gtk_cell_renderer_text_new();
-    column = gtk_tree_view_column_new_with_attributes(_("GnuCash account name"),
+    renderer = gtk_cell_renderer_text_new ();
+    column = gtk_tree_view_column_new_with_attributes (_("GnuCash account name"),
              renderer,
              "text",
              ACCOUNT_COL_GNC_NAME,
@@ -543,27 +543,27 @@ create_account_picker_view(GtkWidget *widget,
              ACCOUNT_COL_ELLIPSIZE,
              NULL);
 
-    g_object_set(column, "expand", TRUE, NULL);
-    gtk_tree_view_column_set_resizable(column, TRUE);
-    gtk_tree_view_append_column(view, column);
+    g_object_set (column, "expand", TRUE, NULL);
+    gtk_tree_view_column_set_resizable (column, TRUE);
+    gtk_tree_view_append_column (view, column);
 
-    renderer = gtk_cell_renderer_toggle_new();
+    renderer = gtk_cell_renderer_toggle_new ();
     g_object_set(renderer, "activatable", FALSE, NULL);
-    column = gtk_tree_view_column_new_with_attributes(_("New?"),
+    column = gtk_tree_view_column_new_with_attributes (_("New?"),
              renderer,
              "active",
              ACCOUNT_COL_NEW,
              NULL);
-    gtk_tree_view_append_column(view, column);
+    gtk_tree_view_append_column (view, column);
 
-    g_object_set_data(G_OBJECT(store), PREV_ROW, GINT_TO_POINTER(-1));
+    g_object_set_data (G_OBJECT(store), PREV_ROW, GINT_TO_POINTER(-1));
 
     /* Connect the signal handlers. */
-    g_signal_connect(view, "row-activated", G_CALLBACK(activate_cb), user_data);
-    g_signal_connect(selection, "changed", G_CALLBACK(select_cb), user_data);
+    g_signal_connect (view, "row-activated", G_CALLBACK(activate_cb), user_data);
+    g_signal_connect (selection, "changed", G_CALLBACK(select_cb), user_data);
 
     /* Allow multiple rows to be selected. */
-    gtk_tree_selection_set_mode(selection, GTK_SELECTION_MULTIPLE);
+    gtk_tree_selection_set_mode (selection, GTK_SELECTION_MULTIPLE);
 }
 
 
@@ -578,13 +578,13 @@ create_account_picker_view(GtkWidget *widget,
  * function is called.
  ********************************************************************/
 static void
-rematch_line(QIFImportWindow *wind, GtkTreeSelection *selection,
-             SCM display_info, SCM map_info,
-             void (*update_page)(QIFImportWindow *))
+rematch_line (QIFImportWindow *wind, GtkTreeSelection *selection,
+              SCM display_info, SCM map_info,
+              void (*update_page)(QIFImportWindow *))
 {
-    SCM           get_qif_name = scm_c_eval_string("qif-map-entry:qif-name");
-    SCM           get_gnc_name = scm_c_eval_string("qif-map-entry:gnc-name");
-    SCM           set_gnc_name = scm_c_eval_string("qif-map-entry:set-gnc-name!");
+    SCM           get_qif_name = scm_c_eval_string ("qif-map-entry:qif-name");
+    SCM           get_gnc_name = scm_c_eval_string ("qif-map-entry:gnc-name");
+    SCM           set_gnc_name = scm_c_eval_string ("qif-map-entry:set-gnc-name!");
     SCM           map_entry;
     SCM           gnc_name;
     GList        *pathlist;
@@ -594,7 +594,7 @@ rematch_line(QIFImportWindow *wind, GtkTreeSelection *selection,
     gint          row;
 
     /* Get a list of selected rows. */
-    pathlist = gtk_tree_selection_get_selected_rows(selection, &model);
+    pathlist = gtk_tree_selection_get_selected_rows (selection, &model);
     if (!pathlist)
         return;
 
@@ -603,25 +603,25 @@ rematch_line(QIFImportWindow *wind, GtkTreeSelection *selection,
      */
 
     /* Get the row number of the first selected row. */
-    if (!gtk_tree_model_get_iter(model, &iter, (GtkTreePath *) pathlist->data))
+    if (!gtk_tree_model_get_iter (model, &iter, (GtkTreePath *) pathlist->data))
         return;
-    gtk_tree_model_get(model, &iter, ACCOUNT_COL_INDEX, &row, -1);
+    gtk_tree_model_get (model, &iter, ACCOUNT_COL_INDEX, &row, -1);
 
     /* Save the row number. */
-    g_object_set_data(G_OBJECT(model), PREV_ROW, GINT_TO_POINTER(row));
+    g_object_set_data (G_OBJECT(model), PREV_ROW, GINT_TO_POINTER(row));
     if (row == -1)
         return;
 
     /* Find the <qif-map-entry> corresponding to the selected row. */
-    map_entry = scm_list_ref(display_info, scm_from_int (row));
+    map_entry = scm_list_ref (display_info, scm_from_int (row));
 
     /* Call the account picker to update it. */
-    if (!qif_account_picker_dialog(GTK_WINDOW(wind->window), wind, map_entry))
+    if (!qif_account_picker_dialog (GTK_WINDOW(wind->window), wind, map_entry))
         return;
-    gnc_name = scm_call_1(get_gnc_name, map_entry);
+    gnc_name = scm_call_1 (get_gnc_name, map_entry);
 
     /* Update the mapping hash table. */
-    scm_hash_set_x(map_info, scm_call_1(get_qif_name, map_entry), map_entry);
+    scm_hash_set_x (map_info, scm_call_1 (get_qif_name, map_entry), map_entry);
 
     /*
      * Map all other selected rows to the same GnuCash account.
@@ -629,23 +629,23 @@ rematch_line(QIFImportWindow *wind, GtkTreeSelection *selection,
     for (current = pathlist->next; current; current = current->next)
     {
         /* Get the row number. */
-        gtk_tree_model_get_iter(model, &iter, (GtkTreePath *) current->data);
-        gtk_tree_model_get(model, &iter, ACCOUNT_COL_INDEX, &row, -1);
+        gtk_tree_model_get_iter (model, &iter, (GtkTreePath *) current->data);
+        gtk_tree_model_get (model, &iter, ACCOUNT_COL_INDEX, &row, -1);
 
         /* Update the <qif-map-entry> for the selected row. */
-        map_entry = scm_list_ref(display_info, scm_from_int (row));
-        scm_call_2(set_gnc_name, map_entry, gnc_name);
+        map_entry = scm_list_ref (display_info, scm_from_int (row));
+        scm_call_2 (set_gnc_name, map_entry, gnc_name);
 
         /* Update the mapping hash table. */
-        scm_hash_set_x(map_info, scm_call_1(get_qif_name, map_entry), map_entry);
+        scm_hash_set_x (map_info, scm_call_1 (get_qif_name, map_entry), map_entry);
     }
 
     /* Free the path list. */
-    g_list_foreach(pathlist, (GFunc) gtk_tree_path_free, NULL);
-    g_list_free(pathlist);
+    g_list_foreach (pathlist, (GFunc) gtk_tree_path_free, NULL);
+    g_list_free (pathlist);
 
     /* Update the display. */
-    update_page(wind);
+    update_page (wind);
 }
 
 
@@ -656,17 +656,17 @@ rematch_line(QIFImportWindow *wind, GtkTreeSelection *selection,
  * QIF accounts to GnuCash accounts" page.
  ********************************************************************/
 static void
-gnc_ui_qif_import_account_activate_cb(GtkTreeView *view, GtkTreePath *path,
-                                      GtkTreeViewColumn *column,
-                                      gpointer user_data)
+gnc_ui_qif_import_account_activate_cb (GtkTreeView *view, GtkTreePath *path,
+                                       GtkTreeViewColumn *column,
+                                       gpointer user_data)
 {
     QIFImportWindow  *wind = user_data;
 
-    g_return_if_fail(wind);
+    g_return_if_fail (wind);
 
-    rematch_line(wind, gtk_tree_view_get_selection(view),
-                 wind->acct_display_info, wind->acct_map_info,
-                 update_account_page);
+    rematch_line (wind, gtk_tree_view_get_selection (view),
+                  wind->acct_display_info, wind->acct_map_info,
+                  update_account_page);
 }
 
 
@@ -678,30 +678,30 @@ gnc_ui_qif_import_account_activate_cb(GtkTreeView *view, GtkTreePath *path,
  * the "Change" button.
  ********************************************************************/
 static void
-gnc_ui_qif_import_account_select_cb(GtkTreeSelection *selection,
-                                    gpointer user_data)
+gnc_ui_qif_import_account_select_cb (GtkTreeSelection *selection,
+                                     gpointer user_data)
 {
     QIFImportWindow  *wind = user_data;
-    gint              count = gtk_tree_selection_count_selected_rows(selection);
+    gint              count = gtk_tree_selection_count_selected_rows (selection);
     gchar            *count_str;
 
-    g_return_if_fail(wind);
+    g_return_if_fail (wind);
 
     /* Update the "items selected" count. */
     if (wind->acct_view_count)
     {
-        count_str = g_strdup_printf("%d", count);
-        gtk_label_set_text(GTK_LABEL(wind->acct_view_count), count_str);
-        g_free(count_str);
+        count_str = g_strdup_printf ("%d", count);
+        gtk_label_set_text (GTK_LABEL(wind->acct_view_count), count_str);
+        g_free (count_str);
     }
 
     /* Enable/disable the Change button. */
     if (wind->acct_view_btn)
     {
         if (count)
-            gtk_widget_set_sensitive(wind->acct_view_btn, TRUE);
+            gtk_widget_set_sensitive (wind->acct_view_btn, TRUE);
         else
-            gtk_widget_set_sensitive(wind->acct_view_btn, FALSE);
+            gtk_widget_set_sensitive (wind->acct_view_btn, FALSE);
     }
 }
 
@@ -713,18 +713,18 @@ gnc_ui_qif_import_account_select_cb(GtkTreeSelection *selection,
  * QIF categories to GnuCash accounts" page.
  ********************************************************************/
 static void
-gnc_ui_qif_import_category_activate_cb(GtkTreeView *view, GtkTreePath *path,
-                                       GtkTreeViewColumn *column,
-                                       gpointer user_data)
+gnc_ui_qif_import_category_activate_cb (GtkTreeView *view, GtkTreePath *path,
+                                        GtkTreeViewColumn *column,
+                                        gpointer user_data)
 {
     QIFImportWindow *wind = user_data;
     GtkTreeSelection *selection;
 
-    g_return_if_fail(view && wind);
-    selection = gtk_tree_view_get_selection(view);
+    g_return_if_fail (view && wind);
+    selection = gtk_tree_view_get_selection (view);
 
-    rematch_line(wind, selection, wind->cat_display_info, wind->cat_map_info,
-                 update_category_page);
+    rematch_line (wind, selection, wind->cat_display_info, wind->cat_map_info,
+                  update_category_page);
 }
 
 
@@ -736,30 +736,30 @@ gnc_ui_qif_import_category_activate_cb(GtkTreeView *view, GtkTreePath *path,
  * the "Change" button.
  ********************************************************************/
 static void
-gnc_ui_qif_import_category_select_cb(GtkTreeSelection *selection,
-                                     gpointer user_data)
+gnc_ui_qif_import_category_select_cb (GtkTreeSelection *selection,
+                                      gpointer user_data)
 {
     QIFImportWindow  *wind = user_data;
-    gint              count = gtk_tree_selection_count_selected_rows(selection);
+    gint              count = gtk_tree_selection_count_selected_rows (selection);
     gchar            *count_str;
 
-    g_return_if_fail(wind);
+    g_return_if_fail (wind);
 
     /* Update the "items selected" count. */
     if (wind->cat_view_count)
     {
-        count_str = g_strdup_printf("%d", count);
-        gtk_label_set_text(GTK_LABEL(wind->cat_view_count), count_str);
-        g_free(count_str);
+        count_str = g_strdup_printf ("%d", count);
+        gtk_label_set_text (GTK_LABEL(wind->cat_view_count), count_str);
+        g_free (count_str);
     }
 
     /* Enable/disable the Change button. */
     if (wind->cat_view_btn)
     {
         if (count)
-            gtk_widget_set_sensitive(wind->cat_view_btn, TRUE);
+            gtk_widget_set_sensitive (wind->cat_view_btn, TRUE);
         else
-            gtk_widget_set_sensitive(wind->cat_view_btn, FALSE);
+            gtk_widget_set_sensitive (wind->cat_view_btn, FALSE);
     }
 }
 
@@ -771,18 +771,18 @@ gnc_ui_qif_import_category_select_cb(GtkTreeSelection *selection,
  * QIF payee/memo to GnuCash accounts" page.
  ********************************************************************/
 static void
-gnc_ui_qif_import_memo_activate_cb(GtkTreeView *view, GtkTreePath *path,
-                                   GtkTreeViewColumn *column,
-                                   gpointer user_data)
+gnc_ui_qif_import_memo_activate_cb (GtkTreeView *view, GtkTreePath *path,
+                                    GtkTreeViewColumn *column,
+                                    gpointer user_data)
 {
     QIFImportWindow *wind = user_data;
     GtkTreeSelection *selection;
 
-    g_return_if_fail(view && wind);
-    selection = gtk_tree_view_get_selection(view);
+    g_return_if_fail (view && wind);
+    selection = gtk_tree_view_get_selection (view);
 
-    rematch_line(wind, selection, wind->memo_display_info, wind->memo_map_info,
-                 update_memo_page);
+    rematch_line (wind, selection, wind->memo_display_info, wind->memo_map_info,
+                  update_memo_page);
 }
 
 
@@ -794,30 +794,30 @@ gnc_ui_qif_import_memo_activate_cb(GtkTreeView *view, GtkTreePath *path,
  * the "Change" button.
  ********************************************************************/
 static void
-gnc_ui_qif_import_memo_select_cb(GtkTreeSelection *selection,
+gnc_ui_qif_import_memo_select_cb (GtkTreeSelection *selection,
                                  gpointer user_data)
 {
     QIFImportWindow  *wind = user_data;
-    gint              count = gtk_tree_selection_count_selected_rows(selection);
+    gint              count = gtk_tree_selection_count_selected_rows (selection);
     gchar            *count_str;
 
-    g_return_if_fail(wind);
+    g_return_if_fail (wind);
 
     /* Update the "items selected" count. */
     if (wind->memo_view_count)
     {
-        count_str = g_strdup_printf("%d", count);
-        gtk_label_set_text(GTK_LABEL(wind->memo_view_count), count_str);
-        g_free(count_str);
+        count_str = g_strdup_printf ("%d", count);
+        gtk_label_set_text (GTK_LABEL(wind->memo_view_count), count_str);
+        g_free (count_str);
     }
 
     /* Enable/disable the Change button. */
     if (wind->memo_view_btn)
     {
         if (count)
-            gtk_widget_set_sensitive(wind->memo_view_btn, TRUE);
+            gtk_widget_set_sensitive (wind->memo_view_btn, TRUE);
         else
-            gtk_widget_set_sensitive(wind->memo_view_btn, FALSE);
+            gtk_widget_set_sensitive (wind->memo_view_btn, FALSE);
     }
 }
 
@@ -826,10 +826,10 @@ gnc_ui_qif_import_memo_select_cb(GtkTreeSelection *selection,
  * new_security_page
  *********************************************/
 static QIFAssistantPage *
-new_security_page(SCM security_hash_key, gnc_commodity *comm, QIFImportWindow *wind )
+new_security_page (SCM security_hash_key, gnc_commodity *comm, QIFImportWindow *wind)
 {
 
-    QIFAssistantPage *retval = g_new0(QIFAssistantPage, 1);
+    QIFAssistantPage *retval = g_new0 (QIFAssistantPage, 1);
     GtkListStore *store;
     GtkWidget    *table;
     GtkWidget    *label;
@@ -849,47 +849,47 @@ new_security_page(SCM security_hash_key, gnc_commodity *comm, QIFImportWindow *w
 
     /* Make the page widget. */
     page = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
-    gtk_box_set_homogeneous (GTK_BOX (page), FALSE);
+    gtk_box_set_homogeneous (GTK_BOX(page), FALSE);
     retval->page = page;
-    g_object_set_data(G_OBJECT(retval->page), "page_struct", retval);
+    g_object_set_data (G_OBJECT(retval->page), "page_struct", retval);
     page = retval->page;
 
     /* Insert the new page */
     gtk_assistant_insert_page (GTK_ASSISTANT(wind->window), page, 14);
-    gtk_assistant_set_page_type(GTK_ASSISTANT(wind->window), page, GTK_ASSISTANT_PAGE_PROGRESS );
-    gtk_assistant_set_page_complete (GTK_ASSISTANT (wind->window), page, TRUE);
-    gtk_assistant_update_buttons_state (GTK_ASSISTANT (wind->window));
+    gtk_assistant_set_page_type (GTK_ASSISTANT(wind->window), page, GTK_ASSISTANT_PAGE_PROGRESS);
+    gtk_assistant_set_page_complete (GTK_ASSISTANT(wind->window), page, TRUE);
+    gtk_assistant_update_buttons_state (GTK_ASSISTANT(wind->window));
 
     /* Save the commodity and the hash table key. */
     retval->commodity = comm;
     retval->hash_key = security_hash_key;
-    scm_gc_protect_object(retval->hash_key);
+    scm_gc_protect_object (retval->hash_key);
 
     /* Set the page title. */
-    str = gnc_commodity_get_mnemonic(comm);
+    str = gnc_commodity_get_mnemonic (comm);
     str = str ? str : "";
     title = _("Enter information about");
-    title =  g_strdup_printf("%s \"%s\"", title, str);
-    gtk_assistant_set_page_title(GTK_ASSISTANT(wind->window), page, title);
-    g_free(title);
+    title =  g_strdup_printf ("%s \"%s\"", title, str);
+    gtk_assistant_set_page_title (GTK_ASSISTANT(wind->window), page, title);
+    g_free (title);
 
     /*
      * Add all the widgets to the page.
      */
-    table = gtk_grid_new();
+    table = gtk_grid_new ();
     gtk_grid_set_row_spacing (GTK_GRID(table), 6);
     gtk_grid_set_column_spacing (GTK_GRID(table), 12);
 
     /* Name entry */
-    retval->name_entry = gtk_entry_new();
-    gtk_entry_set_text(GTK_ENTRY(retval->name_entry),
-                       gnc_commodity_get_fullname(comm));
-    label = gtk_label_new_with_mnemonic(_("_Name or description:"));
-    gtk_label_set_mnemonic_widget(GTK_LABEL(label), retval->name_entry);
-    gnc_label_set_alignment(label, 0, 0.5);
+    retval->name_entry = gtk_entry_new ();
+    gtk_entry_set_text (GTK_ENTRY(retval->name_entry),
+                        gnc_commodity_get_fullname (comm));
+    label = gtk_label_new_with_mnemonic (_("_Name or description:"));
+    gtk_label_set_mnemonic_widget (GTK_LABEL(label), retval->name_entry);
+    gnc_label_set_alignment (label, 0, 0.5);
 
-    gtk_widget_set_tooltip_text(label, name_tooltip);
-    gtk_widget_set_tooltip_text(retval->name_entry, name_tooltip);
+    gtk_widget_set_tooltip_text (label, name_tooltip);
+    gtk_widget_set_tooltip_text (retval->name_entry, name_tooltip);
 
     gtk_grid_attach (GTK_GRID(table), label, 0, 0, 1, 1);
     gtk_widget_set_halign (label, GTK_ALIGN_FILL);
@@ -901,19 +901,19 @@ new_security_page(SCM security_hash_key, gnc_commodity *comm, QIFImportWindow *w
     gtk_grid_attach (GTK_GRID(table), retval->name_entry, 1, 0, 1, 1);
 
     g_signal_connect (retval->name_entry, "changed",
-                      G_CALLBACK (gnc_ui_qif_import_comm_changed_cb), wind);
+                      G_CALLBACK(gnc_ui_qif_import_comm_changed_cb), wind);
 
     /* Mnemonic entry */
-    retval->mnemonic_entry = gtk_entry_new();
-    gtk_entry_set_text(GTK_ENTRY(retval->mnemonic_entry),
-                       gnc_commodity_get_mnemonic(comm));
-    label = gtk_label_new_with_mnemonic(
+    retval->mnemonic_entry = gtk_entry_new ();
+    gtk_entry_set_text (GTK_ENTRY(retval->mnemonic_entry),
+                       gnc_commodity_get_mnemonic (comm));
+    label = gtk_label_new_with_mnemonic (
                 _("_Ticker symbol or other abbreviation:"));
-    gtk_label_set_mnemonic_widget(GTK_LABEL(label), retval->mnemonic_entry);
-    gnc_label_set_alignment(label, 0, 0.5);
+    gtk_label_set_mnemonic_widget (GTK_LABEL(label), retval->mnemonic_entry);
+    gnc_label_set_alignment (label, 0, 0.5);
 
-    gtk_widget_set_tooltip_text(label, mnemonic_tooltip);
-    gtk_widget_set_tooltip_text(retval->mnemonic_entry, mnemonic_tooltip);
+    gtk_widget_set_tooltip_text (label, mnemonic_tooltip);
+    gtk_widget_set_tooltip_text (retval->mnemonic_entry, mnemonic_tooltip);
 
     gtk_grid_attach (GTK_GRID(table), label, 0, 1, 1, 1);
     gtk_widget_set_halign (label, GTK_ALIGN_FILL);
@@ -925,24 +925,24 @@ new_security_page(SCM security_hash_key, gnc_commodity *comm, QIFImportWindow *w
     gtk_grid_attach (GTK_GRID(table), retval->mnemonic_entry, 1, 1, 1, 1);
 
     g_signal_connect (retval->mnemonic_entry, "changed",
-                      G_CALLBACK (gnc_ui_qif_import_comm_changed_cb), wind);
+                      G_CALLBACK(gnc_ui_qif_import_comm_changed_cb), wind);
 
     /* Namespace entry */
     store = gtk_list_store_new (1, G_TYPE_STRING);
-    retval->namespace_combo = gtk_combo_box_new_with_model_and_entry(GTK_TREE_MODEL(store));
-    g_object_unref(store);
+    retval->namespace_combo = gtk_combo_box_new_with_model_and_entry (GTK_TREE_MODEL(store));
+    g_object_unref (store);
 
     /* Set the column for the text */
     gtk_combo_box_set_entry_text_column (GTK_COMBO_BOX(retval->namespace_combo), 0);
 
-    gnc_cbwe_add_completion(GTK_COMBO_BOX(retval->namespace_combo));
-    label = gtk_label_new_with_mnemonic(
+    gnc_cbwe_add_completion (GTK_COMBO_BOX(retval->namespace_combo));
+    label = gtk_label_new_with_mnemonic (
                 _("_Exchange or abbreviation type:"));
-    gtk_label_set_mnemonic_widget(GTK_LABEL(label), retval->namespace_combo);
-    gnc_label_set_alignment(label, 0, 0.5);
+    gtk_label_set_mnemonic_widget (GTK_LABEL(label), retval->namespace_combo);
+    gnc_label_set_alignment (label, 0, 0.5);
 
-    gtk_widget_set_tooltip_text(label, namespace_tooltip);
-    gtk_widget_set_tooltip_text(retval->namespace_combo, namespace_tooltip);
+    gtk_widget_set_tooltip_text (label, namespace_tooltip);
+    gtk_widget_set_tooltip_text (retval->namespace_combo, namespace_tooltip);
 
     gtk_grid_attach (GTK_GRID(table), label, 0, 2, 1, 1);
     gtk_widget_set_halign (label, GTK_ALIGN_FILL);
@@ -953,9 +953,9 @@ new_security_page(SCM security_hash_key, gnc_commodity *comm, QIFImportWindow *w
 
     gtk_grid_attach (GTK_GRID(table), retval->namespace_combo, 1, 2, 1, 1);
 
-    gtk_container_set_border_width(GTK_CONTAINER(page), 12);
+    gtk_container_set_border_width (GTK_CONTAINER(page), 12);
 
-    gtk_box_pack_start(GTK_BOX(page), table, FALSE, FALSE, 12);
+    gtk_box_pack_start (GTK_BOX(page), table, FALSE, FALSE, 12);
 
     return retval;
 }
@@ -967,23 +967,23 @@ new_security_page(SCM security_hash_key, gnc_commodity *comm, QIFImportWindow *w
  * Prepare the assistant page for each security.
  ********************************************************************/
 static void
-prepare_security_pages(QIFImportWindow * wind)
+prepare_security_pages (QIFImportWindow * wind)
 {
-    SCM   hash_ref  = scm_c_eval_string("hash-ref");
+    SCM   hash_ref  = scm_c_eval_string ("hash-ref");
     SCM   securities;
     SCM   comm_ptr_token;
 
-    GList          * current;
-    gnc_commodity  * commodity;
+    GList              * current;
+    gnc_commodity      * commodity;
     QIFAssistantPage   * new_page;
 
     /*
      * Make assistant pages for each new QIF security.
      */
-    gnc_set_busy_cursor(NULL, TRUE);
+    gnc_set_busy_cursor (NULL, TRUE);
     securities = wind->new_securities;
     current = wind->commodity_pages;
-    while (!scm_is_null(securities) && (securities != SCM_BOOL_F))
+    while (!scm_is_null (securities) && (securities != SCM_BOOL_F))
     {
         if (current)
         {
@@ -993,28 +993,28 @@ prepare_security_pages(QIFImportWindow * wind)
         else
         {
             /* Get the GnuCash commodity corresponding to the new QIF security. */
-            comm_ptr_token = scm_call_2(hash_ref,
-                                        wind->security_hash,
-                                        SCM_CAR(securities));
+            comm_ptr_token = scm_call_2 (hash_ref,
+                                         wind->security_hash,
+                                         SCM_CAR(securities));
 #define FUNC_NAME "new_security_page"
-            commodity = SWIG_MustGetPtr(comm_ptr_token,
-                                        SWIG_TypeQuery("_p_gnc_commodity"), 1, 0);
+            commodity = SWIG_MustGetPtr (comm_ptr_token,
+                                         SWIG_TypeQuery ("_p_gnc_commodity"), 1, 0);
 #undef FUNC_NAME
 
             /* Build a new security page. */
-            new_page = new_security_page(SCM_CAR(securities), commodity, wind);
+            new_page = new_security_page (SCM_CAR(securities), commodity, wind);
 
             /* Add it to the list of security pages. */
-            wind->commodity_pages = g_list_append(wind->commodity_pages,
-                                                  new_page->page);
+            wind->commodity_pages = g_list_append (wind->commodity_pages,
+                                                   new_page->page);
 
-            gtk_widget_show_all(new_page->page);
+            gtk_widget_show_all (new_page->page);
         }
         wind->num_new_pages = wind->num_new_pages + 1;
         securities = SCM_CDR(securities);
     }
-    gnc_unset_busy_cursor(NULL);
-    PINFO("Number of New Security pages is %d", wind->num_new_pages);
+    gnc_unset_busy_cursor (NULL);
+    PINFO ("Number of New Security pages is %d", wind->num_new_pages);
 }
 
 
@@ -1025,7 +1025,7 @@ prepare_security_pages(QIFImportWindow * wind)
  * mnemonic, namespace, and name approved by the user.
  ****************************************************************/
 static void
-gnc_ui_qif_import_commodity_update(QIFImportWindow * wind)
+gnc_ui_qif_import_commodity_update (QIFImportWindow * wind)
 {
     GList              *pageptr;
     GtkWidget          *gtkpage;
@@ -1038,39 +1038,39 @@ gnc_ui_qif_import_commodity_update(QIFImportWindow * wind)
     for (pageptr = wind->commodity_pages; pageptr; pageptr = pageptr->next)
     {
         gtkpage   = pageptr->data;
-        page      = g_object_get_data(G_OBJECT(gtkpage), "page_struct");
+        page      = g_object_get_data (G_OBJECT(gtkpage), "page_struct");
 
         /* Get any changes from the commodity page. */
-        mnemonic  = gtk_entry_get_text(GTK_ENTRY(page->mnemonic_entry));
-        name_space = gnc_ui_namespace_picker_ns(page->namespace_combo);
-        fullname  = gtk_entry_get_text(GTK_ENTRY(page->name_entry));
+        mnemonic  = gtk_entry_get_text (GTK_ENTRY(page->mnemonic_entry));
+        name_space = gnc_ui_namespace_picker_ns (page->namespace_combo);
+        fullname  = gtk_entry_get_text (GTK_ENTRY(page->name_entry));
 
         /* Update the commodity with the new values. */
-        gnc_commodity_set_namespace(page->commodity, name_space);
-        gnc_commodity_set_fullname(page->commodity, fullname);
-        gnc_commodity_set_mnemonic(page->commodity, mnemonic);
+        gnc_commodity_set_namespace (page->commodity, name_space);
+        gnc_commodity_set_fullname (page->commodity, fullname);
+        gnc_commodity_set_mnemonic (page->commodity, mnemonic);
 
         /* Add the commodity to the commodity table (if it isn't a duplicate). */
-        tab_commodity = gnc_commodity_table_lookup(gnc_get_current_commodities(),
+        tab_commodity = gnc_commodity_table_lookup (gnc_get_current_commodities (),
                         name_space, mnemonic);
         if (!tab_commodity || tab_commodity == page->commodity)
-            tab_commodity = gnc_commodity_table_insert(gnc_get_current_commodities(),
+            tab_commodity = gnc_commodity_table_insert (gnc_get_current_commodities (),
                             page->commodity);
 
         /* Update the security hash table. */
-        scm_hash_set_x(wind->security_hash,
+        scm_hash_set_x (wind->security_hash,
                        page->hash_key,
-                       SWIG_NewPointerObj(tab_commodity,
-                                          SWIG_TypeQuery("_p_gnc_commodity"), 0));
+                       SWIG_NewPointerObj (tab_commodity,
+                                           SWIG_TypeQuery ("_p_gnc_commodity"), 0));
 
-        g_free(name_space);
+        g_free (name_space);
     }
 }
 
 static void
-_gfec_error_handler(const char *message)
+_gfec_error_handler (const char *message)
 {
-    PERR("qif-import:qif-to-gnc-undo encountered an error: %s", message);
+    PERR ("qif-import:qif-to-gnc-undo encountered an error: %s", message);
 }
 
 /****************************************************************

commit aab89065da63db13d003dc75a1f63a2840928667
Author: David Palma <dbpalma9 at gmail.com>
Date:   Sat May 4 15:02:02 2019 +0100

    Bug 796949 - Fix division and rounding of zero.
    
    Fix division of 128-bit integers so that the remainder inherits the dividend's sign.
    Fix rounding for truncated zero.

diff --git a/libgnucash/engine/gnc-int128.cpp b/libgnucash/engine/gnc-int128.cpp
index e545649f7..8ec77f5ce 100644
--- a/libgnucash/engine/gnc-int128.cpp
+++ b/libgnucash/engine/gnc-int128.cpp
@@ -71,7 +71,7 @@ GncInt128::GncInt128 (int64_t upper, int64_t lower, uint8_t flags) :
     m_lo {static_cast<uint64_t>(lower < 0 ? -lower : lower)}
 {
     if ((upper < 0 && lower > 0) || (upper > 0 && lower < 0))
-	m_lo = (m_hi << 63) - m_lo;
+        m_lo = (m_hi << 63) - m_lo;
     else
         m_lo += (m_hi << 63);
 
@@ -142,7 +142,7 @@ GncInt128::operator int64_t() const
 GncInt128::operator uint64_t() const
 {
     auto flags = get_flags(m_hi);
-    if (flags & neg)
+    if ((flags & neg) && !isZero()) // exclude negative zero
         throw std::underflow_error ("Can't represent negative value as uint64_t");
     if ((flags & (overflow | NaN)) || (m_hi || m_lo > UINT64_MAX))
         throw std::overflow_error ("Value to large to represent as uint64_t");
@@ -160,14 +160,15 @@ GncInt128::cmp (const GncInt128& b) const noexcept
         return 1;
     auto hi = get_num(m_hi);
     auto bhi = get_num(b.m_hi);
+    if (isZero() && b.isZero()) return 0;
     if (flags & neg)
     {
-	if (!b.isNeg()) return -1;
-	if (hi > bhi) return -1;
-	if (hi < bhi) return 1;
-	if (m_lo > b.m_lo) return -1;
-	if (m_lo < b.m_lo) return 1;
-	return 0;
+        if (!b.isNeg()) return -1;
+        if (hi > bhi) return -1;
+        if (hi < bhi) return 1;
+        if (m_lo > b.m_lo) return -1;
+        if (m_lo < b.m_lo) return 1;
+        return 0;
     }
     if (b.isNeg()) return 1;
     if (hi < bhi) return -1;
@@ -309,9 +310,9 @@ GncInt128::operator-() const noexcept
     auto retval = *this;
     auto flags = get_flags(retval.m_hi);
     if (isNeg())
-	flags ^= neg;
+        flags ^= neg;
     else
-	flags |= neg;
+        flags |= neg;
     retval.m_hi = set_flags(retval.m_hi, flags);
     return retval;
 }
@@ -357,7 +358,7 @@ GncInt128::operator+= (const GncInt128& b) noexcept
     if (isOverflow() || isNan())
         return *this;
     if ((isNeg () && !b.isNeg ()) || (!isNeg () && b.isNeg ()))
-	return this->operator-= (-b);
+        return this->operator-= (-b);
     uint64_t result = m_lo + b.m_lo;
     uint64_t carry = static_cast<int64_t>(result < m_lo);  //Wrapping
     m_lo = result;
@@ -365,7 +366,7 @@ GncInt128::operator+= (const GncInt128& b) noexcept
     auto bhi = get_num(b.m_hi);
     result = hi + bhi + carry;
     if (result < hi || result & flagmask)
-	flags |= overflow;
+        flags |= overflow;
     m_hi = set_flags(result, flags);
     return *this;
 }
@@ -439,7 +440,7 @@ GncInt128::operator-= (const GncInt128& b) noexcept
         return *this;
 
     if ((!isNeg() && b.isNeg()) || (isNeg() && !b.isNeg()))
-	return this->operator+= (-b);
+        return this->operator+= (-b);
     bool operand_bigger {abs().cmp (b.abs()) < 0};
     auto hi = get_num(m_hi);
     auto far_hi = get_num(b.m_hi);
@@ -478,6 +479,8 @@ GncInt128::operator*= (const GncInt128& b) noexcept
 {
     /* Test for 0 first */
     auto flags = get_flags(m_hi);
+    /* Handle the sign; ^ flips if b is negative */
+    flags ^= (get_flags(b.m_hi) & neg);
     if (isZero() || b.isZero())
     {
         m_lo = 0;
@@ -514,8 +517,7 @@ GncInt128::operator*= (const GncInt128& b) noexcept
         m_hi = set_flags(m_hi, flags);
         return *this;
     }
-    /* Handle the sign; ^ flips if b is negative */
-    flags ^= (get_flags(b.m_hi) & neg);
+
     /* The trivial case */
     if (abits + bbits <= legbits)
     {
@@ -602,6 +604,7 @@ div_multi_leg (uint64_t* u, size_t m, uint64_t* v, size_t n,
     uint64_t d {(UINT64_C(1) << sublegbits)/(v[n - 1] + UINT64_C(1))};
     uint64_t carry {UINT64_C(0)};
     bool negative {q.isNeg()};
+    bool rnegative {r.isNeg()};
     for (size_t i = 0; i < m; ++i)
     {
         u[i] = u[i] * d + carry;
@@ -689,6 +692,7 @@ div_multi_leg (uint64_t* u, size_t m, uint64_t* v, size_t n,
     r = GncInt128 ((u[3] << sublegbits) + u[2], (u[1] << sublegbits) + u[0]);
     r /= d;
     if (negative) q = -q;
+    if (rnegative) r = -r;
 }
 
 void
@@ -698,6 +702,7 @@ div_single_leg (uint64_t* u, size_t m, uint64_t v,
     uint64_t qv[sublegs] {};
     uint64_t carry {};
     bool negative {q.isNeg()};
+    bool rnegative {r.isNeg()};
     for (int i = m - 1; i >= 0; --i)
     {
         qv[i] = u[i] / v;
@@ -713,13 +718,18 @@ div_single_leg (uint64_t* u, size_t m, uint64_t v,
     q = GncInt128 ((qv[3] << sublegbits) + qv[2], (qv[1] << sublegbits) + qv[0]);
     r = GncInt128 ((u[3] << sublegbits) + u[2], (u[1] << sublegbits) + u[0]);
     if (negative) q = -q;
+    if (rnegative) r = -r;
 }
 
 }// namespace
 
- void
+void
 GncInt128::div (const GncInt128& b, GncInt128& q, GncInt128& r) const noexcept
 {
+    // clear remainder and quotient
+    r = GncInt128(0);
+    q = GncInt128(0);
+
     auto qflags = get_flags(q.m_hi);
     auto rflags = get_flags(r.m_hi);
     if (isOverflow() || b.isOverflow())
@@ -745,6 +755,7 @@ GncInt128::div (const GncInt128& b, GncInt128& q, GncInt128& r) const noexcept
     assert (&r != &b);
 
     q.zero(), r.zero();
+    qflags = rflags = 0;
     if (b.isZero())
     {
         qflags |= NaN;
@@ -755,11 +766,17 @@ GncInt128::div (const GncInt128& b, GncInt128& q, GncInt128& r) const noexcept
     }
 
     if (isNeg())
+    {
         qflags |= neg;
+        rflags |= neg;          // the remainder inherits the dividend's sign
+    }
 
     if (b.isNeg())
         qflags ^= neg;
 
+    q.m_hi = set_flags(q.m_hi, qflags);
+    r.m_hi = set_flags(r.m_hi, rflags);
+
     if (abs() < b.abs())
     {
         r = *this;
@@ -767,7 +784,7 @@ GncInt128::div (const GncInt128& b, GncInt128& q, GncInt128& r) const noexcept
     }
     auto hi = get_num(m_hi);
     auto bhi = get_num(b.m_hi);
-    q.m_hi = set_flags(hi, qflags);
+
     if (hi == 0 && bhi == 0) //let the hardware do it
     {
         assert (b.m_lo != 0); // b.m_hi is 0 but b isn't or we didn't get here.
@@ -914,6 +931,11 @@ GncInt128::asCharBufR(char* buf) const noexcept
         sprintf (buf, "%s", "NaN");
         return buf;
     }
+    if (isZero())
+    {
+        sprintf (buf, "%d", 0);
+        return buf;
+    }
     uint64_t d[dec_array_size] {};
     decimal_from_binary(d, get_num(m_hi), m_lo);
     char* next = buf;
diff --git a/libgnucash/engine/gnc-rational-rounding.hpp b/libgnucash/engine/gnc-rational-rounding.hpp
index 692301701..11987b6cb 100644
--- a/libgnucash/engine/gnc-rational-rounding.hpp
+++ b/libgnucash/engine/gnc-rational-rounding.hpp
@@ -25,6 +25,12 @@
 #include "gnc-numeric.h"
 #include "gnc-int128.hpp"
 
+template <typename T> inline bool
+quotient_is_positive(T dividend, T divisor)
+{
+    return (dividend > 0 && divisor > 0) || (dividend < 0 && divisor < 0);
+}
+
 enum class RoundType
 {
     floor = GNC_HOW_RND_FLOOR,
@@ -72,8 +78,23 @@ round(T num, T den, T rem, RT2T<RoundType::floor>)
 //              << ", and rem " << rem << ".\n";
     if (rem == 0)
         return num;
-    if (num < 0)
-        return num + 1;
+    // floor num==0 that is the quotient of two numbers with opposite signs
+    if (num < 0 || (num == 0 && !quotient_is_positive(rem, den)))
+        return num - 1;
+    return num;
+}
+
+
+template <> inline GncInt128
+round<GncInt128>(GncInt128 num, GncInt128 den, GncInt128 rem,
+                 RT2T<RoundType::floor>)
+{
+//    std::cout << "Rounding to floor  with num " << num << " den " << den
+//              << ", and rem " << rem << ".\n";
+    if (rem == 0)
+        return num;
+    if (num.isNeg())
+        return num - 1;
     return num;
 }
 
@@ -82,7 +103,18 @@ round(T num, T den, T rem, RT2T<RoundType::ceiling>)
 {
     if (rem == 0)
         return num;
-    if (num > 0)
+    if (num > 0 || (num == 0 && quotient_is_positive(rem, den)))
+        return num + 1;
+    return num;
+}
+
+template <> inline GncInt128
+round<GncInt128>(GncInt128 num, GncInt128 den, GncInt128 rem,
+      RT2T<RoundType::ceiling>)
+{
+    if (rem == 0)
+        return num;
+    if (!num.isNeg())
         return num + 1;
     return num;
 }
@@ -98,16 +130,31 @@ round(T num, T den, T rem, RT2T<RoundType::promote>)
 {
     if (rem == 0)
         return num;
+    if (num == 0)
+        return (!quotient_is_positive(rem, den) ? -1 : 1);
     return num + (num < 0 ? -1 : 1);
 }
 
+template <> inline GncInt128
+round<GncInt128>(GncInt128 num, GncInt128 den, GncInt128 rem,
+                 RT2T<RoundType::promote>)
+{
+    if (rem == 0)
+        return num;
+    return num + (num.isNeg() ? -1 : 1);
+}
+
 template <typename T> inline T
 round(T num, T den, T rem, RT2T<RoundType::half_down>)
 {
     if (rem == 0)
         return num;
     if (std::abs(rem * 2) > std::abs(den))
+    {
+        if (num == 0)
+            return (!quotient_is_positive(rem, den) ? -1 : 1);
         return num + (num < 0 ? -1 : 1);
+    }
     return num;
 }
 
@@ -118,7 +165,7 @@ round<GncInt128>(GncInt128 num, GncInt128 den, GncInt128 rem,
     if (rem == 0)
         return num;
     if (rem.abs() * 2 > den.abs())
-        return num + (num < 0 ? -1 : 1);
+        return num + (num.isNeg() ? -1 : 1);
     return num;
 }
 
@@ -128,7 +175,11 @@ round(T num, T den, T rem, RT2T<RoundType::half_up>)
     if (rem == 0)
         return num;
     if (std::abs(rem) * 2 >= std::abs(den))
+    {
+        if (num == 0)
+            return (!quotient_is_positive(rem, den) ? -1 : 1);
         return num + (num < 0 ? -1 : 1);
+    }
     return num;
 }
 
@@ -139,7 +190,7 @@ round<GncInt128>(GncInt128 num, GncInt128 den, GncInt128 rem,
     if (rem == 0)
         return num;
     if (rem.abs() * 2 >= den.abs())
-        return num + (num < 0 ? -1 : 1);
+        return num + (num.isNeg() ? -1 : 1);
     return num;
 }
 
@@ -150,11 +201,15 @@ round(T num, T den, T rem, RT2T<RoundType::bankers>)
         return num;
     if (std::abs(rem * 2) > std::abs(den) ||
         (std::abs(rem * 2) == std::abs(den) && num % 2))
-        return num += (num < 0 ? -1 : 1);
+    {
+        if (num == 0)
+            return (!quotient_is_positive(rem, den) ? -1 : 1);
+        return num + (num < 0 ? -1 : 1);
+    }
     return num;
 }
 
-template<> inline GncInt128
+template <> inline GncInt128
 round<GncInt128>(GncInt128 num, GncInt128 den, GncInt128 rem,
                  RT2T<RoundType::bankers>)
 {
@@ -162,7 +217,7 @@ round<GncInt128>(GncInt128 num, GncInt128 den, GncInt128 rem,
         return num;
     if (rem.abs() * 2 > den.abs() ||
         (rem.abs() * 2 == den.abs() && num % 2))
-        return num += (num < 0 ? -1 : 1);
+        return num + (num.isNeg() ? -1 : 1);
     return num;
 }
 #endif //__GNC_RATIONAL_ROUNDING_HPP__
diff --git a/libgnucash/engine/test/gtest-gnc-int128.cpp b/libgnucash/engine/test/gtest-gnc-int128.cpp
index 5aa04f8f6..82ed98ba0 100644
--- a/libgnucash/engine/test/gtest-gnc-int128.cpp
+++ b/libgnucash/engine/test/gtest-gnc-int128.cpp
@@ -432,7 +432,7 @@ TEST(GncInt128_functions, divide)
     GncInt128 big (sarg, barg);
     GncInt128 bigger (static_cast<uint64_t>(sarg), uarg);
     GncInt128 nsmall = -small;
-    GncInt128 nbig = -bigger;
+    GncInt128 nbigger = -bigger;
 
     EXPECT_EQ (GncInt128(INT64_C(0)), zero /= smallest);
     EXPECT_EQ (GncInt128(INT64_C(0)), zero %= smallest);
@@ -451,11 +451,20 @@ TEST(GncInt128_functions, divide)
 
     nsmall.div (smaller, q, r);
     EXPECT_EQ (-two, q);
-    EXPECT_EQ (GncInt128(INT64_C(3810195028972355394)), r);
+    EXPECT_EQ (GncInt128(INT64_C(-3810195028972355394)), r);
 
     nsmall.div (-smaller, q, r);
     EXPECT_EQ (two, q);
-    EXPECT_EQ (GncInt128(INT64_C(3810195028972355394)), r);
+    EXPECT_EQ (GncInt128(INT64_C(-3810195028972355394)), r);
+
+    smaller.div (small, q, r);
+    EXPECT_EQ (zero, q);
+    EXPECT_EQ (smaller, r);
+
+    smaller.div (nsmall, q, r);
+    EXPECT_EQ (zero, q);
+    EXPECT_TRUE (q.isNeg());
+    EXPECT_EQ (smaller, r);
 
     bigger.div (bigger, q, r);
     EXPECT_EQ (one, q);
@@ -477,18 +486,23 @@ TEST(GncInt128_functions, divide)
     EXPECT_EQ (-two, q);
     EXPECT_EQ (GncInt128(UINT64_C(3810195028972355394)), r);
 
-    nbig.div (-big, q, r);
+    nbigger.div (-big, q, r);
     EXPECT_EQ (two, q);
-    EXPECT_EQ (GncInt128(UINT64_C(3810195028972355394)), r);
+    EXPECT_EQ (GncInt128(0, UINT64_C(3810195028972355394), GncInt128::neg), r);
 
-    nbig.div (-big, q, r);
+    nbigger.div (-big, q, r);
     EXPECT_EQ (two, q);
-    EXPECT_EQ (GncInt128(UINT64_C(3810195028972355394)), r);
+    EXPECT_EQ (GncInt128(0, UINT64_C(3810195028972355394), GncInt128::neg), r);
 
     big.div (bigger, q, r);
     EXPECT_EQ (zero, q);
     EXPECT_EQ (big, r);
 
+    big.div (nbigger, q, r);
+    EXPECT_EQ (zero, q);
+    EXPECT_TRUE (q.isNeg());
+    EXPECT_EQ (big, r);
+
     big.div (big - 1, q, r);
     EXPECT_EQ(one, q);
     EXPECT_EQ(one, r);
diff --git a/libgnucash/engine/test/gtest-gnc-numeric.cpp b/libgnucash/engine/test/gtest-gnc-numeric.cpp
index f6ba3f114..680b6d82d 100644
--- a/libgnucash/engine/test/gtest-gnc-numeric.cpp
+++ b/libgnucash/engine/test/gtest-gnc-numeric.cpp
@@ -411,7 +411,7 @@ TEST(gncnumeric_functions, test_convert)
     EXPECT_EQ(3465453, c.num());
     EXPECT_EQ(128, c.denom());
     ASSERT_NO_THROW(c = b.convert<RoundType::floor>(128));
-    EXPECT_EQ(-3465452, c.num());
+    EXPECT_EQ(-3465454, c.num());
     EXPECT_EQ(128, c.denom());
     ASSERT_NO_THROW(c = a.convert<RoundType::ceiling>(128));
     EXPECT_EQ(3465454, c.num());

commit 94c5fe9f1d526a367a8704bdddf89f5df48f781e
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Fri May 10 22:35:31 2019 +0800

    [balsheet-pnl] fix stress-options failure
    
    retained-earnings-fn will return a list of monetary (for different
    currencies) or a monetary (all currencies converted). either must be
    negated. handle separate paths separately.

diff --git a/gnucash/report/standard-reports/balsheet-pnl.scm b/gnucash/report/standard-reports/balsheet-pnl.scm
index 7a331ee9e..1c37c0e6e 100644
--- a/gnucash/report/standard-reports/balsheet-pnl.scm
+++ b/gnucash/report/standard-reports/balsheet-pnl.scm
@@ -940,15 +940,16 @@ also show overall period profit & loss."))
                                (else (list-ref report-dates col-idx))))
                        (income-expense-balance
                         (list-ref income-expense-balances col-idx)))
-                  (map
-                   gnc:monetary-neg
-                   (if (and common-currency
-                            (every has-price?
-                                   (map xaccAccountGetCommodity
-                                        (append income-accounts
-                                                expense-accounts))))
+                  (if (and common-currency
+                           (every has-price?
+                                  (map xaccAccountGetCommodity
+                                       (append income-accounts
+                                               expense-accounts))))
+                      (gnc:monetary-neg
                        (monetaries->exchanged income-expense-balance
-                                              common-currency price-source date)
+                                              common-currency price-source date))
+                      (map
+                       gnc:monetary-neg
                        (income-expense-balance 'format gnc:make-gnc-monetary #f))))))
              (chart (and include-chart?
                          (gnc:make-report-anchor

commit e983d07cb12913740a38472baa98ed0eeea5dc7d
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Wed Jun 27 19:29:40 2018 +0800

    [balsheet-pnl] Initial commit

diff --git a/gnucash/report/report-gnome/report-gnome.scm b/gnucash/report/report-gnome/report-gnome.scm
index 004db7d62..6d6748bc0 100644
--- a/gnucash/report/report-gnome/report-gnome.scm
+++ b/gnucash/report/report-gnome/report-gnome.scm
@@ -104,6 +104,8 @@
     (gnc:make-menu gnc:menuname-budget (list gnc:menuname-reports)))
   (define utility-menu
     (gnc:make-menu gnc:menuname-utility (list gnc:menuname-reports)))
+  (define experimental-menu
+    (gnc:make-menu gnc:menuname-experimental (list gnc:menuname-reports)))
   (define tax-menu 
     (gnc:make-menu gnc:menuname-taxes (list gnc:menuname-reports)))
   (define business-menu 
@@ -123,6 +125,7 @@
   (gnc-add-scm-extension asset-liability-menu)
   (gnc-add-scm-extension budget-menu)
   (gnc-add-scm-extension utility-menu)
+  (gnc-add-scm-extension experimental-menu)
   (gnc-add-scm-extension business-menu)
 
   ;; run report-hook danglers
diff --git a/gnucash/report/report-system/report-system.scm b/gnucash/report/report-system/report-system.scm
index 387135e51..de16b73fc 100644
--- a/gnucash/report/report-system/report-system.scm
+++ b/gnucash/report/report-system/report-system.scm
@@ -131,6 +131,7 @@
 (export gnc:menuname-budget)
 (export gnc:menuname-taxes)
 (export gnc:menuname-utility)
+(export gnc:menuname-experimental)
 (export gnc:menuname-custom)
 (export gnc:menuname-business-reports)
 (export gnc:pagename-general)
diff --git a/gnucash/report/report-system/report.scm b/gnucash/report/report-system/report.scm
index b48acd828..a0793ef54 100644
--- a/gnucash/report/report-system/report.scm
+++ b/gnucash/report/report-system/report.scm
@@ -63,6 +63,7 @@
 (define gnc:menuname-budget (N_ "B_udget"))
 (define gnc:menuname-taxes (N_ "_Taxes"))
 (define gnc:menuname-utility (N_ "_Sample & Custom"))
+(define gnc:menuname-experimental (N_ "_Experimental"))
 (define gnc:menuname-custom (N_ "_Custom"))
 (define gnc:pagename-general (N_ "General"))
 (define gnc:pagename-accounts (N_ "Accounts"))
diff --git a/gnucash/report/standard-reports/CMakeLists.txt b/gnucash/report/standard-reports/CMakeLists.txt
index 429e7a43f..df87daf30 100644
--- a/gnucash/report/standard-reports/CMakeLists.txt
+++ b/gnucash/report/standard-reports/CMakeLists.txt
@@ -10,6 +10,7 @@ set (standard_reports_SCHEME_2
     average-balance.scm
     balance-sheet.scm
     balance-forecast.scm
+    balsheet-pnl.scm
     budget-balance-sheet.scm
     budget-barchart.scm
     budget-flow.scm
diff --git a/gnucash/report/standard-reports/balsheet-pnl.scm b/gnucash/report/standard-reports/balsheet-pnl.scm
new file mode 100644
index 000000000..7a331ee9e
--- /dev/null
+++ b/gnucash/report/standard-reports/balsheet-pnl.scm
@@ -0,0 +1,1253 @@
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; balsheet-pnl.scm: multi-column report. includes
+;; balance-sheet and p&l reports.
+;;
+;; By Christopher Lam, 2018
+;;
+;; Improved from balance-sheet.scm
+;;
+;; 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 balsheet-pnl))
+(use-modules (gnucash utilities))
+(use-modules (gnucash gnc-module))
+(use-modules (gnucash gettext))
+(use-modules (srfi srfi-1))
+
+(gnc:module-load "gnucash/report/report-system" 0)
+
+(define FOOTER-TEXT
+  (gnc:make-html-text
+   (_ "WARNING: Foreign currency conversions, and unrealized gains
+calculations are not confirmed correct. This report may be modified
+without notice. Bug reports are very welcome at
+https://bugs.gnucash.org/")))
+
+;; define all option's names and help text so that they are properly
+
+(define optname-startdate (N_ "Start Date"))
+(define optname-enddate (N_ "End Date"))
+
+(define optname-period (N_ "Period duration"))
+(define opthelp-period (N_ "Duration between time periods"))
+
+(define optname-dual-columns (N_ "Enable dual columns"))
+(define opthelp-dual-columns (N_ "Selecting this option will enable double-column \
+reporting."))
+
+(define optname-disable-amount-indent (N_ "Disable amount indenting"))
+(define opthelp-disable-amount-indent (N_ "Selecting this option will disable amount indenting, and condense amounts into a single column."))
+
+(define optname-options-summary (N_ "Add options summary"))
+(define opthelp-options-summary (N_ "Add summary of options."))
+
+(define optname-account-full-name (N_ "Account full name instead of indenting"))
+(define opthelp-account-full-name (N_ "Selecting this option enables full account name instead, and disables indenting account names."))
+
+(define optname-accounts (N_ "Accounts"))
+(define opthelp-accounts (N_ "Report on these accounts, if display depth allows."))
+
+(define optname-depth-limit (N_ "Levels of Subaccounts"))
+(define opthelp-depth-limit (N_ "Maximum number of levels in the account tree displayed."))
+
+(define optname-parent-balance-mode (N_ "Parent account amounts include children"))
+(define opthelp-parent-balance-mode (N_ "If this option is enabled, subtotals are \
+displayed within parent amounts, and if parent has own amount, it is displayed on \
+the next row as a child account. If this option is disabled, subtotals are displayed \
+below parent and children groups."))
+
+(define optname-show-zb-accts (N_ "Include accounts with zero total balances"))
+(define opthelp-show-zb-accts (N_ "Include accounts with zero total (recursive) balances in this report."))
+
+(define optname-omit-zb-bals (N_ "Omit zero balance figures"))
+(define opthelp-omit-zb-bals (N_ "Show blank space in place of any zero balances which would be shown."))
+
+(define optname-account-links (N_ "Display accounts as hyperlinks"))
+(define opthelp-account-links (N_ "Shows each account in the table as a hyperlink to its register window."))
+
+(define optname-amount-links (N_ "Display amounts as hyperlinks"))
+(define opthelp-amount-links (N_ "Shows each amounts in the table as a hyperlink to a register or report."))
+
+;; closing entries filter - for P&L report
+(define pagename-entries "Closing Entries")
+(define optname-closing-pattern (N_ "Closing Entries pattern"))
+(define opthelp-closing-pattern (N_ "Any text in the Description column which identifies closing entries."))
+(define optname-closing-casing (N_ "Closing Entries pattern is case-sensitive"))
+(define opthelp-closing-casing (N_ "Causes the Closing Entries Pattern match to be case-sensitive."))
+(define optname-closing-regexp (N_ "Closing Entries Pattern is regular expression"))
+(define opthelp-closing-regexp (N_ "Causes the Closing Entries Pattern to be treated as a regular expression."))
+
+;; section labels
+(define optname-label-sections (N_ "Label sections"))
+(define opthelp-label-sections (N_ "Whether or not to include a label for sections."))
+(define optname-total-sections (N_ "Include totals"))
+(define opthelp-total-sections (N_ "Whether or not to include a line indicating total amounts."))
+
+;; commodities
+(define pagename-commodities (N_ "Commodities"))
+(define optname-include-chart (N_ "Enable chart"))
+(define opthelp-include-chart (N_ "Enable link to chart"))
+
+(define optname-common-currency (N_ "Common Currency"))
+(define opthelp-common-currency (N_ "Convert all amounts to a single currency."))
+
+(define optname-report-commodity (N_ "Report's currency"))
+
+(define optname-price-source (N_ "Price Source"))
+
+(define optname-show-foreign (N_ "Show original currency amount"))
+(define opthelp-show-foreign (N_ "Also show original currency amounts"))
+
+(define optname-include-overall-period (N_ "If more than 1 period column, include overall period?"))
+(define opthelp-include-overall-period (N_ "If several profit & loss period columns are shown, \
+also show overall period profit & loss."))
+
+(define optname-show-rates (N_ "Show Exchange Rates"))
+(define opthelp-show-rates (N_ "Show the exchange rates used."))
+
+(define trep-uuid "2fe3b9833af044abb929a88d5a59620f")
+(define networth-barchart-uuid "cbba1696c8c24744848062c7f1cf4a72")
+(define pnl-barchart-uuid "80769921e87943adade887b9835a7685")
+
+(define periodlist
+  (list
+   (list #f
+         (cons 'delta #f)
+         (cons 'text (_ "Disabled"))
+         (cons 'tip (_ "Disabled")))
+
+   (list 'year
+         (cons 'delta YearDelta)
+         (cons 'text (_ "Year"))
+         (cons 'tip (_ "One year.")))
+
+   (list 'halfyear
+         (cons 'delta HalfYearDelta)
+         (cons 'text (_ "Half Year"))
+         (cons 'tip (_ "Half Year.")))
+
+   (list 'quarter
+         (cons 'delta QuarterDelta)
+         (cons 'text (_ "Quarter"))
+         (cons 'tip (_ "One Quarter.")))
+
+   (list 'month
+         (cons 'delta MonthDelta)
+         (cons 'text (_ "Month"))
+         (cons 'tip (_ "One Month.")))
+
+   (list 'twoweek
+         (cons 'delta TwoWeekDelta)
+         (cons 'text (_ "2Week"))
+         (cons 'tip (_ "Two Weeks.")))
+
+   (list 'week
+         (cons 'delta WeekDelta)
+         (cons 'text (_ "Week"))
+         (cons 'tip (_ "One Week.")))))
+
+(define (keylist->vectorlist keylist)
+  (map
+   (lambda (item)
+     (vector
+      (car item)
+      (keylist-get-info keylist (car item) 'text)
+      (keylist-get-info keylist (car item) 'tip)))
+   keylist))
+
+(define (keylist-get-info keylist key info)
+  (assq-ref (assq-ref keylist key) info))
+
+;; options generator
+(define (multicol-report-options-generator report-type)
+  (let* ((options (gnc:new-options))
+         (book (gnc-get-current-book))
+         (add-option
+          (lambda (new-option)
+            (gnc:register-option options new-option))))
+
+    ;; date at which to report balance
+    (gnc:options-add-date-interval!
+     options gnc:pagename-general optname-startdate optname-enddate "c")
+
+    (add-option
+     (gnc:make-multichoice-callback-option
+      gnc:pagename-general optname-period
+      "c2" opthelp-period
+      #f
+      (keylist->vectorlist periodlist)
+      #f
+      (lambda (x)
+        (gnc-option-db-set-option-selectable-by-name
+         options
+         gnc:pagename-general optname-disable-amount-indent
+         (not x))
+        (gnc-option-db-set-option-selectable-by-name
+         options
+         gnc:pagename-general optname-dual-columns
+         (not x))
+        (gnc-option-db-set-option-selectable-by-name
+         options
+         gnc:pagename-general
+         (case report-type
+           ((balsheet) optname-startdate)
+           ((pnl) optname-include-overall-period))
+         x))))
+
+    (add-option
+     (gnc:make-simple-boolean-option
+      gnc:pagename-general optname-disable-amount-indent
+      "c3" opthelp-disable-amount-indent #f))
+
+    (add-option
+     (gnc:make-simple-boolean-option
+      gnc:pagename-general optname-include-chart
+      "d" opthelp-include-chart #f))
+
+    (add-option
+     (gnc:make-simple-boolean-option
+      gnc:pagename-general optname-dual-columns
+      "c4" opthelp-dual-columns #t))
+
+    (add-option
+     (gnc:make-multichoice-option
+      gnc:pagename-general optname-options-summary
+      "d" opthelp-options-summary
+      'never
+      (list (vector 'always
+                    (_ "Always")
+                    (_ "Always display summary."))
+            (vector 'never
+                    (_ "Never")
+                    (_ "Disable report summary.")))))
+
+    ;; accounts to work on
+    (add-option
+     (gnc:make-account-list-option
+      gnc:pagename-accounts optname-accounts
+      "a"
+      opthelp-accounts
+      (lambda ()
+        (gnc:filter-accountlist-type
+         (list ACCT-TYPE-BANK ACCT-TYPE-CASH ACCT-TYPE-CREDIT
+               ACCT-TYPE-ASSET ACCT-TYPE-LIABILITY
+               ACCT-TYPE-STOCK ACCT-TYPE-MUTUAL ACCT-TYPE-CURRENCY
+               ACCT-TYPE-PAYABLE ACCT-TYPE-RECEIVABLE
+               ACCT-TYPE-EQUITY ACCT-TYPE-INCOME ACCT-TYPE-EXPENSE
+               ACCT-TYPE-TRADING)
+         (gnc-account-get-descendants-sorted (gnc-get-current-root-account))))
+      #f #t))
+
+    ;; the depth-limit option is not well debugged; it may be better
+    ;; to disable it altogether
+    (gnc:options-add-account-levels!
+     options gnc:pagename-accounts optname-depth-limit
+     "b" opthelp-depth-limit 'all)
+
+    ;; all about currencies
+    (add-option
+     (gnc:make-complex-boolean-option
+      pagename-commodities optname-common-currency
+      "b" opthelp-common-currency #f #f
+      (lambda (x)
+        (for-each
+         (lambda (optname)
+           (gnc-option-db-set-option-selectable-by-name
+            options pagename-commodities optname x))
+         (list optname-report-commodity
+               optname-show-rates
+               optname-show-foreign
+               optname-price-source)))))
+
+    (gnc:options-add-currency!
+     options pagename-commodities
+     optname-report-commodity "c")
+
+    (gnc:options-add-price-source!
+     options pagename-commodities
+     optname-price-source "d" 'pricedb-nearest)
+
+    (add-option
+     (gnc:make-simple-boolean-option
+      pagename-commodities optname-show-foreign
+      "e" opthelp-show-foreign #t))
+
+    (add-option
+     (gnc:make-simple-boolean-option
+      pagename-commodities optname-show-rates
+      "f" opthelp-show-rates #t))
+
+    ;; what to show for zero-balance accounts
+    (add-option
+     (gnc:make-simple-boolean-option
+      gnc:pagename-display optname-show-zb-accts
+      "a" opthelp-show-zb-accts #t))
+
+    (add-option
+     (gnc:make-simple-boolean-option
+      gnc:pagename-display optname-omit-zb-bals
+      "b" opthelp-omit-zb-bals #f))
+
+    (add-option
+     (gnc:make-simple-boolean-option
+      gnc:pagename-display optname-parent-balance-mode
+      "c" opthelp-parent-balance-mode #t))
+
+    ;; some detailed formatting options
+    (add-option
+     (gnc:make-simple-boolean-option
+      gnc:pagename-display optname-account-links
+      "e" opthelp-account-links #t))
+
+    (add-option
+     (gnc:make-simple-boolean-option
+      gnc:pagename-display optname-amount-links
+      "e5" opthelp-amount-links #t))
+
+    (add-option
+     (gnc:make-simple-boolean-option
+      gnc:pagename-display optname-account-full-name
+      "f" opthelp-account-full-name #f))
+
+    (add-option
+     (gnc:make-simple-boolean-option
+      gnc:pagename-display optname-label-sections "g" opthelp-label-sections #t))
+
+    (add-option
+     (gnc:make-simple-boolean-option
+      gnc:pagename-display optname-total-sections "h" opthelp-total-sections #t))
+
+    (when (eq? report-type 'pnl)
+      ;; include overall period column?
+      (add-option
+       (gnc:make-simple-boolean-option
+        gnc:pagename-general optname-include-overall-period
+        "e" opthelp-include-overall-period #f))
+
+      ;; closing entry match criteria
+      (add-option
+       (gnc:make-string-option
+        pagename-entries optname-closing-pattern
+        "a" opthelp-closing-pattern (_ "Closing Entries")))
+
+      (add-option
+       (gnc:make-simple-boolean-option
+        pagename-entries optname-closing-casing
+        "b" opthelp-closing-casing #f))
+
+      (add-option
+       (gnc:make-simple-boolean-option
+        pagename-entries optname-closing-regexp
+        "c" opthelp-closing-regexp #f)))
+
+    (gnc:options-set-default-section options gnc:pagename-general)
+
+    options))
+
+(define* (add-multicolumn-acct-table
+          table title accountlist maxindent get-cell-monetary-fn cols-data #:key
+          (omit-zb-bals? #f)
+          (show-zb-accts? #t)
+          (disable-account-indent? #f)
+          (disable-amount-indent? #f)
+          (show-orig-cur? #t)
+          (show-title? #t)
+          (show-accounts? #t)
+          (show-total? #t)
+          (depth-limit #f)
+          (negate-amounts? #f)
+          (recursive-bals? #f)
+          (account-anchor? #t)
+          (get-col-header-fn #f)
+          (convert-curr-fn #f)
+          (get-cell-anchor-fn #f))
+
+  ;; this function will add a 2D grid into the html-table
+  ;; the data cells are generated from (get-cell-monetary-fn account col-datum)
+  ;; the data cells may request an alternative (eg. original currency) monetary
+  ;; horizontal labels are generated from calling (get-col-header-fn col-datum)
+  ;; vertical labels are the account list. it can have multilevel subtotals.
+
+  ;; the following are compulsory arguments:
+  ;; table - an existing html-table object
+  ;; title - string as the first row
+  ;; accountlist - list of accounts
+  ;; maxindent - maximum account depth
+  ;; cols-data - list of data to be passed as parameter to the following helper functions
+  ;; get-cell-monetary-fn - a lambda (account cols-data) which produces a gnc-monetary or #f (eg price conversion impossible)
+
+  ;; the following are optional:
+  ;; omit-zb-bals?      - a boolean to omit "$0.00" amounts
+  ;; show-zb-accts?     - a boolean to omit whole account lines where all amounts are $0.00 (eg closed accts)
+  ;; show-title?        - a bool to show/hide individual sections: title row
+  ;; show-accounts?     - a bool to show/hide individual sections: accounts list and data columns
+  ;; show-total?        - a bool to show/hide individual sections: accounts total
+  ;; disable-account-indent? - a boolean to disable narrow-cell indenting, and render account full-name instead
+  ;; disable-amount-indent? - a bool to disable amount indenting (only for single data column reports)
+  ;; negate-amounts?    - a boolean to negate amounts. useful for e.g. income-type accounts.
+  ;; depth-limit        - (untested) accounts whose levels exceed this depth limit are not shown
+  ;; recursive-bals?    - a boolean to confirm recursive-balances enabled (parent-accounts show balances) or
+  ;;                      disabled (multilevel subtotals after each parent+children)
+  ;; account-anchor?    - a boolean to enable/disable account link to account
+  ;; amount-anchor?     - a boolean to enable/disable amount link to report/register
+  ;; get-col-header-fn  - a lambda (accounts cols-data) to produce html-object - this is optional
+  ;; convert-curr-fn    - a lambda (monetary cols-data) which produces a gnc-monetary or #f - optional
+  ;; show-orig-cur?     - a boolean to enable/disable original currency after convert-curr-fn
+  ;; get-cell-anchor-fn - a lambda (account cols-data) which produces a url string - optional
+
+  (define num-columns (length cols-data))
+
+  (define amount-indenting? (and (not disable-amount-indent?) (= num-columns 1)))
+
+  (define (make-list-thunk n thunk)
+    (let loop ((result '()) (n n))
+      (if (zero? n) result
+          (loop (cons (thunk) result) (1- n)))))
+
+  (define (make-narrow-cell)
+    (let ((narrow (gnc:make-html-table-cell/markup "text-cell" #f)))
+      (gnc:html-table-cell-set-style!
+       narrow "text-cell"
+       'attribute '("style" "width:1px"))
+      narrow))
+
+  (define (add-indented-row indent label label-markup amount-indent rest)
+    (when (or (not depth-limit) (<= indent depth-limit))
+      (gnc:html-table-append-row!
+       table
+       (append (if disable-account-indent?
+                   '() (make-list-thunk indent make-narrow-cell))
+               (list (if label-markup
+                         (gnc:make-html-table-cell/size/markup
+                          1 (if disable-account-indent? 1 (- maxindent indent))
+                          label-markup label)
+                         (gnc:make-html-table-cell/size
+                          1 (if disable-account-indent? 1 (- maxindent indent))
+                          label)))
+               (gnc:html-make-empty-cells
+                (if amount-indenting? (1- amount-indent) 0))
+               rest
+               (gnc:html-make-empty-cells
+                (if amount-indenting? (- maxindent amount-indent) 0))))))
+
+  (define (monetary+ . monetaries)
+    ;; usage: (monetary+ monetary...)
+    ;; inputs: list of gnc-monetary (e.g. USD 10, USD 25, GBP 5, GBP 8)
+    ;; outputs: list of gnc-monetary (e.g. USD 35, GBP 13), or '()
+    (let ((coll (gnc:make-commodity-collector)))
+      (for-each
+       (lambda (monetary)
+         (if monetary
+             (coll 'add
+                   (gnc:gnc-monetary-commodity monetary)
+                   (let ((amount (gnc:gnc-monetary-amount monetary)))
+                     (if negate-amounts? (- amount) amount)))))
+       monetaries)
+      (coll 'format gnc:make-gnc-monetary #f)))
+
+  (define (list-of-monetary->html-text monetaries col-datum anchor)
+    ;; inputs:
+    ;; monetaries: list of gnc-monetary (or #f, or html-text object)
+    ;; col-datum: col-datum to help convert monetary currency
+    ;; anchor: url string for monetaries (or #f) (all have same anchor)
+    ;;
+    ;; outputs: html-text object
+    (let ((text (gnc:make-html-text)))
+      (for-each
+       (lambda (monetary)
+         (let ((converted (and show-orig-cur?
+                               convert-curr-fn
+                               (convert-curr-fn monetary col-datum))))
+           (if (not (and omit-zb-bals?
+                         (gnc:gnc-monetary? monetary)
+                         (zero? (gnc:gnc-monetary-amount monetary))))
+               (gnc:html-text-append! text
+                                      (if converted
+                                          (gnc:html-markup-i
+                                           (gnc:html-markup "small" monetary " "))
+                                          "")
+                                      (if anchor
+                                          (gnc:html-markup-anchor
+                                           anchor (or converted monetary))
+                                          (or converted monetary))
+                                      (gnc:html-markup-br)))))
+       monetaries)
+      text))
+
+  (define (account->depth acc)
+    (cond ((vector? acc) 0)
+          (else (gnc-account-get-current-depth acc))))
+
+  (define (account->descendants acc)
+    (cond ((vector? acc) '())
+          (else (gnc-account-get-descendants acc))))
+
+  (define (render-account account total?)
+    ;; input: account-name
+    ;; outputs: string or html-markup-anchor object
+    (let* ((virtual? (vector? account))
+           (acct-name (cond
+                       (virtual? (vector-ref account 0))
+                       (disable-account-indent? (gnc-account-get-full-name account))
+                       (else (xaccAccountGetName account))))
+           (acct-label (if (and (not virtual?) total?)
+                           (string-append (_ "Total For ") acct-name)
+                           acct-name))
+           (acct-url (and account-anchor?
+                          (not total?)
+                          (not virtual?)
+                          (not (xaccAccountGetPlaceholder account))
+                          (gnc:account-anchor-text account))))
+      (gnc:make-html-text
+       (if acct-url
+           (gnc:html-markup-anchor acct-url acct-label)
+           acct-label))))
+
+  (define (add-whole-line contents)
+    (gnc:html-table-append-row!
+     table (gnc:make-html-table-cell/size
+            1 (+ 1 (if disable-account-indent? 0 maxindent) num-columns)
+            contents)))
+
+  (define (account-and-descendants account)
+    (cons account (filter (lambda (acc) (member acc accountlist))
+                          (account->descendants account))))
+
+  (define (sum-accounts-at-col accounts datum convert?)
+    ;; outputs: list of gnc-monetary
+
+    (let loop ((accounts accounts)
+               (result '()))
+      (cond
+       ((null? accounts)
+        (apply monetary+ result))
+       (else
+        (let* ((acc (car accounts))
+               (monetary (if (vector? acc)
+                             ((vector-ref acc 1) datum)
+                             (get-cell-monetary-fn acc datum)))
+               (amt (or (and convert? convert-curr-fn
+                             (not (list? monetary))
+                             (convert-curr-fn monetary datum))
+                        monetary)))
+          (loop (cdr accounts)
+                (if (list? amt)
+                    (append amt result)
+                    (cons amt result))))))))
+
+  (define (is-not-zero? accts)
+    ;; this function tests whether accounts (with descendants) of all
+    ;; columns are zero.
+    (not (every zero? (concatenate
+                       (map
+                        (lambda (col-datum)
+                          (map gnc:gnc-monetary-amount
+                               (sum-accounts-at-col accts col-datum #f)))
+                        cols-data)))))
+
+  (define* (add-recursive-subtotal lvl lvl-acct #:key account-style-normal?)
+    (if (or show-zb-accts?
+            (is-not-zero? (account-and-descendants lvl-acct)))
+        (add-indented-row lvl
+                          (render-account lvl-acct (not account-style-normal?))
+                          (if account-style-normal?
+                              "text-cell"
+                              "total-label-cell")
+                          (- maxindent lvl)
+                          (map
+                           (lambda (col-datum)
+                             (gnc:make-html-table-cell/markup
+                              "total-number-cell"
+                              (list-of-monetary->html-text
+                               (sum-accounts-at-col (account-and-descendants lvl-acct)
+                                                    col-datum
+                                                    #t)
+                               col-datum
+                               #f)))
+                           cols-data))))
+
+  (define* (add-account-row lvl-curr curr #:key
+                            (override-show-zb-accts? #f)
+                            (account-indent 0))
+    (if (or show-zb-accts?
+            override-show-zb-accts?
+            (is-not-zero? (list curr)))
+        (add-indented-row lvl-curr
+                          (render-account curr #f)
+                          "text-cell"
+                          (- maxindent lvl-curr account-indent)
+                          (map
+                           (lambda (col-datum)
+                             (gnc:make-html-table-cell/markup
+                              "number-cell"
+                              (list-of-monetary->html-text
+                               (sum-accounts-at-col
+                                (list curr)
+                                col-datum
+                                (not show-orig-cur?))
+                               col-datum
+                               (and get-cell-anchor-fn
+                                    (not (vector? curr))
+                                    (get-cell-anchor-fn curr col-datum)))))
+                           cols-data))))
+
+  ;; header ASSET/LIABILITY etc
+  (if show-title?
+      (add-indented-row 0
+                        title
+                        "total-label-cell"
+                        maxindent
+                        (if get-col-header-fn
+                            (map
+                             (lambda (col-datum)
+                               (get-col-header-fn accountlist col-datum))
+                             cols-data)
+                            (gnc:html-make-empty-cells num-columns))))
+
+  (let loop ((accounts (if show-accounts? accountlist '())))
+    (if (pair? accounts)
+        (let* ((curr (car accounts))
+               (rest (cdr accounts))
+               (next (and (pair? rest) (car rest)))
+               (lvl-curr (account->depth curr))
+               (lvl-next (if next (account->depth next) 0))
+               (curr-descendants-list (filter
+                                       (lambda (acc) (member acc accountlist))
+                                       (account->descendants curr)))
+               (recursive-parent-acct? (and recursive-bals?
+                                            (pair? curr-descendants-list)))
+               (multilevel-parent-acct? (and (not recursive-bals?)
+                                             (pair? curr-descendants-list))))
+
+          (if recursive-parent-acct?
+              (begin
+                (add-recursive-subtotal lvl-curr curr #:account-style-normal? #t)
+                (if (is-not-zero? (list curr))
+                    (add-account-row (1+ lvl-curr) curr #:override-show-zb-accts? #t)))
+              (add-account-row lvl-curr curr
+                               #:account-indent (if multilevel-parent-acct? 1 0)
+                               #:override-show-zb-accts? multilevel-parent-acct?))
+
+          (if (and (not recursive-bals?)
+                   (> lvl-curr lvl-next))
+              (let multilevel-loop ((lvl (1- lvl-curr))
+                                    (lvl-acct (gnc-account-get-parent curr)))
+                (unless (or (zero? lvl)
+                            (not (member lvl-acct accountlist))
+                            (< lvl lvl-next))
+                  (add-recursive-subtotal lvl lvl-acct)
+                  (multilevel-loop (1- lvl)
+                                   (gnc-account-get-parent lvl-acct)))))
+          (loop rest))))
+
+  (if show-total?
+      (add-indented-row 0
+                        (string-append (_ "Total For ") title)
+                        "total-label-cell"
+                        maxindent
+                        (map
+                         (lambda (col-datum)
+                           (let ((total-cell (gnc:make-html-table-cell/markup
+                                              "total-number-cell"
+                                              (list-of-monetary->html-text
+                                               (sum-accounts-at-col accountlist
+                                                                    col-datum
+                                                                    #t)
+                                               col-datum
+                                               #f))))
+                             (gnc:html-table-cell-set-style!
+                              total-cell "total-number-cell"
+                              'attribute '("style" "border-top-style:solid; border-top-width: 1px; border-bottom-style:double"))
+                             total-cell))
+                         cols-data)))
+  (add-whole-line #f))
+
+(define (monetary-less . monetaries)
+  ;; syntax: (monetary-less mon0 mon1 mon2 ...)
+  ;; equiv:  (- mon0 mon1 mon2 ...)
+  ;; this works only if all monetaries have the same commodity
+  (let ((res (gnc:make-commodity-collector)))
+    (res 'add (gnc:gnc-monetary-commodity (car monetaries))
+         (gnc:gnc-monetary-amount (car monetaries)))
+    (for-each
+     (lambda (mon)
+       (res 'add (gnc:gnc-monetary-commodity mon) (- (gnc:gnc-monetary-amount mon))))
+     (cdr monetaries))
+    (let ((reslist (res 'format gnc:make-gnc-monetary #f)))
+      (if (null? (cdr reslist))
+          (car reslist)
+          (gnc:error "monetary-less: 1 commodity only" monetaries)))))
+
+  ;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; multicol-report-renderer
+  ;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(define (multicol-report-renderer report-obj report-type)
+  (define (get-option pagename optname)
+    (gnc:option-value
+     (gnc:lookup-option
+      (gnc:report-options report-obj) pagename optname)))
+
+  (gnc:report-starting (get-option gnc:pagename-general gnc:optname-reportname))
+
+  ;; get all options values
+  (let* ((report-title (get-option gnc:pagename-general gnc:optname-reportname))
+         (startdate (gnc:date-option-absolute-time
+                     (get-option gnc:pagename-general
+                                 optname-startdate)))
+         (enddate (gnc:date-option-absolute-time
+                   (get-option gnc:pagename-general
+                               optname-enddate)))
+         (disable-account-indent? (get-option gnc:pagename-display
+                                              optname-account-full-name))
+         (incr (let ((period (get-option gnc:pagename-general optname-period)))
+                 (and period
+                      (keylist-get-info periodlist period 'delta))))
+         (disable-amount-indent? (and (not incr)
+                                      (get-option gnc:pagename-general
+                                                  optname-disable-amount-indent)))
+         (enable-dual-columns? (and (not incr)
+                                    (get-option gnc:pagename-general
+                                                optname-dual-columns)))
+         (accounts (get-option gnc:pagename-accounts
+                               optname-accounts))
+         (depth-limit (let ((limit (get-option gnc:pagename-accounts
+                                               optname-depth-limit)))
+                        (and (not (eq? limit 'all)) limit)))
+         (show-zb-accts? (get-option gnc:pagename-display
+                                     optname-show-zb-accts))
+         (omit-zb-bals? (get-option gnc:pagename-display
+                                    optname-omit-zb-bals))
+         (recursive-bals? (get-option gnc:pagename-display
+                                      optname-parent-balance-mode))
+         (label-sections? (get-option gnc:pagename-display
+                                      optname-label-sections))
+         (total-sections? (get-option gnc:pagename-display
+                                      optname-total-sections))
+         (use-links? (get-option gnc:pagename-display
+                                 optname-account-links))
+         (use-amount-links? (get-option gnc:pagename-display
+                                        optname-amount-links))
+         (include-chart? (get-option gnc:pagename-general optname-include-chart))
+         (common-currency (and
+                           (get-option pagename-commodities optname-common-currency)
+                           (get-option pagename-commodities optname-report-commodity)))
+         (has-price? (lambda (commodity)
+                       ;; the following tests whether an amount in
+                       ;; commodity can be converted to
+                       ;; common-currency. if conversion successful,
+                       ;; it will be a non-zero value.  note if we use
+                       ;; API gnc-pricedb-has-prices, we're only
+                       ;; querying the pricedb.  if we use
+                       ;; gnc-pricedb-convert-balance-latest-price, we
+                       ;; can potentially use an intermediate
+                       ;; currency.
+                       (not (zero? (gnc-pricedb-convert-balance-latest-price
+                                    (gnc-pricedb-get-db (gnc-get-current-book))
+                                    (gnc-commodity-get-fraction commodity)
+                                    commodity
+                                    common-currency)))))
+         (price-source (and common-currency
+                            (get-option pagename-commodities optname-price-source)))
+         (report-dates (map (if (eq? report-type 'balsheet)
+                                gnc:time64-end-day-time
+                                gnc:time64-start-day-time)
+                            (if incr
+                                (gnc:make-date-list startdate enddate incr)
+                                (if (eq? report-type 'balsheet)
+                                    (list enddate)
+                                    (list startdate enddate)))))
+         (accounts-balances (map
+                             (lambda (acc)
+                               (cons acc
+                                     (gnc:account-get-balances-at-dates
+                                      acc report-dates)))
+                             accounts))
+         (exchange-fn (and common-currency
+                           (gnc:case-exchange-time-fn
+                            price-source common-currency
+                            (map xaccAccountGetCommodity accounts) enddate
+                            #f #f)))
+         (convert-curr-fn (lambda (monetary col-idx)
+                            (and common-currency
+                                 (not (gnc-commodity-equal
+                                       (gnc:gnc-monetary-commodity monetary)
+                                       common-currency))
+                                 (has-price? (gnc:gnc-monetary-commodity monetary))
+                                 (let* ((date (case price-source
+                                                ((pricedb-latest) (current-time))
+                                                (else
+                                                 (list-ref report-dates
+                                                           (case report-type
+                                                             ((balsheet) col-idx)
+                                                             ((pnl) (1+ col-idx))))))))
+                                   (exchange-fn monetary common-currency date)))))
+         ;; the following function generates an gnc:html-text object
+         ;; to dump exchange rate for a particular column. From the
+         ;; accountlist given, obtain commodities, and convert 1 unit
+         ;; currency into report-currency. If cannot convert due to
+         ;; missing price, say so.
+         (get-exchange-rates-fn
+          (lambda (accounts col-idx)
+            (let ((commodities (delete
+                                common-currency
+                                (delete-duplicates
+                                 (map xaccAccountGetCommodity accounts)
+                                 gnc-commodity-equal)
+                                gnc-commodity-equal))
+                  (cell (gnc:make-html-text)))
+              (for-each
+               (lambda (commodity)
+                 (let ((orig-monetary (gnc:make-gnc-monetary commodity 1)))
+                   (if (has-price? commodity)
+                       (let ((conv-monetary (convert-curr-fn orig-monetary col-idx)))
+                         (gnc:html-text-append!
+                          cell
+                          (format #f "~a ~a"
+                                  (gnc:monetary->string orig-monetary)
+                                  (gnc:monetary->string conv-monetary))))
+                       (gnc:html-text-append!
+                        cell
+                        (string-append
+                         (format #f "~a ~a "
+                                 (gnc:monetary->string orig-monetary)
+                                 (gnc-commodity-get-nice-symbol common-currency))
+                         (_ "missing")))))
+                 (gnc:html-text-append! cell (gnc:html-markup-br)))
+               commodities)
+              (gnc:make-html-table-cell/markup "number-cell" cell))))
+
+         ;; decompose the account list
+         (show-foreign? (get-option pagename-commodities optname-show-foreign))
+         (show-rates? (get-option pagename-commodities optname-show-rates))
+         (split-up-accounts (gnc:decompose-accountlist accounts))
+         (asset-accounts
+          (assoc-ref split-up-accounts ACCT-TYPE-ASSET))
+         (liability-accounts
+          (assoc-ref split-up-accounts ACCT-TYPE-LIABILITY))
+         (income-accounts
+          (assoc-ref split-up-accounts ACCT-TYPE-INCOME))
+         (expense-accounts
+          (assoc-ref split-up-accounts ACCT-TYPE-EXPENSE))
+         (equity-accounts
+          (assoc-ref split-up-accounts ACCT-TYPE-EQUITY))
+         (trading-accounts
+          (assoc-ref split-up-accounts ACCT-TYPE-TRADING))
+         (doc (gnc:make-html-document))
+         (multicol-table-left (gnc:make-html-table))
+         (multicol-table-right (if enable-dual-columns?
+                                   (gnc:make-html-table)
+                                   multicol-table-left))
+         (maxindent (gnc-account-get-tree-depth (gnc-get-current-root-account))))
+
+    (gnc:html-document-set-title!
+     doc (with-output-to-string
+           (lambda ()
+             (display report-title)
+             (display " ")
+             (when (or incr (eq? report-type 'pnl))
+               (display (qof-print-date startdate))
+               (display (_ " to ")))
+             (display (qof-print-date enddate)))))
+
+    (if (eq? (get-option gnc:pagename-general optname-options-summary) 'always)
+        (gnc:html-document-add-object!
+         doc (gnc:html-render-options-changed (gnc:report-options report-obj))))
+
+    (cond
+     ((null? accounts)
+      (gnc:html-document-add-object!
+       doc
+       (gnc:html-make-no-account-warning
+        report-title (gnc:report-id report-obj))))
+
+     ((eq? report-type 'balsheet)
+      (let* ((get-cell-monetary-fn
+              (lambda (account col-idx)
+                (let ((account-balance-list (assoc account accounts-balances)))
+                  (and account-balance-list
+                       (list-ref account-balance-list (1+ col-idx))))))
+             (get-cell-anchor-fn
+              (lambda (account col-idx)
+                (let* ((splits (xaccAccountGetSplitList account))
+                       (split-date (compose xaccTransGetDate xaccSplitGetParent))
+                       (date (list-ref report-dates col-idx))
+                       (valid-split? (lambda (s) (< (split-date s) date)))
+                       (valid-splits (filter valid-split? splits)))
+                  (and (pair? valid-splits)
+                       (gnc:split-anchor-text (last valid-splits))))))
+             (asset-liability-balances
+              (apply map gnc:monetaries-add
+                     (map cdr (filter
+                               (lambda (acc-balances)
+                                 (member (car acc-balances)
+                                         (append asset-accounts liability-accounts)))
+                               accounts-balances))))
+             (income-expense-balances
+              (map gnc:commodity-collector-get-negated
+                   (apply map gnc:monetaries-add
+                          (map cdr
+                               (filter
+                                (lambda (acc-balances)
+                                  (member (car acc-balances)
+                                          (append income-accounts expense-accounts)))
+                                accounts-balances)))))
+             (monetaries->exchanged
+              (lambda (monetaries target-currency price-source date)
+                (let ((exchange-fn (gnc:case-exchange-fn
+                                    price-source target-currency date)))
+                  (apply gnc:monetary+
+                         (map
+                          (lambda (mon)
+                            (exchange-fn mon target-currency))
+                          (monetaries 'format gnc:make-gnc-monetary #f))))))
+             (unrealized-gain-fn
+              (lambda (col-idx)
+                (and common-currency
+                     (let* ((date (case price-source
+                                    ((pricedb-latest) (current-time))
+                                    (else (list-ref report-dates col-idx))))
+                            (asset-liability-balance
+                             (list-ref asset-liability-balances col-idx))
+                            (latest (monetaries->exchanged
+                                     asset-liability-balance
+                                     common-currency price-source date))
+                            (avg-cost (monetaries->exchanged
+                                       asset-liability-balance
+                                       common-currency 'average-cost date)))
+                       (gnc:monetary+ latest (gnc:monetary-neg avg-cost))))))
+             (retained-earnings-fn
+              (lambda (col-idx)
+                (let* ((date (case price-source
+                               ((pricedb-latest) (current-time))
+                               (else (list-ref report-dates col-idx))))
+                       (income-expense-balance
+                        (list-ref income-expense-balances col-idx)))
+                  (map
+                   gnc:monetary-neg
+                   (if (and common-currency
+                            (every has-price?
+                                   (map xaccAccountGetCommodity
+                                        (append income-accounts
+                                                expense-accounts))))
+                       (monetaries->exchanged income-expense-balance
+                                              common-currency price-source date)
+                       (income-expense-balance 'format gnc:make-gnc-monetary #f))))))
+             (chart (and include-chart?
+                         (gnc:make-report-anchor
+                          networth-barchart-uuid report-obj
+                          (list (list "General" "Start Date" (cons 'absolute startdate))
+                                (list "General" "End Date" (cons 'absolute enddate))
+                                (list "General" "Report's currency"
+                                      (or common-currency
+                                          (gnc-default-report-currency)))
+                                (list "General" "Price Source"
+                                      (or price-source 'pricedb-nearest))
+                                (list "Accounts" "Accounts"
+                                      (append asset-accounts liability-accounts))))))
+             (get-col-header-fn (lambda (accounts col-idx)
+                                  (let* ((date (list-ref report-dates col-idx))
+                                         (header (qof-print-date date))
+                                         (cell (gnc:make-html-table-cell/markup
+                                                "total-label-cell" header)))
+                                    (gnc:html-table-cell-set-style!
+                                     cell "total-label-cell"
+                                     'attribute '("style" "text-align:right"))
+                                    cell)))
+             (add-to-table (lambda* (table title accounts #:key
+                                           (get-col-header-fn #f)
+                                           (show-accounts? #t)
+                                           (show-total? #t)
+                                           (show-title? #t)
+                                           (force-total? #f)
+                                           (convert-fn #f)
+                                           (negate-amounts? #f))
+                             (add-multicolumn-acct-table
+                              table title accounts
+                              maxindent get-cell-monetary-fn
+                              (iota (length report-dates))
+                              #:omit-zb-bals? omit-zb-bals?
+                              #:show-zb-accts? show-zb-accts?
+                              #:disable-account-indent? disable-account-indent?
+                              #:negate-amounts? negate-amounts?
+                              #:disable-amount-indent? disable-amount-indent?
+                              #:depth-limit (if get-col-header-fn 0 depth-limit)
+                              #:show-orig-cur? (and (not convert-fn) show-foreign?)
+                              #:show-title? (and show-title? label-sections?)
+                              #:show-accounts? show-accounts?
+                              #:show-total? (or (and total-sections? show-total?)
+                                                force-total?)
+                              #:recursive-bals? recursive-bals?
+                              #:account-anchor? use-links?
+                              #:convert-curr-fn (and common-currency
+                                                     (or convert-fn convert-curr-fn))
+                              #:get-col-header-fn get-col-header-fn
+                              #:get-cell-anchor-fn (and use-amount-links?
+                                                        get-cell-anchor-fn)
+                              ))))
+
+        (when incr
+          (add-to-table multicol-table-left (_ "Date") '()
+                        #:get-col-header-fn get-col-header-fn
+                        #:show-accounts? #f
+                        #:show-total? #f)
+          (if enable-dual-columns?
+              (add-to-table multicol-table-right (_ "Date") '()
+                            #:get-col-header-fn get-col-header-fn
+                            #:show-accounts? #f
+                            #:show-total? #f)))
+
+        (unless (null? asset-accounts)
+          (add-to-table multicol-table-left (_ "Asset") asset-accounts))
+
+        (unless (null? liability-accounts)
+          (add-to-table multicol-table-right (_ "Liability") liability-accounts
+                        #:negate-amounts? #t))
+
+        (add-to-table
+         multicol-table-right (_ "Equity")
+         (append equity-accounts
+                 (list
+                  (vector "Unrealized Gains"
+                          unrealized-gain-fn)
+                  (vector "Retained Earnings"
+                          retained-earnings-fn)))
+         #:negate-amounts? #t)
+
+        (if (and common-currency show-rates?)
+            (add-to-table multicol-table-right (_ "Exchange Rates")
+                          (append asset-accounts liability-accounts)
+                          #:get-col-header-fn get-exchange-rates-fn
+                          #:show-accounts? #f
+                          #:show-total? #f))
+
+        (if include-chart?
+            (gnc:html-document-add-object!
+             doc
+             (gnc:make-html-text
+              (gnc:html-markup-anchor chart "Barchart"))))))
+
+     ((eq? report-type 'pnl)
+      (let* ((closing-str (get-option pagename-entries optname-closing-pattern))
+             (closing-cased (get-option pagename-entries optname-closing-casing))
+             (closing-regexp (get-option pagename-entries optname-closing-regexp))
+             (include-overall-period? (get-option gnc:pagename-general
+                                                  optname-include-overall-period))
+             (col-idx->datepair (lambda (idx)
+                                  (if (eq? idx 'overall-period)
+                                      (cons (car report-dates) (last report-dates))
+                                      (cons (list-ref report-dates idx)
+                                            (gnc:time64-end-day-time
+                                             (decdate
+                                              (list-ref report-dates (1+ idx))
+                                              DayDelta))))))
+             (col-idx->monetarypair (lambda (balancelist idx)
+                                      (if (eq? idx 'overall-period)
+                                          (cons (car balancelist) (last balancelist))
+                                          (cons (list-ref balancelist idx)
+                                                (list-ref balancelist (1+ idx))))))
+             (closing-entries (let ((query (qof-query-create-for-splits)))
+                                (qof-query-set-book query (gnc-get-current-book))
+                                (xaccQueryAddAccountMatch
+                                 query (append income-accounts expense-accounts)
+                                 QOF-GUID-MATCH-ANY QOF-QUERY-AND)
+                                (if (and closing-str (not (string-null? closing-str)))
+                                    (xaccQueryAddDescriptionMatch
+                                     query closing-str closing-cased closing-regexp
+                                     QOF-COMPARE-CONTAINS QOF-QUERY-AND))
+                                (xaccQueryAddClosingTransMatch query #t QOF-QUERY-OR)
+                                (let ((splits (qof-query-run query)))
+                                  (qof-query-destroy query)
+                                  splits)))
+             ;; this function will query the above closing-entries for
+             ;; splits within the date range, and produce the total
+             ;; amount for these closing entries
+             (closing-adjustment
+              (lambda (account col-idx)
+                (define datepair (col-idx->datepair col-idx))
+                (define (include-split? split)
+                  (and (equal? (xaccSplitGetAccount split) account)
+                       (<= (car datepair)
+                           (xaccTransGetDate (xaccSplitGetParent split))
+                           (cdr datepair))))
+                (let ((account-closing-splits (filter include-split? closing-entries)))
+                  (gnc:make-gnc-monetary
+                   (xaccAccountGetCommodity account)
+                   (apply + (map xaccSplitGetAmount account-closing-splits))))))
+             (get-cell-monetary-fn
+              (lambda (account col-idx)
+                (let ((account-balance-list (assoc account accounts-balances)))
+                  (and account-balance-list
+                       (let ((monetarypair (col-idx->monetarypair
+                                            (cdr account-balance-list)
+                                            col-idx)))
+                         (monetary-less
+                          (cdr monetarypair)
+                          (car monetarypair)
+                          (closing-adjustment account col-idx)))))))
+             (get-cell-anchor-fn (lambda (account col-idx)
+                                   (define datepair (col-idx->datepair col-idx))
+                                   (gnc:make-report-anchor
+                                    trep-uuid report-obj
+                                    (list
+                                     (list "General" "Start Date"
+                                           (cons 'absolute (car datepair)))
+                                     (list "General" "End Date"
+                                           (cons 'absolute (cdr datepair)))
+                                     (list "Display" "Amount" 'double)
+                                     (list "Accounts" "Accounts"
+                                           (list account))))))
+             (chart (and include-chart?
+                         (gnc:make-report-anchor
+                          pnl-barchart-uuid report-obj
+                          (list (list "General" "Start Date"
+                                      (cons 'absolute startdate))
+                                (list "General" "End Date"
+                                      (cons 'absolute enddate))
+                                (list "General" "Report's currency"
+                                      (or common-currency
+                                          (gnc-default-report-currency)))
+                                (list "General" "Price Source"
+                                      (or price-source 'pricedb-nearest))
+                                (list "Accounts" "Accounts"
+                                      (append income-accounts expense-accounts))))))
+             (get-col-header-fn
+              (lambda (accounts col-idx)
+                (let* ((datepair (col-idx->datepair col-idx))
+                       (header (gnc:make-html-text
+                                (qof-print-date (car datepair))
+                                (gnc:html-markup-br)
+                                (_ " to ")
+                                (qof-print-date (cdr datepair))))
+                       (cell (gnc:make-html-table-cell/markup
+                              "total-label-cell" header)))
+                  (gnc:html-table-cell-set-style!
+                   cell "total-label-cell"
+                   'attribute '("style" "text-align:right"))
+                  cell)))
+             (add-to-table (lambda* (table title accounts #:key
+                                           (get-col-header-fn #f)
+                                           (show-accounts? #t)
+                                           (show-total? #t)
+                                           (force-total? #f)
+                                           (negate-amounts? #f))
+                             (add-multicolumn-acct-table
+                              table title accounts
+                              maxindent get-cell-monetary-fn
+                              (append
+                               (iota (1- (length report-dates)))
+                               (if (and include-overall-period?
+                                        (> (length report-dates) 2))
+                                   '(overall-period)
+                                   '()))
+                              #:omit-zb-bals? omit-zb-bals?
+                              #:show-zb-accts? show-zb-accts?
+                              #:disable-account-indent? disable-account-indent?
+                              #:negate-amounts? negate-amounts?
+                              #:disable-amount-indent? disable-amount-indent?
+                              #:depth-limit (if get-col-header-fn 0 depth-limit)
+                              #:show-orig-cur? show-foreign?
+                              #:show-title? label-sections?
+                              #:show-accounts? show-accounts?
+                              #:show-total? (or (and total-sections? show-total?)
+                                                force-total?)
+                              #:recursive-bals? recursive-bals?
+                              #:account-anchor? use-links?
+                              #:convert-curr-fn (and common-currency convert-curr-fn)
+                              #:get-col-header-fn get-col-header-fn
+                              #:get-cell-anchor-fn (and use-amount-links?
+                                                        get-cell-anchor-fn)))))
+
+        (when incr
+          (add-to-table multicol-table-left (_ "Period") '()
+                        #:get-col-header-fn get-col-header-fn
+                        #:show-accounts? #f
+                        #:show-total? #f)
+          (if enable-dual-columns?
+              (add-to-table multicol-table-right (_ "Period") '()
+                            #:get-col-header-fn get-col-header-fn
+                            #:show-accounts? #f
+                            #:show-total? #f)))
+
+        (unless (null? income-accounts)
+          (add-to-table multicol-table-left (_ "Income") income-accounts
+                        #:negate-amounts? #t))
+
+        (unless (null? expense-accounts)
+          (add-to-table multicol-table-right (_ "Expense") expense-accounts))
+
+        (unless (or (null? income-accounts)
+                    (null? expense-accounts))
+          (add-to-table multicol-table-left (_ "Net Income")
+                        (append income-accounts expense-accounts)
+                        #:show-accounts? #f
+                        #:negate-amounts? #t
+                        #:force-total? #t))
+
+        (if (and common-currency show-rates?)
+            (add-to-table multicol-table-left (_ "Exchange Rates")
+                          (append income-accounts expense-accounts)
+                          #:get-col-header-fn get-exchange-rates-fn
+                          #:show-accounts? #f
+                          #:show-total? #f))
+
+        (if include-chart?
+            (gnc:html-document-add-object!
+             doc
+             (gnc:make-html-text
+              (gnc:html-markup-anchor chart "Barchart")))))))
+
+    (let ((multicol-table (if enable-dual-columns?
+                              (gnc:make-html-table)
+                              multicol-table-left)))
+      (when enable-dual-columns?
+        (gnc:html-table-append-row! multicol-table
+                                    (list multicol-table-left multicol-table-right)))
+      (gnc:html-document-add-object!
+       doc multicol-table))
+
+    (gnc:html-document-add-object!
+     doc FOOTER-TEXT)
+
+    (gnc:report-finished)
+    ;; (gnc:html-document-set-style-text!
+    ;;  doc " table, td{ border-width: 1px; border-style:solid; border-color: lightgray; border-collapse: collapse}")
+    doc))
+
+(define balsheet-reportname (_ "Balance Sheet (Multicolumn)"))
+(define pnl-reportname (_ "Income Statement (Multicolumn)"))
+
+(gnc:define-report
+ 'version 1
+ 'name balsheet-reportname
+ 'report-guid "065d5d5a77ba11e8b31e83ada73c5eea"
+ 'menu-path (list gnc:menuname-experimental)
+ 'options-generator (lambda () (multicol-report-options-generator 'balsheet))
+ 'renderer (lambda (rpt) (multicol-report-renderer rpt 'balsheet)))
+
+(gnc:define-report
+ 'version 1
+ 'name pnl-reportname
+ 'report-guid "0e94fd0277ba11e8825d43e27232c9d4"
+ 'menu-path (list gnc:menuname-experimental)
+ 'options-generator (lambda () (multicol-report-options-generator 'pnl))
+ 'renderer (lambda (rpt) (multicol-report-renderer rpt 'pnl)))
+
+;; END
diff --git a/po/POTFILES.in b/po/POTFILES.in
index a4cabf716..a8d79d06b 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -469,6 +469,7 @@ gnucash/report/standard-reports/advanced-portfolio.scm
 gnucash/report/standard-reports/average-balance.scm
 gnucash/report/standard-reports/balance-forecast.scm
 gnucash/report/standard-reports/balance-sheet.scm
+gnucash/report/standard-reports/balsheet-pnl.scm
 gnucash/report/standard-reports/budget-balance-sheet.scm
 gnucash/report/standard-reports/budget-barchart.scm
 gnucash/report/standard-reports/budget-flow.scm

commit 101f8402555154951a1ab59905458891892e0473
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Fri May 10 19:31:52 2019 +0800

    [taxtxf] compact get-acct-tax-info

diff --git a/gnucash/report/locale-specific/us/taxtxf.scm b/gnucash/report/locale-specific/us/taxtxf.scm
index 89ec7569f..2a61b242b 100644
--- a/gnucash/report/locale-specific/us/taxtxf.scm
+++ b/gnucash/report/locale-specific/us/taxtxf.scm
@@ -298,94 +298,34 @@
        (string->symbol (if (string-null? code) "N000" code))))
 
 (define (get-acct-txf-info info-type acct-type code)
-  (let ((tax-entity-type (gnc-get-current-book-tax-type)))
-    (cond
-      ((= acct-type ACCT-TYPE-INCOME)
-       (cond
-         ((eqv? info-type 'form)
-           (gnc:txf-get-form txf-income-categories code tax-entity-type))
-         ((eqv? info-type 'desc)
-           (gnc:txf-get-description txf-income-categories code tax-entity-type))
-         ((eqv? info-type 'pns)
-           (gnc:txf-get-payer-name-source txf-income-categories code
-                                                               tax-entity-type))
-         ((eqv? info-type 'format)
-           (gnc:txf-get-format txf-income-categories code tax-entity-type))
-         ((eqv? info-type 'multiple)
-           (gnc:txf-get-multiple txf-income-categories code tax-entity-type))
-         ((eqv? info-type 'cat-key)
-           (gnc:txf-get-category-key txf-income-categories code tax-entity-type))
-         ((eqv? info-type 'line)
-           (gnc:txf-get-line-data txf-income-categories code tax-entity-type))
-         ((eqv? info-type 'last-yr)
-           (gnc:txf-get-last-year txf-income-categories code tax-entity-type))
-         (else #f)))
-      ((= acct-type ACCT-TYPE-EXPENSE)
-       (cond
-         ((eqv? info-type 'form)
-           (gnc:txf-get-form txf-expense-categories code tax-entity-type))
-         ((eqv? info-type 'desc)
-           (gnc:txf-get-description txf-expense-categories code tax-entity-type))
-         ((eqv? info-type 'pns)
-           (gnc:txf-get-payer-name-source txf-expense-categories code
-                                                               tax-entity-type))
-         ((eqv? info-type 'format)
-           (gnc:txf-get-format txf-expense-categories code tax-entity-type))
-         ((eqv? info-type 'multiple)
-           (gnc:txf-get-multiple txf-expense-categories code tax-entity-type))
-         ((eqv? info-type 'cat-key)
-           (gnc:txf-get-category-key txf-expense-categories code tax-entity-type))
-         ((eqv? info-type 'line)
-           (gnc:txf-get-line-data txf-expense-categories code tax-entity-type))
-         ((eqv? info-type 'last-yr)
-           (gnc:txf-get-last-year txf-expense-categories code tax-entity-type))
-         (else #f)))
-      ((or (= acct-type ACCT-TYPE-BANK) (= acct-type ACCT-TYPE-CASH)
-           (= acct-type ACCT-TYPE-ASSET) (= acct-type ACCT-TYPE-STOCK)
-           (= acct-type ACCT-TYPE-MUTUAL) (= acct-type ACCT-TYPE-RECEIVABLE))
-       (cond
-         ((eqv? info-type 'form)
-           (gnc:txf-get-form txf-asset-categories code tax-entity-type))
-         ((eqv? info-type 'desc)
-           (gnc:txf-get-description txf-asset-categories code tax-entity-type))
-         ((eqv? info-type 'pns)
-           (gnc:txf-get-payer-name-source txf-asset-categories code
-                                                               tax-entity-type))
-         ((eqv? info-type 'format)
-           (gnc:txf-get-format txf-asset-categories code tax-entity-type))
-         ((eqv? info-type 'multiple)
-           (gnc:txf-get-multiple txf-asset-categories code tax-entity-type))
-         ((eqv? info-type 'cat-key)
-           (gnc:txf-get-category-key txf-asset-categories code tax-entity-type))
-         ((eqv? info-type 'line)
-           (gnc:txf-get-line-data txf-asset-categories code tax-entity-type))
-         ((eqv? info-type 'last-yr)
-           (gnc:txf-get-last-year txf-asset-categories code tax-entity-type))
-         (else #f)))
-      ((or (= acct-type ACCT-TYPE-CREDIT) (= acct-type ACCT-TYPE-LIABILITY)
-           (= acct-type ACCT-TYPE-EQUITY) (= acct-type ACCT-TYPE-PAYABLE))
-       (cond
-         ((eqv? info-type 'form)
-           (gnc:txf-get-form txf-liab-eq-categories code tax-entity-type))
-         ((eqv? info-type 'desc)
-           (gnc:txf-get-description txf-liab-eq-categories code tax-entity-type))
-         ((eqv? info-type 'pns)
-           (gnc:txf-get-payer-name-source txf-liab-eq-categories code
-                                                               tax-entity-type))
-         ((eqv? info-type 'format)
-           (gnc:txf-get-format txf-liab-eq-categories code tax-entity-type))
-         ((eqv? info-type 'multiple)
-           (gnc:txf-get-multiple txf-liab-eq-categories code tax-entity-type))
-         ((eqv? info-type 'cat-key)
-           (gnc:txf-get-category-key txf-liab-eq-categories code tax-entity-type))
-         ((eqv? info-type 'line)
-           (gnc:txf-get-line-data txf-liab-eq-categories code tax-entity-type))
-         ((eqv? info-type 'last-yr)
-           (gnc:txf-get-last-year txf-liab-eq-categories code tax-entity-type))
-         (else #f)))
-      (else #f))
-  )
-)
+  (let ((categories (assv-ref
+                     (list (cons ACCT-TYPE-INCOME txf-income-categories)
+                           (cons ACCT-TYPE-EXPENSE txf-expense-categories)
+                           (cons ACCT-TYPE-BANK txf-asset-categories)
+                           (cons ACCT-TYPE-CASH txf-asset-categories)
+                           (cons ACCT-TYPE-ASSET txf-asset-categories)
+                           (cons ACCT-TYPE-STOCK txf-asset-categories)
+                           (cons ACCT-TYPE-MUTUAL txf-asset-categories)
+                           (cons ACCT-TYPE-RECEIVABLE txf-asset-categories)
+                           (cons ACCT-TYPE-CREDIT txf-liab-eq-categories)
+                           (cons ACCT-TYPE-LIABILITY txf-liab-eq-categories)
+                           (cons ACCT-TYPE-EQUITY txf-liab-eq-categories)
+                           (cons ACCT-TYPE-PAYABLE txf-liab-eq-categories))
+                     acct-type))
+        (get-info-fn
+         (case info-type
+           ((form) gnc:txf-get-form)
+           ((desc) gnc:txf-get-description)
+           ((pns) gnc:txf-get-payer-name-sourcecategories)
+           ((format) gnc:txf-get-formatcategories)
+           ((multiple) gnc:txf-get-multiplecategories)
+           ((cat-key) gnc:txf-get-category-keycategories)
+           ((line) gnc:txf-get-line-datacategories)
+           ((last-yr) gnc:txf-get-last-yearcategories)
+           (else #f))))
+    (and categories
+         get-info-fn
+         (get-info-fn categories code (gnc-get-current-book-tax-type)))))
 
 (define (gnc:account-get-txf-payer-source account)
   (let ((pns (xaccAccountGetTaxUSPayerNameSource account)))

commit 7345a4adfa402af75f15167baf26317ef72fbdcc
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Fri May 10 12:07:45 2019 +0100

    Change dialog-job to use GtkGrids

diff --git a/gnucash/gtkbuilder/dialog-job.glade b/gnucash/gtkbuilder/dialog-job.glade
index 9326aa68d..b563fba4f 100644
--- a/gnucash/gtkbuilder/dialog-job.glade
+++ b/gnucash/gtkbuilder/dialog-job.glade
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.20.0 -->
+<!-- Generated with glade 3.22.1 -->
 <interface>
   <requires lib="gtk+" version="3.10"/>
   <object class="GtkDialog" id="job_dialog">
@@ -8,6 +8,9 @@
     <property name="resizable">False</property>
     <property name="type_hint">dialog</property>
     <signal name="destroy" handler="gnc_job_window_destroy_cb" swapped="no"/>
+    <child>
+      <placeholder/>
+    </child>
     <child internal-child="vbox">
       <object class="GtkBox" id="dialog-vbox3">
         <property name="visible">True</property>
@@ -87,99 +90,70 @@
                 <property name="border_width">3</property>
                 <property name="label_xalign">0</property>
                 <child>
-                  <object class="GtkBox" id="hbox8">
+                  <object class="GtkGrid">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="border_width">3</property>
+                    <property name="border_width">6</property>
+                    <property name="row_spacing">6</property>
+                    <property name="column_spacing">6</property>
                     <child>
-                      <object class="GtkBox" id="vbox4">
+                      <object class="GtkLabel" id="label1">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
-                        <property name="border_width">3</property>
-                        <property name="orientation">vertical</property>
-                        <property name="homogeneous">True</property>
-                        <child>
-                          <object class="GtkLabel" id="label1">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <property name="halign">end</property>
-                            <property name="label" translatable="yes">Job Number</property>
-                            <property name="justify">right</property>
-                          </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                            <property name="position">0</property>
-                          </packing>
-                        </child>
-                        <child>
-                          <object class="GtkLabel" id="label3">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <property name="halign">end</property>
-                            <property name="label" translatable="yes">Job Name</property>
-                            <property name="justify">right</property>
-                          </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                            <property name="position">1</property>
-                          </packing>
-                        </child>
+                        <property name="halign">end</property>
+                        <property name="label" translatable="yes">Job Number</property>
+                        <property name="justify">right</property>
                       </object>
                       <packing>
-                        <property name="expand">False</property>
-                        <property name="fill">True</property>
-                        <property name="position">0</property>
+                        <property name="left_attach">0</property>
+                        <property name="top_attach">0</property>
                       </packing>
                     </child>
                     <child>
-                      <object class="GtkBox" id="vbox12">
+                      <object class="GtkLabel" id="label3">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
-                        <property name="border_width">3</property>
-                        <property name="orientation">vertical</property>
-                        <property name="homogeneous">True</property>
-                        <child>
-                          <object class="GtkEntry" id="id_entry">
-                            <property name="visible">True</property>
-                            <property name="can_focus">True</property>
-                            <property name="has_tooltip">True</property>
-                            <property name="tooltip_markup">The job ID number. If left blank a reasonable number will be chosen for you</property>
-                            <property name="tooltip_text" translatable="yes">The job ID number. If left blank a reasonable number will be chosen for you</property>
-                            <property name="invisible_char">●</property>
-                            <property name="activates_default">True</property>
-                            <property name="primary_icon_activatable">False</property>
-                            <property name="secondary_icon_activatable">False</property>
-                            <signal name="changed" handler="gnc_job_name_changed_cb" swapped="no"/>
-                          </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                            <property name="position">0</property>
-                          </packing>
-                        </child>
-                        <child>
-                          <object class="GtkEntry" id="name_entry">
-                            <property name="visible">True</property>
-                            <property name="can_focus">True</property>
-                            <property name="invisible_char">●</property>
-                            <property name="activates_default">True</property>
-                            <property name="primary_icon_activatable">False</property>
-                            <property name="secondary_icon_activatable">False</property>
-                            <signal name="changed" handler="gnc_job_name_changed_cb" swapped="no"/>
-                          </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                            <property name="position">1</property>
-                          </packing>
-                        </child>
+                        <property name="halign">end</property>
+                        <property name="label" translatable="yes">Job Name</property>
+                        <property name="justify">right</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">0</property>
+                        <property name="top_attach">1</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkEntry" id="id_entry">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="has_tooltip">True</property>
+                        <property name="tooltip_markup">The job ID number. If left blank a reasonable number will be chosen for you</property>
+                        <property name="tooltip_text" translatable="yes">The job ID number. If left blank a reasonable number will be chosen for you</property>
+                        <property name="hexpand">True</property>
+                        <property name="invisible_char">●</property>
+                        <property name="activates_default">True</property>
+                        <property name="primary_icon_activatable">False</property>
+                        <property name="secondary_icon_activatable">False</property>
+                        <signal name="changed" handler="gnc_job_name_changed_cb" swapped="no"/>
+                      </object>
+                      <packing>
+                        <property name="left_attach">1</property>
+                        <property name="top_attach">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkEntry" id="name_entry">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="invisible_char">●</property>
+                        <property name="activates_default">True</property>
+                        <property name="primary_icon_activatable">False</property>
+                        <property name="secondary_icon_activatable">False</property>
+                        <signal name="changed" handler="gnc_job_name_changed_cb" swapped="no"/>
                       </object>
                       <packing>
-                        <property name="expand">True</property>
-                        <property name="fill">True</property>
-                        <property name="position">1</property>
+                        <property name="left_attach">1</property>
+                        <property name="top_attach">1</property>
                       </packing>
                     </child>
                   </object>
@@ -205,120 +179,89 @@
                 <property name="border_width">3</property>
                 <property name="label_xalign">0</property>
                 <child>
-                  <object class="GtkBox" id="hbox9">
+                  <object class="GtkGrid">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="border_width">3</property>
+                    <property name="border_width">6</property>
+                    <property name="row_spacing">6</property>
+                    <property name="column_spacing">6</property>
                     <child>
-                      <object class="GtkBox" id="vbox5">
+                      <object class="GtkLabel" id="owner_label">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
-                        <property name="border_width">3</property>
-                        <property name="orientation">vertical</property>
-                        <property name="homogeneous">True</property>
-                        <child>
-                          <object class="GtkLabel" id="owner_label">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <property name="halign">end</property>
-                            <property name="label">(owner)</property>
-                            <property name="justify">right</property>
-                          </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                            <property name="position">0</property>
-                          </packing>
-                        </child>
-                        <child>
-                          <object class="GtkLabel" id="label4">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <property name="halign">end</property>
-                            <property name="label" translatable="yes">Billing ID</property>
-                            <property name="justify">right</property>
-                          </object>
-                          <packing>
-                            <property name="expand">True</property>
-                            <property name="fill">True</property>
-                            <property name="position">1</property>
-                          </packing>
-                        </child>
-                        <child>
-                          <object class="GtkLabel" id="labelrate">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <property name="halign">end</property>
-                            <property name="label" translatable="yes">Rate</property>
-                            <property name="justify">right</property>
-                          </object>
-                          <packing>
-                            <property name="expand">True</property>
-                            <property name="fill">True</property>
-                            <property name="position">1</property>
-                          </packing>
-                        </child>
+                        <property name="halign">end</property>
+                        <property name="label">(owner)</property>
+                        <property name="justify">right</property>
                       </object>
                       <packing>
-                        <property name="expand">False</property>
-                        <property name="fill">True</property>
-                        <property name="position">0</property>
+                        <property name="left_attach">0</property>
+                        <property name="top_attach">0</property>
                       </packing>
                     </child>
                     <child>
-                      <object class="GtkBox" id="vbox13">
+                      <object class="GtkLabel" id="labelrate">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="halign">end</property>
+                        <property name="label" translatable="yes">Rate</property>
+                        <property name="justify">right</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">0</property>
+                        <property name="top_attach">1</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="label4">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="halign">end</property>
+                        <property name="label" translatable="yes">Billing ID</property>
+                        <property name="justify">right</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">0</property>
+                        <property name="top_attach">2</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkBox" id="customer_hbox">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
-                        <property name="border_width">3</property>
-                        <property name="orientation">vertical</property>
-                        <property name="homogeneous">True</property>
-                        <child>
-                          <object class="GtkBox" id="customer_hbox">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <child>
-                              <placeholder/>
-                            </child>
-                          </object>
-                          <packing>
-                            <property name="expand">True</property>
-                            <property name="fill">True</property>
-                            <property name="position">0</property>
-                          </packing>
-                        </child>
                         <child>
-                          <object class="GtkEntry" id="desc_entry">
-                            <property name="visible">True</property>
-                            <property name="can_focus">True</property>
-                            <property name="invisible_char">●</property>
-                            <property name="primary_icon_activatable">False</property>
-                            <property name="secondary_icon_activatable">False</property>
-                          </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                            <property name="position">1</property>
-                          </packing>
+                          <placeholder/>
                         </child>
+                      </object>
+                      <packing>
+                        <property name="left_attach">1</property>
+                        <property name="top_attach">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkBox" id="rate_entry">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
                         <child>
-                          <object class="GtkBox" id="rate_entry">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <child>
-                              <placeholder/>
-                            </child>
-                          </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">True</property>
-                            <property name="position">1</property>
-                          </packing>
+                          <placeholder/>
                         </child>
                       </object>
                       <packing>
-                        <property name="expand">True</property>
-                        <property name="fill">True</property>
-                        <property name="position">1</property>
+                        <property name="left_attach">1</property>
+                        <property name="top_attach">1</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkEntry" id="desc_entry">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="hexpand">True</property>
+                        <property name="invisible_char">●</property>
+                        <property name="primary_icon_activatable">False</property>
+                        <property name="secondary_icon_activatable">False</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">1</property>
+                        <property name="top_attach">2</property>
                       </packing>
                     </child>
                   </object>

commit 1a40caee9d1c9ed57cebb5754825860c70d33099
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Fri May 10 12:07:05 2019 +0100

    Change dialog-order to use GtkGrids

diff --git a/gnucash/gnome/dialog-order.c b/gnucash/gnome/dialog-order.c
index 0c9bfbe00..10a34c442 100644
--- a/gnucash/gnome/dialog-order.c
+++ b/gnucash/gnome/dialog-order.c
@@ -90,8 +90,6 @@ struct _order_window
     GtkWidget *	active_check;
 
     GtkWidget * cd_label;
-    GtkWidget * hide1;
-    GtkWidget * hide2;
     GtkWidget * close_order_button;
 
     GtkWidget *	owner_box;
@@ -512,8 +510,6 @@ gnc_order_update_window (OrderWindow *ow)
     {
         gtk_widget_hide (ow->closed_date);
         gtk_widget_hide (ow->cd_label);
-        gtk_widget_hide (ow->hide1);
-        gtk_widget_hide (ow->hide2);
     }
 
     if (ow->dialog_type == VIEW_ORDER)
@@ -606,8 +602,6 @@ gnc_order_new_window (GtkWindow *parent, QofBook *bookp, OrderDialogType type,
     ow->owner_label = GTK_WIDGET(gtk_builder_get_object (builder, "owner_label"));
 
     ow->cd_label = GTK_WIDGET(gtk_builder_get_object (builder, "cd_label"));
-    ow->hide1 = GTK_WIDGET(gtk_builder_get_object (builder, "hide1"));
-    ow->hide2 = GTK_WIDGET(gtk_builder_get_object (builder, "hide2"));
     ow->close_order_button = GTK_WIDGET(gtk_builder_get_object (builder, "close_order_button"));
 
 
diff --git a/gnucash/gtkbuilder/dialog-order.glade b/gnucash/gtkbuilder/dialog-order.glade
index e9707a0f9..09e36238f 100644
--- a/gnucash/gtkbuilder/dialog-order.glade
+++ b/gnucash/gtkbuilder/dialog-order.glade
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.20.0 -->
+<!-- Generated with glade 3.22.1 -->
 <interface>
   <requires lib="gtk+" version="3.10"/>
   <object class="GtkTextBuffer" id="notes_buffer"/>
@@ -9,6 +9,9 @@
     <property name="default_width">950</property>
     <property name="type_hint">dialog</property>
     <signal name="destroy" handler="gnc_order_window_destroy_cb" swapped="no"/>
+    <child>
+      <placeholder/>
+    </child>
     <child internal-child="vbox">
       <object class="GtkBox" id="dialog-vbox4">
         <property name="visible">True</property>
@@ -107,150 +110,116 @@
                     <property name="can_focus">False</property>
                     <property name="label_xalign">0</property>
                     <child>
-                      <object class="GtkBox" id="hbox2">
+                      <object class="GtkGrid">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
-                        <property name="border_width">3</property>
+                        <property name="border_width">6</property>
+                        <property name="row_spacing">6</property>
+                        <property name="column_spacing">6</property>
                         <child>
-                          <object class="GtkBox" id="vbox2">
+                          <object class="GtkLabel" id="label1">
                             <property name="visible">True</property>
                             <property name="can_focus">False</property>
-                            <property name="border_width">2</property>
-                            <property name="orientation">vertical</property>
-                            <property name="homogeneous">True</property>
-                            <child>
-                              <object class="GtkLabel" id="label1">
-                                <property name="visible">True</property>
-                                <property name="can_focus">False</property>
-                                <property name="halign">end</property>
-                                <property name="label" translatable="yes">Order ID</property>
-                                <property name="justify">right</property>
-                              </object>
-                              <packing>
-                                <property name="expand">False</property>
-                                <property name="fill">False</property>
-                                <property name="position">0</property>
-                              </packing>
-                            </child>
-                            <child>
-                              <object class="GtkLabel" id="label3">
-                                <property name="visible">True</property>
-                                <property name="can_focus">False</property>
-                                <property name="halign">end</property>
-                                <property name="label" translatable="yes">Date Opened</property>
-                                <property name="justify">right</property>
-                              </object>
-                              <packing>
-                                <property name="expand">False</property>
-                                <property name="fill">False</property>
-                                <property name="position">1</property>
-                              </packing>
-                            </child>
-                            <child>
-                              <object class="GtkLabel" id="cd_label">
-                                <property name="visible">True</property>
-                                <property name="can_focus">False</property>
-                                <property name="halign">end</property>
-                                <property name="label" translatable="yes">Date Closed</property>
-                                <property name="justify">right</property>
-                              </object>
-                              <packing>
-                                <property name="expand">False</property>
-                                <property name="fill">False</property>
-                                <property name="position">2</property>
-                              </packing>
-                            </child>
-                            <child>
-                              <object class="GtkLabel" id="label8">
-                                <property name="visible">True</property>
-                                <property name="can_focus">False</property>
-                                <property name="justify">center</property>
-                              </object>
-                              <packing>
-                                <property name="expand">False</property>
-                                <property name="fill">False</property>
-                                <property name="position">3</property>
-                              </packing>
-                            </child>
+                            <property name="halign">end</property>
+                            <property name="label" translatable="yes">Order ID</property>
+                            <property name="justify">right</property>
                           </object>
                           <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">True</property>
-                            <property name="position">0</property>
+                            <property name="left_attach">0</property>
+                            <property name="top_attach">0</property>
                           </packing>
                         </child>
                         <child>
-                          <object class="GtkBox" id="vbox3">
+                          <object class="GtkLabel" id="label3">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="halign">end</property>
+                            <property name="label" translatable="yes">Date Opened</property>
+                            <property name="justify">right</property>
+                          </object>
+                          <packing>
+                            <property name="left_attach">0</property>
+                            <property name="top_attach">1</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkLabel" id="cd_label">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="halign">end</property>
+                            <property name="label" translatable="yes">Date Closed</property>
+                            <property name="justify">right</property>
+                          </object>
+                          <packing>
+                            <property name="left_attach">0</property>
+                            <property name="top_attach">2</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkEntry" id="id_entry">
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="editable">False</property>
+                            <property name="invisible_char">●</property>
+                            <property name="activates_default">True</property>
+                            <property name="primary_icon_activatable">False</property>
+                            <property name="secondary_icon_activatable">False</property>
+                          </object>
+                          <packing>
+                            <property name="left_attach">1</property>
+                            <property name="top_attach">0</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkBox" id="opened_date_hbox">
                             <property name="visible">True</property>
                             <property name="can_focus">False</property>
-                            <property name="border_width">3</property>
-                            <property name="orientation">vertical</property>
-                            <property name="homogeneous">True</property>
-                            <child>
-                              <object class="GtkEntry" id="id_entry">
-                                <property name="visible">True</property>
-                                <property name="can_focus">True</property>
-                                <property name="editable">False</property>
-                                <property name="invisible_char">●</property>
-                                <property name="activates_default">True</property>
-                                <property name="primary_icon_activatable">False</property>
-                                <property name="secondary_icon_activatable">False</property>
-                              </object>
-                              <packing>
-                                <property name="expand">False</property>
-                                <property name="fill">False</property>
-                                <property name="position">0</property>
-                              </packing>
-                            </child>
-                            <child>
-                              <object class="GtkBox" id="opened_date_hbox">
-                                <property name="visible">True</property>
-                                <property name="can_focus">False</property>
-                                <child>
-                                  <placeholder/>
-                                </child>
-                              </object>
-                              <packing>
-                                <property name="expand">True</property>
-                                <property name="fill">True</property>
-                                <property name="position">1</property>
-                              </packing>
-                            </child>
                             <child>
-                              <object class="GtkBox" id="closed_date_hbox">
-                                <property name="visible">True</property>
-                                <property name="can_focus">False</property>
-                                <child>
-                                  <placeholder/>
-                                </child>
-                              </object>
-                              <packing>
-                                <property name="expand">True</property>
-                                <property name="fill">True</property>
-                                <property name="position">2</property>
-                              </packing>
+                              <placeholder/>
                             </child>
+                          </object>
+                          <packing>
+                            <property name="left_attach">1</property>
+                            <property name="top_attach">1</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkBox" id="closed_date_hbox">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
                             <child>
-                              <object class="GtkCheckButton" id="active_check">
-                                <property name="label" translatable="yes">Active</property>
-                                <property name="visible">True</property>
-                                <property name="can_focus">True</property>
-                                <property name="receives_default">False</property>
-                                <property name="halign">start</property>
-                                <property name="use_underline">True</property>
-                                <property name="draw_indicator">True</property>
-                              </object>
-                              <packing>
-                                <property name="expand">False</property>
-                                <property name="fill">False</property>
-                                <property name="position">3</property>
-                              </packing>
+                              <placeholder/>
                             </child>
                           </object>
                           <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                            <property name="position">1</property>
+                            <property name="left_attach">1</property>
+                            <property name="top_attach">2</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkCheckButton" id="active_check">
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="receives_default">False</property>
+                            <property name="halign">start</property>
+                            <property name="use_underline">True</property>
+                            <property name="draw_indicator">True</property>
+                          </object>
+                          <packing>
+                            <property name="left_attach">1</property>
+                            <property name="top_attach">3</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkLabel">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="halign">end</property>
+                            <property name="label" translatable="yes">Active</property>
+                          </object>
+                          <packing>
+                            <property name="left_attach">0</property>
+                            <property name="top_attach">3</property>
                           </packing>
                         </child>
                       </object>
@@ -276,139 +245,62 @@
                     <property name="border_width">3</property>
                     <property name="label_xalign">0</property>
                     <child>
-                      <object class="GtkBox" id="hbox3">
+                      <object class="GtkGrid">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
+                        <property name="border_width">6</property>
+                        <property name="row_spacing">6</property>
+                        <property name="column_spacing">6</property>
                         <child>
-                          <object class="GtkBox" id="vbox8">
+                          <object class="GtkLabel" id="owner_label">
                             <property name="visible">True</property>
                             <property name="can_focus">False</property>
-                            <property name="border_width">3</property>
-                            <property name="orientation">vertical</property>
-                            <property name="homogeneous">True</property>
-                            <child>
-                              <object class="GtkLabel" id="owner_label">
-                                <property name="visible">True</property>
-                                <property name="can_focus">False</property>
-                                <property name="halign">end</property>
-                                <property name="label">(owner)</property>
-                                <property name="justify">right</property>
-                              </object>
-                              <packing>
-                                <property name="expand">False</property>
-                                <property name="fill">False</property>
-                                <property name="position">0</property>
-                              </packing>
-                            </child>
-                            <child>
-                              <object class="GtkLabel" id="label7">
-                                <property name="visible">True</property>
-                                <property name="can_focus">False</property>
-                                <property name="halign">end</property>
-                                <property name="label" translatable="yes">Reference</property>
-                                <property name="justify">center</property>
-                              </object>
-                              <packing>
-                                <property name="expand">False</property>
-                                <property name="fill">False</property>
-                                <property name="position">1</property>
-                              </packing>
-                            </child>
-                            <child>
-                              <object class="GtkLabel" id="hide1">
-                                <property name="visible">True</property>
-                                <property name="can_focus">False</property>
-                                <property name="justify">center</property>
-                              </object>
-                              <packing>
-                                <property name="expand">False</property>
-                                <property name="fill">False</property>
-                                <property name="position">2</property>
-                              </packing>
-                            </child>
-                            <child>
-                              <object class="GtkLabel" id="label11">
-                                <property name="visible">True</property>
-                                <property name="can_focus">False</property>
-                                <property name="justify">center</property>
-                              </object>
-                              <packing>
-                                <property name="expand">False</property>
-                                <property name="fill">False</property>
-                                <property name="position">3</property>
-                              </packing>
-                            </child>
+                            <property name="halign">end</property>
+                            <property name="label">(owner)</property>
+                            <property name="justify">right</property>
                           </object>
                           <packing>
-                            <property name="expand">True</property>
-                            <property name="fill">True</property>
-                            <property name="position">0</property>
+                            <property name="left_attach">0</property>
+                            <property name="top_attach">0</property>
                           </packing>
                         </child>
                         <child>
-                          <object class="GtkBox" id="vbox9">
+                          <object class="GtkLabel" id="label7">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="halign">end</property>
+                            <property name="label" translatable="yes">Reference</property>
+                            <property name="justify">center</property>
+                          </object>
+                          <packing>
+                            <property name="left_attach">0</property>
+                            <property name="top_attach">1</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkBox" id="owner_hbox">
                             <property name="visible">True</property>
                             <property name="can_focus">False</property>
-                            <property name="border_width">3</property>
-                            <property name="orientation">vertical</property>
-                            <property name="homogeneous">True</property>
-                            <child>
-                              <object class="GtkBox" id="owner_hbox">
-                                <property name="visible">True</property>
-                                <property name="can_focus">False</property>
-                                <child>
-                                  <placeholder/>
-                                </child>
-                              </object>
-                              <packing>
-                                <property name="expand">True</property>
-                                <property name="fill">True</property>
-                                <property name="position">0</property>
-                              </packing>
-                            </child>
-                            <child>
-                              <object class="GtkEntry" id="ref_entry">
-                                <property name="visible">True</property>
-                                <property name="can_focus">True</property>
-                                <property name="invisible_char">●</property>
-                                <property name="primary_icon_activatable">False</property>
-                                <property name="secondary_icon_activatable">False</property>
-                              </object>
-                              <packing>
-                                <property name="expand">False</property>
-                                <property name="fill">False</property>
-                                <property name="position">1</property>
-                              </packing>
-                            </child>
-                            <child>
-                              <object class="GtkLabel" id="hide2">
-                                <property name="visible">True</property>
-                                <property name="can_focus">False</property>
-                                <property name="justify">center</property>
-                              </object>
-                              <packing>
-                                <property name="expand">False</property>
-                                <property name="fill">False</property>
-                                <property name="position">2</property>
-                              </packing>
-                            </child>
                             <child>
-                              <object class="GtkLabel" id="label12">
-                                <property name="visible">True</property>
-                                <property name="can_focus">False</property>
-                                <property name="justify">center</property>
-                              </object>
-                              <packing>
-                                <property name="expand">False</property>
-                                <property name="fill">False</property>
-                                <property name="position">3</property>
-                              </packing>
+                              <placeholder/>
                             </child>
                           </object>
                           <packing>
-                            <property name="expand">True</property>
-                            <property name="fill">True</property>
-                            <property name="position">1</property>
+                            <property name="left_attach">1</property>
+                            <property name="top_attach">0</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkEntry" id="ref_entry">
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="invisible_char">●</property>
+                            <property name="primary_icon_activatable">False</property>
+                            <property name="secondary_icon_activatable">False</property>
+                          </object>
+                          <packing>
+                            <property name="left_attach">1</property>
+                            <property name="top_attach">1</property>
                           </packing>
                         </child>
                       </object>
@@ -446,8 +338,8 @@
                             <property name="visible">True</property>
                             <property name="can_focus">True</property>
                             <property name="wrap_mode">word</property>
-                            <property name="accepts_tab">False</property>
                             <property name="buffer">notes_buffer</property>
+                            <property name="accepts_tab">False</property>
                           </object>
                         </child>
                       </object>
@@ -530,6 +422,9 @@
     <property name="title" translatable="yes">New Order</property>
     <property name="type_hint">dialog</property>
     <signal name="destroy" handler="gnc_order_window_destroy_cb" swapped="no"/>
+    <child>
+      <placeholder/>
+    </child>
     <child internal-child="vbox">
       <object class="GtkBox" id="dialog-vbox6">
         <property name="visible">True</property>
@@ -610,95 +505,67 @@
                 <property name="border_width">3</property>
                 <property name="label_xalign">0</property>
                 <child>
-                  <object class="GtkBox" id="hbox4">
+                  <object class="GtkGrid">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
+                    <property name="border_width">6</property>
+                    <property name="row_spacing">6</property>
+                    <property name="column_spacing">6</property>
                     <child>
-                      <object class="GtkBox" id="vbox12">
+                      <object class="GtkLabel" id="label4">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
-                        <property name="border_width">3</property>
-                        <property name="orientation">vertical</property>
-                        <property name="homogeneous">True</property>
-                        <child>
-                          <object class="GtkLabel" id="label4">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <property name="halign">end</property>
-                            <property name="label" translatable="yes">Order ID</property>
-                            <property name="justify">right</property>
-                          </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                            <property name="position">0</property>
-                          </packing>
-                        </child>
-                        <child>
-                          <object class="GtkLabel" id="label5">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <property name="halign">end</property>
-                            <property name="label" translatable="yes">Date Opened</property>
-                            <property name="justify">right</property>
-                          </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                            <property name="position">1</property>
-                          </packing>
-                        </child>
+                        <property name="halign">end</property>
+                        <property name="label" translatable="yes">Order ID</property>
+                        <property name="justify">right</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">0</property>
+                        <property name="top_attach">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkEntry" id="entry_id">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="has_tooltip">True</property>
+                        <property name="tooltip_markup">The order ID number. If left blank a reasonable number will be chosen for you</property>
+                        <property name="tooltip_text" translatable="yes">The order ID number. If left blank a reasonable number will be chosen for you</property>
+                        <property name="hexpand">True</property>
+                        <property name="invisible_char">●</property>
+                        <property name="activates_default">True</property>
+                        <property name="primary_icon_activatable">False</property>
+                        <property name="secondary_icon_activatable">False</property>
                       </object>
                       <packing>
-                        <property name="expand">True</property>
-                        <property name="fill">True</property>
-                        <property name="position">0</property>
+                        <property name="left_attach">1</property>
+                        <property name="top_attach">0</property>
                       </packing>
                     </child>
                     <child>
-                      <object class="GtkBox" id="vbox13">
+                      <object class="GtkLabel" id="label5">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="halign">end</property>
+                        <property name="label" translatable="yes">Date Opened</property>
+                        <property name="justify">right</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">0</property>
+                        <property name="top_attach">1</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkBox" id="date_opened_hbox">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
-                        <property name="border_width">3</property>
-                        <property name="orientation">vertical</property>
-                        <property name="homogeneous">True</property>
-                        <child>
-                          <object class="GtkEntry" id="entry_id">
-                            <property name="visible">True</property>
-                            <property name="can_focus">True</property>
-                            <property name="has_tooltip">True</property>
-                            <property name="tooltip_markup">The order ID number. If left blank a reasonable number will be chosen for you</property>
-                            <property name="tooltip_text" translatable="yes">The order ID number. If left blank a reasonable number will be chosen for you</property>
-                            <property name="invisible_char">●</property>
-                            <property name="activates_default">True</property>
-                            <property name="primary_icon_activatable">False</property>
-                            <property name="secondary_icon_activatable">False</property>
-                          </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                            <property name="position">0</property>
-                          </packing>
-                        </child>
                         <child>
-                          <object class="GtkBox" id="date_opened_hbox">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <child>
-                              <placeholder/>
-                            </child>
-                          </object>
-                          <packing>
-                            <property name="expand">True</property>
-                            <property name="fill">True</property>
-                            <property name="position">1</property>
-                          </packing>
+                          <placeholder/>
                         </child>
                       </object>
                       <packing>
-                        <property name="expand">True</property>
-                        <property name="fill">True</property>
-                        <property name="position">1</property>
+                        <property name="left_attach">1</property>
+                        <property name="top_attach">1</property>
                       </packing>
                     </child>
                   </object>
@@ -724,91 +591,64 @@
                 <property name="border_width">3</property>
                 <property name="label_xalign">0</property>
                 <child>
-                  <object class="GtkBox" id="hbox5">
+                  <object class="GtkGrid">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
+                    <property name="border_width">6</property>
+                    <property name="row_spacing">6</property>
+                    <property name="column_spacing">6</property>
                     <child>
-                      <object class="GtkBox" id="vbox14">
+                      <object class="GtkLabel" id="bill_owner_label">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
-                        <property name="border_width">3</property>
-                        <property name="orientation">vertical</property>
-                        <property name="homogeneous">True</property>
-                        <child>
-                          <object class="GtkLabel" id="bill_owner_label">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <property name="halign">end</property>
-                            <property name="label" translatable="yes">(owner)</property>
-                            <property name="justify">right</property>
-                          </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                            <property name="position">0</property>
-                          </packing>
-                        </child>
-                        <child>
-                          <object class="GtkLabel" id="label16">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <property name="halign">end</property>
-                            <property name="label" translatable="yes">Reference</property>
-                            <property name="justify">right</property>
-                          </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                            <property name="position">1</property>
-                          </packing>
-                        </child>
+                        <property name="halign">end</property>
+                        <property name="label" translatable="yes">(owner)</property>
+                        <property name="justify">right</property>
                       </object>
                       <packing>
-                        <property name="expand">True</property>
-                        <property name="fill">True</property>
-                        <property name="position">0</property>
+                        <property name="left_attach">0</property>
+                        <property name="top_attach">0</property>
                       </packing>
                     </child>
                     <child>
-                      <object class="GtkBox" id="vbox15">
+                      <object class="GtkBox" id="bill_owner_hbox">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
-                        <property name="border_width">3</property>
-                        <property name="orientation">vertical</property>
                         <child>
-                          <object class="GtkBox" id="bill_owner_hbox">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <child>
-                              <placeholder/>
-                            </child>
-                          </object>
-                          <packing>
-                            <property name="expand">True</property>
-                            <property name="fill">True</property>
-                            <property name="position">0</property>
-                          </packing>
-                        </child>
-                        <child>
-                          <object class="GtkEntry" id="entry_ref">
-                            <property name="visible">True</property>
-                            <property name="can_focus">True</property>
-                            <property name="editable">False</property>
-                            <property name="invisible_char">●</property>
-                            <property name="primary_icon_activatable">False</property>
-                            <property name="secondary_icon_activatable">False</property>
-                          </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                            <property name="position">1</property>
-                          </packing>
+                          <placeholder/>
                         </child>
                       </object>
                       <packing>
-                        <property name="expand">True</property>
-                        <property name="fill">True</property>
-                        <property name="position">1</property>
+                        <property name="left_attach">1</property>
+                        <property name="top_attach">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="label16">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="halign">end</property>
+                        <property name="label" translatable="yes">Reference</property>
+                        <property name="justify">right</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">0</property>
+                        <property name="top_attach">1</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkEntry" id="entry_ref">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="hexpand">True</property>
+                        <property name="editable">False</property>
+                        <property name="invisible_char">●</property>
+                        <property name="primary_icon_activatable">False</property>
+                        <property name="secondary_icon_activatable">False</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">1</property>
+                        <property name="top_attach">1</property>
                       </packing>
                     </child>
                   </object>
@@ -848,8 +688,8 @@
                         <property name="can_focus">True</property>
                         <property name="editable">False</property>
                         <property name="wrap_mode">word</property>
-                        <property name="accepts_tab">False</property>
                         <property name="buffer">text_buffer</property>
+                        <property name="accepts_tab">False</property>
                       </object>
                     </child>
                   </object>

commit 3b73c49e8001a0e0db494c3c47ce14483780f6f1
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Fri May 10 12:03:36 2019 +0100

    Change dialog-invoice to use GtkGrid widgets
    
    There was a column alignment error between the labels and widgets as
    they were using separate vboxs so moving them all to a Gtkgrid
    eliminates this.

diff --git a/gnucash/gnome/dialog-invoice.c b/gnucash/gnome/dialog-invoice.c
index 11db30780..3194f00ca 100644
--- a/gnucash/gnome/dialog-invoice.c
+++ b/gnucash/gnome/dialog-invoice.c
@@ -1873,20 +1873,12 @@ gnc_invoice_update_window (InvoiceWindow *iw, GtkWidget *widget)
 
         if (is_posted)
         {
-            hide = GTK_WIDGET (gtk_builder_get_object (iw->builder, "hide3"));
-            gtk_widget_hide (hide);
-
             show = GTK_WIDGET (gtk_builder_get_object (iw->builder, "posted_label"));
             gtk_widget_show (show);
             gtk_widget_show (iw->posted_date_hbox);
             show = GTK_WIDGET (gtk_builder_get_object (iw->builder, "acct_label"));
             gtk_widget_show (show);
             gtk_widget_show (acct_entry);
-
-            show = GTK_WIDGET (gtk_builder_get_object (iw->builder, "hide1"));
-            gtk_widget_show (show);
-            show = GTK_WIDGET (gtk_builder_get_object (iw->builder, "hide2"));
-            gtk_widget_show (show);
         }
         else           /* ! posted */
         {
@@ -1897,11 +1889,6 @@ gnc_invoice_update_window (InvoiceWindow *iw, GtkWidget *widget)
             hide = GTK_WIDGET (gtk_builder_get_object (iw->builder, "acct_label"));
             gtk_widget_hide (hide);
             gtk_widget_hide (acct_entry);
-
-            hide = GTK_WIDGET (gtk_builder_get_object (iw->builder, "hide1"));
-            gtk_widget_hide (hide);
-            hide = GTK_WIDGET (gtk_builder_get_object (iw->builder, "hide2"));
-            gtk_widget_hide (hide);
         }
     }
 
@@ -2322,7 +2309,10 @@ gnc_invoice_create_page (InvoiceWindow *iw, gpointer page)
     iw->owner_label = GTK_WIDGET (gtk_builder_get_object (builder, "page_owner_label"));
     iw->job_label = GTK_WIDGET (gtk_builder_get_object (builder, "page_job_label"));
     iw->job_box = GTK_WIDGET (gtk_builder_get_object (builder, "page_job_hbox"));
-    iw->paid_label = GTK_WIDGET (gtk_builder_get_object (builder, "hide4"));
+    iw->paid_label = GTK_WIDGET (gtk_builder_get_object (builder, "paid_label"));
+
+    // Set the style context for this label so it can be easily manipulated with css
+    gnc_widget_set_style_context (GTK_WIDGET(iw->paid_label), "gnc-class-highlight");
 
     /* grab the project widgets */
     iw->proj_frame = GTK_WIDGET (gtk_builder_get_object (builder, "page_proj_frame"));
diff --git a/gnucash/gtkbuilder/dialog-invoice.glade b/gnucash/gtkbuilder/dialog-invoice.glade
index 602dacc08..751838d9e 100644
--- a/gnucash/gtkbuilder/dialog-invoice.glade
+++ b/gnucash/gtkbuilder/dialog-invoice.glade
@@ -1,11 +1,14 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.20.0 -->
+<!-- Generated with glade 3.22.1 -->
 <interface>
   <requires lib="gtk+" version="3.10"/>
   <object class="GtkWindow" id="invoice_entry_window">
     <property name="visible">True</property>
     <property name="can_focus">False</property>
     <property name="title" translatable="yes">Invoice</property>
+    <child>
+      <placeholder/>
+    </child>
     <child>
       <object class="GtkBox" id="invoice_entry_vbox">
         <property name="visible">True</property>
@@ -24,230 +27,183 @@
                 <property name="can_focus">False</property>
                 <property name="label_xalign">0</property>
                 <child>
-                  <object class="GtkBox" id="hbox2">
+                  <object class="GtkGrid">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="border_width">3</property>
-                    <property name="spacing">2</property>
+                    <property name="border_width">6</property>
+                    <property name="row_spacing">6</property>
+                    <property name="column_spacing">6</property>
                     <child>
-                      <object class="GtkBox" id="vbox2">
+                      <object class="GtkLabel" id="label3">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
-                        <property name="margin_right">5</property>
-                        <property name="orientation">vertical</property>
-                        <property name="homogeneous">True</property>
-                        <child>
-                          <object class="GtkLabel" id="label9">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <property name="halign">end</property>
-                            <property name="label" translatable="yes">Type</property>
-                            <property name="justify">right</property>
-                          </object>
-                          <packing>
-                            <property name="expand">True</property>
-                            <property name="fill">True</property>
-                            <property name="position">0</property>
-                          </packing>
-                        </child>
-                        <child>
-                          <object class="GtkLabel" id="label3">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <property name="halign">end</property>
-                            <property name="label" translatable="yes">Invoice ID</property>
-                            <property name="justify">right</property>
-                          </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                            <property name="position">1</property>
-                          </packing>
-                        </child>
-                        <child>
-                          <object class="GtkLabel" id="label4">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <property name="halign">end</property>
-                            <property name="label" translatable="yes">Date Opened</property>
-                            <property name="justify">right</property>
-                          </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                            <property name="position">2</property>
-                          </packing>
-                        </child>
-                        <child>
-                          <object class="GtkLabel" id="posted_label">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <property name="halign">end</property>
-                            <property name="label" translatable="yes">Date Posted</property>
-                            <property name="justify">right</property>
-                          </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                            <property name="position">3</property>
-                          </packing>
-                        </child>
-                        <child>
-                          <object class="GtkLabel" id="acct_label">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <property name="halign">end</property>
-                            <property name="label" translatable="yes">Posted Account</property>
-                            <property name="justify">right</property>
-                          </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                            <property name="position">4</property>
-                          </packing>
-                        </child>
-                        <child>
-                          <object class="GtkLabel" id="label8">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <property name="justify">center</property>
-                          </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                            <property name="position">5</property>
-                          </packing>
-                        </child>
-                        <child>
-                          <object class="GtkLabel" id="hide3">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <property name="justify">center</property>
-                          </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                            <property name="position">6</property>
-                          </packing>
-                        </child>
+                        <property name="halign">end</property>
+                        <property name="label" translatable="yes">Invoice ID</property>
+                        <property name="justify">right</property>
                       </object>
                       <packing>
-                        <property name="expand">False</property>
-                        <property name="fill">True</property>
-                        <property name="position">0</property>
+                        <property name="left_attach">0</property>
+                        <property name="top_attach">1</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkEntry" id="page_id_entry">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="editable">False</property>
+                        <property name="primary_icon_activatable">False</property>
+                        <property name="secondary_icon_activatable">False</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">1</property>
+                        <property name="top_attach">1</property>
                       </packing>
                     </child>
                     <child>
-                      <object class="GtkBox" id="vbox3">
+                      <object class="GtkLabel" id="label4">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="halign">end</property>
+                        <property name="label" translatable="yes">Date Opened</property>
+                        <property name="justify">right</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">0</property>
+                        <property name="top_attach">2</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkBox" id="page_date_opened_hbox">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
-                        <property name="orientation">vertical</property>
-                        <property name="homogeneous">True</property>
-                        <child>
-                          <object class="GtkLabel" id="page_type_label">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <property name="halign">start</property>
-                            <property name="label" translatable="yes">Invoice</property>
-                          </object>
-                          <packing>
-                            <property name="expand">True</property>
-                            <property name="fill">True</property>
-                            <property name="position">0</property>
-                          </packing>
-                        </child>
-                        <child>
-                          <object class="GtkEntry" id="page_id_entry">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <property name="editable">False</property>
-                            <property name="primary_icon_activatable">False</property>
-                            <property name="secondary_icon_activatable">False</property>
-                          </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                            <property name="position">1</property>
-                          </packing>
-                        </child>
-                        <child>
-                          <object class="GtkBox" id="page_date_opened_hbox">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <child>
-                              <placeholder/>
-                            </child>
-                          </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                            <property name="position">2</property>
-                          </packing>
-                        </child>
-                        <child>
-                          <object class="GtkBox" id="date_posted_hbox">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <child>
-                              <placeholder/>
-                            </child>
-                          </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                            <property name="position">3</property>
-                          </packing>
-                        </child>
-                        <child>
-                          <object class="GtkEntry" id="acct_entry">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <property name="editable">False</property>
-                            <property name="primary_icon_activatable">False</property>
-                            <property name="secondary_icon_activatable">False</property>
-                          </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                            <property name="position">4</property>
-                          </packing>
-                        </child>
                         <child>
-                          <object class="GtkCheckButton" id="active_check">
-                            <property name="label" translatable="yes">Active</property>
-                            <property name="visible">True</property>
-                            <property name="can_focus">True</property>
-                            <property name="receives_default">False</property>
-                            <property name="halign">start</property>
-                            <property name="use_underline">True</property>
-                            <property name="draw_indicator">True</property>
-                            <signal name="toggled" handler="gnc_invoice_window_active_toggled_cb" swapped="no"/>
-                          </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                            <property name="position">5</property>
-                          </packing>
+                          <placeholder/>
                         </child>
+                      </object>
+                      <packing>
+                        <property name="left_attach">1</property>
+                        <property name="top_attach">2</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="posted_label">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="halign">end</property>
+                        <property name="label" translatable="yes">Date Posted</property>
+                        <property name="justify">right</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">0</property>
+                        <property name="top_attach">3</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkBox" id="date_posted_hbox">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
                         <child>
-                          <object class="GtkLabel" id="hide4">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <property name="justify">center</property>
-                          </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                            <property name="position">6</property>
-                          </packing>
+                          <placeholder/>
                         </child>
                       </object>
                       <packing>
-                        <property name="expand">False</property>
-                        <property name="fill">False</property>
-                        <property name="position">1</property>
+                        <property name="left_attach">1</property>
+                        <property name="top_attach">3</property>
                       </packing>
                     </child>
+                    <child>
+                      <object class="GtkLabel" id="acct_label">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="halign">end</property>
+                        <property name="label" translatable="yes">Posted Account</property>
+                        <property name="justify">right</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">0</property>
+                        <property name="top_attach">4</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkEntry" id="acct_entry">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="editable">False</property>
+                        <property name="primary_icon_activatable">False</property>
+                        <property name="secondary_icon_activatable">False</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">1</property>
+                        <property name="top_attach">4</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="page_type_label">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="halign">start</property>
+                        <property name="label" translatable="yes">Invoice</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">1</property>
+                        <property name="top_attach">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="label9">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="halign">end</property>
+                        <property name="label" translatable="yes">Type</property>
+                        <property name="justify">right</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">0</property>
+                        <property name="top_attach">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="paid_label">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="halign">end</property>
+                        <property name="justify">center</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">1</property>
+                        <property name="top_attach">6</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkCheckButton" id="active_check">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="receives_default">False</property>
+                        <property name="halign">start</property>
+                        <property name="use_underline">True</property>
+                        <property name="draw_indicator">True</property>
+                        <signal name="toggled" handler="gnc_invoice_window_active_toggled_cb" swapped="no"/>
+                      </object>
+                      <packing>
+                        <property name="left_attach">1</property>
+                        <property name="top_attach">5</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="halign">end</property>
+                        <property name="label" translatable="yes">Active</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">0</property>
+                        <property name="top_attach">5</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
                   </object>
                 </child>
                 <child type="label">
@@ -270,173 +226,115 @@
                 <property name="can_focus">False</property>
                 <property name="label_xalign">0</property>
                 <child>
-                  <object class="GtkBox" id="hbox6">
+                  <object class="GtkGrid">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="border_width">3</property>
-                    <property name="spacing">2</property>
+                    <property name="border_width">6</property>
+                    <property name="row_spacing">6</property>
+                    <property name="column_spacing">6</property>
                     <child>
-                      <object class="GtkBox" id="vbox8">
+                      <object class="GtkLabel" id="page_owner_label">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
-                        <property name="margin_right">5</property>
-                        <property name="orientation">vertical</property>
-                        <property name="homogeneous">True</property>
-                        <child>
-                          <object class="GtkLabel" id="page_owner_label">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <property name="halign">end</property>
-                            <property name="label" translatable="yes">(owner)</property>
-                            <property name="justify">right</property>
-                          </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                            <property name="position">0</property>
-                          </packing>
-                        </child>
-                        <child>
-                          <object class="GtkLabel" id="page_job_label">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <property name="halign">end</property>
-                            <property name="label" translatable="yes">Job</property>
-                            <property name="justify">right</property>
-                          </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                            <property name="position">1</property>
-                          </packing>
-                        </child>
-                        <child>
-                          <object class="GtkLabel" id="label19">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <property name="halign">end</property>
-                            <property name="label" translatable="yes">Billing ID</property>
-                            <property name="justify">right</property>
-                          </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                            <property name="position">2</property>
-                          </packing>
-                        </child>
-                        <child>
-                          <object class="GtkLabel" id="label13">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <property name="halign">end</property>
-                            <property name="label" translatable="yes">Terms</property>
-                            <property name="justify">right</property>
-                          </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                            <property name="position">3</property>
-                          </packing>
-                        </child>
-                        <child>
-                          <object class="GtkLabel" id="hide1">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <property name="justify">center</property>
-                          </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                            <property name="position">4</property>
-                          </packing>
-                        </child>
+                        <property name="halign">end</property>
+                        <property name="label" translatable="yes">(owner)</property>
+                        <property name="justify">right</property>
                       </object>
                       <packing>
-                        <property name="expand">True</property>
-                        <property name="fill">True</property>
-                        <property name="position">0</property>
+                        <property name="left_attach">0</property>
+                        <property name="top_attach">0</property>
                       </packing>
                     </child>
                     <child>
-                      <object class="GtkBox" id="vbox9">
+                      <object class="GtkBox" id="page_owner_hbox">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
-                        <property name="orientation">vertical</property>
-                        <property name="homogeneous">True</property>
-                        <child>
-                          <object class="GtkBox" id="page_owner_hbox">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <child>
-                              <placeholder/>
-                            </child>
-                          </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                            <property name="position">0</property>
-                          </packing>
-                        </child>
-                        <child>
-                          <object class="GtkBox" id="page_job_hbox">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <child>
-                              <placeholder/>
-                            </child>
-                          </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                            <property name="position">1</property>
-                          </packing>
-                        </child>
-                        <child>
-                          <object class="GtkEntry" id="page_billing_id_entry">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <property name="editable">False</property>
-                            <property name="primary_icon_activatable">False</property>
-                            <property name="secondary_icon_activatable">False</property>
-                          </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                            <property name="position">2</property>
-                          </packing>
-                        </child>
                         <child>
-                          <object class="GtkEntry" id="page_terms_menu">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <property name="editable">False</property>
-                            <property name="invisible_char">●</property>
-                            <property name="primary_icon_activatable">False</property>
-                            <property name="secondary_icon_activatable">False</property>
-                          </object>
-                          <packing>
-                            <property name="expand">True</property>
-                            <property name="fill">True</property>
-                            <property name="position">3</property>
-                          </packing>
+                          <placeholder/>
                         </child>
+                      </object>
+                      <packing>
+                        <property name="left_attach">1</property>
+                        <property name="top_attach">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="page_job_label">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="halign">end</property>
+                        <property name="label" translatable="yes">Job</property>
+                        <property name="justify">right</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">0</property>
+                        <property name="top_attach">1</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkBox" id="page_job_hbox">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
                         <child>
-                          <object class="GtkLabel" id="hide2">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <property name="justify">center</property>
-                          </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                            <property name="position">4</property>
-                          </packing>
+                          <placeholder/>
                         </child>
                       </object>
                       <packing>
-                        <property name="expand">True</property>
-                        <property name="fill">True</property>
-                        <property name="position">1</property>
+                        <property name="left_attach">1</property>
+                        <property name="top_attach">1</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="label19">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="halign">end</property>
+                        <property name="label" translatable="yes">Billing ID</property>
+                        <property name="justify">right</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">0</property>
+                        <property name="top_attach">2</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkEntry" id="page_billing_id_entry">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="editable">False</property>
+                        <property name="primary_icon_activatable">False</property>
+                        <property name="secondary_icon_activatable">False</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">1</property>
+                        <property name="top_attach">2</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="label13">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="halign">end</property>
+                        <property name="label" translatable="yes">Terms</property>
+                        <property name="justify">right</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">0</property>
+                        <property name="top_attach">3</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkEntry" id="page_terms_menu">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="editable">False</property>
+                        <property name="invisible_char">●</property>
+                        <property name="primary_icon_activatable">False</property>
+                        <property name="secondary_icon_activatable">False</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">1</property>
+                        <property name="top_attach">3</property>
                       </packing>
                     </child>
                   </object>
@@ -682,6 +580,9 @@
     <property name="title" translatable="yes">New Invoice</property>
     <property name="type_hint">dialog</property>
     <signal name="destroy" handler="gnc_invoice_window_destroy_cb" swapped="no"/>
+    <child>
+      <placeholder/>
+    </child>
     <child internal-child="vbox">
       <object class="GtkBox" id="dialog-vbox2">
         <property name="visible">True</property>
@@ -761,80 +662,110 @@
                 <property name="border_width">3</property>
                 <property name="label_xalign">0</property>
                 <child>
-                  <object class="GtkBox" id="hbox3">
+                  <object class="GtkGrid">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
+                    <property name="border_width">6</property>
+                    <property name="row_spacing">6</property>
+                    <property name="column_spacing">6</property>
+                    <child>
+                      <object class="GtkLabel" id="label7">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="halign">end</property>
+                        <property name="label" translatable="yes">Type</property>
+                        <property name="justify">right</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">0</property>
+                        <property name="top_attach">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="label14">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="halign">end</property>
+                        <property name="label" translatable="yes">Invoice ID</property>
+                        <property name="justify">right</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">0</property>
+                        <property name="top_attach">1</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="label15">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="halign">end</property>
+                        <property name="label" translatable="yes">Date Opened</property>
+                        <property name="justify">right</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">0</property>
+                        <property name="top_attach">2</property>
+                      </packing>
+                    </child>
                     <child>
-                      <object class="GtkBox" id="vbox11">
+                      <object class="GtkBox" id="dialog_date_opened_hbox">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
-                        <property name="border_width">3</property>
-                        <property name="orientation">vertical</property>
-                        <property name="homogeneous">True</property>
-                        <child>
-                          <object class="GtkLabel" id="label7">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <property name="halign">end</property>
-                            <property name="label" translatable="yes">Type</property>
-                            <property name="justify">right</property>
-                          </object>
-                          <packing>
-                            <property name="expand">True</property>
-                            <property name="fill">True</property>
-                            <property name="position">0</property>
-                          </packing>
-                        </child>
-                        <child>
-                          <object class="GtkLabel" id="label14">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <property name="halign">end</property>
-                            <property name="label" translatable="yes">Invoice ID</property>
-                            <property name="justify">right</property>
-                          </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                            <property name="position">1</property>
-                          </packing>
-                        </child>
+                        <property name="halign">start</property>
                         <child>
-                          <object class="GtkLabel" id="label15">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <property name="halign">end</property>
-                            <property name="label" translatable="yes">Date Opened</property>
-                            <property name="justify">right</property>
-                          </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                            <property name="position">2</property>
-                          </packing>
+                          <placeholder/>
                         </child>
                       </object>
                       <packing>
-                        <property name="expand">True</property>
-                        <property name="fill">True</property>
-                        <property name="position">0</property>
+                        <property name="left_attach">1</property>
+                        <property name="top_attach">2</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkEntry" id="dialog_id_entry">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="tooltip_text" translatable="yes">The invoice ID number. If left blank a reasonable number will be chosen for you.</property>
+                        <property name="hexpand">True</property>
+                        <property name="activates_default">True</property>
+                        <property name="primary_icon_activatable">False</property>
+                        <property name="secondary_icon_activatable">False</property>
+                        <signal name="changed" handler="gnc_invoice_id_changed_cb" swapped="no"/>
+                      </object>
+                      <packing>
+                        <property name="left_attach">1</property>
+                        <property name="top_attach">1</property>
                       </packing>
                     </child>
                     <child>
-                      <object class="GtkBox" id="vbox12">
+                      <object class="GtkBox" id="dialog_type_hbox">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
-                        <property name="border_width">3</property>
-                        <property name="orientation">vertical</property>
-                        <property name="homogeneous">True</property>
                         <child>
-                          <object class="GtkBox" id="dialog_type_hbox">
+                          <object class="GtkLabel" id="dialog_type_label">
+                            <property name="can_focus">False</property>
+                            <property name="label" translatable="yes">Invoice</property>
+                          </object>
+                          <packing>
+                            <property name="expand">True</property>
+                            <property name="fill">True</property>
+                            <property name="position">0</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkBox" id="dialog_type_choice_hbox">
                             <property name="visible">True</property>
                             <property name="can_focus">False</property>
                             <child>
-                              <object class="GtkLabel" id="dialog_type_label">
-                                <property name="can_focus">False</property>
+                              <object class="GtkRadioButton" id="dialog_invoice_type">
                                 <property name="label" translatable="yes">Invoice</property>
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">False</property>
+                                <property name="halign">start</property>
+                                <property name="active">True</property>
+                                <property name="draw_indicator">True</property>
+                                <signal name="toggled" handler="gnc_invoice_type_toggled_cb" swapped="no"/>
                               </object>
                               <packing>
                                 <property name="expand">True</property>
@@ -843,93 +774,32 @@
                               </packing>
                             </child>
                             <child>
-                              <object class="GtkBox" id="dialog_type_choice_hbox">
+                              <object class="GtkRadioButton" id="dialog_creditnote_type">
+                                <property name="label" translatable="yes">Credit Note</property>
                                 <property name="visible">True</property>
-                                <property name="can_focus">False</property>
-                                <child>
-                                  <object class="GtkRadioButton" id="dialog_invoice_type">
-                                    <property name="label" translatable="yes">Invoice</property>
-                                    <property name="visible">True</property>
-                                    <property name="can_focus">True</property>
-                                    <property name="receives_default">False</property>
-                                    <property name="halign">start</property>
-                                    <property name="active">True</property>
-                                    <property name="draw_indicator">True</property>
-                                    <signal name="toggled" handler="gnc_invoice_type_toggled_cb" swapped="no"/>
-                                  </object>
-                                  <packing>
-                                    <property name="expand">True</property>
-                                    <property name="fill">True</property>
-                                    <property name="position">0</property>
-                                  </packing>
-                                </child>
-                                <child>
-                                  <object class="GtkRadioButton" id="dialog_creditnote_type">
-                                    <property name="label" translatable="yes">Credit Note</property>
-                                    <property name="visible">True</property>
-                                    <property name="can_focus">True</property>
-                                    <property name="receives_default">False</property>
-                                    <property name="halign">start</property>
-                                    <property name="active">True</property>
-                                    <property name="draw_indicator">True</property>
-                                    <property name="group">dialog_invoice_type</property>
-                                  </object>
-                                  <packing>
-                                    <property name="expand">True</property>
-                                    <property name="fill">True</property>
-                                    <property name="position">1</property>
-                                  </packing>
-                                </child>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">False</property>
+                                <property name="halign">start</property>
+                                <property name="draw_indicator">True</property>
+                                <property name="group">dialog_invoice_type</property>
                               </object>
                               <packing>
-                                <property name="expand">False</property>
-                                <property name="fill">False</property>
+                                <property name="expand">True</property>
+                                <property name="fill">True</property>
                                 <property name="position">1</property>
                               </packing>
                             </child>
                           </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                            <property name="position">0</property>
-                          </packing>
-                        </child>
-                        <child>
-                          <object class="GtkEntry" id="dialog_id_entry">
-                            <property name="visible">True</property>
-                            <property name="can_focus">True</property>
-                            <property name="has_focus">True</property>
-                            <property name="tooltip_text" translatable="yes">The invoice ID number. If left blank a reasonable number will be chosen for you.</property>
-                            <property name="activates_default">True</property>
-                            <property name="primary_icon_activatable">False</property>
-                            <property name="secondary_icon_activatable">False</property>
-                            <signal name="changed" handler="gnc_invoice_id_changed_cb" swapped="no"/>
-                          </object>
                           <packing>
                             <property name="expand">False</property>
                             <property name="fill">False</property>
                             <property name="position">1</property>
                           </packing>
                         </child>
-                        <child>
-                          <object class="GtkBox" id="dialog_date_opened_hbox">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <child>
-                              <placeholder/>
-                            </child>
-                          </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                            <property name="position">2</property>
-                          </packing>
-                        </child>
                       </object>
                       <packing>
-                        <property name="expand">True</property>
-                        <property name="fill">True</property>
-                        <property name="position">1</property>
+                        <property name="left_attach">1</property>
+                        <property name="top_attach">0</property>
                       </packing>
                     </child>
                   </object>
@@ -943,7 +813,7 @@
                 </child>
               </object>
               <packing>
-                <property name="expand">False</property>
+                <property name="expand">True</property>
                 <property name="fill">False</property>
                 <property name="position">0</property>
               </packing>
@@ -955,151 +825,120 @@
                 <property name="border_width">3</property>
                 <property name="label_xalign">0</property>
                 <child>
-                  <object class="GtkBox" id="hbox4">
+                  <object class="GtkGrid">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
+                    <property name="border_width">6</property>
+                    <property name="row_spacing">6</property>
+                    <property name="column_spacing">6</property>
                     <child>
-                      <object class="GtkBox" id="vbox13">
+                      <object class="GtkLabel" id="dialog_owner_label">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
-                        <property name="border_width">3</property>
-                        <property name="orientation">vertical</property>
-                        <property name="homogeneous">True</property>
-                        <child>
-                          <object class="GtkLabel" id="dialog_owner_label">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <property name="halign">end</property>
-                            <property name="label">(owner)</property>
-                            <property name="justify">right</property>
-                          </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                            <property name="position">0</property>
-                          </packing>
-                        </child>
-                        <child>
-                          <object class="GtkLabel" id="dialog_job_label">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <property name="halign">end</property>
-                            <property name="label" translatable="yes">Job</property>
-                            <property name="justify">right</property>
-                          </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                            <property name="position">1</property>
-                          </packing>
-                        </child>
-                        <child>
-                          <object class="GtkLabel" id="label20">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <property name="halign">end</property>
-                            <property name="label" translatable="yes">Billing ID</property>
-                            <property name="justify">right</property>
-                          </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                            <property name="position">2</property>
-                          </packing>
-                        </child>
-                        <child>
-                          <object class="GtkLabel" id="label17">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <property name="halign">end</property>
-                            <property name="label" translatable="yes">Terms</property>
-                            <property name="justify">right</property>
-                          </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                            <property name="position">3</property>
-                          </packing>
-                        </child>
+                        <property name="halign">end</property>
+                        <property name="label">(owner)</property>
+                        <property name="justify">right</property>
                       </object>
                       <packing>
-                        <property name="expand">True</property>
-                        <property name="fill">True</property>
-                        <property name="position">0</property>
+                        <property name="left_attach">0</property>
+                        <property name="top_attach">0</property>
                       </packing>
                     </child>
                     <child>
-                      <object class="GtkBox" id="vbox14">
+                      <object class="GtkLabel" id="dialog_job_label">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="halign">end</property>
+                        <property name="label" translatable="yes">Job</property>
+                        <property name="justify">right</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">0</property>
+                        <property name="top_attach">1</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="label20">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="halign">end</property>
+                        <property name="label" translatable="yes">Billing ID</property>
+                        <property name="justify">right</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">0</property>
+                        <property name="top_attach">2</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="label17">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="halign">end</property>
+                        <property name="label" translatable="yes">Terms</property>
+                        <property name="justify">right</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">0</property>
+                        <property name="top_attach">3</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkBox" id="dialog_owner_hbox">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
-                        <property name="border_width">3</property>
-                        <property name="orientation">vertical</property>
-                        <property name="homogeneous">True</property>
-                        <child>
-                          <object class="GtkBox" id="dialog_owner_hbox">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <child>
-                              <placeholder/>
-                            </child>
-                          </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                            <property name="position">0</property>
-                          </packing>
-                        </child>
                         <child>
-                          <object class="GtkBox" id="dialog_job_hbox">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <child>
-                              <placeholder/>
-                            </child>
-                          </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                            <property name="position">1</property>
-                          </packing>
+                          <placeholder/>
                         </child>
+                      </object>
+                      <packing>
+                        <property name="left_attach">1</property>
+                        <property name="top_attach">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkBox" id="dialog_job_hbox">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
                         <child>
-                          <object class="GtkEntry" id="dialog_billing_id_entry">
-                            <property name="visible">True</property>
-                            <property name="can_focus">True</property>
-                            <property name="primary_icon_activatable">False</property>
-                            <property name="secondary_icon_activatable">False</property>
-                          </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                            <property name="position">2</property>
-                          </packing>
+                          <placeholder/>
                         </child>
+                      </object>
+                      <packing>
+                        <property name="left_attach">1</property>
+                        <property name="top_attach">1</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkEntry" id="dialog_billing_id_entry">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="hexpand">True</property>
+                        <property name="primary_icon_activatable">False</property>
+                        <property name="secondary_icon_activatable">False</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">1</property>
+                        <property name="top_attach">2</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkComboBox" id="dialog_terms_menu">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="halign">start</property>
+                        <property name="model">terms_store</property>
+                        <signal name="changed" handler="gnc_invoice_terms_changed_cb" swapped="no"/>
                         <child>
-                          <object class="GtkComboBox" id="dialog_terms_menu">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <property name="model">terms_store</property>
-                            <signal name="changed" handler="gnc_invoice_terms_changed_cb" swapped="no"/>
-                            <child>
-                              <object class="GtkCellRendererText" id="dialog_cell_renderer_text"/>
-                              <attributes>
-                                <attribute name="text">0</attribute>
-                              </attributes>
-                            </child>
-                          </object>
-                          <packing>
-                            <property name="expand">True</property>
-                            <property name="fill">True</property>
-                            <property name="position">3</property>
-                          </packing>
+                          <object class="GtkCellRendererText" id="dialog_cell_renderer_text"/>
+                          <attributes>
+                            <attribute name="text">0</attribute>
+                          </attributes>
                         </child>
                       </object>
                       <packing>
-                        <property name="expand">True</property>
-                        <property name="fill">True</property>
-                        <property name="position">1</property>
+                        <property name="left_attach">1</property>
+                        <property name="top_attach">3</property>
                       </packing>
                     </child>
                   </object>
@@ -1124,92 +963,62 @@
                 <property name="can_focus">False</property>
                 <property name="label_xalign">0</property>
                 <child>
-                  <object class="GtkBox" id="hbox5">
+                  <object class="GtkGrid">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="border_width">3</property>
+                    <property name="border_width">6</property>
+                    <property name="row_spacing">6</property>
+                    <property name="column_spacing">6</property>
                     <child>
-                      <object class="GtkBox" id="vbox15">
+                      <object class="GtkLabel" id="label22">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
-                        <property name="border_width">3</property>
-                        <property name="orientation">vertical</property>
-                        <property name="homogeneous">True</property>
-                        <child>
-                          <object class="GtkLabel" id="label22">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <property name="halign">end</property>
-                            <property name="label" translatable="yes">Customer</property>
-                            <property name="justify">right</property>
-                          </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                            <property name="position">0</property>
-                          </packing>
-                        </child>
-                        <child>
-                          <object class="GtkLabel" id="label23">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <property name="halign">end</property>
-                            <property name="label" translatable="yes">Job</property>
-                            <property name="justify">right</property>
-                          </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                            <property name="position">1</property>
-                          </packing>
-                        </child>
+                        <property name="halign">end</property>
+                        <property name="label" translatable="yes">Customer</property>
+                        <property name="justify">right</property>
                       </object>
                       <packing>
-                        <property name="expand">False</property>
-                        <property name="fill">True</property>
-                        <property name="position">0</property>
+                        <property name="left_attach">0</property>
+                        <property name="top_attach">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="label23">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="halign">end</property>
+                        <property name="label" translatable="yes">Job</property>
+                        <property name="justify">right</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">0</property>
+                        <property name="top_attach">1</property>
                       </packing>
                     </child>
                     <child>
-                      <object class="GtkBox" id="vbox16">
+                      <object class="GtkBox" id="dialog_proj_cust_hbox">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
-                        <property name="border_width">3</property>
-                        <property name="orientation">vertical</property>
-                        <property name="homogeneous">True</property>
                         <child>
-                          <object class="GtkBox" id="dialog_proj_cust_hbox">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <child>
-                              <placeholder/>
-                            </child>
-                          </object>
-                          <packing>
-                            <property name="expand">True</property>
-                            <property name="fill">True</property>
-                            <property name="position">0</property>
-                          </packing>
+                          <placeholder/>
                         </child>
+                      </object>
+                      <packing>
+                        <property name="left_attach">1</property>
+                        <property name="top_attach">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkBox" id="dialog_proj_job_hbox">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
                         <child>
-                          <object class="GtkBox" id="dialog_proj_job_hbox">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <child>
-                              <placeholder/>
-                            </child>
-                          </object>
-                          <packing>
-                            <property name="expand">True</property>
-                            <property name="fill">True</property>
-                            <property name="position">1</property>
-                          </packing>
+                          <placeholder/>
                         </child>
                       </object>
                       <packing>
-                        <property name="expand">True</property>
-                        <property name="fill">True</property>
-                        <property name="position">1</property>
+                        <property name="left_attach">1</property>
+                        <property name="top_attach">1</property>
                       </packing>
                     </child>
                   </object>
@@ -1287,6 +1096,9 @@
     <property name="resizable">False</property>
     <property name="modal">True</property>
     <property name="type_hint">dialog</property>
+    <child>
+      <placeholder/>
+    </child>
     <child internal-child="vbox">
       <object class="GtkBox" id="dialog-vbox3">
         <property name="visible">True</property>

commit a26a7c590813391242ad992cb1385e0ae8bbd82b
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Fri May 10 11:56:23 2019 +0100

    Change assistant-ab-initial.glade so it displays correctly
    
    The text on the first page was squashed as the width could not be
    negotiated properly as all the text was set to wrap automaticity and on
    subsequent pages there was no wide widgets. Moved the first text row to
    a separate widget and not wrap-able so a decent width can be negotiated.

diff --git a/gnucash/import-export/aqb/assistant-ab-initial.glade b/gnucash/import-export/aqb/assistant-ab-initial.glade
index 1dc8f58e6..0c44e4ef4 100644
--- a/gnucash/import-export/aqb/assistant-ab-initial.glade
+++ b/gnucash/import-export/aqb/assistant-ab-initial.glade
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.20.0 -->
+<!-- Generated with glade 3.22.1 -->
 <interface>
   <requires lib="gtk+" version="3.10"/>
   <object class="GtkAssistant" id="aqbanking_init_assistant">
@@ -7,6 +7,7 @@
     <property name="border_width">12</property>
     <property name="title" translatable="yes">AqBanking Initial Assistant</property>
     <property name="default_width">400</property>
+    <property name="default_height">500</property>
     <signal name="cancel" handler="aai_on_cancel" swapped="no"/>
     <signal name="close" handler="aai_on_finish" swapped="no"/>
     <signal name="prepare" handler="aai_on_prepare" swapped="no"/>
@@ -14,12 +15,29 @@
       <placeholder/>
     </child>
     <child>
-      <object class="GtkLabel" id="start_page">
+      <object class="GtkGrid" id="start_page">
         <property name="visible">True</property>
         <property name="can_focus">False</property>
-        <property name="label" translatable="yes">
-This assistant helps you setting up your Online Banking connection with your bank.
-
+        <property name="margin_left">12</property>
+        <property name="border_width">12</property>
+        <child>
+          <object class="GtkLabel">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="halign">start</property>
+            <property name="label" translatable="yes">This assistant helps you setting up your Online Banking connection with your bank.</property>
+          </object>
+          <packing>
+            <property name="left_attach">0</property>
+            <property name="top_attach">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkLabel">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="halign">start</property>
+            <property name="label" translatable="yes">
 You first need to apply for Online Banking access at your bank. If your bank  decides to grant you electronic access, they will send you a letter containing 
 
 * The bank code of your bank
@@ -32,54 +50,62 @@ This information will be needed in the following. Press "Next" now.
 NOTE: NO WARRANTIES FOR ANYTHING. Some banks run a poorly implemented Online Banking server. You should not rely on time-critical transfers through Online Banking, because sometimes the bank does not give you correct feedback when a transfer is rejected.
 
 Press "Cancel" if you do not wish to setup any Online Banking connection now.
-</property>
-        <property name="wrap">True</property>
+
+Lastly, for repeated imports the preview page has buttons to Load and Save the settings. To save the settings, tweak the settings to your preferences (optionally starting from an existing preset), then (optionally change the settings name and press the Save Settings button. Note you can't save to built-in presets.
+
+This operation is not reversable, so make sure you have a working backup.
+
+Click on "Next" to proceed or "Cancel" to Abort Import.</property>
+            <property name="wrap">True</property>
+          </object>
+          <packing>
+            <property name="left_attach">0</property>
+            <property name="top_attach">1</property>
+          </packing>
+        </child>
       </object>
       <packing>
         <property name="page_type">intro</property>
         <property name="title" translatable="yes">Initial Online Banking Setup</property>
         <property name="complete">True</property>
+        <property name="has_padding">False</property>
       </packing>
     </child>
     <child>
       <object class="GtkBox" id="wizard_page">
         <property name="visible">True</property>
         <property name="can_focus">False</property>
+        <property name="valign">center</property>
+        <property name="margin_left">12</property>
         <property name="border_width">12</property>
         <property name="orientation">vertical</property>
         <property name="spacing">12</property>
         <child>
-          <object class="GtkLabel" id="label8877441">
+          <object class="GtkLabel" id="wizard_label">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
             <property name="label" translatable="yes">The Setup of your Online Banking connection is handled by the external program "AqBanking Setup Wizard". Please press the button below to start this program.</property>
             <property name="wrap">True</property>
           </object>
           <packing>
-            <property name="expand">True</property>
-            <property name="fill">False</property>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
             <property name="position">0</property>
           </packing>
         </child>
         <child>
-          <object class="GtkAlignment" id="alignment7">
+          <object class="GtkButton" id="ab_wizard_button">
+            <property name="label" translatable="yes">_Start AqBanking Wizard</property>
             <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="xscale">0</property>
-            <child>
-              <object class="GtkButton" id="ab_wizard_button">
-                <property name="label" translatable="yes">_Start AqBanking Wizard</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">True</property>
-                <property name="use_underline">True</property>
-                <signal name="clicked" handler="aai_wizard_button_clicked_cb" swapped="no"/>
-              </object>
-            </child>
+            <property name="can_focus">True</property>
+            <property name="receives_default">True</property>
+            <property name="halign">center</property>
+            <property name="use_underline">True</property>
+            <signal name="clicked" handler="aai_wizard_button_clicked_cb" swapped="no"/>
           </object>
           <packing>
-            <property name="expand">True</property>
-            <property name="fill">False</property>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
             <property name="position">1</property>
           </packing>
         </child>
@@ -87,88 +113,89 @@ Press "Cancel" if you do not wish to setup any Online Banking connection now.
       <packing>
         <property name="page_type">intro</property>
         <property name="title" translatable="yes">Start Online Banking Wizard</property>
+        <property name="complete">True</property>
+        <property name="has_padding">False</property>
       </packing>
     </child>
     <child>
       <object class="GtkBox" id="account_match_page">
         <property name="visible">True</property>
         <property name="can_focus">False</property>
+        <property name="margin_left">12</property>
         <property name="border_width">12</property>
         <property name="orientation">vertical</property>
+        <property name="spacing">12</property>
         <child>
-          <object class="GtkBox" id="vbox157">
+          <object class="GtkScrolledWindow" id="account_scrolledwindow">
             <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="orientation">vertical</property>
-            <property name="spacing">12</property>
+            <property name="can_focus">True</property>
+            <property name="shadow_type">in</property>
             <child>
-              <object class="GtkScrolledWindow" id="scrolledwindow25">
+              <object class="GtkTreeView" id="account_page_view">
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
-                <property name="shadow_type">in</property>
-                <child>
-                  <object class="GtkTreeView" id="account_page_view">
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="rules_hint">True</property>
-                    <child internal-child="selection">
-                      <object class="GtkTreeSelection"/>
-                    </child>
-                  </object>
+                <child internal-child="selection">
+                  <object class="GtkTreeSelection"/>
                 </child>
               </object>
-              <packing>
-                <property name="expand">True</property>
-                <property name="fill">True</property>
-                <property name="position">0</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkLabel" id="label828">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="label" translatable="yes">Double Click on the line of an Online Banking account name if you want to match it to a GnuCash account. Click "Next" when all desired accounts are matching.</property>
-                <property name="wrap">True</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">1</property>
-              </packing>
             </child>
           </object>
           <packing>
-            <property name="expand">True</property>
+            <property name="expand">False</property>
             <property name="fill">True</property>
             <property name="position">0</property>
           </packing>
         </child>
+        <child>
+          <object class="GtkLabel" id="account_label">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="label" translatable="yes">Double Click on the line of an Online Banking account name if you want to match it to a GnuCash account. Click "Next" when all desired accounts are matching.</property>
+            <property name="wrap">True</property>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
       </object>
       <packing>
         <property name="title" translatable="yes">Match Online accounts with GnuCash accounts</property>
+        <property name="has_padding">False</property>
       </packing>
     </child>
     <child>
-      <object class="GtkLabel" id="finish_page">
+      <object class="GtkBox" id="finish_page">
         <property name="visible">True</property>
         <property name="can_focus">False</property>
-        <property name="label" translatable="yes">The setup for matching Online Banking accounts to GnuCash accounts is now finished. You can now invoke Online Banking actions on those accounts.
+        <property name="border_width">12</property>
+        <property name="orientation">vertical</property>
+        <property name="spacing">12</property>
+        <child>
+          <object class="GtkLabel" id="finish_label">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="label" translatable="yes">The setup for matching Online Banking accounts to GnuCash accounts is now finished. You can now invoke Online Banking actions on those accounts.
 
 If you want to add another bank, user, or account, you can start this assistant again anytime.
 
 Press "Apply" now.</property>
-        <property name="wrap">True</property>
+            <property name="wrap">True</property>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
       </object>
       <packing>
         <property name="page_type">confirm</property>
         <property name="title" translatable="yes">Online Banking Setup Finished</property>
         <property name="complete">True</property>
+        <property name="has_padding">False</property>
       </packing>
     </child>
-    <child internal-child="action_area">
-      <object class="GtkBox">
-        <property name="can_focus">False</property>
-      </object>
-    </child>
   </object>
 </interface>

commit 584654327902e35c95c7745e9827b7829c56169a
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Fri May 10 11:55:40 2019 +0100

    Bug 797232 - Convert dialog-ab.glade to gtk3

diff --git a/gnucash/import-export/aqb/dialog-ab-daterange.c b/gnucash/import-export/aqb/dialog-ab-daterange.c
index 8604a83d5..2d56c6f3a 100644
--- a/gnucash/import-export/aqb/dialog-ab-daterange.c
+++ b/gnucash/import-export/aqb/dialog-ab-daterange.c
@@ -79,7 +79,7 @@ gnc_ab_enter_daterange(GtkWidget *parent,
     if (parent)
         gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(parent));
 
-    heading_label  = GTK_WIDGET(gtk_builder_get_object (builder, "heading_label"));
+    heading_label  = GTK_WIDGET(gtk_builder_get_object (builder, "date_heading_label"));
     first_button  = GTK_WIDGET(gtk_builder_get_object (builder, "first_button"));
     last_retrieval_button  = GTK_WIDGET(gtk_builder_get_object (builder, "last_retrieval_button"));
     info.enter_from_button  = GTK_WIDGET(gtk_builder_get_object (builder, "enter_from_button"));
diff --git a/gnucash/import-export/aqb/dialog-ab.glade b/gnucash/import-export/aqb/dialog-ab.glade
index 11afc3844..bb2f0f861 100644
--- a/gnucash/import-export/aqb/dialog-ab.glade
+++ b/gnucash/import-export/aqb/dialog-ab.glade
@@ -1,6 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.22.1 -->
 <interface>
-  <requires lib="gtk+" version="2.16"/>
+  <requires lib="gtk+" version="3.10"/>
   <object class="GtkDialog" id="aqbanking_connection_dialog">
     <property name="can_focus">False</property>
     <property name="border_width">5</property>
@@ -9,10 +10,14 @@
     <property name="default_height">420</property>
     <property name="type_hint">dialog</property>
     <signal name="delete-event" handler="ggg_delete_event_cb" swapped="no"/>
+    <child>
+      <placeholder/>
+    </child>
     <child internal-child="vbox">
       <object class="GtkBox" id="dialog-vbox9">
         <property name="visible">True</property>
         <property name="can_focus">False</property>
+        <property name="orientation">vertical</property>
         <property name="spacing">2</property>
         <child internal-child="action_area">
           <object class="GtkButtonBox" id="dialog-action_area9">
@@ -21,14 +26,13 @@
             <property name="layout_style">end</property>
             <child>
               <object class="GtkButton" id="abort_button">
-                <property name="label">gtk-cancel</property>
+                <property name="label">_Cancel</property>
                 <property name="visible">True</property>
                 <property name="sensitive">False</property>
                 <property name="can_focus">True</property>
                 <property name="can_default">True</property>
                 <property name="receives_default">True</property>
-                <property name="use_action_appearance">False</property>
-                <property name="use_stock">True</property>
+                <property name="use_underline">True</property>
                 <signal name="clicked" handler="ggg_abort_clicked_cb" swapped="no"/>
               </object>
               <packing>
@@ -39,13 +43,12 @@
             </child>
             <child>
               <object class="GtkButton" id="close_button">
-                <property name="label">gtk-close</property>
+                <property name="label">C_lose</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="can_default">True</property>
                 <property name="receives_default">True</property>
-                <property name="use_action_appearance">False</property>
-                <property name="use_stock">True</property>
+                <property name="use_underline">True</property>
                 <signal name="clicked" handler="ggg_close_clicked_cb" swapped="no"/>
               </object>
               <packing>
@@ -63,23 +66,25 @@
           </packing>
         </child>
         <child>
-          <object class="GtkVBox" id="vbox149">
+          <object class="GtkBox" id="vbox149">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
             <property name="border_width">5</property>
+            <property name="orientation">vertical</property>
             <property name="spacing">18</property>
             <child>
-              <object class="GtkVBox" id="vbox160">
+              <object class="GtkBox" id="vbox160">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
+                <property name="orientation">vertical</property>
                 <property name="spacing">6</property>
                 <child>
                   <object class="GtkLabel" id="label8877443">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="xalign">0</property>
                     <property name="label" translatable="yes"><b>Progress</b></property>
                     <property name="use_markup">True</property>
+                    <property name="xalign">0</property>
                   </object>
                   <packing>
                     <property name="expand">False</property>
@@ -88,114 +93,97 @@
                   </packing>
                 </child>
                 <child>
-                  <object class="GtkAlignment" id="alignment2">
+                  <object class="GtkGrid" id="entries_grid">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="left_padding">12</property>
+                    <property name="margin_left">12</property>
+                    <property name="row_spacing">6</property>
+                    <property name="column_spacing">12</property>
                     <child>
-                      <object class="GtkTable" id="entries_table">
+                      <object class="GtkLabel" id="label8877424">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
-                        <property name="n_rows">3</property>
-                        <property name="n_columns">2</property>
-                        <property name="column_spacing">12</property>
-                        <property name="row_spacing">6</property>
-                        <child>
-                          <object class="GtkLabel" id="label8877424">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <property name="xalign">0</property>
-                            <property name="label" translatable="yes">Current Job</property>
-                            <property name="justify">center</property>
-                          </object>
-                          <packing>
-                            <property name="x_options">GTK_FILL</property>
-                            <property name="y_options"></property>
-                          </packing>
-                        </child>
-                        <child>
-                          <object class="GtkEntry" id="top_entry">
-                            <property name="visible">True</property>
-                            <property name="can_focus">True</property>
-                            <property name="invisible_char">●</property>
-                            <property name="invisible_char_set">True</property>
-                            <property name="primary_icon_activatable">False</property>
-                            <property name="secondary_icon_activatable">False</property>
-                          </object>
-                          <packing>
-                            <property name="left_attach">1</property>
-                            <property name="right_attach">2</property>
-                            <property name="y_options"></property>
-                          </packing>
-                        </child>
-                        <child>
-                          <object class="GtkProgressBar" id="top_progress">
-                            <property name="visible">True</property>
-                            <property name="sensitive">False</property>
-                            <property name="can_focus">False</property>
-                            <property name="pulse_step">0.10000000149</property>
-                          </object>
-                          <packing>
-                            <property name="left_attach">1</property>
-                            <property name="right_attach">2</property>
-                            <property name="top_attach">1</property>
-                            <property name="bottom_attach">2</property>
-                            <property name="x_options">GTK_FILL</property>
-                            <property name="y_options"></property>
-                          </packing>
-                        </child>
-                        <child>
-                          <object class="GtkLabel" id="label8877426">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <property name="xalign">0</property>
-                            <property name="label" translatable="yes">Progress</property>
-                            <property name="justify">center</property>
-                          </object>
-                          <packing>
-                            <property name="top_attach">1</property>
-                            <property name="bottom_attach">2</property>
-                            <property name="x_options">GTK_FILL</property>
-                            <property name="y_options"></property>
-                          </packing>
-                        </child>
-                        <child>
-                          <object class="GtkLabel" id="label8877425">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <property name="xalign">0</property>
-                            <property name="label" translatable="yes">Current Action</property>
-                            <property name="justify">center</property>
-                          </object>
-                          <packing>
-                            <property name="top_attach">2</property>
-                            <property name="bottom_attach">3</property>
-                            <property name="x_options">GTK_FILL</property>
-                            <property name="y_options"></property>
-                          </packing>
-                        </child>
-                        <child>
-                          <object class="GtkEntry" id="second_entry">
-                            <property name="visible">True</property>
-                            <property name="can_focus">True</property>
-                            <property name="invisible_char">●</property>
-                            <property name="invisible_char_set">True</property>
-                            <property name="primary_icon_activatable">False</property>
-                            <property name="secondary_icon_activatable">False</property>
-                          </object>
-                          <packing>
-                            <property name="left_attach">1</property>
-                            <property name="right_attach">2</property>
-                            <property name="top_attach">2</property>
-                            <property name="bottom_attach">3</property>
-                            <property name="y_options"></property>
-                          </packing>
-                        </child>
+                        <property name="halign">start</property>
+                        <property name="label" translatable="yes">Current Job</property>
+                        <property name="justify">center</property>
+                        <property name="xalign">0</property>
                       </object>
+                      <packing>
+                        <property name="left_attach">0</property>
+                        <property name="top_attach">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkEntry" id="top_entry">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="hexpand">True</property>
+                        <property name="invisible_char">●</property>
+                        <property name="primary_icon_activatable">False</property>
+                        <property name="secondary_icon_activatable">False</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">1</property>
+                        <property name="top_attach">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkProgressBar" id="top_progress">
+                        <property name="visible">True</property>
+                        <property name="sensitive">False</property>
+                        <property name="can_focus">False</property>
+                        <property name="pulse_step">0.10000000149</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">1</property>
+                        <property name="top_attach">1</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="label8877426">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="halign">start</property>
+                        <property name="label" translatable="yes">Progress</property>
+                        <property name="justify">center</property>
+                        <property name="xalign">0</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">0</property>
+                        <property name="top_attach">1</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="label8877425">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="halign">start</property>
+                        <property name="label" translatable="yes">Current Action</property>
+                        <property name="justify">center</property>
+                        <property name="xalign">0</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">0</property>
+                        <property name="top_attach">2</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkEntry" id="second_entry">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="hexpand">True</property>
+                        <property name="invisible_char">●</property>
+                        <property name="primary_icon_activatable">False</property>
+                        <property name="secondary_icon_activatable">False</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">1</property>
+                        <property name="top_attach">2</property>
+                      </packing>
                     </child>
                   </object>
                   <packing>
-                    <property name="expand">True</property>
+                    <property name="expand">False</property>
                     <property name="fill">True</property>
                     <property name="position">1</property>
                   </packing>
@@ -208,17 +196,18 @@
               </packing>
             </child>
             <child>
-              <object class="GtkVBox" id="vbox162">
+              <object class="GtkBox" id="vbox162">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
+                <property name="orientation">vertical</property>
                 <property name="spacing">6</property>
                 <child>
                   <object class="GtkLabel" id="label8877444">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="xalign">0</property>
                     <property name="label" translatable="yes"><b>Log Messages</b></property>
                     <property name="use_markup">True</property>
+                    <property name="xalign">0</property>
                   </object>
                   <packing>
                     <property name="expand">False</property>
@@ -227,24 +216,18 @@
                   </packing>
                 </child>
                 <child>
-                  <object class="GtkAlignment" id="alignment1">
+                  <object class="GtkScrolledWindow" id="scrolledwindow30">
                     <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="left_padding">12</property>
+                    <property name="can_focus">True</property>
+                    <property name="margin_left">12</property>
+                    <property name="shadow_type">in</property>
                     <child>
-                      <object class="GtkScrolledWindow" id="scrolledwindow30">
+                      <object class="GtkTextView" id="log_text">
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
-                        <property name="shadow_type">in</property>
-                        <child>
-                          <object class="GtkTextView" id="log_text">
-                            <property name="visible">True</property>
-                            <property name="can_focus">True</property>
-                            <property name="editable">False</property>
-                            <property name="wrap_mode">word</property>
-                            <property name="accepts_tab">False</property>
-                          </object>
-                        </child>
+                        <property name="editable">False</property>
+                        <property name="wrap_mode">word</property>
+                        <property name="accepts_tab">False</property>
                       </object>
                     </child>
                   </object>
@@ -256,7 +239,7 @@
                 </child>
               </object>
               <packing>
-                <property name="expand">True</property>
+                <property name="expand">False</property>
                 <property name="fill">True</property>
                 <property name="position">1</property>
               </packing>
@@ -267,7 +250,7 @@
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="receives_default">False</property>
-                <property name="use_action_appearance">False</property>
+                <property name="halign">start</property>
                 <property name="use_underline">True</property>
                 <property name="active">True</property>
                 <property name="draw_indicator">True</property>
@@ -281,7 +264,7 @@
             </child>
           </object>
           <packing>
-            <property name="expand">True</property>
+            <property name="expand">False</property>
             <property name="fill">True</property>
             <property name="position">2</property>
           </packing>
@@ -289,8 +272,8 @@
       </object>
     </child>
     <action-widgets>
-      <action-widget response="0">abort_button</action-widget>
-      <action-widget response="0">close_button</action-widget>
+      <action-widget response="-6">abort_button</action-widget>
+      <action-widget response="-7">close_button</action-widget>
     </action-widgets>
   </object>
   <object class="GtkDialog" id="aqbanking_date_range_dialog">
@@ -298,10 +281,14 @@
     <property name="border_width">5</property>
     <property name="title" translatable="yes">Get Transactions Online</property>
     <property name="type_hint">dialog</property>
+    <child>
+      <placeholder/>
+    </child>
     <child internal-child="vbox">
       <object class="GtkBox" id="dialog-vbox1">
         <property name="visible">True</property>
         <property name="can_focus">False</property>
+        <property name="orientation">vertical</property>
         <property name="spacing">2</property>
         <child internal-child="action_area">
           <object class="GtkButtonBox" id="dialog-action_area1">
@@ -310,13 +297,12 @@
             <property name="layout_style">end</property>
             <child>
               <object class="GtkButton" id="cancel_button1">
-                <property name="label">gtk-cancel</property>
+                <property name="label">_Cancel</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="can_default">True</property>
                 <property name="receives_default">True</property>
-                <property name="use_action_appearance">False</property>
-                <property name="use_stock">True</property>
+                <property name="use_underline">True</property>
               </object>
               <packing>
                 <property name="expand">False</property>
@@ -326,13 +312,12 @@
             </child>
             <child>
               <object class="GtkButton" id="ok_button">
-                <property name="label">gtk-ok</property>
+                <property name="label">_OK</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="can_default">True</property>
                 <property name="receives_default">True</property>
-                <property name="use_action_appearance">False</property>
-                <property name="use_stock">True</property>
+                <property name="use_underline">True</property>
               </object>
               <packing>
                 <property name="expand">False</property>
@@ -349,13 +334,14 @@
           </packing>
         </child>
         <child>
-          <object class="GtkVBox" id="vbox152">
+          <object class="GtkBox" id="vbox152">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
             <property name="border_width">5</property>
+            <property name="orientation">vertical</property>
             <property name="spacing">18</property>
             <child>
-              <object class="GtkLabel" id="heading_label1">
+              <object class="GtkLabel" id="date_heading_label">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
                 <property name="label" translatable="yes">Date range of transactions to retrieve:</property>
@@ -369,17 +355,18 @@
               </packing>
             </child>
             <child>
-              <object class="GtkVBox" id="vbox163">
+              <object class="GtkBox" id="vbox163">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
+                <property name="orientation">vertical</property>
                 <property name="spacing">6</property>
                 <child>
                   <object class="GtkLabel" id="label8877445">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="xalign">0</property>
                     <property name="label" translatable="yes"><b>From</b></property>
                     <property name="use_markup">True</property>
+                    <property name="xalign">0</property>
                   </object>
                   <packing>
                     <property name="expand">False</property>
@@ -388,98 +375,90 @@
                   </packing>
                 </child>
                 <child>
-                  <object class="GtkAlignment" id="alignment9">
+                  <object class="GtkBox" id="vbox164">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="left_padding">12</property>
+                    <property name="margin_left">12</property>
+                    <property name="orientation">vertical</property>
+                    <property name="spacing">6</property>
                     <child>
-                      <object class="GtkVBox" id="vbox164">
+                      <object class="GtkRadioButton" id="first_button">
+                        <property name="label" translatable="yes">_Earliest possible date</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="receives_default">False</property>
+                        <property name="halign">start</property>
+                        <property name="use_underline">True</property>
+                        <property name="active">True</property>
+                        <property name="draw_indicator">True</property>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">False</property>
+                        <property name="position">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkRadioButton" id="last_retrieval_button">
+                        <property name="label" translatable="yes">_Last retrieval date</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="receives_default">False</property>
+                        <property name="halign">start</property>
+                        <property name="use_underline">True</property>
+                        <property name="draw_indicator">True</property>
+                        <property name="group">first_button</property>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">False</property>
+                        <property name="position">1</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkBox" id="hbox123">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
-                        <property name="spacing">6</property>
-                        <child>
-                          <object class="GtkRadioButton" id="first_button">
-                            <property name="label" translatable="yes">_Earliest possible date</property>
-                            <property name="visible">True</property>
-                            <property name="can_focus">True</property>
-                            <property name="receives_default">False</property>
-                            <property name="use_action_appearance">False</property>
-                            <property name="use_underline">True</property>
-                            <property name="active">True</property>
-                            <property name="draw_indicator">True</property>
-                          </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                            <property name="position">0</property>
-                          </packing>
-                        </child>
+                        <property name="spacing">12</property>
                         <child>
-                          <object class="GtkRadioButton" id="last_retrieval_button">
-                            <property name="label" translatable="yes">_Last retrieval date</property>
+                          <object class="GtkRadioButton" id="enter_from_button">
+                            <property name="label" translatable="yes">E_nter date:</property>
                             <property name="visible">True</property>
                             <property name="can_focus">True</property>
                             <property name="receives_default">False</property>
-                            <property name="use_action_appearance">False</property>
+                            <property name="halign">start</property>
                             <property name="use_underline">True</property>
                             <property name="draw_indicator">True</property>
                             <property name="group">first_button</property>
+                            <signal name="toggled" handler="ddr_toggled_cb" swapped="no"/>
                           </object>
                           <packing>
                             <property name="expand">False</property>
                             <property name="fill">False</property>
-                            <property name="position">1</property>
+                            <property name="position">0</property>
                           </packing>
                         </child>
                         <child>
-                          <object class="GtkHBox" id="hbox123">
+                          <object class="GtkBox" id="enter_from_box">
                             <property name="visible">True</property>
                             <property name="can_focus">False</property>
-                            <property name="spacing">12</property>
-                            <child>
-                              <object class="GtkRadioButton" id="enter_from_button">
-                                <property name="label" translatable="yes">E_nter date:</property>
-                                <property name="visible">True</property>
-                                <property name="can_focus">True</property>
-                                <property name="receives_default">False</property>
-                                <property name="use_action_appearance">False</property>
-                                <property name="use_underline">True</property>
-                                <property name="draw_indicator">True</property>
-                                <property name="group">first_button</property>
-                                <signal name="toggled" handler="ddr_toggled_cb" swapped="no"/>
-                              </object>
-                              <packing>
-                                <property name="expand">False</property>
-                                <property name="fill">False</property>
-                                <property name="position">0</property>
-                              </packing>
-                            </child>
-                            <child>
-                              <object class="GtkHBox" id="enter_from_box">
-                                <property name="visible">True</property>
-                                <property name="can_focus">False</property>
-                                <child>
-                                  <placeholder/>
-                                </child>
-                              </object>
-                              <packing>
-                                <property name="expand">True</property>
-                                <property name="fill">True</property>
-                                <property name="position">1</property>
-                              </packing>
-                            </child>
                           </object>
                           <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                            <property name="position">2</property>
+                            <property name="expand">True</property>
+                            <property name="fill">True</property>
+                            <property name="position">1</property>
                           </packing>
                         </child>
                       </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">False</property>
+                        <property name="position">2</property>
+                      </packing>
                     </child>
                   </object>
                   <packing>
-                    <property name="expand">True</property>
+                    <property name="expand">False</property>
                     <property name="fill">True</property>
                     <property name="position">1</property>
                   </packing>
@@ -492,17 +471,18 @@
               </packing>
             </child>
             <child>
-              <object class="GtkVBox" id="vbox165">
+              <object class="GtkBox" id="vbox165">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
+                <property name="orientation">vertical</property>
                 <property name="spacing">6</property>
                 <child>
                   <object class="GtkLabel" id="label8877446">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="xalign">0</property>
                     <property name="label" translatable="yes"><b>To</b></property>
                     <property name="use_markup">True</property>
+                    <property name="xalign">0</property>
                   </object>
                   <packing>
                     <property name="expand">False</property>
@@ -511,25 +491,45 @@
                   </packing>
                 </child>
                 <child>
-                  <object class="GtkAlignment" id="alignment10">
+                  <object class="GtkBox" id="vbox166">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="left_padding">12</property>
+                    <property name="margin_left">12</property>
+                    <property name="orientation">vertical</property>
+                    <property name="spacing">6</property>
                     <child>
-                      <object class="GtkVBox" id="vbox166">
+                      <object class="GtkRadioButton" id="now_button">
+                        <property name="label" translatable="yes">_Now</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="receives_default">False</property>
+                        <property name="halign">start</property>
+                        <property name="use_underline">True</property>
+                        <property name="active">True</property>
+                        <property name="draw_indicator">True</property>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">False</property>
+                        <property name="position">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkBox" id="hbox124">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
-                        <property name="spacing">6</property>
+                        <property name="spacing">12</property>
                         <child>
-                          <object class="GtkRadioButton" id="now_button">
-                            <property name="label" translatable="yes">_Now</property>
+                          <object class="GtkRadioButton" id="enter_to_button">
+                            <property name="label" translatable="yes">Ente_r date:</property>
                             <property name="visible">True</property>
                             <property name="can_focus">True</property>
                             <property name="receives_default">False</property>
-                            <property name="use_action_appearance">False</property>
+                            <property name="halign">start</property>
                             <property name="use_underline">True</property>
-                            <property name="active">True</property>
                             <property name="draw_indicator">True</property>
+                            <property name="group">now_button</property>
+                            <signal name="toggled" handler="ddr_toggled_cb" swapped="no"/>
                           </object>
                           <packing>
                             <property name="expand">False</property>
@@ -538,42 +538,9 @@
                           </packing>
                         </child>
                         <child>
-                          <object class="GtkHBox" id="hbox124">
+                          <object class="GtkBox" id="enter_to_box">
                             <property name="visible">True</property>
                             <property name="can_focus">False</property>
-                            <property name="spacing">12</property>
-                            <child>
-                              <object class="GtkRadioButton" id="enter_to_button">
-                                <property name="label" translatable="yes">Ente_r date:</property>
-                                <property name="visible">True</property>
-                                <property name="can_focus">True</property>
-                                <property name="receives_default">False</property>
-                                <property name="use_action_appearance">False</property>
-                                <property name="use_underline">True</property>
-                                <property name="draw_indicator">True</property>
-                                <property name="group">now_button</property>
-                                <signal name="toggled" handler="ddr_toggled_cb" swapped="no"/>
-                              </object>
-                              <packing>
-                                <property name="expand">False</property>
-                                <property name="fill">False</property>
-                                <property name="position">0</property>
-                              </packing>
-                            </child>
-                            <child>
-                              <object class="GtkHBox" id="enter_to_box">
-                                <property name="visible">True</property>
-                                <property name="can_focus">False</property>
-                                <child>
-                                  <placeholder/>
-                                </child>
-                              </object>
-                              <packing>
-                                <property name="expand">True</property>
-                                <property name="fill">True</property>
-                                <property name="position">1</property>
-                              </packing>
-                            </child>
                           </object>
                           <packing>
                             <property name="expand">True</property>
@@ -582,10 +549,15 @@
                           </packing>
                         </child>
                       </object>
+                      <packing>
+                        <property name="expand">True</property>
+                        <property name="fill">True</property>
+                        <property name="position">1</property>
+                      </packing>
                     </child>
                   </object>
                   <packing>
-                    <property name="expand">True</property>
+                    <property name="expand">False</property>
                     <property name="fill">True</property>
                     <property name="position">1</property>
                   </packing>
@@ -616,10 +588,14 @@
     <property name="border_width">5</property>
     <property name="title" translatable="yes">Enter Password</property>
     <property name="type_hint">dialog</property>
+    <child>
+      <placeholder/>
+    </child>
     <child internal-child="vbox">
       <object class="GtkBox" id="dialog-vbox3">
         <property name="visible">True</property>
         <property name="can_focus">False</property>
+        <property name="orientation">vertical</property>
         <child internal-child="action_area">
           <object class="GtkButtonBox" id="dialog-action_area3">
             <property name="visible">True</property>
@@ -627,13 +603,12 @@
             <property name="layout_style">end</property>
             <child>
               <object class="GtkButton" id="cancelbutton2">
-                <property name="label">gtk-cancel</property>
+                <property name="label">_Cancel</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="can_default">True</property>
                 <property name="receives_default">True</property>
-                <property name="use_action_appearance">False</property>
-                <property name="use_stock">True</property>
+                <property name="use_underline">True</property>
               </object>
               <packing>
                 <property name="expand">False</property>
@@ -643,13 +618,12 @@
             </child>
             <child>
               <object class="GtkButton" id="okbutton2">
-                <property name="label">gtk-ok</property>
+                <property name="label">_OK</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="can_default">True</property>
                 <property name="receives_default">True</property>
-                <property name="use_action_appearance">False</property>
-                <property name="use_stock">True</property>
+                <property name="use_underline">True</property>
               </object>
               <packing>
                 <property name="expand">False</property>
@@ -666,10 +640,11 @@
           </packing>
         </child>
         <child>
-          <object class="GtkVBox" id="vbox167">
+          <object class="GtkBox" id="vbox167">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
             <property name="border_width">5</property>
+            <property name="orientation">vertical</property>
             <property name="spacing">18</property>
             <child>
               <object class="GtkLabel" id="heading_pw_label">
@@ -685,37 +660,35 @@
               </packing>
             </child>
             <child>
-              <object class="GtkTable" id="table7">
+              <object class="GtkGrid" id="grid1">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
-                <property name="n_rows">3</property>
-                <property name="n_columns">2</property>
-                <property name="column_spacing">12</property>
                 <property name="row_spacing">6</property>
+                <property name="column_spacing">12</property>
                 <child>
                   <object class="GtkLabel" id="label8877456">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="xalign">0</property>
+                    <property name="halign">start</property>
                     <property name="label" translatable="yes">Password:</property>
+                    <property name="xalign">0</property>
                   </object>
                   <packing>
-                    <property name="x_options">GTK_FILL</property>
-                    <property name="y_options"></property>
+                    <property name="left_attach">0</property>
+                    <property name="top_attach">0</property>
                   </packing>
                 </child>
                 <child>
                   <object class="GtkLabel" id="confirm_label">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="xalign">0</property>
+                    <property name="halign">start</property>
                     <property name="label" translatable="yes">Confirm Password:</property>
+                    <property name="xalign">0</property>
                   </object>
                   <packing>
+                    <property name="left_attach">0</property>
                     <property name="top_attach">1</property>
-                    <property name="bottom_attach">2</property>
-                    <property name="x_options">GTK_FILL</property>
-                    <property name="y_options"></property>
                   </packing>
                 </child>
                 <child>
@@ -724,14 +697,12 @@
                     <property name="can_focus">True</property>
                     <property name="visibility">False</property>
                     <property name="invisible_char">●</property>
-                    <property name="invisible_char_set">True</property>
                     <property name="primary_icon_activatable">False</property>
                     <property name="secondary_icon_activatable">False</property>
                   </object>
                   <packing>
                     <property name="left_attach">1</property>
-                    <property name="right_attach">2</property>
-                    <property name="y_options"></property>
+                    <property name="top_attach">0</property>
                   </packing>
                 </child>
                 <child>
@@ -740,16 +711,12 @@
                     <property name="can_focus">True</property>
                     <property name="visibility">False</property>
                     <property name="invisible_char">●</property>
-                    <property name="invisible_char_set">True</property>
                     <property name="primary_icon_activatable">False</property>
                     <property name="secondary_icon_activatable">False</property>
                   </object>
                   <packing>
                     <property name="left_attach">1</property>
-                    <property name="right_attach">2</property>
                     <property name="top_attach">1</property>
-                    <property name="bottom_attach">2</property>
-                    <property name="y_options"></property>
                   </packing>
                 </child>
                 <child>
@@ -761,21 +728,19 @@
                     <property name="has_tooltip">True</property>
                     <property name="tooltip_markup">If active, the PIN for HBCI/AqBanking actions will be remembered in memory during a session. Otherwise it will have to be entered again each time during a session when it is needed.</property>
                     <property name="tooltip_text" translatable="yes">If active, the PIN for HBCI/AqBanking actions will be remembered in memory during a session. Otherwise it will have to be entered again each time during a session when it is needed.</property>
-                    <property name="use_action_appearance">False</property>
+                    <property name="halign">start</property>
                     <property name="use_underline">True</property>
                     <property name="draw_indicator">True</property>
                   </object>
                   <packing>
-                    <property name="right_attach">2</property>
+                    <property name="left_attach">0</property>
                     <property name="top_attach">2</property>
-                    <property name="bottom_attach">3</property>
-                    <property name="x_options">GTK_FILL</property>
-                    <property name="y_options"></property>
+                    <property name="width">2</property>
                   </packing>
                 </child>
               </object>
               <packing>
-                <property name="expand">True</property>
+                <property name="expand">False</property>
                 <property name="fill">True</property>
                 <property name="position">1</property>
               </packing>
@@ -799,10 +764,14 @@
     <property name="border_width">5</property>
     <property name="title" translatable="yes">Name for new template</property>
     <property name="type_hint">dialog</property>
+    <child>
+      <placeholder/>
+    </child>
     <child internal-child="vbox">
       <object class="GtkBox" id="dialog-vbox2">
         <property name="visible">True</property>
         <property name="can_focus">False</property>
+        <property name="orientation">vertical</property>
         <child internal-child="action_area">
           <object class="GtkButtonBox" id="dialog-action_area2">
             <property name="visible">True</property>
@@ -810,13 +779,12 @@
             <property name="layout_style">end</property>
             <child>
               <object class="GtkButton" id="cancelbutton1">
-                <property name="label">gtk-cancel</property>
+                <property name="label">_Cancel</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="can_default">True</property>
                 <property name="receives_default">True</property>
-                <property name="use_action_appearance">False</property>
-                <property name="use_stock">True</property>
+                <property name="use_underline">True</property>
               </object>
               <packing>
                 <property name="expand">False</property>
@@ -826,14 +794,13 @@
             </child>
             <child>
               <object class="GtkButton" id="okbutton1">
-                <property name="label">gtk-ok</property>
+                <property name="label">_OK</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="can_default">True</property>
                 <property name="has_default">True</property>
                 <property name="receives_default">True</property>
-                <property name="use_action_appearance">False</property>
-                <property name="use_stock">True</property>
+                <property name="use_underline">True</property>
               </object>
               <packing>
                 <property name="expand">False</property>
@@ -850,10 +817,11 @@
           </packing>
         </child>
         <child>
-          <object class="GtkVBox" id="vbox159">
+          <object class="GtkBox" id="vbox159">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
             <property name="border_width">5</property>
+            <property name="orientation">vertical</property>
             <property name="spacing">12</property>
             <child>
               <object class="GtkLabel" id="label8877450">
@@ -874,7 +842,6 @@
                 <property name="max_length">250</property>
                 <property name="invisible_char">●</property>
                 <property name="activates_default">True</property>
-                <property name="invisible_char_set">True</property>
                 <property name="primary_icon_activatable">False</property>
                 <property name="secondary_icon_activatable">False</property>
               </object>
@@ -903,17 +870,82 @@
     <property name="border_width">5</property>
     <property name="title" translatable="yes">Online Transaction</property>
     <property name="type_hint">dialog</property>
+    <child>
+      <placeholder/>
+    </child>
     <child internal-child="vbox">
       <object class="GtkBox" id="dialog-vbox7">
         <property name="visible">True</property>
         <property name="can_focus">False</property>
         <property name="orientation">vertical</property>
         <property name="spacing">2</property>
+        <child internal-child="action_area">
+          <object class="GtkButtonBox" id="dialog-action_area7">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="layout_style">end</property>
+            <child>
+              <object class="GtkButton" id="exec_later_button">
+                <property name="label" translatable="yes">Execute _later (unimpl.)</property>
+                <property name="can_focus">True</property>
+                <property name="can_default">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_underline">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkButton" id="cancel_button">
+                <property name="label">_Cancel</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="can_default">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_underline">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkButton" id="exec_now_button">
+                <property name="label" translatable="yes">Execute _Now</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="can_default">True</property>
+                <property name="has_default">True</property>
+                <property name="receives_default">True</property>
+                <property name="has_tooltip">True</property>
+                <property name="tooltip_markup">Execute this online transaction now</property>
+                <property name="tooltip_text" translatable="yes">Execute this online transaction now</property>
+                <property name="use_underline">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">2</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="pack_type">end</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
         <child>
-          <object class="GtkVBox" id="trans_vbox">
+          <object class="GtkBox" id="trans_vbox">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
             <property name="border_width">5</property>
+            <property name="orientation">vertical</property>
             <child>
               <object class="GtkLabel" id="heading_label">
                 <property name="visible">True</property>
@@ -928,41 +960,38 @@
               </packing>
             </child>
             <child>
-              <object class="GtkTable" id="table6">
+              <object class="GtkGrid" id="grid">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
-                <property name="n_rows">21</property>
-                <property name="n_columns">3</property>
+                <property name="row_spacing">5</property>
+                <property name="column_spacing">12</property>
+                <property name="column_homogeneous">True</property>
                 <child>
                   <object class="GtkEntry" id="recp_account_entry">
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
                     <property name="max_length">12</property>
                     <property name="invisible_char">●</property>
-                    <property name="invisible_char_set">True</property>
                     <property name="primary_icon_activatable">False</property>
                     <property name="secondary_icon_activatable">False</property>
                     <signal name="changed" handler="gnc_ab_trans_dialog_verify_values" swapped="yes"/>
                     <signal name="insert-text" handler="gnc_ab_trans_dialog_ibanentry_filter_cb" swapped="no"/>
                   </object>
                   <packing>
+                    <property name="left_attach">0</property>
                     <property name="top_attach">3</property>
-                    <property name="bottom_attach">4</property>
-                    <property name="y_options"></property>
                   </packing>
                 </child>
                 <child>
                   <object class="GtkLabel" id="recp_account_heading">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="xalign">0</property>
                     <property name="label" translatable="yes">Recipient Account Number</property>
+                    <property name="xalign">0</property>
                   </object>
                   <packing>
+                    <property name="left_attach">0</property>
                     <property name="top_attach">2</property>
-                    <property name="bottom_attach">3</property>
-                    <property name="x_options">GTK_FILL</property>
-                    <property name="y_options"></property>
                   </packing>
                 </child>
                 <child>
@@ -971,33 +1000,25 @@
                     <property name="can_focus">True</property>
                     <property name="max_length">8</property>
                     <property name="invisible_char">●</property>
-                    <property name="invisible_char_set">True</property>
                     <property name="primary_icon_activatable">False</property>
                     <property name="secondary_icon_activatable">False</property>
                     <signal name="insert-text" handler="gnc_ab_trans_dialog_bicentry_filter_cb" swapped="no"/>
                   </object>
                   <packing>
-                    <property name="left_attach">2</property>
-                    <property name="right_attach">3</property>
+                    <property name="left_attach">1</property>
                     <property name="top_attach">3</property>
-                    <property name="bottom_attach">4</property>
-                    <property name="y_options"></property>
                   </packing>
                 </child>
                 <child>
                   <object class="GtkLabel" id="recp_bankcode_heading">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="xalign">0</property>
                     <property name="label" translatable="yes">Recipient Bank Code</property>
+                    <property name="xalign">0</property>
                   </object>
                   <packing>
-                    <property name="left_attach">2</property>
-                    <property name="right_attach">3</property>
+                    <property name="left_attach">1</property>
                     <property name="top_attach">2</property>
-                    <property name="bottom_attach">3</property>
-                    <property name="x_options">GTK_FILL</property>
-                    <property name="y_options"></property>
                   </packing>
                 </child>
                 <child>
@@ -1006,122 +1027,109 @@
                     <property name="can_focus">True</property>
                     <property name="max_length">27</property>
                     <property name="invisible_char">●</property>
-                    <property name="invisible_char_set">True</property>
                     <property name="primary_icon_activatable">False</property>
                     <property name="secondary_icon_activatable">False</property>
                     <signal name="changed" handler="gnc_ab_trans_dialog_verify_values" swapped="yes"/>
                   </object>
                   <packing>
-                    <property name="right_attach">3</property>
+                    <property name="left_attach">0</property>
                     <property name="top_attach">1</property>
-                    <property name="bottom_attach">2</property>
-                    <property name="y_options"></property>
+                    <property name="width">2</property>
                   </packing>
                 </child>
                 <child>
                   <object class="GtkLabel" id="recp_name_heading">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="xalign">0</property>
                     <property name="label" translatable="yes">Recipient Name</property>
                     <property name="justify">center</property>
+                    <property name="xalign">0</property>
                   </object>
                   <packing>
-                    <property name="right_attach">3</property>
-                    <property name="x_options">GTK_FILL</property>
-                    <property name="y_options"></property>
+                    <property name="left_attach">0</property>
+                    <property name="top_attach">0</property>
+                    <property name="width">2</property>
                   </packing>
                 </child>
                 <child>
                   <object class="GtkLabel" id="recp_bankname_heading">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="xalign">0</property>
                     <property name="label" translatable="yes">at Bank</property>
+                    <property name="xalign">0</property>
                   </object>
                   <packing>
-                    <property name="right_attach">3</property>
+                    <property name="left_attach">0</property>
                     <property name="top_attach">4</property>
-                    <property name="bottom_attach">5</property>
-                    <property name="x_options">GTK_FILL</property>
-                    <property name="y_options"></property>
+                    <property name="width">2</property>
                   </packing>
                 </child>
                 <child>
                   <object class="GtkLabel" id="recp_bankname_label">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="xalign">0</property>
                     <property name="label" translatable="yes">(filled in automatically)</property>
                     <property name="justify">center</property>
+                    <property name="xalign">0</property>
                   </object>
                   <packing>
-                    <property name="right_attach">3</property>
+                    <property name="left_attach">0</property>
                     <property name="top_attach">5</property>
-                    <property name="bottom_attach">6</property>
-                    <property name="x_options">GTK_FILL</property>
-                    <property name="y_options"></property>
+                    <property name="width">2</property>
                   </packing>
                 </child>
                 <child>
                   <object class="GtkLabel" id="label8877434">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="xalign">0</property>
                     <property name="label" translatable="yes">Amount</property>
                     <property name="justify">center</property>
+                    <property name="xalign">0</property>
                   </object>
                   <packing>
+                    <property name="left_attach">0</property>
                     <property name="top_attach">7</property>
-                    <property name="bottom_attach">8</property>
-                    <property name="x_options">GTK_FILL</property>
-                    <property name="y_options"></property>
+                    <property name="width">2</property>
                   </packing>
                 </child>
                 <child>
                   <object class="GtkLabel" id="label8877433">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="xalign">0</property>
                     <property name="label" translatable="yes">Payment Purpose (only for recipient)</property>
                     <property name="justify">center</property>
+                    <property name="xalign">0</property>
                   </object>
                   <packing>
-                    <property name="right_attach">3</property>
+                    <property name="left_attach">0</property>
                     <property name="top_attach">10</property>
-                    <property name="bottom_attach">11</property>
-                    <property name="x_options">GTK_FILL</property>
-                    <property name="y_options"></property>
+                    <property name="width">2</property>
                   </packing>
                 </child>
                 <child>
                   <object class="GtkLabel" id="label8877435">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="xalign">0</property>
                     <property name="label" translatable="yes">Payment Purpose continued</property>
                     <property name="justify">center</property>
+                    <property name="xalign">0</property>
                   </object>
                   <packing>
-                    <property name="right_attach">3</property>
+                    <property name="left_attach">0</property>
                     <property name="top_attach">12</property>
-                    <property name="bottom_attach">13</property>
-                    <property name="x_options">GTK_FILL</property>
-                    <property name="y_options"></property>
+                    <property name="width">2</property>
                   </packing>
                 </child>
                 <child>
                   <object class="GtkLabel" id="orig_name_heading">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="xalign">0</property>
                     <property name="label" translatable="yes">Originator Name</property>
+                    <property name="xalign">0</property>
                   </object>
                   <packing>
+                    <property name="left_attach">0</property>
                     <property name="top_attach">15</property>
-                    <property name="bottom_attach">16</property>
-                    <property name="x_options">GTK_FILL</property>
-                    <property name="y_options"></property>
                   </packing>
                 </child>
                 <child>
@@ -1130,107 +1138,84 @@
                     <property name="can_focus">True</property>
                     <property name="max_length">54</property>
                     <property name="invisible_char">●</property>
-                    <property name="invisible_char_set">True</property>
                     <property name="primary_icon_activatable">False</property>
                     <property name="secondary_icon_activatable">False</property>
                   </object>
                   <packing>
+                    <property name="left_attach">0</property>
                     <property name="top_attach">16</property>
-                    <property name="bottom_attach">17</property>
-                    <property name="x_options">GTK_FILL</property>
-                    <property name="y_options"></property>
                   </packing>
                 </child>
                 <child>
                   <object class="GtkLabel" id="orig_bankname_heading">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="xalign">0</property>
                     <property name="label" translatable="yes">at Bank</property>
+                    <property name="xalign">0</property>
                   </object>
                   <packing>
+                    <property name="left_attach">0</property>
                     <property name="top_attach">17</property>
-                    <property name="bottom_attach">18</property>
-                    <property name="x_options">GTK_FILL</property>
-                    <property name="y_options"></property>
                   </packing>
                 </child>
                 <child>
                   <object class="GtkLabel" id="orig_bankname_label">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="xalign">0</property>
                     <property name="label" translatable="yes">something</property>
+                    <property name="xalign">0</property>
                   </object>
                   <packing>
+                    <property name="left_attach">0</property>
                     <property name="top_attach">18</property>
-                    <property name="bottom_attach">19</property>
-                    <property name="x_options">GTK_FILL</property>
-                    <property name="y_options"></property>
                   </packing>
                 </child>
                 <child>
                   <object class="GtkLabel" id="orig_account_heading">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="xalign">0</property>
                     <property name="label" translatable="yes">Originator Account Number</property>
+                    <property name="xalign">0</property>
                   </object>
                   <packing>
-                    <property name="left_attach">2</property>
-                    <property name="right_attach">3</property>
+                    <property name="left_attach">1</property>
                     <property name="top_attach">15</property>
-                    <property name="bottom_attach">16</property>
-                    <property name="x_options">GTK_FILL</property>
-                    <property name="y_options"></property>
                   </packing>
                 </child>
                 <child>
                   <object class="GtkLabel" id="orig_account_label">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="xalign">0</property>
                     <property name="label" translatable="yes">something</property>
+                    <property name="xalign">0</property>
                   </object>
                   <packing>
-                    <property name="left_attach">2</property>
-                    <property name="right_attach">3</property>
+                    <property name="left_attach">1</property>
                     <property name="top_attach">16</property>
-                    <property name="bottom_attach">17</property>
-                    <property name="x_options">GTK_FILL</property>
-                    <property name="y_options"></property>
                   </packing>
                 </child>
                 <child>
                   <object class="GtkLabel" id="orig_bankcode_heading">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="xalign">0</property>
                     <property name="label" translatable="yes">Bank Code</property>
+                    <property name="xalign">0</property>
                   </object>
                   <packing>
-                    <property name="left_attach">2</property>
-                    <property name="right_attach">3</property>
+                    <property name="left_attach">1</property>
                     <property name="top_attach">17</property>
-                    <property name="bottom_attach">18</property>
-                    <property name="x_options">GTK_FILL</property>
-                    <property name="y_options"></property>
                   </packing>
                 </child>
                 <child>
                   <object class="GtkLabel" id="orig_bankcode_label">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="xalign">0</property>
                     <property name="label" translatable="yes">something</property>
+                    <property name="xalign">0</property>
                   </object>
                   <packing>
-                    <property name="left_attach">2</property>
-                    <property name="right_attach">3</property>
+                    <property name="left_attach">1</property>
                     <property name="top_attach">18</property>
-                    <property name="bottom_attach">19</property>
-                    <property name="x_options">GTK_FILL</property>
-                    <property name="y_options"></property>
                   </packing>
                 </child>
                 <child>
@@ -1239,15 +1224,13 @@
                     <property name="can_focus">True</property>
                     <property name="max_length">27</property>
                     <property name="invisible_char">●</property>
-                    <property name="invisible_char_set">True</property>
                     <property name="primary_icon_activatable">False</property>
                     <property name="secondary_icon_activatable">False</property>
                     <signal name="changed" handler="gnc_ab_trans_dialog_verify_values" swapped="yes"/>
                   </object>
                   <packing>
+                    <property name="left_attach">0</property>
                     <property name="top_attach">11</property>
-                    <property name="bottom_attach">12</property>
-                    <property name="y_options"></property>
                   </packing>
                 </child>
                 <child>
@@ -1256,15 +1239,13 @@
                     <property name="can_focus">True</property>
                     <property name="max_length">27</property>
                     <property name="invisible_char">●</property>
-                    <property name="invisible_char_set">True</property>
                     <property name="primary_icon_activatable">False</property>
                     <property name="secondary_icon_activatable">False</property>
                     <signal name="changed" handler="gnc_ab_trans_dialog_verify_values" swapped="yes"/>
                   </object>
                   <packing>
+                    <property name="left_attach">0</property>
                     <property name="top_attach">13</property>
-                    <property name="bottom_attach">14</property>
-                    <property name="y_options"></property>
                   </packing>
                 </child>
                 <child>
@@ -1273,17 +1254,13 @@
                     <property name="can_focus">True</property>
                     <property name="max_length">27</property>
                     <property name="invisible_char">●</property>
-                    <property name="invisible_char_set">True</property>
                     <property name="primary_icon_activatable">False</property>
                     <property name="secondary_icon_activatable">False</property>
                     <signal name="changed" handler="gnc_ab_trans_dialog_verify_values" swapped="yes"/>
                   </object>
                   <packing>
-                    <property name="left_attach">2</property>
-                    <property name="right_attach">3</property>
+                    <property name="left_attach">1</property>
                     <property name="top_attach">11</property>
-                    <property name="bottom_attach">12</property>
-                    <property name="y_options"></property>
                   </packing>
                 </child>
                 <child>
@@ -1292,132 +1269,72 @@
                     <property name="can_focus">True</property>
                     <property name="max_length">27</property>
                     <property name="invisible_char">●</property>
-                    <property name="invisible_char_set">True</property>
                     <property name="primary_icon_activatable">False</property>
                     <property name="secondary_icon_activatable">False</property>
                     <signal name="changed" handler="gnc_ab_trans_dialog_verify_values" swapped="yes"/>
                   </object>
                   <packing>
-                    <property name="left_attach">2</property>
-                    <property name="right_attach">3</property>
+                    <property name="left_attach">1</property>
                     <property name="top_attach">13</property>
-                    <property name="bottom_attach">14</property>
-                    <property name="y_options"></property>
                   </packing>
                 </child>
                 <child>
-                  <object class="GtkHBox" id="amount_hbox">
+                  <object class="GtkBox" id="amount_hbox">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <child>
-                      <placeholder/>
-                    </child>
                   </object>
                   <packing>
+                    <property name="left_attach">0</property>
                     <property name="top_attach">8</property>
-                    <property name="bottom_attach">9</property>
-                    <property name="y_options"></property>
                   </packing>
                 </child>
                 <child>
-                  <object class="GtkHSeparator" id="hseparator8">
+                  <object class="GtkSeparator" id="hseparator8">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
                   </object>
                   <packing>
-                    <property name="right_attach">3</property>
+                    <property name="left_attach">0</property>
                     <property name="top_attach">19</property>
-                    <property name="bottom_attach">20</property>
-                    <property name="x_options">GTK_FILL</property>
-                    <property name="y_options"></property>
-                    <property name="y_padding">1</property>
+                    <property name="width">2</property>
                   </packing>
                 </child>
                 <child>
-                  <object class="GtkHSeparator" id="hseparator4">
+                  <object class="GtkSeparator" id="hseparator4">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
                   </object>
                   <packing>
-                    <property name="right_attach">3</property>
+                    <property name="left_attach">0</property>
                     <property name="top_attach">14</property>
-                    <property name="bottom_attach">15</property>
-                    <property name="x_options">GTK_FILL</property>
-                    <property name="y_options"></property>
+                    <property name="width">2</property>
                   </packing>
                 </child>
                 <child>
-                  <object class="GtkHSeparator" id="hseparator5">
+                  <object class="GtkSeparator" id="hseparator5">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
                   </object>
                   <packing>
-                    <property name="right_attach">3</property>
+                    <property name="left_attach">0</property>
                     <property name="top_attach">6</property>
-                    <property name="bottom_attach">7</property>
-                    <property name="x_options">GTK_FILL</property>
-                    <property name="y_options"></property>
-                    <property name="y_padding">1</property>
+                    <property name="width">2</property>
                   </packing>
                 </child>
                 <child>
-                  <object class="GtkHSeparator" id="hseparator6">
+                  <object class="GtkSeparator" id="hseparator6">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
                   </object>
                   <packing>
-                    <property name="right_attach">3</property>
+                    <property name="left_attach">0</property>
                     <property name="top_attach">9</property>
-                    <property name="bottom_attach">10</property>
-                    <property name="x_options">GTK_FILL</property>
-                    <property name="y_options"></property>
+                    <property name="width">2</property>
                   </packing>
                 </child>
                 <child>
                   <placeholder/>
                 </child>
-                <child>
-                  <placeholder/>
-                </child>
-                <child>
-                  <placeholder/>
-                </child>
-                <child>
-                  <placeholder/>
-                </child>
-                <child>
-                  <placeholder/>
-                </child>
-                <child>
-                  <placeholder/>
-                </child>
-                <child>
-                  <placeholder/>
-                </child>
-                <child>
-                  <placeholder/>
-                </child>
-                <child>
-                  <placeholder/>
-                </child>
-                <child>
-                  <placeholder/>
-                </child>
-                <child>
-                  <placeholder/>
-                </child>
-                <child>
-                  <placeholder/>
-                </child>
-                <child>
-                  <placeholder/>
-                </child>
-                <child>
-                  <placeholder/>
-                </child>
-                <child>
-                  <placeholder/>
-                </child>
               </object>
               <packing>
                 <property name="expand">True</property>
@@ -1430,65 +1347,27 @@
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <child>
-                  <object class="GtkHBox" id="hbox117">
+                  <object class="GtkBox" id="hbox117">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
                     <property name="spacing">4</property>
                     <child>
-                      <object class="GtkVButtonBox" id="vbutonbox158">
+                      <object class="GtkButtonBox" id="vbutonbox158">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
+                        <property name="orientation">vertical</property>
                         <property name="homogeneous">True</property>
                         <child>
                           <object class="GtkButton" id="add_templ_button">
+                            <property name="label" translatable="yes">_Add current</property>
                             <property name="visible">True</property>
                             <property name="can_focus">True</property>
                             <property name="receives_default">True</property>
                             <property name="has_tooltip">True</property>
                             <property name="tooltip_markup">Add the current online transaction as a new transaction template</property>
                             <property name="tooltip_text" translatable="yes">Add the current online transaction as a new transaction template</property>
-                            <property name="use_action_appearance">False</property>
+                            <property name="use_underline">True</property>
                             <signal name="clicked" handler="gnc_ab_trans_dialog_add_templ_cb" swapped="no"/>
-                            <child>
-                              <object class="GtkAlignment" id="alignment3">
-                                <property name="visible">True</property>
-                                <property name="can_focus">False</property>
-                                <property name="xscale">0</property>
-                                <property name="yscale">0</property>
-                                <child>
-                                  <object class="GtkHBox" id="hbox119">
-                                    <property name="visible">True</property>
-                                    <property name="can_focus">False</property>
-                                    <property name="spacing">2</property>
-                                    <child>
-                                      <object class="GtkImage" id="image1">
-                                        <property name="visible">True</property>
-                                        <property name="can_focus">False</property>
-                                        <property name="stock">gtk-add</property>
-                                      </object>
-                                      <packing>
-                                        <property name="expand">False</property>
-                                        <property name="fill">False</property>
-                                        <property name="position">0</property>
-                                      </packing>
-                                    </child>
-                                    <child>
-                                      <object class="GtkLabel" id="label8877451">
-                                        <property name="visible">True</property>
-                                        <property name="can_focus">False</property>
-                                        <property name="label" translatable="yes">Add current</property>
-                                        <property name="use_underline">True</property>
-                                      </object>
-                                      <packing>
-                                        <property name="expand">False</property>
-                                        <property name="fill">False</property>
-                                        <property name="position">1</property>
-                                      </packing>
-                                    </child>
-                                  </object>
-                                </child>
-                              </object>
-                            </child>
                           </object>
                           <packing>
                             <property name="expand">False</property>
@@ -1498,15 +1377,14 @@
                         </child>
                         <child>
                           <object class="GtkButton" id="moveup_templ_button">
-                            <property name="label">gtk-go-up</property>
+                            <property name="label">_Up</property>
                             <property name="visible">True</property>
                             <property name="can_focus">True</property>
                             <property name="receives_default">True</property>
                             <property name="has_tooltip">True</property>
                             <property name="tooltip_markup">Move the selected transaction template one row up</property>
                             <property name="tooltip_text" translatable="yes">Move the selected transaction template one row up</property>
-                            <property name="use_action_appearance">False</property>
-                            <property name="use_stock">True</property>
+                            <property name="use_underline">True</property>
                             <signal name="clicked" handler="gnc_ab_trans_dialog_moveup_templ_cb" swapped="no"/>
                           </object>
                           <packing>
@@ -1517,15 +1395,14 @@
                         </child>
                         <child>
                           <object class="GtkButton" id="movedown_templ_button">
-                            <property name="label">gtk-go-down</property>
+                            <property name="label">_Down</property>
                             <property name="visible">True</property>
                             <property name="can_focus">True</property>
                             <property name="receives_default">True</property>
                             <property name="has_tooltip">True</property>
                             <property name="tooltip_markup">Move the selected transaction template one row down</property>
                             <property name="tooltip_text" translatable="yes">Move the selected transaction template one row down</property>
-                            <property name="use_action_appearance">False</property>
-                            <property name="use_stock">True</property>
+                            <property name="use_underline">True</property>
                             <signal name="clicked" handler="gnc_ab_trans_dialog_movedown_templ_cb" swapped="no"/>
                           </object>
                           <packing>
@@ -1536,54 +1413,15 @@
                         </child>
                         <child>
                           <object class="GtkButton" id="sort_templ_button">
+                            <property name="label" translatable="yes">_Sort</property>
                             <property name="visible">True</property>
                             <property name="can_focus">True</property>
                             <property name="receives_default">True</property>
                             <property name="has_tooltip">True</property>
                             <property name="tooltip_markup">Sort the list of transaction templates alphabetically</property>
                             <property name="tooltip_text" translatable="yes">Sort the list of transaction templates alphabetically</property>
-                            <property name="use_action_appearance">False</property>
+                            <property name="use_underline">True</property>
                             <signal name="clicked" handler="gnc_ab_trans_dialog_sort_templ_cb" swapped="no"/>
-                            <child>
-                              <object class="GtkAlignment" id="alignment4">
-                                <property name="visible">True</property>
-                                <property name="can_focus">False</property>
-                                <property name="xscale">0</property>
-                                <property name="yscale">0</property>
-                                <child>
-                                  <object class="GtkHBox" id="hbox120">
-                                    <property name="visible">True</property>
-                                    <property name="can_focus">False</property>
-                                    <property name="spacing">2</property>
-                                    <child>
-                                      <object class="GtkImage" id="image2">
-                                        <property name="visible">True</property>
-                                        <property name="can_focus">False</property>
-                                        <property name="stock">gtk-sort-ascending</property>
-                                      </object>
-                                      <packing>
-                                        <property name="expand">False</property>
-                                        <property name="fill">False</property>
-                                        <property name="position">0</property>
-                                      </packing>
-                                    </child>
-                                    <child>
-                                      <object class="GtkLabel" id="label8877452">
-                                        <property name="visible">True</property>
-                                        <property name="can_focus">False</property>
-                                        <property name="label" translatable="yes">Sort</property>
-                                        <property name="use_underline">True</property>
-                                      </object>
-                                      <packing>
-                                        <property name="expand">False</property>
-                                        <property name="fill">False</property>
-                                        <property name="position">1</property>
-                                      </packing>
-                                    </child>
-                                  </object>
-                                </child>
-                              </object>
-                            </child>
                           </object>
                           <packing>
                             <property name="expand">False</property>
@@ -1593,15 +1431,14 @@
                         </child>
                         <child>
                           <object class="GtkButton" id="del_templ_button">
-                            <property name="label">gtk-delete</property>
+                            <property name="label">D_elete</property>
                             <property name="visible">True</property>
                             <property name="can_focus">True</property>
                             <property name="receives_default">True</property>
                             <property name="has_tooltip">True</property>
                             <property name="tooltip_markup">Delete the currently selected transaction template</property>
                             <property name="tooltip_text" translatable="yes">Delete the currently selected transaction template</property>
-                            <property name="use_action_appearance">False</property>
-                            <property name="use_stock">True</property>
+                            <property name="use_underline">True</property>
                             <signal name="clicked" handler="gnc_ab_trans_dialog_del_templ_cb" swapped="no"/>
                           </object>
                           <packing>
@@ -1660,7 +1497,7 @@
               </packing>
             </child>
             <child>
-              <object class="GtkHSeparator" id="hseparator7">
+              <object class="GtkSeparator" id="hseparator7">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
               </object>
@@ -1677,108 +1514,6 @@
             <property name="position">0</property>
           </packing>
         </child>
-        <child internal-child="action_area">
-          <object class="GtkButtonBox" id="dialog-action_area7">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="layout_style">end</property>
-            <child>
-              <object class="GtkButton" id="exec_later_button">
-                <property name="label" translatable="yes">Execute later (unimpl.)</property>
-                <property name="can_focus">True</property>
-                <property name="can_default">True</property>
-                <property name="receives_default">True</property>
-                <property name="use_action_appearance">False</property>
-                <property name="use_underline">True</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">0</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkButton" id="cancel_button">
-                <property name="label">gtk-cancel</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="can_default">True</property>
-                <property name="receives_default">True</property>
-                <property name="use_action_appearance">False</property>
-                <property name="use_stock">True</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">1</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkButton" id="exec_now_button">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="can_default">True</property>
-                <property name="has_default">True</property>
-                <property name="receives_default">True</property>
-                <property name="has_tooltip">True</property>
-                <property name="tooltip_markup">Execute this online transaction now</property>
-                <property name="tooltip_text" translatable="yes">Execute this online transaction now</property>
-                <property name="use_action_appearance">False</property>
-                <child>
-                  <object class="GtkAlignment" id="alignment6">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="xscale">0</property>
-                    <property name="yscale">0</property>
-                    <child>
-                      <object class="GtkHBox" id="hbox122">
-                        <property name="visible">True</property>
-                        <property name="can_focus">False</property>
-                        <property name="spacing">2</property>
-                        <child>
-                          <object class="GtkImage" id="image4">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <property name="stock">gtk-execute</property>
-                          </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                            <property name="position">0</property>
-                          </packing>
-                        </child>
-                        <child>
-                          <object class="GtkLabel" id="label8877454">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <property name="label" translatable="yes">Execute Now</property>
-                            <property name="use_underline">True</property>
-                          </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                            <property name="position">1</property>
-                          </packing>
-                        </child>
-                      </object>
-                    </child>
-                  </object>
-                </child>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">2</property>
-              </packing>
-            </child>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">True</property>
-            <property name="pack_type">end</property>
-            <property name="position">1</property>
-          </packing>
-        </child>
       </object>
     </child>
     <action-widgets>
@@ -1788,4 +1523,3 @@
     </action-widgets>
   </object>
 </interface>
-
diff --git a/gnucash/import-export/aqb/gnc-gwen-gui.c b/gnucash/import-export/aqb/gnc-gwen-gui.c
index 94ef52b05..d3c9fe012 100644
--- a/gnucash/import-export/aqb/gnc-gwen-gui.c
+++ b/gnucash/import-export/aqb/gnc-gwen-gui.c
@@ -238,7 +238,7 @@ struct _GncGWENGui
     GtkWidget *dialog;
 
     /* Progress bars */
-    GtkWidget *entries_table;
+    GtkWidget *entries_grid;
     GtkWidget *top_entry;
     GtkWidget *top_progress;
     GtkWidget *second_entry;
@@ -531,7 +531,7 @@ setup_dialog(GncGWENGui *gui)
 
     gui->dialog = GTK_WIDGET(gtk_builder_get_object (builder, "aqbanking_connection_dialog"));
 
-    gui->entries_table = GTK_WIDGET(gtk_builder_get_object (builder, "entries_table"));
+    gui->entries_grid = GTK_WIDGET(gtk_builder_get_object (builder, "entries_grid"));
     gui->top_entry = GTK_WIDGET(gtk_builder_get_object (builder, "top_entry"));
     gui->top_progress = GTK_WIDGET(gtk_builder_get_object (builder, "top_progress"));
     gui->second_entry = GTK_WIDGET(gtk_builder_get_object (builder, "second_entry"));
@@ -604,8 +604,8 @@ reset_dialog(GncGWENGui *gui)
 
     if (gui->other_entries_box)
     {
-        gtk_table_resize(GTK_TABLE(gui->entries_table),
-                         OTHER_ENTRIES_ROW_OFFSET, 2);
+        gtk_grid_remove_row (GTK_GRID(gui->entries_grid),
+                             OTHER_ENTRIES_ROW_OFFSET);
         gtk_widget_destroy(gui->other_entries_box);
         gui->other_entries_box = NULL;
     }
@@ -806,11 +806,8 @@ show_progress(GncGWENGui *gui, Progress *progress)
             gtk_widget_show(entry);
             if (new_box)
             {
-                gtk_table_resize(GTK_TABLE(gui->entries_table),
-                                 OTHER_ENTRIES_ROW_OFFSET + 1, 2);
-                gtk_table_attach_defaults(
-                    GTK_TABLE(gui->entries_table), box, 1, 2,
-                    OTHER_ENTRIES_ROW_OFFSET, OTHER_ENTRIES_ROW_OFFSET + 1);
+                gtk_grid_attach (GTK_GRID(gui->entries_grid), box,
+                                 1, OTHER_ENTRIES_ROW_OFFSET, 1, 1);
                 gtk_widget_show(box);
             }
         }
@@ -885,8 +882,8 @@ hide_progress(GncGWENGui *gui, Progress *progress)
             else
             {
                 /* Last other progress to be hided */
-                gtk_table_resize(GTK_TABLE(gui->entries_table),
-                                 OTHER_ENTRIES_ROW_OFFSET, 2);
+                gtk_grid_remove_row (GTK_GRID(gui->entries_grid),
+                                     OTHER_ENTRIES_ROW_OFFSET);
                 gtk_widget_destroy(box);
                 gui->other_entries_box = NULL;
             }

commit d624894099063181bf724432d30242876e4326c3
Author: John Ralls <jralls at ceridwen.us>
Date:   Thu May 9 19:33:08 2019 -0500

    Bug 797186 - gtk crash closing parent window edit->stylesheets
    
    Free then NULL, not the other way around.

diff --git a/gnucash/report/report-gnome/dialog-report-style-sheet.c b/gnucash/report/report-gnome/dialog-report-style-sheet.c
index 148cd7b60..2c20f7b01 100644
--- a/gnucash/report/report-gnome/dialog-report-style-sheet.c
+++ b/gnucash/report/report-gnome/dialog-report-style-sheet.c
@@ -390,8 +390,8 @@ gnc_style_sheet_select_dialog_response_cb (GtkDialog *unused,
 
     case GTK_RESPONSE_CLOSE:
     default:
-        gnc_style_sheet_dialog = NULL;
         gtk_widget_destroy(ss->toplevel);
+        gnc_style_sheet_dialog = NULL;
         g_free(ss);
         break;
     }

commit 7b6b86000dd0894ecb75e52fe9810be6feb93763
Author: Christopher Zimmermann <christopher at gmerlin.de>
Date:   Thu May 9 19:13:41 2019 -0500

    Bug 797230 - Use after free in
    
    gnucash__sheet_style_destroy.

diff --git a/gnucash/register/register-gnome/gnucash-style.c b/gnucash/register/register-gnome/gnucash-style.c
index f2a04fbdf..37fa3f0af 100644
--- a/gnucash/register/register-gnome/gnucash-style.c
+++ b/gnucash/register/register-gnome/gnucash-style.c
@@ -709,9 +709,9 @@ gnucash_sheet_style_destroy (GnucashSheet *sheet, SheetBlockStyle *style)
 
     if (style->dimensions->refcount == 0)
     {
+        style_dimensions_destroy (style->dimensions);
         g_hash_table_remove (sheet->dimensions_hash_table,
                              style_get_key (style));
-        style_dimensions_destroy (style->dimensions);
     }
 
     g_free (style);

commit 48c3c8bc511f181f5de90ea079ec20d5c6dd2a0e
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Tue May 7 20:34:55 2019 +0800

    [commodity-utils] partially revert eac79bd506395120
    
    The eac79bd506395120 commit was slightly overzealous - if pair was #f,
    originally this make-exchange-function would create a function that
    returns (gnc:make-gnc-monetary domestic 0); I thought it was
    acceptable to return #f instead but this would lead to report
    crash. Revert previous behaviour.

diff --git a/gnucash/report/report-system/commodity-utilities.scm b/gnucash/report/report-system/commodity-utilities.scm
index a0877a1c5..65c203259 100644
--- a/gnucash/report/report-system/commodity-utilities.scm
+++ b/gnucash/report/report-system/commodity-utilities.scm
@@ -698,10 +698,11 @@ construct with gnc:make-gnc-monetary and gnc:monetary->string instead.")
              (gnc:exchange-if-same foreign domestic)
              (let* ((foreign-comm (gnc:gnc-monetary-commodity foreign))
                     (pair (assoc foreign-comm exchange-alist)))
-               (and pair
-                    (gnc:make-gnc-monetary
-                     domestic
-                     (* (gnc:gnc-monetary-amount foreign) (cadr pair)))))))))
+               (gnc:make-gnc-monetary
+                domestic
+                (if pair
+                    (* (gnc:gnc-monetary-amount foreign) (cadr pair))
+                    0)))))))
 
 ;; Helper for the gnc:exchange-by-pricalist* below. Exchange the
 ;; <gnc:monetary> 'foreign' into the <gnc:commodity*> 'domestic' by

commit 810d283e73e80d2d4f80de28477857eb820c4eea
Author: John Ralls <jralls at ceridwen.us>
Date:   Mon May 6 21:41:17 2019 -0700

    "Second fix, revert extraneous change in prior fix."

diff --git a/gnucash/gnome-utils/gnc-cell-renderer-popup.c b/gnucash/gnome-utils/gnc-cell-renderer-popup.c
index 6d3d9f093..7ba11429c 100644
--- a/gnucash/gnome-utils/gnc-cell-renderer-popup.c
+++ b/gnucash/gnome-utils/gnc-cell-renderer-popup.c
@@ -271,13 +271,10 @@ gcrp_show_popup (GncCellRendererPopup *cell,
 		 gint                 y2)
 {
 #if GTK_CHECK_VERSION(3,22,0)
-        GdkMonitor *mon;
-#else
-        GdkScreen *screen;
-        int monitor_num;
-#endif
         GdkWindow *win;
+        GdkMonitor *mon;
         GdkRectangle monitor_size;
+#endif
 	GtkAllocation alloc;
 	gint          x, y;
 	gint          screen_height, screen_width;
@@ -300,19 +297,18 @@ gcrp_show_popup (GncCellRendererPopup *cell,
 
 	button_height = y2 - y1;
 
-        win = gtk_widget_get_window (cell->popup_window);
 #if GTK_CHECK_VERSION(3,22,0)
-        mon = gdk_display_get_monitor_at_window (gtk_widget_get_display (cell->popup_window), win);
+        win = gdk_screen_get_root_window (gtk_window_get_screen (GTK_WINDOW (cell->popup_window)));
+        mon = gdk_display_get_monitor_at_window (gtk_widget_get_display (GTK_WIDGET(cell->popup_window)), win);
         gdk_monitor_get_geometry (mon, &monitor_size);
 
-#else
-        screen = gtk_window_get_screen (cell->popup_window);
-        monitor_num = gdk_screen_get_monitor_at_window (screen, win);
-        gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor_size);
-#endif
         screen_width = monitor_size.width;
         screen_height = monitor_size.height - y;
-
+#else
+        screen_width = gdk_screen_width();
+        screen_height = gdk_screen_height() - y;
+#endif
+	
 	/* Check if it fits in the available height. */
 	if (alloc.height > screen_height) {
 		/* It doesn't fit, so we see if we have the minimum space needed. */

commit eec00c8a3fbadaaf1874a6cd02e6f6cd3286ec6d
Author: John Ralls <jralls at ceridwen.us>
Date:   Mon May 6 21:17:54 2019 -0700

    Fix Travis failure.

diff --git a/gnucash/gnome-utils/gnc-cell-renderer-popup.c b/gnucash/gnome-utils/gnc-cell-renderer-popup.c
index 7ba11429c..6d3d9f093 100644
--- a/gnucash/gnome-utils/gnc-cell-renderer-popup.c
+++ b/gnucash/gnome-utils/gnc-cell-renderer-popup.c
@@ -271,10 +271,13 @@ gcrp_show_popup (GncCellRendererPopup *cell,
 		 gint                 y2)
 {
 #if GTK_CHECK_VERSION(3,22,0)
-        GdkWindow *win;
         GdkMonitor *mon;
-        GdkRectangle monitor_size;
+#else
+        GdkScreen *screen;
+        int monitor_num;
 #endif
+        GdkWindow *win;
+        GdkRectangle monitor_size;
 	GtkAllocation alloc;
 	gint          x, y;
 	gint          screen_height, screen_width;
@@ -297,18 +300,19 @@ gcrp_show_popup (GncCellRendererPopup *cell,
 
 	button_height = y2 - y1;
 
+        win = gtk_widget_get_window (cell->popup_window);
 #if GTK_CHECK_VERSION(3,22,0)
-        win = gdk_screen_get_root_window (gtk_window_get_screen (GTK_WINDOW (cell->popup_window)));
-        mon = gdk_display_get_monitor_at_window (gtk_widget_get_display (GTK_WIDGET(cell->popup_window)), win);
+        mon = gdk_display_get_monitor_at_window (gtk_widget_get_display (cell->popup_window), win);
         gdk_monitor_get_geometry (mon, &monitor_size);
 
-        screen_width = monitor_size.width;
-        screen_height = monitor_size.height - y;
 #else
-        screen_width = gdk_screen_width();
-        screen_height = gdk_screen_height() - y;
+        screen = gtk_window_get_screen (cell->popup_window);
+        monitor_num = gdk_screen_get_monitor_at_window (screen, win);
+        gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor_size);
 #endif
-	
+        screen_width = monitor_size.width;
+        screen_height = monitor_size.height - y;
+
 	/* Check if it fits in the available height. */
 	if (alloc.height > screen_height) {
 		/* It doesn't fit, so we see if we have the minimum space needed. */
diff --git a/gnucash/gnome/dialog-invoice.c b/gnucash/gnome/dialog-invoice.c
index cd3f6ceed..11db30780 100644
--- a/gnucash/gnome/dialog-invoice.c
+++ b/gnucash/gnome/dialog-invoice.c
@@ -1932,7 +1932,7 @@ gnc_invoice_update_window (InvoiceWindow *iw, GtkWidget *widget)
         /* Setup viewer for read-only access */
         gtk_widget_set_sensitive (acct_entry, FALSE);
         gtk_widget_set_sensitive (iw->id_entry, FALSE);
-        gtk_widget_set_selectable (iw->id_entry, TRUE);
+        gtk_widget_set_sensitive (iw->id_entry, TRUE);
         gtk_widget_set_sensitive (iw->terms_menu, FALSE);
         gtk_widget_set_sensitive (iw->owner_box, FALSE);
         gtk_widget_set_sensitive (iw->job_box, FALSE);

commit f1fe106d5c5a219f248b53fbf374e3c1cee09631
Author: Frank H. Ellenberger <frank.h.ellenberger at gmail.com>
Date:   Mon May 6 19:35:27 2019 +0200

    de.po: Remove forgotten fuzzy flag from "Issue _SEPA Transaction..."
    
    5219 übersetzte Meldungen, 39 ungenaue Übersetzungen, 2 unübersetzte
    Meldungen.
    
    https://lists.gnucash.org/pipermail/gnucash-de/2019-May/010593.html

diff --git a/po/de.po b/po/de.po
index afa010464..e6ed27109 100644
--- a/po/de.po
+++ b/po/de.po
@@ -19121,7 +19121,6 @@ msgstr "Kontoumsätze online abfragen via HBCI/Onlinebanking"
 
 #. Translators: https://en.wikipedia.org/wiki/Single_Euro_Payments_Area
 #: gnucash/import-export/aqb/gnc-plugin-aqbanking.c:113
-#, fuzzy
 msgid "Issue _SEPA Transaction..."
 msgstr "SE_PA Einzelüberweisung..."
 

commit 0cb60dd224a97b6d54e874fce3c46d122eb3defd
Author: Mike Evans <mikee at saxicola.co.uk>
Date:   Mon May 6 13:40:21 2019 +0100

    Repair unintended indent changes,
    
    This happened in commit 126dc3a for bug 797168

diff --git a/gnucash/gnome/dialog-invoice.c b/gnucash/gnome/dialog-invoice.c
index 610f71372..cd3f6ceed 100644
--- a/gnucash/gnome/dialog-invoice.c
+++ b/gnucash/gnome/dialog-invoice.c
@@ -161,7 +161,8 @@ struct _invoice_window
     GtkWidget  * posted_date_hbox;
     GtkWidget  * posted_date;
     GtkWidget  * active_check;
-
+    GtkWidget  * paid_label;
+    
     GtkWidget  * owner_box;
     GtkWidget  * owner_label;
     GtkWidget  * owner_choice;
@@ -760,12 +761,12 @@ gnc_dialog_post_invoice(InvoiceWindow *iw, char *message,
     *ddue = *postdate;
     *memo = NULL;
     {
-        GncGUID *guid = NULL;
-        owner_inst = qofOwnerGetOwner (gncOwnerGetEndOwner (&(iw->owner)));
-        qof_instance_get (owner_inst,
-                  "invoice-last-posted-account", &guid,
-                  NULL);
-        *acc = xaccAccountLookup (guid, iw->book);
+    GncGUID *guid = NULL;
+    owner_inst = qofOwnerGetOwner (gncOwnerGetEndOwner (&(iw->owner)));
+    qof_instance_get (owner_inst,
+                      "invoice-last-posted-account", &guid,
+                      NULL);
+    *acc = xaccAccountLookup (guid, iw->book);
     }
     /* Get the default for the accumulate option */
     *accumulate = gnc_prefs_get_bool(GNC_PREFS_GROUP_INVOICE, GNC_PREF_ACCUM_SPLITS);
@@ -957,12 +958,12 @@ gnc_invoice_post(InvoiceWindow *iw, struct post_invoice_params *post_params)
      */
     owner_inst = qofOwnerGetOwner (gncOwnerGetEndOwner (&(iw->owner)));
     {
-        const GncGUID *guid = qof_instance_get_guid (QOF_INSTANCE (acc));
-        qof_begin_edit (owner_inst);
-        qof_instance_set (owner_inst,
-                  "invoice-last-posted-account", guid,
-                  NULL);
-        qof_commit_edit (owner_inst);
+    const GncGUID *guid = qof_instance_get_guid (QOF_INSTANCE (acc));
+    qof_begin_edit (owner_inst);
+    qof_instance_set (owner_inst,
+                      "invoice-last-posted-account", guid,
+                      NULL);
+    qof_commit_edit (owner_inst);
     }
 
     /* ... post it ... */
@@ -1874,8 +1875,6 @@ gnc_invoice_update_window (InvoiceWindow *iw, GtkWidget *widget)
         {
             hide = GTK_WIDGET (gtk_builder_get_object (iw->builder, "hide3"));
             gtk_widget_hide (hide);
-            hide = GTK_WIDGET (gtk_builder_get_object (iw->builder, "hide4"));
-            gtk_widget_hide (hide);
 
             show = GTK_WIDGET (gtk_builder_get_object (iw->builder, "posted_label"));
             gtk_widget_show (show);
@@ -1933,6 +1932,7 @@ gnc_invoice_update_window (InvoiceWindow *iw, GtkWidget *widget)
         /* Setup viewer for read-only access */
         gtk_widget_set_sensitive (acct_entry, FALSE);
         gtk_widget_set_sensitive (iw->id_entry, FALSE);
+        gtk_widget_set_selectable (iw->id_entry, TRUE);
         gtk_widget_set_sensitive (iw->terms_menu, FALSE);
         gtk_widget_set_sensitive (iw->owner_box, FALSE);
         gtk_widget_set_sensitive (iw->job_box, FALSE);
@@ -1949,6 +1949,11 @@ gnc_invoice_update_window (InvoiceWindow *iw, GtkWidget *widget)
         gtk_widget_set_sensitive (iw->notes_text, TRUE);
     }
 
+    if(gncInvoiceIsPaid (invoice))
+            gtk_label_set_text(GTK_LABEL(iw->paid_label),  _("PAID"));
+    else
+        gtk_label_set_text(GTK_LABEL(iw->paid_label),  _("UNPAID"));
+    
     if (widget)
         gtk_widget_show (widget);
     else
@@ -2317,6 +2322,7 @@ gnc_invoice_create_page (InvoiceWindow *iw, gpointer page)
     iw->owner_label = GTK_WIDGET (gtk_builder_get_object (builder, "page_owner_label"));
     iw->job_label = GTK_WIDGET (gtk_builder_get_object (builder, "page_job_label"));
     iw->job_box = GTK_WIDGET (gtk_builder_get_object (builder, "page_job_hbox"));
+    iw->paid_label = GTK_WIDGET (gtk_builder_get_object (builder, "hide4"));
 
     /* grab the project widgets */
     iw->proj_frame = GTK_WIDGET (gtk_builder_get_object (builder, "page_proj_frame"));
@@ -3358,7 +3364,7 @@ gnc_invoice_show_docs_due (GtkWindow *parent, QofBook *book, double days_in_adva
     if (param_list == NULL)
     {
         /* Translators: This abbreviation is the column heading for
-       the condition "Is this invoice a Credit Note?" */
+           the condition "Is this invoice a Credit Note?" */
         param_list = gnc_search_param_prepend (param_list, _("CN?"), NULL, type,
                                                INVOICE_IS_CN, NULL);
         param_list = gnc_search_param_prepend (param_list, _("Amount"), NULL, type,

commit 6e246ef8ad818b3c04e62939f686f478afbe8877
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Thu Apr 11 23:18:46 2019 +0800

    [options] compact option-setter in generator
    
    slightly more compact, avoids confusing structure whereby 'option' is
    both the lambda's argument and the definition of argument.

diff --git a/libgnucash/app-utils/options.scm b/libgnucash/app-utils/options.scm
index 9f9bf62e9..48b84e525 100644
--- a/libgnucash/app-utils/options.scm
+++ b/libgnucash/app-utils/options.scm
@@ -202,11 +202,9 @@ the option '~a'."))
 
 
 (define (gnc:restore-form-generator value->string)
-  (lambda () (string-append
-              "(lambda (option) "
-              "(if option ((gnc:option-setter option) "
-              (value->string)
-              ")))")))
+  (lambda ()
+    (string-append "(lambda (o) (if o (gnc:option-set-value o "
+                   (value->string) ")))")))
 
 (define (gnc:value->string value)
   (format #f "~s" value))

commit 6dd04cfa58d46d855ab510d4926e43ce4605082e
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Tue Apr 9 06:59:44 2019 +0800

    [stylesheet-plain] compact functions

diff --git a/gnucash/report/stylesheets/stylesheet-plain.scm b/gnucash/report/stylesheets/stylesheet-plain.scm
index 97983a4b1..6cb790942 100644
--- a/gnucash/report/stylesheets/stylesheet-plain.scm
+++ b/gnucash/report/stylesheets/stylesheet-plain.scm
@@ -84,35 +84,28 @@
     options))
 
 (define (plain-renderer options doc)
-  (let*
-      ((ssdoc (gnc:make-html-document))
-       (opt-val
-        (lambda (section name)
-          (gnc:option-value
-           (gnc:lookup-option options section name))))
-       (bgcolor
-        (gnc:color-option->html
-         (gnc:lookup-option options
-                            "General"
-                            "Background Color")))
-       (bgpixmap (opt-val "General" "Background Pixmap"))
-       (links? (opt-val "General" "Enable Links"))
-       (alternate-row-color
-        (gnc:color-option->html
-         (gnc:lookup-option options
-                            "Colors"
-                            "Alternate Table Cell Color")))
-       (spacing (opt-val "Tables" "Table cell spacing"))
-       (padding (opt-val "Tables" "Table cell padding"))
-       (border (opt-val "Tables" "Table border width"))
-       )
+  (define (opt-val section name)
+    (gnc:option-value
+     (gnc:lookup-option options section name)))
+  (let* ((ssdoc (gnc:make-html-document))
+         (bgcolor
+          (gnc:color-option->html
+           (gnc:lookup-option options "General" "Background Color")))
+         (bgpixmap (opt-val "General" "Background Pixmap"))
+         (links? (opt-val "General" "Enable Links"))
+         (alternate-row-color
+          (gnc:color-option->html
+           (gnc:lookup-option options "Colors" "Alternate Table Cell Color")))
+         (spacing (opt-val "Tables" "Table cell spacing"))
+         (padding (opt-val "Tables" "Table cell padding"))
+         (border (opt-val "Tables" "Table border width")))
 
     (gnc:html-document-set-style!
      ssdoc "body"
      'attribute (list "bgcolor" bgcolor))
 
     (if (and bgpixmap
-             (not (string=? bgpixmap "")))
+             (not (string-null? bgpixmap)))
         (gnc:html-document-set-style!
          ssdoc "body"
          'attribute (list "background" (make-file-url bgpixmap))))
@@ -218,18 +211,15 @@
 
     (add-css-information-to-doc options ssdoc doc)
 
-    (let* ((title (gnc:html-document-title doc))
-           (doc-headline (gnc:html-document-headline doc))
-           (headline (if (eq? doc-headline #f)
-                         title doc-headline)))
+    (let ((headline (or (gnc:html-document-headline doc)
+                        (gnc:html-document-title doc))))
       (if headline
           (gnc:html-document-add-object!
            ssdoc
            (gnc:make-html-text
             (gnc:html-markup-h3 headline)))))
 
-    (gnc:html-document-append-objects! ssdoc
-                                       (gnc:html-document-objects doc))
+    (gnc:html-document-append-objects! ssdoc (gnc:html-document-objects doc))
 
     ssdoc))
 

commit 1338162d144fcf0e7dc896d28cf245083dc43045
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Tue Apr 9 06:57:45 2019 +0800

    [stylesheets] *reindent/delete-trailing-whitespace/untabify*

diff --git a/gnucash/report/stylesheets/stylesheet-easy.scm b/gnucash/report/stylesheets/stylesheet-easy.scm
index 3f5cff55d..b1eed52f5 100644
--- a/gnucash/report/stylesheets/stylesheet-easy.scm
+++ b/gnucash/report/stylesheets/stylesheet-easy.scm
@@ -4,23 +4,23 @@
 ;;
 ;; Copyright 2004 James Strandboge <jstrand1 at rochester.rr.com>
 ;;
-;; This program is free software; you can redistribute it and/or    
-;; modify it under the terms of the GNU General Public License as   
-;; published by the Free Software Foundation; either version 2 of   
-;; the License, or (at your option) any later version.              
-;;                                                                  
-;; This program is distributed in the hope that it will be useful,  
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of   
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    
-;; GNU General Public License for more details.                     
-;;                                                                  
+;; 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
-;; 
+;;
 ;; Based on work from:
 ;; stylesheet-header.scm
 ;; Copyright 2000 Bill Gribble <grib at gnumatic.com>
@@ -29,7 +29,7 @@
 
 (define-module (gnucash report stylesheet-easy))
 
-(use-modules (gnucash utilities)) 
+(use-modules (gnucash utilities))
 (use-modules (gnucash gnc-module))
 (use-modules (gnucash gettext))
 
@@ -38,34 +38,34 @@
 
 (define (easy-options)
   (let* ((options (gnc:new-options))
-	 (opt-register 
-	  (lambda (opt) 
-	    (gnc:register-option options opt))))
-    (opt-register 
+         (opt-register
+          (lambda (opt)
+            (gnc:register-option options opt))))
+    (opt-register
      (gnc:make-string-option
       (N_ "General")
       (N_ "Preparer") "a"
-      (N_ "Name of person preparing the report.") 
+      (N_ "Name of person preparing the report.")
       ""))
-    (opt-register 
+    (opt-register
      (gnc:make-string-option
       (N_ "General")
       (N_ "Prepared for") "b"
-      (N_ "Name of organization or company prepared for.") 
+      (N_ "Name of organization or company prepared for.")
       ""))
-    (opt-register 
+    (opt-register
      (gnc:make-simple-boolean-option
       (N_ "General")
       (N_ "Show preparer info") "c"
-      (N_ "Name of organization or company.") 
+      (N_ "Name of organization or company.")
       #f))
-    (opt-register 
+    (opt-register
      (gnc:make-simple-boolean-option
       (N_ "General")
       (N_ "Enable Links") "d"
-      (N_ "Enable hyperlinks in reports.") 
+      (N_ "Enable hyperlinks in reports.")
       #t))
-    
+
     (opt-register
      (gnc:make-pixmap-option
       (N_ "Images")
@@ -82,14 +82,14 @@
       (N_ "Heading Alignment") "c" (N_ "Banner for top of report.")
       'left
       (list (vector 'left
-                     (N_ "Left")
-                     (N_ "Align the banner to the left."))
+                    (N_ "Left")
+                    (N_ "Align the banner to the left."))
             (vector 'center
-                     (N_ "Center")
-                     (N_ "Align the banner in the center."))
+                    (N_ "Center")
+                    (N_ "Align the banner in the center."))
             (vector 'right
-                     (N_ "Right")
-                     (N_ "Align the banner to the right."))
+                    (N_ "Right")
+                    (N_ "Align the banner to the right."))
             )))
     (opt-register
      (gnc:make-pixmap-option
@@ -102,14 +102,14 @@
       (N_ "Colors")
       (N_ "Background Color") "a" (N_ "General background color for report.")
       (list #xff #xff #xff #xff)
-      255 #f))      
+      255 #f))
 
     (opt-register
      (gnc:make-color-option
       (N_ "Colors")
       (N_ "Text Color") "b" (N_ "Normal body text color.")
       (list #x00 #x00 #x00 #xff)
-      255 #f))      
+      255 #f))
 
     (opt-register
      (gnc:make-color-option
@@ -123,7 +123,7 @@
       (N_ "Colors")
       (N_ "Table Cell Color") "c" (N_ "Default background for table cells.")
       (list #xff #xff #xff #xff)
-      255 #f))      
+      255 #f))
 
     (opt-register
      (gnc:make-color-option
@@ -157,20 +157,20 @@
       (list #xff #xff #x00 #xff)
       255 #f))
 
-    (opt-register 
-     (gnc:make-number-range-option 
+    (opt-register
+     (gnc:make-number-range-option
       (N_ "Tables")
       (N_ "Table cell spacing") "a" (N_ "Space between table cells.")
       1 0 20 0 1))
 
-    (opt-register 
-     (gnc:make-number-range-option 
+    (opt-register
+     (gnc:make-number-range-option
       (N_ "Tables")
       (N_ "Table cell padding") "b" (N_ "Space between table cell edge and content.")
       1 0 20 0 1))
 
-    (opt-register 
-     (gnc:make-number-range-option 
+    (opt-register
+     (gnc:make-number-range-option
       (N_ "Tables")
       (N_ "Table border width") "c" (N_ "Bevel depth on tables.")
       1 0 20 0 1))
@@ -180,47 +180,47 @@
 
 (define (easy-renderer options doc)
   (let* ((ssdoc (gnc:make-html-document))
-	 (opt-val 
-	  (lambda (section name)
-	    (gnc:option-value
-	     (gnc:lookup-option options section name))))
-	 (color-val
-	  (lambda (section name)
-	    (gnc:color-option->html
-	     (gnc:lookup-option options section name))))
-	 (preparer (opt-val (N_ "General") (N_ "Preparer")))
-	 (prepared-for (opt-val (N_ "General") (N_ "Prepared for")))
-	 (show-preparer? (opt-val (N_ "General") (N_ "Show preparer info")))
-	 (links? (opt-val (N_ "General") (N_ "Enable Links")))           
-	 (bgcolor (color-val (N_ "Colors") (N_ "Background Color")))
-	 (textcolor (color-val (N_ "Colors") (N_ "Text Color")))
-	 (linkcolor (color-val (N_ "Colors") (N_ "Link Color")))
-	 (normal-row-color (color-val (N_ "Colors") (N_ "Table Cell Color")))
-	 (alternate-row-color (color-val (N_ "Colors")
-					 (N_ "Alternate Table Cell Color")))
-	 (primary-subheading-color
-	  (color-val (N_ "Colors")
-		     (N_ "Subheading/Subtotal Cell Color")))
-	 (secondary-subheading-color
-	  (color-val (N_ "Colors") 
-		     (N_ "Sub-subheading/total Cell Color")))
-	 (grand-total-color (color-val (N_ "Colors")
-				       (N_ "Grand Total Cell Color")))
-	 (bgpixmap (opt-val (N_ "Images") (N_ "Background Tile")))
-	 (headpixmap (opt-val (N_ "Images") (N_ "Heading Banner")))
-	 (logopixmap (opt-val (N_ "Images") (N_ "Logo")))
+         (opt-val
+          (lambda (section name)
+            (gnc:option-value
+             (gnc:lookup-option options section name))))
+         (color-val
+          (lambda (section name)
+            (gnc:color-option->html
+             (gnc:lookup-option options section name))))
+         (preparer (opt-val (N_ "General") (N_ "Preparer")))
+         (prepared-for (opt-val (N_ "General") (N_ "Prepared for")))
+         (show-preparer? (opt-val (N_ "General") (N_ "Show preparer info")))
+         (links? (opt-val (N_ "General") (N_ "Enable Links")))
+         (bgcolor (color-val (N_ "Colors") (N_ "Background Color")))
+         (textcolor (color-val (N_ "Colors") (N_ "Text Color")))
+         (linkcolor (color-val (N_ "Colors") (N_ "Link Color")))
+         (normal-row-color (color-val (N_ "Colors") (N_ "Table Cell Color")))
+         (alternate-row-color (color-val (N_ "Colors")
+                                         (N_ "Alternate Table Cell Color")))
+         (primary-subheading-color
+          (color-val (N_ "Colors")
+                     (N_ "Subheading/Subtotal Cell Color")))
+         (secondary-subheading-color
+          (color-val (N_ "Colors")
+                     (N_ "Sub-subheading/total Cell Color")))
+         (grand-total-color (color-val (N_ "Colors")
+                                       (N_ "Grand Total Cell Color")))
+         (bgpixmap (opt-val (N_ "Images") (N_ "Background Tile")))
+         (headpixmap (opt-val (N_ "Images") (N_ "Heading Banner")))
+         (logopixmap (opt-val (N_ "Images") (N_ "Logo")))
          (align (gnc:value->string(opt-val (N_ "Images") (N_ "Heading Alignment"))))
-	 (spacing (opt-val (N_ "Tables") (N_ "Table cell spacing")))
-	 (padding (opt-val (N_ "Tables") (N_ "Table cell padding")))
-	 (border (opt-val (N_ "Tables") (N_ "Table border width")))
+         (spacing (opt-val (N_ "Tables") (N_ "Table cell spacing")))
+         (padding (opt-val (N_ "Tables") (N_ "Table cell padding")))
+         (border (opt-val (N_ "Tables") (N_ "Table border width")))
          (headcolumn 0))
 
-    ; center the document without elements inheriting anything
+                                        ; center the document without elements inheriting anything
     (gnc:html-document-add-object! ssdoc
-       (gnc:make-html-text "<center>"))
+                                   (gnc:make-html-text "<center>"))
 
-    (gnc:html-document-set-style! 
-     ssdoc "body" 
+    (gnc:html-document-set-style!
+     ssdoc "body"
      'attribute (list "bgcolor" bgcolor)
      'attribute (list "text" textcolor)
      'attribute (list "link" linkcolor))
@@ -293,13 +293,13 @@
      'attribute (list "class" "centered-label-cell"))
 
     (if (and bgpixmap
-	     (not (string=? bgpixmap "")))
-	(gnc:html-document-set-style!
-	 ssdoc "body" 
-	 'attribute (list "background" (make-file-url bgpixmap))))
-    
+             (not (string=? bgpixmap "")))
+        (gnc:html-document-set-style!
+         ssdoc "body"
+         'attribute (list "background" (make-file-url bgpixmap))))
+
     (gnc:html-document-set-style!
-     ssdoc "table" 
+     ssdoc "table"
      'attribute (list "border" border)
      'attribute (list "cellspacing" spacing)
      'attribute (list "cellpadding" padding))
@@ -311,38 +311,38 @@
     (gnc:html-document-set-style!
      ssdoc "alternate-row"
      'attribute (list "bgcolor" alternate-row-color)
-     'tag "tr")       
+     'tag "tr")
     (gnc:html-document-set-style!
      ssdoc "primary-subheading"
      'attribute (list "bgcolor" primary-subheading-color)
-     'tag "tr")       
+     'tag "tr")
     (gnc:html-document-set-style!
      ssdoc "secondary-subheading"
      'attribute (list "bgcolor" secondary-subheading-color)
-     'tag "tr")       
+     'tag "tr")
     (gnc:html-document-set-style!
      ssdoc "grand-total"
      'attribute (list "bgcolor" grand-total-color)
-     'tag "tr")   
+     'tag "tr")
 
     ;; don't surround marked-up links with <a> </a>
     (if (not links?)
-	(gnc:html-document-set-style!
-	 ssdoc "a" 'tag ""))
-    
+        (gnc:html-document-set-style!
+         ssdoc "a" 'tag ""))
+
     (let ((t (gnc:make-html-table)))
-      ;; we don't want a bevel for this table, but we don't want 
-      ;; that to propagate 
+      ;; we don't want a bevel for this table, but we don't want
+      ;; that to propagate
       (gnc:html-table-set-style!
-       t "table" 
+       t "table"
        'attribute (list "border" 0)
        'inheritable? #f)
 
-      ; set the header column to be the 2nd when we have a logo
-      ; do this so that when logo is not present, the document
-      ; is perfectly centered
+                                        ; set the header column to be the 2nd when we have a logo
+                                        ; do this so that when logo is not present, the document
+                                        ; is perfectly centered
       (if (and logopixmap (> (string-length logopixmap) 0))
-        (set! headcolumn 1))
+          (set! headcolumn 1))
 
       (add-css-information-to-doc options ssdoc doc)
 
@@ -350,10 +350,10 @@
              (doc-headline (gnc:html-document-headline doc))
              (headline (if (eq? doc-headline #f) title doc-headline)))
 
-        (gnc:html-table-set-cell! 
+        (gnc:html-table-set-cell!
          t 1 headcolumn
-         (if show-preparer? 
-             ;; title plus preparer info 
+         (if show-preparer?
+             ;; title plus preparer info
              (gnc:make-html-text
               (gnc:html-markup-h3 headline)
               (gnc:html-markup-br)
@@ -367,42 +367,42 @@
               (qof-print-date
                (current-time)))
 
-             ;; title only 
+             ;; title only
              (gnc:make-html-text
               (gnc:html-markup-h3 headline))))
         )
-      
-      ; only setup an image if we specified one
+
+                                        ; only setup an image if we specified one
       (if (and logopixmap (> (string-length logopixmap) 0))
-        (begin
-          (gnc:html-table-set-cell!
-            t 0 0
-            (gnc:make-html-text
-	      (gnc:html-markup-img (make-file-url logopixmap))))))
-      
+          (begin
+            (gnc:html-table-set-cell!
+             t 0 0
+             (gnc:make-html-text
+              (gnc:html-markup-img (make-file-url logopixmap))))))
+
       (if (and headpixmap (> (string-length headpixmap) 0))
-        (begin
+          (begin
+            (gnc:html-table-set-cell!
+             t 0 headcolumn
+             (gnc:make-html-text
+              (string-append
+               "<div align=\"" align "\">"
+               "<img src=\"" (make-file-url headpixmap) "\">"
+               "</div>")))
+            )
           (gnc:html-table-set-cell!
-            t 0 headcolumn
-            (gnc:make-html-text 
-               (string-append 
-                 "<div align=\"" align "\">"
-                 "<img src=\"" (make-file-url headpixmap) "\">"
-                 "</div>")))
-        )
-        (gnc:html-table-set-cell!
-          t 0 headcolumn
-          (gnc:make-html-text " ")))
-      
-      (apply 
-       gnc:html-table-set-cell! 
+           t 0 headcolumn
+           (gnc:make-html-text " ")))
+
+      (apply
+       gnc:html-table-set-cell!
        t 2 headcolumn
        (gnc:html-document-objects doc))
       (gnc:html-document-add-object! ssdoc t))
     (gnc:html-document-add-object! ssdoc (gnc:make-html-text "</center>")) ;;TODO: make this a div instead of <center> (deprecated)
     ssdoc))
 
-(gnc:define-html-style-sheet 
+(gnc:define-html-style-sheet
  'version 1
  'name (N_ "Easy")
  'renderer easy-renderer
diff --git a/gnucash/report/stylesheets/stylesheet-fancy.scm b/gnucash/report/stylesheets/stylesheet-fancy.scm
index 46f2bc124..26dae6e55 100644
--- a/gnucash/report/stylesheets/stylesheet-fancy.scm
+++ b/gnucash/report/stylesheets/stylesheet-fancy.scm
@@ -1,17 +1,17 @@
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; stylesheet-header.scm : stylesheet with nicer layout
 ;; Copyright 2000 Bill Gribble <grib at gnumatic.com>
-;; 
-;; This program is free software; you can redistribute it and/or    
-;; modify it under the terms of the GNU General Public License as   
-;; published by the Free Software Foundation; either version 2 of   
-;; the License, or (at your option) any later version.              
-;;                                                                  
-;; This program is distributed in the hope that it will be useful,  
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of   
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    
-;; GNU General Public License for more details.                     
-;;                                                                  
+;;
+;; 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:
 ;;
@@ -23,7 +23,7 @@
 
 (define-module (gnucash report stylesheet-fancy))
 
-(use-modules (gnucash utilities)) 
+(use-modules (gnucash utilities))
 (use-modules (gnucash gnc-module))
 (use-modules (gnucash gettext))
 
@@ -32,34 +32,34 @@
 
 (define (fancy-options)
   (let* ((options (gnc:new-options))
-	 (opt-register 
-	  (lambda (opt) 
-	    (gnc:register-option options opt))))
-    (opt-register 
+         (opt-register
+          (lambda (opt)
+            (gnc:register-option options opt))))
+    (opt-register
      (gnc:make-string-option
       (N_ "General")
       (N_ "Preparer") "a"
-      (N_ "Name of person preparing the report.") 
+      (N_ "Name of person preparing the report.")
       ""))
-    (opt-register 
+    (opt-register
      (gnc:make-string-option
       (N_ "General")
       (N_ "Prepared for") "b"
-      (N_ "Name of organization or company prepared for.") 
+      (N_ "Name of organization or company prepared for.")
       ""))
-    (opt-register 
+    (opt-register
      (gnc:make-simple-boolean-option
       (N_ "General")
       (N_ "Show preparer info") "c"
-      (N_ "Name of organization or company.") 
+      (N_ "Name of organization or company.")
       #f))
-    (opt-register 
+    (opt-register
      (gnc:make-simple-boolean-option
       (N_ "General")
       (N_ "Enable Links") "d"
-      (N_ "Enable hyperlinks in reports.") 
+      (N_ "Enable hyperlinks in reports.")
       #t))
-    
+
     (opt-register
      (gnc:make-pixmap-option
       (N_ "Images")
@@ -76,14 +76,14 @@
       (N_ "Heading Alignment") "c" (N_ "Banner for top of report.")
       'left
       (list (vector 'left
-                     (N_ "Left")
-                     (N_ "Align the banner to the left."))
+                    (N_ "Left")
+                    (N_ "Align the banner to the left."))
             (vector 'center
-                     (N_ "Center")
-                     (N_ "Align the banner in the center."))
+                    (N_ "Center")
+                    (N_ "Align the banner in the center."))
             (vector 'right
-                     (N_ "Right")
-                     (N_ "Align the banner to the right."))
+                    (N_ "Right")
+                    (N_ "Align the banner to the right."))
             )))
     (opt-register
      (gnc:make-pixmap-option
@@ -96,14 +96,14 @@
       (N_ "Colors")
       (N_ "Background Color") "a" (N_ "General background color for report.")
       (list #xff #xff #xff #xff)
-      255 #f))      
+      255 #f))
 
     (opt-register
      (gnc:make-color-option
       (N_ "Colors")
       (N_ "Text Color") "b" (N_ "Normal body text color.")
       (list #x00 #x00 #x00 #xff)
-      255 #f))      
+      255 #f))
 
     (opt-register
      (gnc:make-color-option
@@ -117,7 +117,7 @@
       (N_ "Colors")
       (N_ "Table Cell Color") "c" (N_ "Default background for table cells.")
       (list #xff #xff #xff #xff)
-      255 #f))      
+      255 #f))
 
     (opt-register
      (gnc:make-color-option
@@ -151,20 +151,20 @@
       (list #xff #xff #x00 #xff)
       255 #f))
 
-    (opt-register 
-     (gnc:make-number-range-option 
+    (opt-register
+     (gnc:make-number-range-option
       (N_ "Tables")
       (N_ "Table cell spacing") "a" (N_ "Space between table cells.")
       1 0 20 0 1))
 
-    (opt-register 
-     (gnc:make-number-range-option 
+    (opt-register
+     (gnc:make-number-range-option
       (N_ "Tables")
       (N_ "Table cell padding") "b" (N_ "Space between table cell edge and content.")
       1 0 20 0 1))
 
-    (opt-register 
-     (gnc:make-number-range-option 
+    (opt-register
+     (gnc:make-number-range-option
       (N_ "Tables")
       (N_ "Table border width") "c" (N_ "Bevel depth on tables.")
       1 0 20 0 1))
@@ -174,47 +174,47 @@
 
 (define (fancy-renderer options doc)
   (let* ((ssdoc (gnc:make-html-document))
-	 (opt-val 
-	  (lambda (section name)
-	    (gnc:option-value
-	     (gnc:lookup-option options section name))))
-	 (color-val
-	  (lambda (section name)
-	    (gnc:color-option->html
-	     (gnc:lookup-option options section name))))
-	 (preparer (opt-val (N_ "General") (N_ "Preparer")))
-	 (prepared-for (opt-val (N_ "General") (N_ "Prepared for")))
-	 (show-preparer? (opt-val (N_ "General") (N_ "Show preparer info")))
-	 (links? (opt-val (N_ "General") (N_ "Enable Links")))           
-	 (bgcolor (color-val (N_ "Colors") (N_ "Background Color")))
-	 (textcolor (color-val (N_ "Colors") (N_ "Text Color")))
-	 (linkcolor (color-val (N_ "Colors") (N_ "Link Color")))
-	 (normal-row-color (color-val (N_ "Colors") (N_ "Table Cell Color")))
-	 (alternate-row-color (color-val (N_ "Colors")
-					 (N_ "Alternate Table Cell Color")))
-	 (primary-subheading-color
-	  (color-val (N_ "Colors")
-		     (N_ "Subheading/Subtotal Cell Color")))
-	 (secondary-subheading-color
-	  (color-val (N_ "Colors") 
-		     (N_ "Sub-subheading/total Cell Color")))
-	 (grand-total-color (color-val (N_ "Colors")
-				       (N_ "Grand Total Cell Color")))
-	 (bgpixmap (opt-val (N_ "Images") (N_ "Background Tile")))
-	 (headpixmap (opt-val (N_ "Images") (N_ "Heading Banner")))
-	 (logopixmap (opt-val (N_ "Images") (N_ "Logo")))
+         (opt-val
+          (lambda (section name)
+            (gnc:option-value
+             (gnc:lookup-option options section name))))
+         (color-val
+          (lambda (section name)
+            (gnc:color-option->html
+             (gnc:lookup-option options section name))))
+         (preparer (opt-val (N_ "General") (N_ "Preparer")))
+         (prepared-for (opt-val (N_ "General") (N_ "Prepared for")))
+         (show-preparer? (opt-val (N_ "General") (N_ "Show preparer info")))
+         (links? (opt-val (N_ "General") (N_ "Enable Links")))
+         (bgcolor (color-val (N_ "Colors") (N_ "Background Color")))
+         (textcolor (color-val (N_ "Colors") (N_ "Text Color")))
+         (linkcolor (color-val (N_ "Colors") (N_ "Link Color")))
+         (normal-row-color (color-val (N_ "Colors") (N_ "Table Cell Color")))
+         (alternate-row-color (color-val (N_ "Colors")
+                                         (N_ "Alternate Table Cell Color")))
+         (primary-subheading-color
+          (color-val (N_ "Colors")
+                     (N_ "Subheading/Subtotal Cell Color")))
+         (secondary-subheading-color
+          (color-val (N_ "Colors")
+                     (N_ "Sub-subheading/total Cell Color")))
+         (grand-total-color (color-val (N_ "Colors")
+                                       (N_ "Grand Total Cell Color")))
+         (bgpixmap (opt-val (N_ "Images") (N_ "Background Tile")))
+         (headpixmap (opt-val (N_ "Images") (N_ "Heading Banner")))
+         (logopixmap (opt-val (N_ "Images") (N_ "Logo")))
          (align (gnc:value->string(opt-val (N_ "Images") (N_ "Heading Alignment"))))
-	 (spacing (opt-val (N_ "Tables") (N_ "Table cell spacing")))
-	 (padding (opt-val (N_ "Tables") (N_ "Table cell padding")))
-	 (border (opt-val (N_ "Tables") (N_ "Table border width")))
+         (spacing (opt-val (N_ "Tables") (N_ "Table cell spacing")))
+         (padding (opt-val (N_ "Tables") (N_ "Table cell padding")))
+         (border (opt-val (N_ "Tables") (N_ "Table border width")))
          (headcolumn 0))
 
-    ; center the document without elements inheriting anything
+                                        ; center the document without elements inheriting anything
     (gnc:html-document-add-object! ssdoc
-       (gnc:make-html-text "<center>"))
+                                   (gnc:make-html-text "<center>"))
 
-    (gnc:html-document-set-style! 
-     ssdoc "body" 
+    (gnc:html-document-set-style!
+     ssdoc "body"
      'attribute (list "bgcolor" bgcolor)
      'attribute (list "text" textcolor)
      'attribute (list "link" linkcolor))
@@ -288,13 +288,13 @@
      'attribute (list "class" "centered-label-cell"))
 
     (if (and bgpixmap
-	     (not (string=? bgpixmap "")))
-	(gnc:html-document-set-style!
-	 ssdoc "body" 
-	 'attribute (list "background" (make-file-url bgpixmap))))
-    
+             (not (string=? bgpixmap "")))
+        (gnc:html-document-set-style!
+         ssdoc "body"
+         'attribute (list "background" (make-file-url bgpixmap))))
+
     (gnc:html-document-set-style!
-     ssdoc "table" 
+     ssdoc "table"
      'attribute (list "border" border)
      'attribute (list "cellspacing" spacing)
      'attribute (list "cellpadding" padding))
@@ -306,32 +306,32 @@
     (gnc:html-document-set-style!
      ssdoc "alternate-row"
      'attribute (list "bgcolor" alternate-row-color)
-     'tag "tr")       
+     'tag "tr")
     (gnc:html-document-set-style!
      ssdoc "primary-subheading"
      'attribute (list "bgcolor" primary-subheading-color)
-     'tag "tr")       
+     'tag "tr")
     (gnc:html-document-set-style!
      ssdoc "secondary-subheading"
      'attribute (list "bgcolor" secondary-subheading-color)
-     'tag "tr")       
+     'tag "tr")
     (gnc:html-document-set-style!
      ssdoc "grand-total"
      'attribute (list "bgcolor" grand-total-color)
-     'tag "tr")   
+     'tag "tr")
 
     ;; don't surround marked-up links with <a> </a>
     (if (not links?)
-	(gnc:html-document-set-style!
-	 ssdoc "a" 'tag ""))
-    
+        (gnc:html-document-set-style!
+         ssdoc "a" 'tag ""))
+
     (add-css-information-to-doc options ssdoc doc)
 
     (let ((t (gnc:make-html-table)))
-      ;; we don't want a bevel for this table, but we don't want 
-      ;; that to propagate 
+      ;; we don't want a bevel for this table, but we don't want
+      ;; that to propagate
       (gnc:html-table-set-style!
-       t "table" 
+       t "table"
        'attribute (list "border" 0)
        'inheritable? #f)
 
@@ -339,18 +339,18 @@
              (doc-headline (gnc:html-document-headline doc))
              (headline (if (eq? doc-headline #f) title doc-headline)))
 
-	; set the header column to be the 2nd when we have a logo
-	; do this so that when logo is not present, the document
-	; is perfectly centered
-	(if (and logopixmap (> (string-length logopixmap) 0))
-	    (set! headcolumn 1))
+                                        ; set the header column to be the 2nd when we have a logo
+                                        ; do this so that when logo is not present, the document
+                                        ; is perfectly centered
+        (if (and logopixmap (> (string-length logopixmap) 0))
+            (set! headcolumn 1))
 
-        (gnc:html-table-set-cell! 
+        (gnc:html-table-set-cell!
          t 1 headcolumn
-         (if show-preparer? 
-             ;; title plus preparer info 
+         (if show-preparer?
+             ;; title plus preparer info
              (gnc:make-html-text
-              (gnc:html-markup-h3 headline)  
+              (gnc:html-markup-h3 headline)
               (gnc:html-markup-br)
               (_ "Prepared by: ")
               (gnc:html-markup-b preparer)
@@ -362,48 +362,48 @@
               (qof-print-date
                (current-time)))
 
-             ;; title only 
+             ;; title only
              (gnc:make-html-text
               (gnc:html-markup-h3 headline))))
         )
-      
+
       (if (and logopixmap
-	       (not (string=? logopixmap "")))
-	  ;; check for logo image file name non blank
-	  (gnc:html-table-set-cell!
-	   t 0 0
+               (not (string=? logopixmap "")))
+          ;; check for logo image file name non blank
+          (gnc:html-table-set-cell!
+           t 0 0
            (gnc:make-html-text
-	    (gnc:html-markup-img (make-file-url logopixmap)))) )
+            (gnc:html-markup-img (make-file-url logopixmap)))) )
 
       (if (and headpixmap
-	       (not (string=? headpixmap "")))
-	  ;; check for header image file name nonblank
-	  (begin
-	    (gnc:html-table-set-cell!
+               (not (string=? headpixmap "")))
+          ;; check for header image file name nonblank
+          (begin
+            (gnc:html-table-set-cell!
              t 0 headcolumn
              (gnc:make-html-text
-	      ;; XX: isn't there some way to apply the alignment to
-	      ;; (gnc:html-markup-img headpixmap)?
-	      (string-append
-	       "<div align=\"" align "\">"
-	       "<img src=\"" (make-file-url headpixmap) "\">"
-	       "</div>")))
-	    )
-	  (gnc:html-table-set-cell!
+              ;; XX: isn't there some way to apply the alignment to
+              ;; (gnc:html-markup-img headpixmap)?
+              (string-append
+               "<div align=\"" align "\">"
+               "<img src=\"" (make-file-url headpixmap) "\">"
+               "</div>")))
+            )
+          (gnc:html-table-set-cell!
            t 0 headcolumn
            (gnc:make-html-text " ")))
 
-      (apply 
-       gnc:html-table-set-cell! 
+      (apply
+       gnc:html-table-set-cell!
        t 2 headcolumn
        (gnc:html-document-objects doc))
-      
+
       (gnc:html-document-add-object! ssdoc t))
     (gnc:html-document-add-object! ssdoc
-       (gnc:make-html-text "</center>")) ;;TODO: make this a div instead of <center> (deprecated)
+                                   (gnc:make-html-text "</center>")) ;;TODO: make this a div instead of <center> (deprecated)
     ssdoc))
 
-(gnc:define-html-style-sheet 
+(gnc:define-html-style-sheet
  'version 1.01
  'name (N_ "Fancy")
  'renderer fancy-renderer
diff --git a/gnucash/report/stylesheets/stylesheet-footer.scm b/gnucash/report/stylesheets/stylesheet-footer.scm
index 3464d582b..5f22cbcc1 100644
--- a/gnucash/report/stylesheets/stylesheet-footer.scm
+++ b/gnucash/report/stylesheets/stylesheet-footer.scm
@@ -4,23 +4,23 @@
 ;;
 ;; Copyright 2004 James Strandboge <jstrand1 at rochester.rr.com>
 ;;
-;; This program is free software; you can redistribute it and/or    
-;; modify it under the terms of the GNU General Public License as   
-;; published by the Free Software Foundation; either version 2 of   
-;; the License, or (at your option) any later version.              
-;;                                                                  
-;; This program is distributed in the hope that it will be useful,  
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of   
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    
-;; GNU General Public License for more details.                     
-;;                                                                  
+;; 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
-;; 
+;;
 ;; Based on work from:
 ;; stylesheet-header.scm
 ;; Copyright 2000 Bill Gribble <grib at gnumatic.com>
@@ -34,7 +34,7 @@
 
 (define-module (gnucash report stylesheet-footer))
 
-(use-modules (gnucash utilities)) 
+(use-modules (gnucash utilities))
 (use-modules (gnucash gnc-module))
 (use-modules (gnucash gettext))
 
@@ -43,34 +43,34 @@
 
 (define (footer-options)
   (let* ((options (gnc:new-options))
-	 (opt-register 
-	  (lambda (opt) 
-	    (gnc:register-option options opt))))
-    (opt-register 
+         (opt-register
+          (lambda (opt)
+            (gnc:register-option options opt))))
+    (opt-register
      (gnc:make-string-option
       (N_ "General")
       (N_ "Preparer") "a"
-      (N_ "Name of person preparing the report.") 
+      (N_ "Name of person preparing the report.")
       ""))
-    (opt-register 
+    (opt-register
      (gnc:make-string-option
       (N_ "General")
       (N_ "Prepared for") "b"
-      (N_ "Name of organization or company prepared for.") 
+      (N_ "Name of organization or company prepared for.")
       ""))
-    (opt-register 
+    (opt-register
      (gnc:make-simple-boolean-option
       (N_ "General")
       (N_ "Show preparer info") "c"
-      (N_ "Name of organization or company.") 
+      (N_ "Name of organization or company.")
       #f))
-    (opt-register 
+    (opt-register
      (gnc:make-simple-boolean-option
       (N_ "General")
       (N_ "Enable Links") "d"
-      (N_ "Enable hyperlinks in reports.") 
+      (N_ "Enable hyperlinks in reports.")
       #t))
-    ; FIXME: put this in a more sensible tab like Text or Header/Footer
+    ;; FIXME: put this in a more sensible tab like Text or Header/Footer
     (opt-register
      (gnc:make-text-option
       (N_ "General")
@@ -95,14 +95,14 @@
       (N_ "Heading Alignment") "c" (N_ "Banner for top of report.")
       'left
       (list (vector 'left
-                     (N_ "Left")
-                     (N_ "Align the banner to the left."))
+                    (N_ "Left")
+                    (N_ "Align the banner to the left."))
             (vector 'center
-                     (N_ "Center")
-                     (N_ "Align the banner in the center."))
+                    (N_ "Center")
+                    (N_ "Align the banner in the center."))
             (vector 'right
-                     (N_ "Right")
-                     (N_ "Align the banner to the right."))
+                    (N_ "Right")
+                    (N_ "Align the banner to the right."))
             )))
     (opt-register
      (gnc:make-pixmap-option
@@ -115,14 +115,14 @@
       (N_ "Colors")
       (N_ "Background Color") "a" (N_ "General background color for report.")
       (list #xff #xff #xff #xff)
-      255 #f))      
+      255 #f))
 
     (opt-register
      (gnc:make-color-option
       (N_ "Colors")
       (N_ "Text Color") "b" (N_ "Normal body text color.")
       (list #x00 #x00 #x00 #xff)
-      255 #f))      
+      255 #f))
 
     (opt-register
      (gnc:make-color-option
@@ -136,7 +136,7 @@
       (N_ "Colors")
       (N_ "Table Cell Color") "c" (N_ "Default background for table cells.")
       (list #xff #xff #xff #xff)
-      255 #f))      
+      255 #f))
 
     (opt-register
      (gnc:make-color-option
@@ -170,20 +170,20 @@
       (list #xff #xff #x00 #xff)
       255 #f))
 
-    (opt-register 
-     (gnc:make-number-range-option 
+    (opt-register
+     (gnc:make-number-range-option
       (N_ "Tables")
       (N_ "Table cell spacing") "a" (N_ "Space between table cells.")
       1 0 20 0 1))
 
-    (opt-register 
-     (gnc:make-number-range-option 
+    (opt-register
+     (gnc:make-number-range-option
       (N_ "Tables")
       (N_ "Table cell padding") "b" (N_ "Space between table cell edge and content.")
       1 0 20 0 1))
 
-    (opt-register 
-     (gnc:make-number-range-option 
+    (opt-register
+     (gnc:make-number-range-option
       (N_ "Tables")
       (N_ "Table border width") "c" (N_ "Bevel depth on tables.")
       1 0 20 0 1))
@@ -193,48 +193,48 @@
 
 (define (footer-renderer options doc)
   (let* ((ssdoc (gnc:make-html-document))
-	 (opt-val 
-	  (lambda (section name)
-	    (gnc:option-value
-	     (gnc:lookup-option options section name))))
-	 (color-val
-	  (lambda (section name)
-	    (gnc:color-option->html
-	     (gnc:lookup-option options section name))))
-	 (preparer (opt-val (N_ "General") (N_ "Preparer")))
-	 (prepared-for (opt-val (N_ "General") (N_ "Prepared for")))
-	 (show-preparer? (opt-val (N_ "General") (N_ "Show preparer info")))
-	 (links? (opt-val (N_ "General") (N_ "Enable Links")))           
-	 (footer-text (opt-val (N_ "General") (N_ "Footer")))
-	 (bgcolor (color-val (N_ "Colors") (N_ "Background Color")))
-	 (textcolor (color-val (N_ "Colors") (N_ "Text Color")))
-	 (linkcolor (color-val (N_ "Colors") (N_ "Link Color")))
-	 (normal-row-color (color-val (N_ "Colors") (N_ "Table Cell Color")))
-	 (alternate-row-color (color-val (N_ "Colors")
-					 (N_ "Alternate Table Cell Color")))
-	 (primary-subheading-color
-	  (color-val (N_ "Colors")
-		     (N_ "Subheading/Subtotal Cell Color")))
-	 (secondary-subheading-color
-	  (color-val (N_ "Colors") 
-		     (N_ "Sub-subheading/total Cell Color")))
-	 (grand-total-color (color-val (N_ "Colors")
-				       (N_ "Grand Total Cell Color")))
-	 (bgpixmap (opt-val (N_ "Images") (N_ "Background Tile")))
-	 (headpixmap (opt-val (N_ "Images") (N_ "Heading Banner")))
-	 (logopixmap (opt-val (N_ "Images") (N_ "Logo")))
+         (opt-val
+          (lambda (section name)
+            (gnc:option-value
+             (gnc:lookup-option options section name))))
+         (color-val
+          (lambda (section name)
+            (gnc:color-option->html
+             (gnc:lookup-option options section name))))
+         (preparer (opt-val (N_ "General") (N_ "Preparer")))
+         (prepared-for (opt-val (N_ "General") (N_ "Prepared for")))
+         (show-preparer? (opt-val (N_ "General") (N_ "Show preparer info")))
+         (links? (opt-val (N_ "General") (N_ "Enable Links")))
+         (footer-text (opt-val (N_ "General") (N_ "Footer")))
+         (bgcolor (color-val (N_ "Colors") (N_ "Background Color")))
+         (textcolor (color-val (N_ "Colors") (N_ "Text Color")))
+         (linkcolor (color-val (N_ "Colors") (N_ "Link Color")))
+         (normal-row-color (color-val (N_ "Colors") (N_ "Table Cell Color")))
+         (alternate-row-color (color-val (N_ "Colors")
+                                         (N_ "Alternate Table Cell Color")))
+         (primary-subheading-color
+          (color-val (N_ "Colors")
+                     (N_ "Subheading/Subtotal Cell Color")))
+         (secondary-subheading-color
+          (color-val (N_ "Colors")
+                     (N_ "Sub-subheading/total Cell Color")))
+         (grand-total-color (color-val (N_ "Colors")
+                                       (N_ "Grand Total Cell Color")))
+         (bgpixmap (opt-val (N_ "Images") (N_ "Background Tile")))
+         (headpixmap (opt-val (N_ "Images") (N_ "Heading Banner")))
+         (logopixmap (opt-val (N_ "Images") (N_ "Logo")))
          (align (gnc:value->string(opt-val (N_ "Images") (N_ "Heading Alignment"))))
-	 (spacing (opt-val (N_ "Tables") (N_ "Table cell spacing")))
-	 (padding (opt-val (N_ "Tables") (N_ "Table cell padding")))
-	 (border (opt-val (N_ "Tables") (N_ "Table border width")))
+         (spacing (opt-val (N_ "Tables") (N_ "Table cell spacing")))
+         (padding (opt-val (N_ "Tables") (N_ "Table cell padding")))
+         (border (opt-val (N_ "Tables") (N_ "Table border width")))
          (headcolumn 0))
 
-    ; center the document without elements inheriting anything
+    ;; center the document without elements inheriting anything
     (gnc:html-document-add-object! ssdoc
-       (gnc:make-html-text "<center>"))
+                                   (gnc:make-html-text "<center>"))
 
-    (gnc:html-document-set-style! 
-     ssdoc "body" 
+    (gnc:html-document-set-style!
+     ssdoc "body"
      'attribute (list "bgcolor" bgcolor)
      'attribute (list "text" textcolor)
      'attribute (list "link" linkcolor))
@@ -307,13 +307,13 @@
      'attribute (list "class" "centered-label-cell"))
 
     (if (and bgpixmap
-	     (not (string=? bgpixmap "")))
-	(gnc:html-document-set-style!
-	 ssdoc "body" 
-	 'attribute (list "background" (make-file-url bgpixmap))))
-    
+             (not (string=? bgpixmap "")))
+        (gnc:html-document-set-style!
+         ssdoc "body"
+         'attribute (list "background" (make-file-url bgpixmap))))
+
     (gnc:html-document-set-style!
-     ssdoc "table" 
+     ssdoc "table"
      'attribute (list "border" border)
      'attribute (list "cellspacing" spacing)
      'attribute (list "cellpadding" padding))
@@ -325,48 +325,48 @@
     (gnc:html-document-set-style!
      ssdoc "alternate-row"
      'attribute (list "bgcolor" alternate-row-color)
-     'tag "tr")       
+     'tag "tr")
     (gnc:html-document-set-style!
      ssdoc "primary-subheading"
      'attribute (list "bgcolor" primary-subheading-color)
-     'tag "tr")       
+     'tag "tr")
     (gnc:html-document-set-style!
      ssdoc "secondary-subheading"
      'attribute (list "bgcolor" secondary-subheading-color)
-     'tag "tr")       
+     'tag "tr")
     (gnc:html-document-set-style!
      ssdoc "grand-total"
      'attribute (list "bgcolor" grand-total-color)
-     'tag "tr")   
+     'tag "tr")
 
     ;; don't surround marked-up links with <a> </a>
     (if (not links?)
-	  (gnc:html-document-set-style! ssdoc "a" 'tag ""))
-    
+        (gnc:html-document-set-style! ssdoc "a" 'tag ""))
+
     (add-css-information-to-doc options ssdoc doc)
 
     (let ((t (gnc:make-html-table)))
-      ;; we don't want a bevel for this table, but we don't want 
-      ;; that to propagate 
+      ;; we don't want a bevel for this table, but we don't want
+      ;; that to propagate
       (gnc:html-table-set-style!
-       t "table" 
+       t "table"
        'attribute (list "border" 0)
        'inheritable? #f)
 
-      ; set the header column to be the 2nd when we have a logo
-      ; do this so that when logo is not present, the document
-      ; is perfectly centered
+      ;; set the header column to be the 2nd when we have a logo
+      ;; do this so that when logo is not present, the document
+      ;; is perfectly centered
       (if (and logopixmap (> (string-length logopixmap) 0))
-        (set! headcolumn 1))
+          (set! headcolumn 1))
 
       (let* ((title (gnc:html-document-title doc))
              (doc-headline (gnc:html-document-headline doc))
              (headline (if (eq? doc-headline #f) title doc-headline)))
 
-        (gnc:html-table-set-cell! 
+        (gnc:html-table-set-cell!
          t 1 headcolumn
-         (if show-preparer? 
-             ;; title plus preparer info 
+         (if show-preparer?
+             ;; title plus preparer info
              (gnc:make-html-text
               (gnc:html-markup-h3 headline)
               (gnc:html-markup-br)
@@ -380,47 +380,48 @@
               (qof-print-date
                (current-time)))
 
-             ;; title only 
+             ;; title only
              (gnc:make-html-text
               (gnc:html-markup-h3 headline))))
         )
-      
-      ; only setup an image if we specified one
+
+      ;; only setup an image if we specified one
       (if (and logopixmap (> (string-length logopixmap) 0))
-        (begin
-          (gnc:html-table-set-cell!
-            t 0 0
-            (gnc:make-html-text
-	      (gnc:html-markup-img (make-file-url logopixmap))))))
-      
+          (begin
+            (gnc:html-table-set-cell!
+             t 0 0
+             (gnc:make-html-text
+              (gnc:html-markup-img (make-file-url logopixmap))))))
+
       (if (and headpixmap (> (string-length headpixmap) 0))
-        (begin
+          (begin
+            (gnc:html-table-set-cell!
+             t 0 headcolumn
+             (gnc:make-html-text
+              (string-append
+               "<div align=\"" align "\">"
+               "<img src=\"" (make-file-url headpixmap) "\">"
+               "</div>")))
+            )
           (gnc:html-table-set-cell!
-            t 0 headcolumn
-            (gnc:make-html-text 
-               (string-append 
-                 "<div align=\"" align "\">"
-                 "<img src=\"" (make-file-url headpixmap) "\">"
-                 "</div>")))
-        )
-        (gnc:html-table-set-cell!
-          t 0 headcolumn
-          (gnc:make-html-text " ")))
-      
-      (apply 
-       gnc:html-table-set-cell! 
+           t 0 headcolumn
+           (gnc:make-html-text " ")))
+
+      (apply
+       gnc:html-table-set-cell!
        t 2 headcolumn
        (gnc:html-document-objects doc))
       (gnc:html-document-add-object! ssdoc t)
 
-	; I think this is the correct place to put the footer
-       (gnc:html-table-set-cell!
+      ;; I think this is the correct place to put the footer
+      (gnc:html-table-set-cell!
        t 3 headcolumn
        (gnc:make-html-text footer-text)))
-    (gnc:html-document-add-object! ssdoc (gnc:make-html-text "</center>")) ;;TODO: make this a div instead of <center> (deprecated)
+    (gnc:html-document-add-object! ssdoc (gnc:make-html-text "</center>"))
+    ;;TODO: make this a div instead of <center> (deprecated)
     ssdoc))
 
-(gnc:define-html-style-sheet 
+(gnc:define-html-style-sheet
  'version 1
  'name (N_ "Footer")
  'renderer footer-renderer
diff --git a/gnucash/report/stylesheets/stylesheet-head-or-tail.scm b/gnucash/report/stylesheets/stylesheet-head-or-tail.scm
index c2cbfd4cc..ad755094c 100644
--- a/gnucash/report/stylesheets/stylesheet-head-or-tail.scm
+++ b/gnucash/report/stylesheets/stylesheet-head-or-tail.scm
@@ -35,7 +35,7 @@
 
 (define-module (gnucash report stylesheet-head-or-tail))
 
-(use-modules (gnucash utilities)) 
+(use-modules (gnucash utilities))
 (use-modules (gnucash gnc-module))
 (use-modules (gnucash core-utils)) ; for gnc:version
 (use-modules (gnucash gettext))
@@ -45,9 +45,9 @@
 
 (define (head-or-tail-options)
   (let* ((options (gnc:new-options))
-	 (opt-register
-	  (lambda (opt)
-	    (gnc:register-option options opt))))
+         (opt-register
+          (lambda (opt)
+            (gnc:register-option options opt))))
     (opt-register
      (gnc:make-string-option
       (N_ "General")
@@ -96,7 +96,7 @@
       (N_ "Enable Links") "h"
       (N_ "Enable hyperlinks in reports.")
       #t))
-    ; FIXME: put this in a more sensible tab like Text or Header/Footer
+    ;; FIXME: put this in a more sensible tab like Text or Header/Footer
     (opt-register
      (gnc:make-text-option
       (N_ "General")
@@ -151,14 +151,14 @@
       (N_ "Heading Alignment") "c" (N_ "Banner for top of report.")
       'left
       (list (vector 'left
-                     (N_ "Left")
-                     (N_ "Align the banner to the left."))
+                    (N_ "Left")
+                    (N_ "Align the banner to the left."))
             (vector 'center
-                     (N_ "Center")
-                     (N_ "Align the banner in the center."))
+                    (N_ "Center")
+                    (N_ "Align the banner in the center."))
             (vector 'right
-                     (N_ "Right")
-                     (N_ "Align the banner to the right."))
+                    (N_ "Right")
+                    (N_ "Align the banner to the right."))
             )))
     (opt-register
      (gnc:make-pixmap-option
@@ -249,54 +249,54 @@
 
 (define (head-or-tail-renderer options doc)
   (let* ((ssdoc (gnc:make-html-document))
-	 (opt-val
-	  (lambda (section name)
-	    (gnc:option-value
-	     (gnc:lookup-option options section name))))
-	 (color-val
-	  (lambda (section name)
-	    (gnc:color-option->html
-	     (gnc:lookup-option options section name))))
-	 (preparer (opt-val (N_ "General") (N_ "Preparer")))
-	 (prepared-for (opt-val (N_ "General") (N_ "Prepared for")))
-	 (show-preparer? (opt-val (N_ "General") (N_ "Show preparer info")))
-	 (show-receiver? (opt-val (N_ "General") (N_ "Show receiver info")))
-	 (show-date? (opt-val (N_ "General") (N_ "Show date")))
-	 (show-time? (opt-val (N_ "General") (N_ "Show time in addition to date")))
-	 (show-gnucash-version? (opt-val (N_ "General") (N_ "Show GnuCash Version")))
+         (opt-val
+          (lambda (section name)
+            (gnc:option-value
+             (gnc:lookup-option options section name))))
+         (color-val
+          (lambda (section name)
+            (gnc:color-option->html
+             (gnc:lookup-option options section name))))
+         (preparer (opt-val (N_ "General") (N_ "Preparer")))
+         (prepared-for (opt-val (N_ "General") (N_ "Prepared for")))
+         (show-preparer? (opt-val (N_ "General") (N_ "Show preparer info")))
+         (show-receiver? (opt-val (N_ "General") (N_ "Show receiver info")))
+         (show-date? (opt-val (N_ "General") (N_ "Show date")))
+         (show-time? (opt-val (N_ "General") (N_ "Show time in addition to date")))
+         (show-gnucash-version? (opt-val (N_ "General") (N_ "Show GnuCash Version")))
          (show-preparer-at-bottom? (opt-val (N_ "General") (N_ "Show preparer info at bottom")))
          (show-receiver-at-bottom? (opt-val (N_ "General") (N_ "Show receiver info at bottom")))
          (show-date-time-at-bottom? (opt-val (N_ "General") (N_ "Show date/time at bottom")))
          (show-comments-at-bottom? (opt-val (N_ "General") (N_ "Show comments at bottom")))
          (show-gnucash-version-at-bottom? (opt-val (N_ "General") (N_ "Show GnuCash version at bottom")))
-	 (links? (opt-val (N_ "General") (N_ "Enable Links")))
-	 (additional-comments (opt-val (N_ "General") (N_ "Additional Comments")))
-	 (bgcolor (color-val (N_ "Colors") (N_ "Background Color")))
-	 (textcolor (color-val (N_ "Colors") (N_ "Text Color")))
-	 (linkcolor (color-val (N_ "Colors") (N_ "Link Color")))
-	 (normal-row-color (color-val (N_ "Colors") (N_ "Table Cell Color")))
-	 (alternate-row-color (color-val (N_ "Colors")
-					 (N_ "Alternate Table Cell Color")))
-	 (primary-subheading-color
-	  (color-val (N_ "Colors")
-		     (N_ "Subheading/Subtotal Cell Color")))
-	 (secondary-subheading-color
-	  (color-val (N_ "Colors")
-		     (N_ "Sub-subheading/total Cell Color")))
-	 (grand-total-color (color-val (N_ "Colors")
-				       (N_ "Grand Total Cell Color")))
-	 (bgpixmap (opt-val (N_ "Images") (N_ "Background Tile")))
-	 (headpixmap (opt-val (N_ "Images") (N_ "Heading Banner")))
-	 (logopixmap (opt-val (N_ "Images") (N_ "Logo")))
+         (links? (opt-val (N_ "General") (N_ "Enable Links")))
+         (additional-comments (opt-val (N_ "General") (N_ "Additional Comments")))
+         (bgcolor (color-val (N_ "Colors") (N_ "Background Color")))
+         (textcolor (color-val (N_ "Colors") (N_ "Text Color")))
+         (linkcolor (color-val (N_ "Colors") (N_ "Link Color")))
+         (normal-row-color (color-val (N_ "Colors") (N_ "Table Cell Color")))
+         (alternate-row-color (color-val (N_ "Colors")
+                                         (N_ "Alternate Table Cell Color")))
+         (primary-subheading-color
+          (color-val (N_ "Colors")
+                     (N_ "Subheading/Subtotal Cell Color")))
+         (secondary-subheading-color
+          (color-val (N_ "Colors")
+                     (N_ "Sub-subheading/total Cell Color")))
+         (grand-total-color (color-val (N_ "Colors")
+                                       (N_ "Grand Total Cell Color")))
+         (bgpixmap (opt-val (N_ "Images") (N_ "Background Tile")))
+         (headpixmap (opt-val (N_ "Images") (N_ "Heading Banner")))
+         (logopixmap (opt-val (N_ "Images") (N_ "Logo")))
          (align (gnc:value->string(opt-val (N_ "Images") (N_ "Heading Alignment"))))
-	 (spacing (opt-val (N_ "Tables") (N_ "Table cell spacing")))
-	 (padding (opt-val (N_ "Tables") (N_ "Table cell padding")))
-	 (border (opt-val (N_ "Tables") (N_ "Table border width")))
+         (spacing (opt-val (N_ "Tables") (N_ "Table cell spacing")))
+         (padding (opt-val (N_ "Tables") (N_ "Table cell padding")))
+         (border (opt-val (N_ "Tables") (N_ "Table border width")))
          (headcolumn 0))
 
-    ; center the document without elements inheriting anything
+    ;; center the document without elements inheriting anything
     (gnc:html-document-add-object! ssdoc
-       (gnc:make-html-text "<center>"))
+                                   (gnc:make-html-text "<center>"))
 
     (gnc:html-document-set-style!
      ssdoc "body"
@@ -372,10 +372,10 @@
      'attribute (list "class" "centered-label-cell"))
 
     (if (and bgpixmap
-	     (not (string=? bgpixmap "")))
-	(gnc:html-document-set-style!
-	 ssdoc "body"
-	 'attribute (list "background" (make-file-url bgpixmap))))
+             (not (string=? bgpixmap "")))
+        (gnc:html-document-set-style!
+         ssdoc "body"
+         'attribute (list "background" (make-file-url bgpixmap))))
 
     (gnc:html-document-set-style!
      ssdoc "table"
@@ -406,7 +406,7 @@
 
     ;; don't surround marked-up links with <a> </a>
     (if (not links?)
-	  (gnc:html-document-set-style! ssdoc "a" 'tag ""))
+        (gnc:html-document-set-style! ssdoc "a" 'tag ""))
 
     (add-css-information-to-doc options ssdoc doc)
 
@@ -418,122 +418,122 @@
        'attribute (list "border" 0)
        'inheritable? #f)
 
-      ; set the header column to be the 2nd when we have a logo
-      ; do this so that when logo is not present, the document
-      ; is perfectly centered
+      ;; set the header column to be the 2nd when we have a logo
+      ;; do this so that when logo is not present, the document
+      ;; is perfectly centered
       (if (and logopixmap (> (string-length logopixmap) 0))
-        (set! headcolumn 1))
+          (set! headcolumn 1))
 
       (let* ((title (gnc:html-document-title doc))
              (doc-headline (gnc:html-document-headline doc))
              (headline (if (eq? doc-headline #f) title doc-headline)))
 
         (gnc:html-table-set-cell!
-          t 1 headcolumn
-          ;; print title
-          (gnc:make-html-text
-            (gnc:html-markup-h3 headline))
-          (if (and show-preparer? (not show-preparer-at-bottom?))
-            ;; print preparer info as additional header info
-            (gnc:make-html-text
+         t 1 headcolumn
+         ;; print title
+         (gnc:make-html-text
+          (gnc:html-markup-h3 headline))
+         (if (and show-preparer? (not show-preparer-at-bottom?))
+             ;; print preparer info as additional header info
+             (gnc:make-html-text
               (gnc:html-markup-i
-                (_ "Prepared by: ")
-                (gnc:html-markup-b preparer)
-              )
+               (_ "Prepared by: ")
+               (gnc:html-markup-b preparer)
+               )
               (gnc:html-markup-br)
-            )
-            " "
-          )
-          (if (and show-receiver? (not show-receiver-at-bottom?))
-            ;; print receiver info as additional header info
-            (gnc:make-html-text
-              (gnc:html-markup-i
-                (_ "Prepared for: ")
-                (gnc:html-markup-b prepared-for)
-                (gnc:html-markup-br)
-              )
-            )
-            " "
-          )
-          (if (and show-date? (not show-date-time-at-bottom?))
-            ;; print date/time info as additional header info
-            (if show-time?
-              (gnc:make-html-text
-                (gnc:html-markup-i
-                  (_ "Report Creation Date: ")
-                  (qof-print-date (gnc:get-today))
-                  " "
-                  (strftime "%X %Z" (localtime (current-time)))
-                )
-                (gnc:html-markup-br)
-              )
-              (gnc:make-html-text
-                (gnc:html-markup-i
-                  (_ "Report Creation Date: ")
-                  (qof-print-date (gnc:get-today))
-                )
-                (gnc:html-markup-br)
               )
-            )
-            " "
-          )
-          (if (and show-gnucash-version? (not show-gnucash-version-at-bottom?))
-            ;; print the GnuCash version string as additional header info
-            (gnc:make-html-text
+             " "
+             )
+         (if (and show-receiver? (not show-receiver-at-bottom?))
+             ;; print receiver info as additional header info
+             (gnc:make-html-text
               (gnc:html-markup-i
-                "GnuCash "
-                gnc:version
+               (_ "Prepared for: ")
+               (gnc:html-markup-b prepared-for)
+               (gnc:html-markup-br)
+               )
               )
+             " "
+             )
+         (if (and show-date? (not show-date-time-at-bottom?))
+             ;; print date/time info as additional header info
+             (if show-time?
+                 (gnc:make-html-text
+                  (gnc:html-markup-i
+                   (_ "Report Creation Date: ")
+                   (qof-print-date (gnc:get-today))
+                   " "
+                   (strftime "%X %Z" (localtime (current-time)))
+                   )
+                  (gnc:html-markup-br)
+                  )
+                 (gnc:make-html-text
+                  (gnc:html-markup-i
+                   (_ "Report Creation Date: ")
+                   (qof-print-date (gnc:get-today))
+                   )
+                  (gnc:html-markup-br)
+                  )
+                 )
+             " "
+             )
+         (if (and show-gnucash-version? (not show-gnucash-version-at-bottom?))
+             ;; print the GnuCash version string as additional header info
+             (gnc:make-html-text
+              (gnc:html-markup-i
+               "GnuCash "
+               gnc:version
+               )
               (gnc:html-markup-br)
-            )
-            " "
-          )
-          (if (not show-comments-at-bottom?)
-            ;; print additional comments as additional header info
-            (gnc:make-html-text
+              )
+             " "
+             )
+         (if (not show-comments-at-bottom?)
+             ;; print additional comments as additional header info
+             (gnc:make-html-text
               (gnc:html-markup-br)
               (gnc:html-markup-i additional-comments)
               (gnc:html-markup-br)
-            )
-            " "
-          )
-          ;; add separator line if any additional header info is printed
-          (if (or
-                (and show-preparer? (not show-preparer-at-bottom?))
-                (and show-receiver? (not show-receiver-at-bottom?))
-                (and show-date? (not show-date-time-at-bottom?))
-                (and show-gnucash-version? (not show-gnucash-version-at-bottom?))
-                (not show-comments-at-bottom?)
               )
-            (gnc:make-html-text
+             " "
+             )
+         ;; add separator line if any additional header info is printed
+         (if (or
+              (and show-preparer? (not show-preparer-at-bottom?))
+              (and show-receiver? (not show-receiver-at-bottom?))
+              (and show-date? (not show-date-time-at-bottom?))
+              (and show-gnucash-version? (not show-gnucash-version-at-bottom?))
+              (not show-comments-at-bottom?)
+              )
+             (gnc:make-html-text
               (gnc:html-markup-br)
-            )
-            " "
-          )
+              )
+             " "
+             )
+         )
         )
-      )
 
-      ; only setup an image if we specified one
+      ;; only setup an image if we specified one
       (if (and logopixmap (> (string-length logopixmap) 0))
-        (begin
-          (gnc:html-table-set-cell!
-            t 0 0
-            (gnc:make-html-text
-	      (gnc:html-markup-img (make-file-url logopixmap))))))
+          (begin
+            (gnc:html-table-set-cell!
+             t 0 0
+             (gnc:make-html-text
+              (gnc:html-markup-img (make-file-url logopixmap))))))
 
       (if (and headpixmap (> (string-length headpixmap) 0))
-        (begin
+          (begin
+            (gnc:html-table-set-cell!
+             t 0 headcolumn
+             (gnc:make-html-text
+              (string-append
+               "<div align=\"" align "\">"
+               "<img src=\"" (make-file-url headpixmap) "\">"
+               "</div>")))
+            )
           (gnc:html-table-set-cell!
-            t 0 headcolumn
-            (gnc:make-html-text
-               (string-append
-                 "<div align=\"" align "\">"
-                 "<img src=\"" (make-file-url headpixmap) "\">"
-                 "</div>")))
-        )
-        (gnc:html-table-set-cell!
-          t 0 headcolumn
-          (gnc:make-html-text " ")))
+           t 0 headcolumn
+           (gnc:make-html-text " ")))
 
       (apply
        gnc:html-table-set-cell!
@@ -541,88 +541,88 @@
        (gnc:html-document-objects doc))
       (gnc:html-document-add-object! ssdoc t)
 
-	; I think this is the correct place to put the footer
-       (gnc:html-table-set-cell!
+      ;; I think this is the correct place to put the footer
+      (gnc:html-table-set-cell!
        t 3 headcolumn
        ;;(gnc:make-html-text additional-comments)
-        ;; add separator line if any additional header info is printed
-        (if (or
-              (and show-preparer? show-preparer-at-bottom?)
-              (and show-receiver? show-receiver-at-bottom?)
-              (and show-date? show-date-time-at-bottom?)
-              (and show-gnucash-version? show-gnucash-version-at-bottom?)
-              show-comments-at-bottom?
+       ;; add separator line if any additional header info is printed
+       (if (or
+            (and show-preparer? show-preparer-at-bottom?)
+            (and show-receiver? show-receiver-at-bottom?)
+            (and show-date? show-date-time-at-bottom?)
+            (and show-gnucash-version? show-gnucash-version-at-bottom?)
+            show-comments-at-bottom?
             )
-          (gnc:make-html-text
+           (gnc:make-html-text
             (gnc:html-markup-br)
-          )
-          " "
-        )
-        (if (and show-preparer? show-preparer-at-bottom?)
-          ;; print preparer info as additional header info
-          (gnc:make-html-text
-            (gnc:html-markup-i
-              (_ "Prepared by: ")
-              (gnc:html-markup-b preparer)
             )
-            (gnc:html-markup-br)
-          )
-          " "
-        )
-        (if (and show-receiver? show-receiver-at-bottom?)
-          ;; print receiver info as additional header info
-          (gnc:make-html-text
+           " "
+           )
+       (if (and show-preparer? show-preparer-at-bottom?)
+           ;; print preparer info as additional header info
+           (gnc:make-html-text
             (gnc:html-markup-i
-              (_ "Prepared for: ")
-              (gnc:html-markup-b prepared-for)
+             (_ "Prepared by: ")
+             (gnc:html-markup-b preparer)
+             )
+            (gnc:html-markup-br)
             )
+           " "
+           )
+       (if (and show-receiver? show-receiver-at-bottom?)
+           ;; print receiver info as additional header info
+           (gnc:make-html-text
+            (gnc:html-markup-i
+             (_ "Prepared for: ")
+             (gnc:html-markup-b prepared-for)
+             )
             (gnc:html-markup-br)
-          )
-          " "
-        )
-        (if (and show-date? show-date-time-at-bottom?)
-          ;; print date/time info as additional header info
-          (if show-time?
-            (gnc:make-html-text
-              (gnc:html-markup-i
-                (_ "Report Creation Date: ")
-                (qof-print-date (gnc:get-today))
-                " "
-                (strftime "%X %Z" (localtime (current-time)))
-              )
-              (gnc:html-markup-br)
             )
-            (gnc:make-html-text
-              (gnc:html-markup-i
-                (_ "Report Creation Date: ")
-                (qof-print-date (gnc:get-today))
+           " "
+           )
+       (if (and show-date? show-date-time-at-bottom?)
+           ;; print date/time info as additional header info
+           (if show-time?
+               (gnc:make-html-text
+                (gnc:html-markup-i
+                 (_ "Report Creation Date: ")
+                 (qof-print-date (gnc:get-today))
+                 " "
+                 (strftime "%X %Z" (localtime (current-time)))
+                 )
                 (gnc:html-markup-br)
-              )
-            )
-          )
-          " "
-        )
-        (if (and show-gnucash-version? show-gnucash-version-at-bottom?)
-          ;; print the GnuCash version string as additional header info
-          (gnc:make-html-text
+                )
+               (gnc:make-html-text
+                (gnc:html-markup-i
+                 (_ "Report Creation Date: ")
+                 (qof-print-date (gnc:get-today))
+                 (gnc:html-markup-br)
+                 )
+                )
+               )
+           " "
+           )
+       (if (and show-gnucash-version? show-gnucash-version-at-bottom?)
+           ;; print the GnuCash version string as additional header info
+           (gnc:make-html-text
             (gnc:html-markup-i
-              (_ "GnuCash ")
-              gnc:version
-            )
+             (_ "GnuCash ")
+             gnc:version
+             )
             (gnc:html-markup-br)
-          )
-          " "
-        )
-        (if show-comments-at-bottom?
-          ;; print additional comments as additional header info
-          (gnc:make-html-text
+            )
+           " "
+           )
+       (if show-comments-at-bottom?
+           ;; print additional comments as additional header info
+           (gnc:make-html-text
             (gnc:html-markup-br)
-              (gnc:html-markup-i additional-comments)
+            (gnc:html-markup-i additional-comments)
             (gnc:html-markup-br)
-          )
-          " "
-        )
-     ))
+            )
+           " "
+           )
+       ))
     (gnc:html-document-add-object! ssdoc (gnc:make-html-text "</center>")) ;;TODO: make this a div instead of <center> (deprecated)
     ssdoc))
 
diff --git a/gnucash/report/stylesheets/stylesheet-plain.scm b/gnucash/report/stylesheets/stylesheet-plain.scm
index 2a9d7e334..97983a4b1 100644
--- a/gnucash/report/stylesheets/stylesheet-plain.scm
+++ b/gnucash/report/stylesheets/stylesheet-plain.scm
@@ -24,7 +24,7 @@
 
 (define-module (gnucash report stylesheet-plain))
 
-(use-modules (gnucash utilities)) 
+(use-modules (gnucash utilities))
 (use-modules (gnucash gnc-module))
 (use-modules (gnucash core-utils))
 (use-modules (gnucash gettext))
@@ -39,89 +39,89 @@
 ;; it's supposed to be lightweight and unobtrusive.
 (define (plain-options)
   (let* ((options (gnc:new-options))
-     (opt-register
-      (lambda (opt)
-        (gnc:register-option options opt))))
-     (opt-register
-          (gnc:make-color-option
-           (N_ "General")
-           (N_ "Background Color") "a" (N_ "Background color for reports.")
-           (list #xff #xff #xff #xff)
-           255 #f))
          (opt-register
-          (gnc:make-pixmap-option
-           (N_ "General")
-           (N_ "Background Pixmap") "b" (N_ "Background tile for reports.")
-           ""))
-         (opt-register
-          (gnc:make-simple-boolean-option
-           (N_ "General")
-           (N_ "Enable Links") "c" (N_ "Enable hyperlinks in reports.")
-           #t))
-         (opt-register
-          (gnc:make-color-option
-           (N_ "Colors")
-           (N_ "Alternate Table Cell Color") "a" (N_ "Background color for alternate lines.")
-           (list #xff #xff #xff #xff)
-           255 #f))
-         (opt-register
-          (gnc:make-number-range-option
-           (N_ "Tables")
-           (N_ "Table cell spacing") "a" (N_ "Space between table cells.")
-           0 0 20 0 1))
-         (opt-register
-          (gnc:make-number-range-option
-           (N_ "Tables")
-           (N_ "Table cell padding") "b" (N_ "Space between table cell edge and content.")
-           4 0 20 0 1))
-         (opt-register
-          (gnc:make-number-range-option
-           (N_ "Tables")
-           (N_ "Table border width") "c" (N_ "Bevel depth on tables.")
-           0 0 20 0 1))
-         (register-font-options options)
-
-         options))
+          (lambda (opt)
+            (gnc:register-option options opt))))
+    (opt-register
+     (gnc:make-color-option
+      (N_ "General")
+      (N_ "Background Color") "a" (N_ "Background color for reports.")
+      (list #xff #xff #xff #xff)
+      255 #f))
+    (opt-register
+     (gnc:make-pixmap-option
+      (N_ "General")
+      (N_ "Background Pixmap") "b" (N_ "Background tile for reports.")
+      ""))
+    (opt-register
+     (gnc:make-simple-boolean-option
+      (N_ "General")
+      (N_ "Enable Links") "c" (N_ "Enable hyperlinks in reports.")
+      #t))
+    (opt-register
+     (gnc:make-color-option
+      (N_ "Colors")
+      (N_ "Alternate Table Cell Color") "a" (N_ "Background color for alternate lines.")
+      (list #xff #xff #xff #xff)
+      255 #f))
+    (opt-register
+     (gnc:make-number-range-option
+      (N_ "Tables")
+      (N_ "Table cell spacing") "a" (N_ "Space between table cells.")
+      0 0 20 0 1))
+    (opt-register
+     (gnc:make-number-range-option
+      (N_ "Tables")
+      (N_ "Table cell padding") "b" (N_ "Space between table cell edge and content.")
+      4 0 20 0 1))
+    (opt-register
+     (gnc:make-number-range-option
+      (N_ "Tables")
+      (N_ "Table border width") "c" (N_ "Bevel depth on tables.")
+      0 0 20 0 1))
+    (register-font-options options)
+
+    options))
 
 (define (plain-renderer options doc)
   (let*
-    ((ssdoc (gnc:make-html-document))
-     (opt-val
-      (lambda (section name)
-        (gnc:option-value
-         (gnc:lookup-option options section name))))
-     (bgcolor
-      (gnc:color-option->html
-       (gnc:lookup-option options
-                  "General"
-                  "Background Color")))
-     (bgpixmap (opt-val "General" "Background Pixmap"))
-     (links? (opt-val "General" "Enable Links"))
-     (alternate-row-color
-      (gnc:color-option->html
-       (gnc:lookup-option options
-                  "Colors"
-                  "Alternate Table Cell Color")))
-     (spacing (opt-val "Tables" "Table cell spacing"))
-     (padding (opt-val "Tables" "Table cell padding"))
-     (border (opt-val "Tables" "Table border width"))
-    )
-
-    (gnc:html-document-set-style!
-       ssdoc "body"
-       'attribute (list "bgcolor" bgcolor))
+      ((ssdoc (gnc:make-html-document))
+       (opt-val
+        (lambda (section name)
+          (gnc:option-value
+           (gnc:lookup-option options section name))))
+       (bgcolor
+        (gnc:color-option->html
+         (gnc:lookup-option options
+                            "General"
+                            "Background Color")))
+       (bgpixmap (opt-val "General" "Background Pixmap"))
+       (links? (opt-val "General" "Enable Links"))
+       (alternate-row-color
+        (gnc:color-option->html
+         (gnc:lookup-option options
+                            "Colors"
+                            "Alternate Table Cell Color")))
+       (spacing (opt-val "Tables" "Table cell spacing"))
+       (padding (opt-val "Tables" "Table cell padding"))
+       (border (opt-val "Tables" "Table border width"))
+       )
 
-    (if (and bgpixmap
-         (not (string=? bgpixmap "")))
     (gnc:html-document-set-style!
      ssdoc "body"
-     'attribute (list "background" (make-file-url bgpixmap))))
+     'attribute (list "bgcolor" bgcolor))
+
+    (if (and bgpixmap
+             (not (string=? bgpixmap "")))
+        (gnc:html-document-set-style!
+         ssdoc "body"
+         'attribute (list "background" (make-file-url bgpixmap))))
 
     (gnc:html-document-set-style!
-       ssdoc "table"
-       'attribute (list "border" border)
-       'attribute (list "cellspacing" spacing)
-       'attribute (list "cellpadding" padding))
+     ssdoc "table"
+     'attribute (list "border" border)
+     'attribute (list "cellspacing" spacing)
+     'attribute (list "cellpadding" padding))
 
     (gnc:html-document-set-style!
      ssdoc "column-heading-left"
@@ -189,13 +189,13 @@
      'attribute (list "class" "centered-label-cell"))
 
     (gnc:html-document-set-style!
-       ssdoc "normal-row"
-       'tag "tr")
+     ssdoc "normal-row"
+     'tag "tr")
 
     (gnc:html-document-set-style!
-       ssdoc "alternate-row"
-       'tag "tr"
-       'attribute (list "bgcolor" alternate-row-color))
+     ssdoc "alternate-row"
+     'tag "tr"
+     'attribute (list "bgcolor" alternate-row-color))
 
     (gnc:html-document-set-style!
      ssdoc "primary-subheading"
@@ -212,9 +212,9 @@
 
     ;; don't surround marked-up links with <a> </a>
     (if (not links?)
-    (gnc:html-document-set-style!
-     ssdoc "a"
-     'tag ""))
+        (gnc:html-document-set-style!
+         ssdoc "a"
+         'tag ""))
 
     (add-css-information-to-doc options ssdoc doc)
 
@@ -223,13 +223,13 @@
            (headline (if (eq? doc-headline #f)
                          title doc-headline)))
       (if headline
-      (gnc:html-document-add-object!
-       ssdoc
-       (gnc:make-html-text
-         (gnc:html-markup-h3 headline)))))
+          (gnc:html-document-add-object!
+           ssdoc
+           (gnc:make-html-text
+            (gnc:html-markup-h3 headline)))))
 
     (gnc:html-document-append-objects! ssdoc
-                       (gnc:html-document-objects doc))
+                                       (gnc:html-document-objects doc))
 
     ssdoc))
 
diff --git a/gnucash/report/stylesheets/stylesheets.scm b/gnucash/report/stylesheets/stylesheets.scm
index abaee4a81..3f810a7eb 100644
--- a/gnucash/report/stylesheets/stylesheets.scm
+++ b/gnucash/report/stylesheets/stylesheets.scm
@@ -2,7 +2,7 @@
 ;;  stylesheets.scm
 ;;  load the standard stylesheet definitions
 ;;
-;;  Copyright (c) 2001 Linux Developers Group, Inc. 
+;;  Copyright (c) 2001 Linux Developers Group, Inc.
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; This program is free software; you can redistribute it and/or
@@ -26,7 +26,7 @@
 
 (define-module (gnucash report stylesheets))
 
-(use-modules (gnucash utilities)) 
+(use-modules (gnucash utilities))
 (use-modules (gnucash report stylesheet-plain))
 (use-modules (gnucash report stylesheet-fancy))
 (use-modules (gnucash report stylesheet-footer))

commit 375013f9ea4857f46effc4d4a8c2a68956cb3184
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Sat Apr 20 14:11:03 2019 +0800

    [commodity-utils] simplify gnc:make-exchange-function
    
    Remove assigning exchangelist to exchange-alist.
    
    Removes need to test foreign-amount against 0 - multiplication will
    result in 0 anyway. The only functional change is the condition
    whereby foreign's commodity is not present in exchangelist; previously
    it would return (gnc:make-gnc-monetary domestic 0); now it returns #f.
    
    This function *is* allowed to return #f for invalid or missing prices;
    see the (and foreign ...) conditional.

diff --git a/gnucash/report/report-system/commodity-utilities.scm b/gnucash/report/report-system/commodity-utilities.scm
index b4c73a116..a0877a1c5 100644
--- a/gnucash/report/report-system/commodity-utilities.scm
+++ b/gnucash/report/report-system/commodity-utilities.scm
@@ -690,23 +690,18 @@ construct with gnc:make-gnc-monetary and gnc:monetary->string instead.")
 ;; the <gnc:commodity*> domestic-commodity, exchanges the amount into
 ;; the domestic currency and returns a <gnc-monetary>.
 (define (gnc:make-exchange-function exchange-alist)
-  (let ((exchangelist exchange-alist))
-    (lambda (foreign domestic)
-      (gnc:debug "foreign: " (gnc:monetary->string foreign))
-      (gnc:debug "domestic: " (gnc-commodity-get-printname domestic))
-      (and foreign
-           (or (gnc:exchange-by-euro foreign domestic #f)
-               (gnc:exchange-if-same foreign domestic)
-               (gnc:make-gnc-monetary
-                domestic
-                (let ((pair (assoc (gnc:gnc-monetary-commodity foreign)
-                                   exchangelist))
-                      (foreign-amount (gnc:gnc-monetary-amount foreign)))
-                  (if (or (not pair)
-                          (zero? foreign-amount))
-                      0
-                      (* foreign-amount
-                         (cadr pair))))))))))
+  (lambda (foreign domestic)
+    (gnc:debug "foreign: " (gnc:monetary->string foreign))
+    (gnc:debug "domestic: " (gnc-commodity-get-printname domestic))
+    (and foreign
+         (or (gnc:exchange-by-euro foreign domestic #f)
+             (gnc:exchange-if-same foreign domestic)
+             (let* ((foreign-comm (gnc:gnc-monetary-commodity foreign))
+                    (pair (assoc foreign-comm exchange-alist)))
+               (and pair
+                    (gnc:make-gnc-monetary
+                     domestic
+                     (* (gnc:gnc-monetary-amount foreign) (cadr pair)))))))))
 
 ;; Helper for the gnc:exchange-by-pricalist* below. Exchange the
 ;; <gnc:monetary> 'foreign' into the <gnc:commodity*> 'domestic' by

commit e111c5bb07cf3bbf85f6d248f825beb6fa7ae66c
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Tue Apr 9 21:31:41 2019 +0800

    [commodity-utils] use scheme division instead of gnc-numeric
    
    with small change to test due to increased precision

diff --git a/gnucash/report/report-system/commodity-utilities.scm b/gnucash/report/report-system/commodity-utilities.scm
index eca006dc5..b4c73a116 100644
--- a/gnucash/report/report-system/commodity-utilities.scm
+++ b/gnucash/report/report-system/commodity-utilities.scm
@@ -306,14 +306,6 @@ construct with gnc:make-gnc-monetary and gnc:monetary->string instead.")
                        pricelist))
          (earlier (and (not (null? earlierlist))
                        (last earlierlist))))
-    ;;          (if earlier
-    ;;              (warn "earlier"
-    ;;                    (qof-print-date (car earlier))
-    ;;                    (gnc-numeric-to-double (cadr earlier))))
-    ;;          (if later
-    ;;              (warn "later"
-    ;;                    (qof-print-date (car later))
-    ;;                    (gnc-numeric-to-double (cadr later))))
 
     (if (and earlier later)
         (if (< (abs (- date (car earlier)))
@@ -637,11 +629,8 @@ construct with gnc:make-gnc-monetary and gnc:monetary->string instead.")
   (map
    (lambda (e)
      (list (car e)
-           (abs
-            (gnc-numeric-div ((cdadr e) 'total #f)
-                             ((caadr e) 'total #f)
-                             GNC-DENOM-AUTO
-                             (logior (GNC-DENOM-SIGFIGS 8) GNC-RND-ROUND)))))
+           (abs (/ ((cdadr e) 'total #f)
+                   ((caadr e) 'total #f)))))
    (gnc:get-exchange-totals report-commodity end-date)))
 
 (define (gnc:make-exchange-cost-alist report-commodity end-date)
@@ -651,12 +640,10 @@ construct with gnc:make-gnc-monetary and gnc:monetary->string instead.")
   (map
    (lambda (e)
      (list (car e)
-           (if (zero? ((caadr e) 'total #f)) 0
-           (abs
-            (gnc-numeric-div ((cdadr e) 'total #f)
-                             ((caadr e) 'total #f)
-                             GNC-DENOM-AUTO
-                             (logior (GNC-DENOM-SIGFIGS 8) GNC-RND-ROUND))))))
+           (if (zero? ((caadr e) 'total #f))
+               0
+               (abs (/ ((cdadr e) 'total #f)
+                       ((caadr e) 'total #f))))))
    (gnc:get-exchange-cost-totals report-commodity end-date)))
 
 
@@ -718,10 +705,8 @@ construct with gnc:make-gnc-monetary and gnc:monetary->string instead.")
                   (if (or (not pair)
                           (zero? foreign-amount))
                       0
-                      (gnc-numeric-mul foreign-amount
-                                       (cadr pair)
-                                       (gnc-commodity-get-fraction domestic)
-                                       GNC-RND-ROUND)))))))))
+                      (* foreign-amount
+                         (cadr pair))))))))))
 
 ;; Helper for the gnc:exchange-by-pricalist* below. Exchange the
 ;; <gnc:monetary> 'foreign' into the <gnc:commodity*> 'domestic' by
@@ -734,10 +719,8 @@ construct with gnc:make-gnc-monetary and gnc:monetary->string instead.")
        (gnc:make-gnc-monetary
         domestic
         (if price-value
-            (gnc-numeric-mul (gnc:gnc-monetary-amount foreign)
-                             price-value
-                             (gnc-commodity-get-fraction domestic)
-                             GNC-RND-ROUND)
+            (* (gnc:gnc-monetary-amount foreign)
+               price-value)
             (begin
               (warn "gnc:exchange-by-pricevalue-helper: No price found for "
                     (gnc:monetary->string foreign) " into "
@@ -758,10 +741,8 @@ construct with gnc:make-gnc-monetary and gnc:monetary->string instead.")
         domestic
         (if price
             (let ((result
-                   (gnc-numeric-mul (gnc:gnc-monetary-amount foreign)
-                                    (gnc-price-get-value price)
-                                    (gnc-commodity-get-fraction domestic)
-                                    GNC-RND-ROUND)))
+                   (* (gnc:gnc-monetary-amount foreign)
+                      (gnc-price-get-value price))))
               (gnc-price-unref price)
               result)
             (begin
diff --git a/gnucash/report/report-system/test/test-commodity-utils.scm b/gnucash/report/report-system/test/test-commodity-utils.scm
index 7a1e1cac1..97d104d05 100644
--- a/gnucash/report/report-system/test/test-commodity-utils.scm
+++ b/gnucash/report/report-system/test/test-commodity-utils.scm
@@ -697,7 +697,7 @@
                           (gnc-dmy2time64-neutral 20 02 2016)
                           #f #f)))
         (test-equal "gnc:case-exchange-time-fn average-cost 20/02/2012"
-          8073/100
+          14127/175
           (gnc:gnc-monetary-amount
            (exchange-fn
             (gnc:make-gnc-monetary AAPL 1)

commit f2aacf94cc5b30d2de391ae4ac0a81a0d765394d
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Sat Apr 6 11:05:53 2019 +0800

    [commodity-utils] remove price-is-not-zero? and work-done
    
    because now we're not adding invalid prices to pricelist, and avoids
    set! calls
    
    also fix typo in deprecation message

diff --git a/gnucash/report/report-system/commodity-utilities.scm b/gnucash/report/report-system/commodity-utilities.scm
index fca7f38a9..eca006dc5 100644
--- a/gnucash/report/report-system/commodity-utilities.scm
+++ b/gnucash/report/report-system/commodity-utilities.scm
@@ -90,11 +90,6 @@ construct with gnc:make-gnc-monetary and gnc:monetary->string instead.")
    (gnc:make-gnc-monetary foreign-commodity foreign-numeric)
    domestic date))
 
-;; Returns true if the given pricealist element is a non-zero price.
-(define (gnc:price-is-not-zero? elem)
-  (and (cadr elem)
-       (not (zero? (cadr elem)))))
-
 ;; Create a list of all prices of 'price-commodity' measured in the currency
 ;; 'report-currency'. The prices are taken from all splits in
 ;; 'currency-accounts' up until the date 'end-date'. Returns a list of
@@ -202,14 +197,12 @@ construct with gnc:make-gnc-monetary and gnc:monetary->string instead.")
           (gnc-account-get-descendants-sorted (gnc-get-current-root-account)))
          (all-splits (get-all-splits currency-accounts end-date))
          (interesting-splits (sort (filter interesting-split? all-splits) date<?))
-         (work-to-do (length commodity-list))
-         (work-done 0))
+         (work-to-do (length commodity-list)))
     (map
-     (lambda (c)
+     (lambda (c work-done)
        (define (split-has-commodity? s)
          (or (gnc-commodity-equiv c (xaccTransGetCurrency (xaccSplitGetParent s)))
              (gnc-commodity-equiv c (xaccAccountGetCommodity (xaccSplitGetAccount s)))))
-       (set! work-done (1+ work-done))
        (if start-percent
            (gnc:report-percent-done
             (+ start-percent (* delta-percent (/ work-done work-to-do)))))
@@ -217,7 +210,8 @@ construct with gnc:make-gnc-monetary and gnc:monetary->string instead.")
              (gnc:get-commodity-totalavg-prices-internal
               currency-accounts end-date c report-currency
               (filter split-has-commodity? interesting-splits))))
-     commodity-list)))
+     commodity-list
+     (iota work-to-do))))
 
 ;; Get the instantaneous prices for the 'price-commodity', measured in
 ;; amounts of the 'report-currency'. The prices are taken from all
@@ -284,19 +278,17 @@ construct with gnc:make-gnc-monetary and gnc:monetary->string instead.")
    "gnc:get-commoditylist-inst-prices is deprecated.")
   (let ((currency-accounts
          (gnc-account-get-descendants-sorted (gnc-get-current-root-account)))
-        (work-to-do (length commodity-list))
-        (work-done 0))
+        (work-to-do (length commodity-list)))
     (map
-     (lambda (c)
-       (begin
-         (set! work-done (+ 1 work-done))
-         (if start-percent
-             (gnc:report-percent-done
-              (+ start-percent (* delta-percent (/ work-done work-to-do)))))
-         (cons c
-               (gnc:get-commodity-inst-prices
-                currency-accounts end-date c report-currency))))
-     commodity-list)))
+     (lambda (c work-done)
+       (if start-percent
+           (gnc:report-percent-done
+            (+ start-percent (* delta-percent (/ work-done work-to-do)))))
+       (cons c
+             (gnc:get-commodity-inst-prices
+              currency-accounts end-date c report-currency)))
+     commodity-list
+     (iota work-to-do))))
 
 
 ;; Find the price in 'pricelist' that's nearest to 'date'. The

commit fbcf488237f0f48b3c5e594bce1cb3ddeb514659
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Fri Apr 5 23:41:04 2019 +0800

    [commodity-utils] refactor resolve-unknown-comm

diff --git a/gnucash/report/report-system/commodity-utilities.scm b/gnucash/report/report-system/commodity-utilities.scm
index a0c636df5..fca7f38a9 100644
--- a/gnucash/report/report-system/commodity-utilities.scm
+++ b/gnucash/report/report-system/commodity-utilities.scm
@@ -359,117 +359,114 @@ construct with gnc:make-gnc-monetary and gnc:monetary->string instead.")
   ;; report-commodity, and now the transactions with unknown
   ;; currencies should be added to that list (with an appropriate
   ;; exchange rate).
-  (let ((reportlist (cadr (assoc report-commodity sumlist))))
-
-    ;; Helper function to calculate (a*b)/c and create the new pair of
-    ;; numeric-collectors, where [abc] are numeric-collectors. See the
-    ;; real variable names below.
-    (define (make-newrate unknown-coll un->known-coll known-pair)
-      (let ((a (gnc:make-value-collector))
-            (b (gnc:make-value-collector)))
-        (a 'add (unknown-coll 'total #f))
-        (b 'add
-           ;; round to (at least) 8 significant digits
-           (gnc-numeric-div
-            (gnc-numeric-mul
-             (un->known-coll 'total #f)
-             ((cdadr known-pair) 'total #f)
-             GNC-DENOM-AUTO
-             (logior (GNC-DENOM-SIGFIGS 9) GNC-RND-ROUND))
-            ((caadr known-pair) 'total #f)
-            GNC-DENOM-AUTO
-            (logior (GNC-DENOM-SIGFIGS 8) GNC-RND-ROUND)))
-        ;; in other words: (/ (* (caadr un->known-coll) (cdadr
-        ;; known-pair)) (caadr known-pair) ))
-        (cons a b)))
-
-    ;; Go through sumlist.
-    (for-each
-     (lambda (otherlist)
-       (if (not (gnc-commodity-equiv (car otherlist) report-commodity))
-           (for-each
-            (lambda (pair)
-              ;; Check whether by any accident the report-commodity
-              ;; appears here.
-              (if
-               (not (gnc-commodity-equiv (car pair) report-commodity))
-               ;; pair-{a,b}: Try to find either the currency of
-               ;; otherlist or of pair in reportlist.
-               (let ((pair-a
-                      (or
-                       ;; Find the otherlist's currency in reportlist
-                       (assoc (car otherlist) reportlist)
-                       ;; Or try whether that's an Euro currency.
-                       (let
-                           ((euro-monetary
-                             (gnc:exchange-by-euro (gnc:make-gnc-monetary
-                                                    (car otherlist)
-                                                    ((cdadr pair) 'total #f))
-                                                   report-commodity #f)))
-                         ;; If this is an Euro currency, create the
-                         ;; pair of appropriately exchanged amounts.
-                         (if euro-monetary
-                             (let ((a (gnc:make-value-collector)))
-                               (a 'add
-                                  (gnc:gnc-monetary-amount euro-monetary))
-                               (list report-commodity
-                                     (cons (cdadr pair) a)))
-                             #f))))
-                     ;; Find the pair's currency in reportlist. FIXME:
-                     ;; Also try the Euro here.
-                     (pair-b (assoc (car pair) reportlist))
-                     (rate 0))
-                 (if (and (not pair-a) (not pair-b))
-                     ;; If neither the currency of otherlist nor of
-                     ;; pair was found in reportlist then we can't
-                     ;; resolve the exchange rate to this currency.
-                     (warn "gnc:resolve-unknown-comm:"
-                           "can't calculate rate for "
-                           (gnc:monetary->string
-                            (gnc:make-gnc-monetary (car pair) ((caadr pair) 'total #f)))
-                           " = "
-                           (gnc:monetary->string
-                            (gnc:make-gnc-monetary (car otherlist) ((cdadr pair) 'total #f)))
-                           " to "
-                           (gnc:monetary->string
-                            (gnc:make-gnc-monetary report-commodity 0)))
-                     (if (and pair-a pair-b)
-                         ;; If both currencies are found then something
-                         ;; went wrong inside
-                         ;; gnc:get-exchange-totals. FIXME: Find a
-                         ;; better thing to do in this case.
-                         (warn "gnc:resolve-unknown-comm:"
-                               "Oops - exchange rate ambiguity error: "
-                               (gnc:monetary->string
-                                (gnc:make-gnc-monetary (car pair) ((caadr pair) 'total #f)))
-                               " = "
-                               (gnc:monetary->string
-                                (gnc:make-gnc-monetary (car otherlist)
-                                      ((cdadr pair) 'total #f))))
-                         (let
-                             ;; Usual case: one of pair-{a,b} was found
-                             ;; in reportlist, i.e. this transaction
-                             ;; can be resolved to report-commodity.
-                             ((newrate
-                               (if (not pair-a)
-                                   (list (car otherlist)
-                                         (make-newrate (cdadr pair)
-                                                       (caadr pair) pair-b))
-                                   (list (car pair)
-                                         (make-newrate (caadr pair)
-                                                       (cdadr pair) pair-a)))))
-                           (set! reportlist (cons newrate reportlist))))))
-               ;; Huh, the report-currency showed up on the wrong side
-               ;; -- we will just add it to the reportlist on the
-               ;; right side.
-               (let ((newrate (list (car otherlist)
-                                    (cons (cdadr pair) (caadr pair)))))
-                 (set! reportlist (cons newrate reportlist)))))
-            (cadr otherlist))))
-     sumlist)
-
-    ;; Return the reportlist.
-    reportlist))
+
+  ;; Helper function to calculate (a*b)/c and create the new pair of
+  ;; numeric-collectors, where [abc] are numeric-collectors. See the
+  ;; real variable names below.
+  (define (make-newrate unknown-coll un->known-coll known-pair)
+    (let ((a (gnc:make-value-collector))
+          (b (gnc:make-value-collector))
+          (c ((caadr known-pair) 'total #f)))
+      (a 'add (unknown-coll 'total #f))
+      (unless (zero? c)
+        (b 'add (/ (* (un->known-coll 'total #f)
+                      ((cdadr known-pair) 'total #f))
+                   c)))
+      (cons a b)))
+
+  ;; Go through sumlist.
+  (let loop ((sumlist sumlist)
+             (reportlist (cadr (assoc report-commodity sumlist))))
+    (cond
+     ((null? sumlist) reportlist)
+
+     ((gnc-commodity-equiv (caar sumlist) report-commodity)
+      (loop (cdr sumlist) reportlist))
+
+     (else
+      (let innerloop ((pairs (cadr (car sumlist)))
+                      (reportlist reportlist))
+        (cond
+         ((null? pairs)
+          (loop (cdr sumlist) reportlist))
+
+         ;; Check whether by any accident the report-commodity appears
+         ;; here.  Huh, the report-currency showed up on the wrong
+         ;; side -- we will just add it to the reportlist on the right
+         ;; side.
+         ((gnc-commodity-equiv (caar pairs) report-commodity)
+          (innerloop (cdr pairs)
+                     (cons (list (caar sumlist)
+                                 (cons (cdadr (car pairs)) (caadr (car pairs))))
+                           reportlist)))
+
+         (else
+          ;; pair-{a,b}: Try to find either the currency of (car
+          ;; sumlist) or of pair in reportlist.
+          (let* ((pair (car pairs))
+                 (pair-a (or (assoc (car (car sumlist)) reportlist)
+                             ;; Find the (car sumlist)'s currency in reportlist
+                             ;; Or try whether that's an Euro currency.
+                             (let ((euro-monetary
+                                    (gnc:exchange-by-euro
+                                     (gnc:make-gnc-monetary
+                                      (car (car sumlist))
+                                      ((cdadr pair) 'total #f))
+                                     report-commodity #f)))
+                               ;; If this is an Euro currency, create the
+                               ;; pair of appropriately exchanged amounts.
+                               (and euro-monetary
+                                    (let ((a (gnc:make-value-collector)))
+                                      (a 'add (gnc:gnc-monetary-amount euro-monetary))
+                                      (list report-commodity
+                                            (cons (cdadr pair) a)))))))
+                 ;; Find the pair's currency in reportlist. FIXME:
+                 ;; Also try the Euro here.
+                 (pair-b (assoc (car pair) reportlist)))
+
+            (cond
+             ((and (not pair-a) (not pair-b))
+              ;; If neither the currency of (car sumlist) nor of pair
+              ;; was found in reportlist then we can't resolve the
+              ;; exchange rate to this currency.
+              (warn "gnc:resolve-unknown-comm:"
+                    "can't calculate rate for "
+                    (gnc:monetary->string
+                     (gnc:make-gnc-monetary (car pair) ((caadr pair) 'total #f)))
+                    " = "
+                    (gnc:monetary->string
+                     (gnc:make-gnc-monetary (caar sumlist) ((cdadr pair) 'total #f)))
+                    " to "
+                    (gnc:monetary->string (gnc:make-gnc-monetary report-commodity 0)))
+              (innerloop (cdr pairs) reportlist))
+
+             ((and pair-a pair-b)
+              ;; If both currencies are found then something went
+              ;; wrong inside gnc:get-exchange-totals. FIXME: Find a
+              ;; better thing to do in this case.
+              (warn "gnc:resolve-unknown-comm:"
+                    "Oops - exchange rate ambiguity error: "
+                    (gnc:monetary->string
+                     (gnc:make-gnc-monetary (car pair) ((caadr pair) 'total #f)))
+                    " = "
+                    (gnc:monetary->string
+                     (gnc:make-gnc-monetary (caar sumlist) ((cdadr pair) 'total #f))))
+              (innerloop (cdr pairs) reportlist))
+
+             ;; Usual case: one of pair-{a,b} was found in reportlist,
+             ;; i.e. this transaction can be resolved to
+             ;; report-commodity.
+             (pair-a
+              (innerloop (cdr pairs)
+                         (cons (list (car pair)
+                                     (make-newrate (caadr pair) (cdadr pair) pair-a))
+                               reportlist)))
+             (pair-b
+              (innerloop (cdr pairs)
+                         (cons (list (car (car sumlist))
+                                     (make-newrate (cdadr pair) (caadr pair) pair-b))
+                               reportlist))))))))))))
+
 ;; Some thoughts: In the (and (not pair-a) (not pair-b)) case above we
 ;; will have unresolvable transaction exchange rates. But there might
 ;; be cases where we will be able to resolve this, but only after one

commit ce675eaac6b52e85cd9fe8602002f7b9d55e63ba
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Fri Apr 5 23:31:45 2019 +0800

    [commodity-utils] refactor get-exchange-cost-totals

diff --git a/gnucash/report/report-system/commodity-utilities.scm b/gnucash/report/report-system/commodity-utilities.scm
index 1e7a90405..a0c636df5 100644
--- a/gnucash/report/report-system/commodity-utilities.scm
+++ b/gnucash/report/report-system/commodity-utilities.scm
@@ -563,74 +563,83 @@ construct with gnc:make-gnc-monetary and gnc:monetary->string instead.")
 ;; gains and losses, of each commodity across all accounts. Returns a
 ;; report-list.
 (define (gnc:get-exchange-cost-totals report-commodity end-date)
-  (let ((curr-accounts
-         (gnc-account-get-descendants-sorted (gnc-get-current-root-account)))
-        (sumlist (list (list report-commodity '()))))
-
-    (if (not (null? curr-accounts))
-        ;; Go through all splits and add up all value-amounts
-        ;; and share-amounts
-        ;; However skip splits in trading accounts as these counterbalance
-        ;; the actual value and share amounts back to zero
-        (for-each
-         (lambda (a)
-           (if (not (eq? (xaccAccountGetType (xaccSplitGetAccount a)) ACCT-TYPE-TRADING))
-               (let* ((transaction-comm (xaccTransGetCurrency
-                                         (xaccSplitGetParent a)))
-                      (account-comm (xaccAccountGetCommodity
-                                     (xaccSplitGetAccount a)))
-                      (share-amount (xaccSplitGetAmount a))
-                      (value-amount (xaccSplitGetValue a))
-                      (comm-list (or (assoc transaction-comm sumlist)
-                                     (assoc account-comm sumlist))))
-
-                 ;; entry exists already in comm-list?
-                 (if (not comm-list)
-                     ;; no, create sub-alist from scratch
-                     (let ((pair (list transaction-comm
-                                       (cons (gnc:make-value-collector)
+  (let ((curr-accounts (gnc-account-get-descendants-sorted
+                        (gnc-get-current-root-account))))
+
+    (let loop ((comm-splits (gnc:get-all-commodity-splits curr-accounts end-date))
+               (sumlist (list (list report-commodity '()))))
+      (cond
+       ((null? comm-splits)
+        (gnc:resolve-unknown-comm sumlist report-commodity))
+
+       ;; However skip splits in trading accounts as these counterbalance
+       ;; the actual value and share amounts back to zero
+       ((eqv? (xaccAccountGetType (xaccSplitGetAccount (car comm-splits)))
+              ACCT-TYPE-TRADING)
+        (loop (cdr comm-splits)
+              sumlist))
+
+       ;; Go through all splits and add up all value-amounts
+       ;; and share-amounts
+       (else
+        (let* ((a (car comm-splits))
+               (txn-comm (xaccTransGetCurrency (xaccSplitGetParent a)))
+               (acc-comm (xaccAccountGetCommodity (xaccSplitGetAccount a)))
+               (share-amt (xaccSplitGetAmount a))
+               (value-amt (xaccSplitGetValue a)))
+
+          (cond
+           ((assoc txn-comm sumlist)
+            => (lambda (comm-list)
+                 (cond
+                  ;; other commodity already exists in comm-list?
+                  ((assoc acc-comm (cadr comm-list))
+                   => (lambda (pair)
+                        ((caadr pair) 'add share-amt)
+                        ((cdadr pair) 'add value-amt)
+                        (loop (cdr comm-splits)
+                              sumlist)))
+                  ;; if not, create a new entry in comm-list.
+                  (else
+                   (let ((pair (list acc-comm (cons (gnc:make-value-collector)
+                                                    (gnc:make-value-collector)))))
+                     ((caadr pair) 'add share-amt)
+                     ((cdadr pair) 'add value-amt)
+                     (loop (cdr comm-splits)
+                           (cons (list (car comm-list) (cons pair (cadr comm-list)))
+                                 (alist-delete
+                                  (car comm-list) sumlist))))))))
+
+           ((assoc acc-comm sumlist)
+            => (lambda (comm-list)
+                 (cond
+                  ;; other commodity already exists in comm-list?
+                  ((assoc txn-comm (cadr comm-list))
+                   => (lambda (pair)
+                        ((caadr pair) 'add (- value-amt))
+                        ((cdadr pair) 'add (- share-amt))
+                        (loop (cdr comm-splits)
+                              sumlist)))
+                  (else
+                   (let ((pair (list txn-comm (cons (gnc:make-value-collector)
+                                                    (gnc:make-value-collector)))))
+                     ;; And add the balances to the comm-list entry.
+                     ((caadr pair) 'add (- value-amt))
+                     ((cdadr pair) 'add (- share-amt))
+                     (loop (cdr comm-splits)
+                           (cons (list (car comm-list) (cons pair (cadr comm-list)))
+                                 (alist-delete
+                                  (car comm-list) sumlist))))))))
+
+           (else
+            ;; no, create sub-alist from scratch
+            (let ((pair (list txn-comm (cons (gnc:make-value-collector)
                                              (gnc:make-value-collector)))))
-                       ((caadr pair) 'add value-amount)
-                       ((cdadr pair) 'add share-amount)
-                       (set! comm-list (list account-comm (list pair)))
-                       ;; and add the new sub-alist to sumlist.
-                       (set! sumlist (cons comm-list sumlist)))
-                     ;; yes, check for second commodity.
-                     (let*
-                         ;; Put the amounts in the right place.
-                         ((foreignlist
-                           (if (gnc-commodity-equiv transaction-comm
-                                                    (car comm-list))
-                               (list account-comm
-                                     share-amount value-amount)
-                               (list transaction-comm
-                                     (- value-amount)
-                                     (- share-amount))))
-                          ;; second commodity already existing in comm-list?
-                          (pair (assoc (car foreignlist) (cadr comm-list))))
-                       ;; if not, create a new entry in comm-list.
-                       (if (not pair)
-                           (begin
-                             (set!
-                              pair (list (car foreignlist)
-                                         (cons (gnc:make-value-collector)
-                                               (gnc:make-value-collector))))
-                             (set!
-                              comm-list (list (car comm-list)
-                                              (cons pair (cadr comm-list))))
-                             (set!
-                              sumlist (cons comm-list
-                                            (alist-delete
-                                             (car comm-list) sumlist)))))
-                       ;; And add the balances to the comm-list entry.
-                       ((caadr pair) 'add (cadr foreignlist))
-                       ((cdadr pair) 'add (caddr foreignlist)))))))
-         (gnc:get-all-commodity-splits curr-accounts end-date)))
-
-    (gnc:resolve-unknown-comm sumlist report-commodity)))
-
-;; Anybody feel free to reimplement any of these functions, either in
-;; scheme or in C. -- cstim
+              ((caadr pair) 'add value-amt)
+              ((cdadr pair) 'add share-amt)
+              ;; and add the new sub-alist to sumlist.
+              (loop (cdr comm-splits)
+                    (cons (list acc-comm (list pair)) sumlist)))))))))))
 
 (define (gnc:make-exchange-alist report-commodity end-date)
   ;; This returns the alist with the actual exchange rates, i.e. the

commit b2dc906bcd7c2597aaa585d4c8ae7248783b765c
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Fri Apr 5 22:44:13 2019 +0800

    [commodity-utils] refactor get-exchange-totals

diff --git a/gnucash/report/report-system/commodity-utilities.scm b/gnucash/report/report-system/commodity-utilities.scm
index 2d49cc760..1e7a90405 100644
--- a/gnucash/report/report-system/commodity-utilities.scm
+++ b/gnucash/report/report-system/commodity-utilities.scm
@@ -484,75 +484,80 @@ construct with gnc:make-gnc-monetary and gnc:monetary->string instead.")
 ;; amount total of 2000 GBP and a value of 2400 EUR. Returns a report-list.
 
 (define (gnc:get-exchange-totals report-commodity end-date)
-  (let ((curr-accounts
-         (gnc-account-get-descendants-sorted (gnc-get-current-root-account)))
-        (sumlist (list (list report-commodity '()))))
-
-    (if (not (null? curr-accounts))
-        ;; Go through all splits and add up all value-amounts
-        ;; and share-amounts
-        (for-each
-         (lambda (a)
-           (let* ((transaction-comm (xaccTransGetCurrency
-                                     (xaccSplitGetParent a)))
-                  (account-comm (xaccAccountGetCommodity
-                                 (xaccSplitGetAccount a)))
-                  ;; Always use the absolute value here.
-                  (share-amount (abs
-                                 (xaccSplitGetAmount a)))
-                  (value-amount (abs
-                                 (xaccSplitGetValue a)))
-                  (comm-list (or (assoc transaction-comm sumlist)
-                                 (assoc account-comm sumlist))))
-
-             (cond ((zero? share-amount)
-                    ;; Without shares this is not a buy or sell; ignore it.
-                    #f)
-
-                   ((not comm-list)
-                    ;; entry doesn't exist in comm-list
-                    ;; create sub-alist from scratch
-                    (let ((pair (list transaction-comm
-                                      (cons (gnc:make-value-collector)
-                                            (gnc:make-value-collector)))))
-                      ((caadr pair) 'add value-amount)
-                      ((cdadr pair) 'add share-amount)
-                      (set! comm-list (list account-comm (list pair)))
-                      ;; and add the new sub-alist to sumlist.
-                      (set! sumlist (cons comm-list sumlist))))
-
-                   (else
-                    (let*
-                        ;; Put the amounts in the right place.
-                        ((foreignlist
-                          (if (gnc-commodity-equiv transaction-comm
-                                                   (car comm-list))
-                              (list account-comm
-                                    share-amount value-amount)
-                              (list transaction-comm
-                                    value-amount share-amount)))
-                         ;; second commodity already existing in comm-list?
-                         (pair (assoc (car foreignlist) (cadr comm-list))))
-                      ;; if not, create a new entry in comm-list.
-                      (if (not pair)
-                          (begin
-                            (set!
-                             pair (list (car foreignlist)
-                                        (cons (gnc:make-value-collector)
-                                              (gnc:make-value-collector))))
-                            (set!
-                             comm-list (list (car comm-list)
-                                             (cons pair (cadr comm-list))))
-                            (set!
-                             sumlist (cons comm-list
-                                           (alist-delete
-                                            (car comm-list) sumlist)))))
-                      ;; And add the balances to the comm-list entry.
-                      ((caadr pair) 'add (cadr foreignlist))
-                      ((cdadr pair) 'add (caddr foreignlist)))))))
-         (gnc:get-all-commodity-splits curr-accounts end-date)))
-
-    (gnc:resolve-unknown-comm sumlist report-commodity)))
+  (let ((curr-accounts (gnc-account-get-descendants-sorted
+                        (gnc-get-current-root-account))))
+
+    ;; Go through all splits and add up all value-amounts
+    ;; and share-amounts
+    (let loop ((comm-splits (gnc:get-all-commodity-splits curr-accounts end-date))
+               (sumlist (list (list report-commodity '()))))
+      (cond
+       ((null? comm-splits)
+        (gnc:resolve-unknown-comm sumlist report-commodity))
+
+       (else
+        (let* ((a (car comm-splits))
+               (txn-comm (xaccTransGetCurrency (xaccSplitGetParent a)))
+               (acc-comm (xaccAccountGetCommodity (xaccSplitGetAccount a)))
+               ;; Always use the absolute value here.
+               (share-amt (abs (xaccSplitGetAmount a)))
+               (value-amt (abs (xaccSplitGetValue a))))
+          (cond
+           ;; Without shares this is not a buy or sell; ignore it.
+           ((zero? share-amt)
+            (loop (cdr comm-splits)
+                  sumlist))
+
+           ((assoc txn-comm sumlist)
+            => (lambda (comm-list)
+                 (cond
+                  ((assoc acc-comm (cadr comm-list)) =>
+                   ;; second commodity already exists in comm-list:
+                   (lambda (pair)
+                     ((caadr pair) 'add share-amt)
+                     ((cdadr pair) 'add value-amt)
+                     (loop (cdr comm-splits)
+                           sumlist)))
+                  (else
+                   ;; if not, create a new entry in comm-list.
+                   (let ((pair (list acc-comm (cons (gnc:make-value-collector)
+                                                    (gnc:make-value-collector)))))
+                     ((caadr pair) 'add share-amt)
+                     ((cdadr pair) 'add value-amt)
+                     (loop (cdr comm-splits)
+                           (cons (list txn-comm (cons pair (cadr comm-list)))
+                                 (alist-delete txn-comm sumlist))))))))
+
+           ((assoc acc-comm sumlist)
+            => (lambda (comm-list)
+                 (cond
+                  ((assoc txn-comm (cadr comm-list)) =>
+                   ;; second commodity already exists in comm-list:
+                   (lambda (pair)
+                     ((caadr pair) 'add value-amt)
+                     ((cdadr pair) 'add share-amt)
+                     (loop (cdr comm-splits)
+                           sumlist)))
+                  (else
+                   ;; if not, create a new entry in comm-list.
+                   (let ((pair (list txn-comm (cons (gnc:make-value-collector)
+                                                    (gnc:make-value-collector)))))
+                     ((caadr pair) 'add value-amt)
+                     ((cdadr pair) 'add share-amt)
+                     (loop (cdr comm-splits)
+                           (cons (list acc-comm (cons pair (cadr comm-list)))
+                                 (alist-delete acc-comm sumlist))))))))
+
+           ;; entry doesn't exist in sumlist. create sub-alist from scratch
+           (else
+            (let ((pair (list txn-comm
+                              (cons (gnc:make-value-collector)
+                                    (gnc:make-value-collector)))))
+              ((caadr pair) 'add value-amt)
+              ((cdadr pair) 'add share-amt)
+              (loop (cdr comm-splits)
+                    (cons (list acc-comm (list pair))
+                          sumlist)))))))))))
 
 ;; Sum the net amounts and values in the report commodity, including booked
 ;; gains and losses, of each commodity across all accounts. Returns a

commit 9ef2a2f3dd82a7731cb9dc11f4d7e5190e038f45
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Fri Apr 5 21:23:18 2019 +0800

    [commodity-utils] refactor inst price calculator

diff --git a/gnucash/report/report-system/commodity-utilities.scm b/gnucash/report/report-system/commodity-utilities.scm
index 4938ef0c7..2d49cc760 100644
--- a/gnucash/report/report-system/commodity-utilities.scm
+++ b/gnucash/report/report-system/commodity-utilities.scm
@@ -228,68 +228,49 @@ construct with gnc:make-gnc-monetary and gnc:monetary->string instead.")
 (define (gnc:get-commodity-inst-prices
          currency-accounts end-date price-commodity report-currency)
   ;; go through all splits; convert all splits into a price.
-  (filter
-   gnc:price-is-not-zero?
-   (map-in-order
-    (lambda (a)
-      (let* ((transaction-comm (xaccTransGetCurrency
-                                (xaccSplitGetParent a)))
-             (account-comm (xaccAccountGetCommodity
-                            (xaccSplitGetAccount a)))
-             (share-amount (abs
-                            (xaccSplitGetAmount a)))
-             (value-amount (abs
-                            (xaccSplitGetValue a)))
-             (transaction-date (xaccTransGetDate
-                                (xaccSplitGetParent a)))
-             (foreignlist
-              (if (gnc-commodity-equiv transaction-comm price-commodity)
-                  (list account-comm
-                        share-amount value-amount)
-                  (list transaction-comm
-                        value-amount share-amount))))
-
-        ;; Try EURO exchange if necessary
-        (if (not (gnc-commodity-equiv (car foreignlist)
-                                      report-currency))
-            (let ((exchanged (gnc:exchange-by-euro-numeric
-                              (car foreignlist) (cadr foreignlist)
-                              report-currency transaction-date)))
-              (if exchanged
-                  (set! foreignlist
-                        (list report-currency
-                              (gnc:gnc-monetary-amount exchanged)
-                              (caddr foreignlist))))))
-
-        (list
-         transaction-date
-         (if (not (gnc-commodity-equiv (car foreignlist)
-                                       report-currency))
-             (begin
-               (warn "get-commodity-inst-prices: "
-                     "Sorry, currency exchange not yet implemented:"
-                       (gnc:monetary->string
-                        (gnc:make-gnc-monetary
-                         (car foreignlist) (cadr foreignlist)))
-                       " (buying "
-                       (gnc:monetary->string
-                        (gnc:make-gnc-monetary
-                         price-commodity (caddr foreignlist)))
-                       ") =? "
-                       (gnc:monetary->string
-                        (gnc:make-gnc-monetary
-                         report-currency 0)))
-               0)
-             (if (not (zero? (caddr foreignlist)))
-                 (gnc-numeric-div
-                  (cadr foreignlist)
-                  (caddr foreignlist)
-                  GNC-DENOM-AUTO
-                  (logior (GNC-DENOM-SIGFIGS 8) GNC-RND-ROUND)) 0)))))
-    ;; Get all the interesting splits, sorted by date.
-    (gnc:get-match-commodity-splits-sorted
-     currency-accounts
-     end-date price-commodity))))
+  (let loop ((result '())
+             (commodity-splits (gnc:get-match-commodity-splits-sorted
+                                currency-accounts end-date price-commodity)))
+    (if (null? commodity-splits)
+        (reverse! result)
+        (let* ((a (car commodity-splits))
+               (txn-comm (xaccTransGetCurrency (xaccSplitGetParent a)))
+               (acc-comm (xaccAccountGetCommodity (xaccSplitGetAccount a)))
+               (share-amt (abs (xaccSplitGetAmount a)))
+               (value-amt (abs (xaccSplitGetValue a)))
+               (txn-date (xaccTransGetDate (xaccSplitGetParent a))))
+          (cond
+           ((or (zero? share-amt) (zero? value-amt))
+            (loop result
+                  (cdr commodity-splits)))
+
+           ((gnc-commodity-equiv acc-comm report-currency)
+            (loop (cons (list txn-date (/ share-amt value-amt)) result)
+                  (cdr commodity-splits)))
+
+           ((gnc-commodity-equiv txn-comm report-currency)
+            (loop (cons (list txn-date (/ value-amt share-amt)) result)
+                  (cdr commodity-splits)))
+
+           ((gnc:exchange-by-euro-numeric txn-comm value-amt report-currency txn-date)
+            => (lambda (amt)
+                 (loop (cons (list txn-date (/ (gnc:gnc-monetary-amount amt) share-amt))
+                             result)
+                       (cdr commodity-splits))))
+
+           (else
+            (warn "get-commodity-inst-prices: "
+                  "Sorry, currency exchange not yet implemented:"
+                  (gnc:monetary->string
+                   (gnc:make-gnc-monetary txn-comm value-amt))
+                  " (buying "
+                  (gnc:monetary->string
+                   (gnc:make-gnc-monetary price-commodity share-amt))
+                  ") =? "
+                  (gnc:monetary->string
+                   (gnc:make-gnc-monetary report-currency 0)))
+            (loop result
+                  (cdr commodity-splits))))))))
 
 ;; Get the instantaneous prices for all commodities in
 ;; 'commodity-list', i.e. the same thing as get-commodity-inst-prices

commit 91f3e9fefec44e392adf3968d9cdc7117b7d8913
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Fri Apr 5 21:01:33 2019 +0800

    [commodity-utils] refactor totalavg price calculator
    
    use exact rationals, therefore test suite amended

diff --git a/gnucash/report/report-system/commodity-utilities.scm b/gnucash/report/report-system/commodity-utilities.scm
index 972672717..4938ef0c7 100644
--- a/gnucash/report/report-system/commodity-utilities.scm
+++ b/gnucash/report/report-system/commodity-utilities.scm
@@ -121,86 +121,66 @@ construct with gnc:make-gnc-monetary and gnc:monetary->string instead.")
     currency-accounts end-date price-commodity)))
 
 (define (gnc:get-commodity-totalavg-prices-internal
-         currency-accounts end-date price-commodity report-currency
-         commodity-splits)
-  (let ((total-foreign 0)
-        (total-domestic 0))
-    (filter
-     gnc:price-is-not-zero?
-     (map-in-order
-      (lambda (a)
-        (let* ((transaction-comm (xaccTransGetCurrency
-                                  (xaccSplitGetParent a)))
-               (account-comm (xaccAccountGetCommodity
-                              (xaccSplitGetAccount a)))
-               (share-amount (abs
-                              (xaccSplitGetAmount a)))
-               (value-amount (abs
-                              (xaccSplitGetValue a)))
-               (transaction-date (xaccTransGetDate
-                                  (xaccSplitGetParent a)))
-               (foreignlist
-                (if (and
-                     (not (zero? share-amount))
-                     (not (zero? value-amount)))
-                    (if (gnc-commodity-equiv transaction-comm
-                                             price-commodity)
-                        (list account-comm
-                              share-amount value-amount)
-                        (list transaction-comm
-                              value-amount share-amount))
-                    #f)))
-
-          ;; Try EURO exchange if necessary
-          (if (and foreignlist
-                   (not (gnc-commodity-equiv (car foreignlist)
-                                        report-currency)))
-              (let ((exchanged (gnc:exchange-by-euro-numeric
-                                (car foreignlist) (cadr foreignlist)
-                                report-currency transaction-date)))
-                (if exchanged
-                    (set! foreignlist
-                          (list report-currency
-                                (gnc:gnc-monetary-amount exchanged)
-                                (caddr foreignlist))))))
-
-          (list
-           transaction-date
-           (if foreignlist
-               (if (not (gnc-commodity-equiv (car foreignlist)
-                                             report-currency))
-                   (begin
-                     (warn "gnc:get-commodity-totalavg-prices: "
-                           "Sorry, currency exchange not yet implemented:"
-                           (gnc:monetary->string
-                            (gnc:make-gnc-monetary
-                             (car foreignlist) (cadr foreignlist)))
-                           " (buying "
-                           (gnc:monetary->string
-                            (gnc:make-gnc-monetary
-                             price-commodity (caddr foreignlist)))
-                           ") =? "
-                           (gnc:monetary->string
-                            (gnc:make-gnc-monetary
-                            report-currency 0)))
-                     0)
-                   (begin
-                     (set! total-foreign (gnc-numeric-add total-foreign
-                                                          (caddr foreignlist)
-                                                          GNC-DENOM-AUTO
-                                                          GNC-DENOM-LCD))
-                     (set! total-domestic (gnc-numeric-add total-domestic
-                                                           (cadr foreignlist)
-                                                           GNC-DENOM-AUTO
-                                                           GNC-DENOM-LCD))
-                     (if (not (zero? total-foreign))
-                         (gnc-numeric-div
-                          total-domestic
-                          total-foreign
-                          GNC-DENOM-AUTO
-                          (logior (GNC-DENOM-SIGFIGS 8) GNC-RND-ROUND)) 0)))
-               #f))))
-      commodity-splits))))
+         currency-accounts end-date price-commodity report-currency commodity-splits)
+  (let loop ((tot-foreign 0)
+             (tot-domestic 0)
+             (commodity-splits commodity-splits)
+             (result '()))
+    (if (null? commodity-splits)
+        (reverse! result)
+        (let* ((a (car commodity-splits))
+               (share-amt (abs (xaccSplitGetAmount a)))
+               (value-amt (abs (xaccSplitGetValue a)))
+               (txn-comm (xaccTransGetCurrency (xaccSplitGetParent a)))
+               (acc-comm (xaccAccountGetCommodity (xaccSplitGetAccount a)))
+               (txn-date (xaccTransGetDate (xaccSplitGetParent a))))
+          (cond
+           ((or (zero? share-amt) (zero? value-amt))
+            (loop tot-foreign
+                  tot-domestic
+                  (cdr commodity-splits)
+                  result))
+
+           ((gnc-commodity-equiv acc-comm report-currency)
+            (let ((new-foreign (+ tot-foreign value-amt))
+                  (new-domestic (+ tot-domestic share-amt)))
+              (loop new-foreign
+                    new-domestic
+                    (cdr commodity-splits)
+                    (cons (list txn-date (/ new-domestic new-foreign)) result))))
+
+           ((gnc-commodity-equiv txn-comm report-currency)
+            (let ((new-foreign (+ tot-foreign share-amt))
+                  (new-domestic (+ tot-domestic value-amt)))
+              (loop new-foreign
+                    new-domestic
+                    (cdr commodity-splits)
+                    (cons (list txn-date (/ new-domestic new-foreign)) result))))
+
+           ((gnc:exchange-by-euro-numeric txn-comm value-amt report-currency txn-date)
+            => (lambda (amt)
+                 (let ((new-foreign (+ tot-foreign share-amt))
+                       (new-domestic (+ tot-domestic (gnc:gnc-monetary-amount amt))))
+                   (loop new-foreign
+                         new-domestic
+                         (cdr commodity-splits)
+                         (cons (list txn-date (/ new-domestic new-foreign)) result)))))
+
+           (else
+            (warn "gnc:get-commodity-totalavg-prices: "
+                  "Sorry, currency exchange not yet implemented:"
+                  (gnc:monetary->string
+                   (gnc:make-gnc-monetary txn-comm value-amt))
+                  " (buying "
+                  (gnc:monetary->string
+                   (gnc:make-gnc-monetary price-commodity share-amt))
+                  ") =? "
+                  (gnc:monetary->string
+                   (gnc:make-gnc-monetary report-currency 0)))
+            (loop tot-foreign
+                  tot-domestic
+                  (cdr commodity-splits)
+                  result)))))))
 
 
 ;; Create a list of prices for all commodities in 'commodity-list',
diff --git a/gnucash/report/report-system/test/test-commodity-utils.scm b/gnucash/report/report-system/test/test-commodity-utils.scm
index 3a17d62ab..7a1e1cac1 100644
--- a/gnucash/report/report-system/test/test-commodity-utils.scm
+++ b/gnucash/report/report-system/test/test-commodity-utils.scm
@@ -566,26 +566,22 @@
        (test-equal "MSFT totalavg 2012-01-15" (/ 4216500/100 1500)
                    (cadr (assoc (gnc-dmy2time64-neutral 15 01 2012)
                                 report-list)))
-;; We have to use gnc-numeric-div with rounding in order to match the results
-;; from the function. Astute observers will notice that the totals include the
+;; Astute observers will notice that the totals include the
 ;; capital gain split but not the acutal sell split on the day because the
 ;; capital gain price is first in the list so that's the one (assoc) finds. See
 ;; the comment at the gnc:get-commodity-totalavg-prices definition for more
 ;; about the prices from this function.
        (test-equal "MSFT totalavg 2014-12-05"
-                   (gnc-numeric-div 6637500/100 2000 GNC-DENOM-AUTO
-                                    (logior (GNC-DENOM-SIGFIGS 8) GNC-RND-ROUND))
-                   (cadr (assoc (gnc-dmy2time64-neutral 5 12 2014)
-                                report-list)))
+         (/ 6637500/100 2000)
+         (cadr (assoc (gnc-dmy2time64-neutral 5 12 2014)
+                      report-list)))
        (test-equal "MSFT totalavg 2015-04-02"
-                   (gnc-numeric-div 9860700/100 2800 GNC-DENOM-AUTO
-                                    (logior (GNC-DENOM-SIGFIGS 8) GNC-RND-ROUND))
-                   (cadr (assoc (gnc-dmy2time64-neutral 2 4 2015) report-list)))
+         (/ 9860700/100 2800)
+         (cadr (assoc (gnc-dmy2time64-neutral 2 4 2015) report-list)))
        (test-equal "MSFT totalavg 2016-03-11"
-                   (gnc-numeric-div 14637000/100 3700 GNC-DENOM-AUTO
-                                    (logior (GNC-DENOM-SIGFIGS 8) GNC-RND-ROUND))
-                   (cadr (assoc (gnc-dmy2time64-neutral 11 3 2016)
-                                report-list))))
+         (/ 14637000/100 3700)
+         (cadr (assoc (gnc-dmy2time64-neutral 11 3 2016)
+                      report-list))))
      (test-end "Microsoft-USD")
 
      (test-begin "Daimler-DEM")

commit 76936bc646737116e24306c931d46141914aff00
Author: Frank H. Ellenberger <frank.h.ellenberger at gmail.com>
Date:   Fri May 3 23:05:30 2019 +0200

    [I18N] Improve doc-page of CSV transaction importer
    
    Text based on
    https://lists.gnucash.org/pipermail/gnucash-devel/2019-May/043795.html

diff --git a/gnucash/gtkbuilder/assistant-csv-trans-import.glade b/gnucash/gtkbuilder/assistant-csv-trans-import.glade
index dfeb7f2bd..c4183714a 100644
--- a/gnucash/gtkbuilder/assistant-csv-trans-import.glade
+++ b/gnucash/gtkbuilder/assistant-csv-trans-import.glade
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.20.4 -->
+<!-- Generated with glade 3.22.1 -->
 <interface>
   <requires lib="gtk+" version="3.10"/>
   <object class="GtkListStore" id="account_match_store">
@@ -1080,17 +1080,20 @@ For example
           <object class="GtkLabel" id="label8">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
-            <property name="label" translatable="yes">On the following page you will be able to associate each transaction to a category.
+            <property name="label" translatable="yes">If you click "Next" Gnucash will perform a number of checks.
 
-If there were problems with the import settings, pressing forward will take you back to the preview page to try and correct.
+If one of those <i>checks fails</i> you'll be automatically redirected to the preview page to try and correct.
 
-If this is the first time importing, you will find that all lines may need to be associated. On subsequent imports, the importer will try to associate the transactions based on previous imports.
+On the following page you will be able to associate each transaction to a category.
 
-If this is your initial import into a new file, you will first see a dialog for setting book options, since these can affect how imported data are converted to GnuCash transactions. If this is an existing file, the dialog will not be shown.
+If this is your <i>initial import into a new file</i>, you will first see a dialog for setting book options, since these can affect how imported data are converted to GnuCash transactions. If this is an existing file, the dialog will not be shown.
+
+If this is the <i>first time importing</i>, you will find that all lines may need to be associated. On subsequent imports, the importer will try to associate the transactions based on previous imports.
 
 The confidence of a correct association is displayed as a colored bar.
 
 More information can be displayed by using the help button.</property>
+            <property name="use_markup">True</property>
             <property name="wrap">True</property>
           </object>
           <packing>

commit 8fb2111636613ce134ce90622fe33f994c6e574b
Merge: 53e4e8a97 24ac69d8a
Author: John Ralls <jralls at ceridwen.us>
Date:   Fri May 3 13:26:42 2019 -0700

    Merge Christoph Holtermann's  'pycons-more-verbose' into maint.

diff --cc gnucash/python/init.py
index 5659c6a57,bee795774..5cf1f99c9
--- a/gnucash/python/init.py
+++ b/gnucash/python/init.py
@@@ -95,10 -85,15 +95,15 @@@ class Console (cons.Console)
  
  # Change this to "if True:" to switch on a python console at gnucash
  # startup:
+ # shelltype can either be "python" or "ipython" (the latter is not yet fully functional)
  if False:
-     console = Console(argv = [], shelltype = 'python', banner = [['woop', 'title']], size = 100)
+     shelltype = "python"
+     title = "gnucash "+shelltype+" shell"
+     banner_style = 'title'
+     banner = "Welcome to "+title+"!\n"
+     console = Console(argv = [], shelltype = shelltype, banner = [[banner, banner_style]], size = 100)
  
 -    window = Gtk.Window(Gtk.WindowType.TOPLEVEL)
 +    window = Gtk.Window(type = Gtk.WindowType.TOPLEVEL)
      window.set_position(Gtk.WindowPosition.CENTER)
      window.set_default_size(800,600)
      window.set_border_width(0)

commit 24ac69d8a96ad44153fa1477a3bbf349aa687316
Author: c-holtermann <mail at c-holtermann.net>
Date:   Fri Apr 19 11:13:30 2019 +0200

    make python shell startup more understandable

diff --git a/gnucash/python/init.py b/gnucash/python/init.py
index ca96f1223..bee795774 100644
--- a/gnucash/python/init.py
+++ b/gnucash/python/init.py
@@ -85,8 +85,13 @@ class Console (cons.Console):
 
 # Change this to "if True:" to switch on a python console at gnucash
 # startup:
+# shelltype can either be "python" or "ipython" (the latter is not yet fully functional)
 if False:
-    console = Console(argv = [], shelltype = 'python', banner = [['woop', 'title']], size = 100)
+    shelltype = "python"
+    title = "gnucash "+shelltype+" shell"
+    banner_style = 'title'
+    banner = "Welcome to "+title+"!\n"
+    console = Console(argv = [], shelltype = shelltype, banner = [[banner, banner_style]], size = 100)
 
     window = Gtk.Window(Gtk.WindowType.TOPLEVEL)
     window.set_position(Gtk.WindowPosition.CENTER)

commit 53e4e8a9768dacf18359d1280e114d01f7d8fa22
Author: Frank H. Ellenberger <frank.h.ellenberger at gmail.com>
Date:   Fri May 3 11:50:31 2019 +0200

    Use standard buttons in "Tip of the Day"

diff --git a/gnucash/gtkbuilder/dialog-totd.glade b/gnucash/gtkbuilder/dialog-totd.glade
index 17896d66e..c8bb7db01 100644
--- a/gnucash/gtkbuilder/dialog-totd.glade
+++ b/gnucash/gtkbuilder/dialog-totd.glade
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.20.0 -->
+<!-- Generated with glade 3.22.1 -->
 <interface>
   <requires lib="gtk+" version="3.10"/>
   <object class="GtkDialog" id="totd_dialog">
@@ -10,6 +10,9 @@
     <property name="default_height">300</property>
     <property name="type_hint">dialog</property>
     <signal name="response" handler="gnc_totd_dialog_response_cb" swapped="no"/>
+    <child>
+      <placeholder/>
+    </child>
     <child internal-child="vbox">
       <object class="GtkBox" id="dialog-vbox3">
         <property name="visible">True</property>
@@ -23,12 +26,13 @@
             <property name="layout_style">end</property>
             <child>
               <object class="GtkButton" id="back-button">
-                <property name="label" translatable="yes">_Back</property>
+                <property name="label">gtk-media-previous</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="can_default">True</property>
                 <property name="receives_default">True</property>
                 <property name="use_underline">True</property>
+                <property name="use_stock">True</property>
               </object>
               <packing>
                 <property name="expand">False</property>
@@ -38,12 +42,13 @@
             </child>
             <child>
               <object class="GtkButton" id="forward-button">
-                <property name="label" translatable="yes">_Forward</property>
+                <property name="label">gtk-media-next</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="can_default">True</property>
                 <property name="receives_default">True</property>
                 <property name="use_underline">True</property>
+                <property name="use_stock">True</property>
               </object>
               <packing>
                 <property name="expand">False</property>
@@ -53,12 +58,13 @@
             </child>
             <child>
               <object class="GtkButton" id="close-button">
-                <property name="label" translatable="yes">_Close</property>
+                <property name="label">gtk-close</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="can_default">True</property>
                 <property name="receives_default">True</property>
                 <property name="use_underline">True</property>
+                <property name="use_stock">True</property>
               </object>
               <packing>
                 <property name="expand">False</property>
@@ -125,10 +131,10 @@
                         <property name="border_width">6</property>
                         <property name="editable">False</property>
                         <property name="wrap_mode">word</property>
-                        <property name="accepts_tab">False</property>
                         <property name="left_margin">5</property>
                         <property name="right_margin">5</property>
                         <property name="cursor_visible">False</property>
+                        <property name="accepts_tab">False</property>
                       </object>
                       <packing>
                         <property name="expand">True</property>

commit 275463d3b8a3ab9cad83c6e771ee75c665888475
Author: Frank H. Ellenberger <frank.h.ellenberger at gmail.com>
Date:   Wed May 1 00:57:24 2019 +0200

    N[I18N] "Next" is the new "Forward"
    
    From GTK2 to 3 the button label changed. So several texts referenced a
    no longer existing button.
    
    For changed strings also unify quotation to \"

diff --git a/gnucash/gnome-utils/assistant-xml-encoding.c b/gnucash/gnome-utils/assistant-xml-encoding.c
index 4f5aa69cb..368ef241a 100644
--- a/gnucash/gnome-utils/assistant-xml-encoding.c
+++ b/gnucash/gnome-utils/assistant-xml-encoding.c
@@ -1,5 +1,5 @@
 /**********************************************************************
- * assistant-xml-encoding.c -- Coversion of old XML file
+ * assistant-xml-encoding.c -- Conversion of old XML file
  * Copyright (C) 2006 Andreas Koehler <andi5.py at gmx.net>
  * Copyright (C) 2011 Robert Fewell
  *
@@ -174,6 +174,7 @@ void gxi_add_custom_enc_clicked_cb (GtkButton *button, GncXmlImportData *data);
 void gxi_selected_enc_activated_cb (GtkTreeView *view, GtkTreePath *path, GtkTreeViewColumn *column, GncXmlImportData *data);
 void gxi_remove_enc_clicked_cb (GtkButton *button, GncXmlImportData *data);
 
+/* Translators: Run the assistent in your language to see GTK's translation of the button labels. */
 static const gchar *encodings_doc_string = N_(
             "\nThe file you are trying to load is from an older version of "
             "GnuCash. The file format in the older versions was missing the "
@@ -187,21 +188,21 @@ static const gchar *encodings_doc_string = N_(
             "file. On the next page GnuCash will show the resulting texts when "
             "using this guess. You have to check whether the words look as "
             "expected. Either everything looks fine and you can simply press "
-            "'Forward'. Or the words contain unexpected characters, in which "
+            "\"Next\". Or the words contain unexpected characters, in which "
             "case you should select different character encodings to see "
             "different results. You may have to edit the list of character "
             "encodings by clicking on the respective button."
             "\n\n"
-            "Press 'Forward' now to select the correct character encoding for "
+            "Press \"Next\" now to select the correct character encoding for "
             "your data file.\n");
 
 static const gchar *encodings_doc_page_title = N_("Ambiguous character encoding");
 
 static const gchar *finish_convert_string = N_(
-            "The file has been loaded successfully. If you click 'Apply' it will be saved "
+            "The file has been loaded successfully. If you click \"Apply\" it will be saved "
             "and reloaded into the main application. That way you will have a working "
             "file as backup in the same directory.\n\n"
-            "You can also go back and verify your selections by clicking on 'Back'.");
+            "You can also go back and verify your selections by clicking on \"Back\".");
 
 /* The debugging module that this .o belongs to. */
 static QofLogModule log_module = GNC_MOD_ASSISTANT;
diff --git a/gnucash/gnome/assistant-acct-period.c b/gnucash/gnome/assistant-acct-period.c
index 06e9bb4ed..f338e2f98 100644
--- a/gnucash/gnome/assistant-acct-period.c
+++ b/gnucash/gnome/assistant-acct-period.c
@@ -363,12 +363,14 @@ ap_assistant_book_prepare (GtkAssistant *assistant, gpointer user_data)
     nacc = gnc_account_n_descendants (gnc_book_get_root_account (currbook));
 
     /* Display the book info */
+
     period_text =
+	/* Translators: Run the assistent in your language to see GTK's translation of the button labels. */
         _("You have asked for a book to be created. This book "
           "will contain all transactions up to midnight %s "
           "(for a total of %d transactions spread over %d accounts).\n\n "
-          "Amend the Title and Notes or Click on 'Forward' to proceed.\n "
-          "Click on 'Back' to adjust the dates or 'Cancel'.");
+          "Amend the Title and Notes or Click on \"Next\" to proceed.\n "
+          "Click on \"Back\" to adjust the dates or \"Cancel\".");
     str = g_strdup_printf (period_text, close_date_str, ntrans, nacc);
     gtk_label_set_text (GTK_LABEL(info->book_details), str);
     g_free (str);
@@ -400,8 +402,8 @@ ap_assistant_apply_prepare (GtkAssistant *assistant, gpointer user_data)
     char *str;
     const char *apply_text =
         _("The book will be created with the title %s when you "
-          "click on 'Apply'. Click on 'Back' to adjust, "
-	  "or 'Cancel' to not create any book.");
+          "click on \"Apply\". Click on \"Back\" to adjust, "
+	  "or \"Cancel\" to not create any book.");
 
     btitle = gtk_entry_get_text (GTK_ENTRY(info->book_title));
     str = g_strdup_printf (apply_text, btitle);
diff --git a/gnucash/gtkbuilder/assistant-csv-account-import.glade b/gnucash/gtkbuilder/assistant-csv-account-import.glade
index 17aa12fb8..400817281 100644
--- a/gnucash/gtkbuilder/assistant-csv-account-import.glade
+++ b/gnucash/gtkbuilder/assistant-csv-account-import.glade
@@ -27,14 +27,14 @@
           <object class="GtkLabel" id="start_label">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
-            <property name="label" translatable="yes">
+            <property name="label" translatable="yes" comments="Run the assistent in your language to see GTK's translation of the button labels.">
 This assistant will help you import Accounts from a file.
 
-The file must be in the same format as that exported as this is a fixed format import which can be seen by looking at a file created by using the 'Export Account Tree to CSV' export menu option.
+The file must be in the same format as that exported as this is a fixed format import which can be seen by looking at a file created by using the "Export Account Tree to CSV" export menu option.
 
 If the account is missing, based on the full account name, it will be added as long as the security / currency specified exists. If the account exists, then four fields will be updated. These are code, description, notes and color.
 
-Click on 'Forward' to proceed or 'Cancel' to Abort Import.
+Click on "Next" to proceed or "Cancel" to Abort Import.
 </property>
             <property name="justify">center</property>
             <property name="wrap">True</property>
diff --git a/gnucash/gtkbuilder/assistant-csv-price-import.glade b/gnucash/gtkbuilder/assistant-csv-price-import.glade
index 655d26cdd..ee3c9575a 100644
--- a/gnucash/gtkbuilder/assistant-csv-price-import.glade
+++ b/gnucash/gtkbuilder/assistant-csv-price-import.glade
@@ -61,7 +61,7 @@ Lastly, for repeated imports the preview page has buttons to Load and Save the s
 
 This operation is not reversable, so make sure you have a working backup.
 
-Click on 'Forward' to proceed or 'Cancel' to Abort Import.</property>
+Click on "Next" to proceed or "Cancel" to Abort Import.</property>
         <property name="wrap">True</property>
       </object>
       <packing>
@@ -82,7 +82,7 @@ Click on 'Forward' to proceed or 'Cancel' to Abort Import.</property>
             <property name="visible">True</property>
             <property name="can_focus">False</property>
             <property name="label" translatable="yes">
-Select location and file name for the Import, then click 'OK'...
+Select location and file name for the Import, then click "OK"...
 </property>
             <property name="wrap">True</property>
           </object>
@@ -759,8 +759,8 @@ Select location and file name for the Import, then click 'OK'...
                             <property name="receives_default">False</property>
                             <property name="tooltip_text" translatable="yes">Starting from the first line that is actually imported every second line will be skipped. This option will take the leading lines to skip into account as well.
 For example
-* if 'Leading Lines to Skip' is set to 3, the first line to import will be line 4. Lines 5, 7, 9,... will be skipped.
-* if 'Leading Lines to Skip' is set to 4, the first line to import will be line 5. Lines 6, 8, 10,... will be skipped.</property>
+* if "Leading Lines to Skip" is set to 3, the first line to import will be line 4. Lines 5, 7, 9,... will be skipped.
+* if "Leading Lines to Skip" is set to 4, the first line to import will be line 5. Lines 6, 8, 10,... will be skipped.</property>
                             <property name="halign">start</property>
                             <property name="draw_indicator">True</property>
                             <signal name="toggled" handler="csv_price_imp_preview_skiprows_cb" swapped="no"/>
diff --git a/gnucash/gtkbuilder/assistant-qif-import.glade b/gnucash/gtkbuilder/assistant-qif-import.glade
index d7564f98c..b8ae01fbb 100644
--- a/gnucash/gtkbuilder/assistant-qif-import.glade
+++ b/gnucash/gtkbuilder/assistant-qif-import.glade
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.20.0 -->
+<!-- Generated with glade 3.22.1 -->
 <interface>
   <requires lib="gtk+" version="3.10"/>
   <object class="GtkListStore" id="currency_liststore">
@@ -36,11 +36,11 @@
       <object class="GtkLabel" id="start_page">
         <property name="visible">True</property>
         <property name="can_focus">False</property>
-        <property name="label" translatable="yes">GnuCash can import financial data from QIF (Quicken Interchange Format) files written by Quicken/QuickBooks, MS Money, Moneydance, and many other programs. 
+        <property name="label" translatable="yes" comments="Run the assistent in your language to see GTK's translation of the button labels.">GnuCash can import financial data from QIF (Quicken Interchange Format) files written by Quicken/QuickBooks, MS Money, Moneydance, and many other programs. 
 
 The import process has several steps. Your GnuCash accounts will not be changed until you click "Apply" at the end of the process. 
 
-Click "Forward" to start loading your QIF data, or "Cancel" to abort the process. </property>
+Click "Next" to start loading your QIF data, or "Cancel" to abort the process. </property>
         <property name="wrap">True</property>
       </object>
       <packing>
@@ -60,7 +60,7 @@ Click "Forward" to start loading your QIF data, or "Cancel" to abort the process
           <object class="GtkLabel" id="label822">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
-            <property name="label" translatable="yes">Please select a file to load. When you click "Forward", the file will be loaded and analyzed. You may need to answer some questions about the account(s) in the file.
+            <property name="label" translatable="yes" comments="Run the assistent in your language to see GTK's translation of the button labels.">Please select a file to load. When you click "Next", the file will be loaded and analyzed. You may need to answer some questions about the account(s) in the file.
 
 You will have the opportunity to load as many files as you wish, so don't worry if your data is in multiple files. 
 </property>
@@ -447,9 +447,9 @@ Please enter a name for the account. If the file was exported from another accou
           <object class="GtkLabel" id="label816">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
-            <property name="label" translatable="yes">Click "Load another file" if you have more data to import at this time. Do this if you have saved your accounts to separate QIF files.
+            <property name="label" translatable="yes" comments="Run the assistent in your language to see GTK's translation of the button labels.">Click "Load another file" if you have more data to import at this time. Do this if you have saved your accounts to separate QIF files.
 
-Click "Forward" to finish loading files and move to the next step of the QIF import process. </property>
+Click "Next" to finish loading files and move to the next step of the QIF import process. </property>
             <property name="wrap">True</property>
           </object>
           <packing>
@@ -1165,12 +1165,12 @@ If you don't see your exchange listed, or none of the available choices are appr
           <object class="GtkLabel" id="label847694">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
-            <property name="label" translatable="yes">
+            <property name="label" translatable="yes" comments="Run the assistent in your language to see GTK's translation of the button labels.">
 If you are importing a QIF file from a bank or other financial institution, some of the transactions may already exist in your GnuCash accounts. To avoid duplication, GnuCash has tried to identify matches and needs your help to review them.
 
 On the next page you will be shown a list of imported transactions. As you select each one, a list of possible matches will be shown below it. If you find a correct match, click on it. Your selection will be confirmed by a check mark in the "Match?" column.
 
-Click "Forward" to review the possible matches.</property>
+Click "Next" to review the possible matches.</property>
             <property name="wrap">True</property>
           </object>
           <packing>
@@ -1319,10 +1319,8 @@ Click "Cancel" to abort the QIF import process.</property>
         <property name="has_padding">False</property>
       </packing>
     </child>
-    <child internal-child="action_area">
-      <object class="GtkBox" id="assistant-action_area2">
-        <property name="can_focus">False</property>
-      </object>
+    <child>
+      <placeholder/>
     </child>
   </object>
 </interface>
diff --git a/gnucash/gtkbuilder/assistant-stock-split.glade b/gnucash/gtkbuilder/assistant-stock-split.glade
index b2a395ba8..8ffe8fb92 100644
--- a/gnucash/gtkbuilder/assistant-stock-split.glade
+++ b/gnucash/gtkbuilder/assistant-stock-split.glade
@@ -244,7 +244,7 @@
           <object class="GtkLabel" id="stock_cash_label">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
-            <property name="label" translatable="yes">If you received a cash disbursement as a result of the stock split, enter the details of that payment here. Otherwise, just click `Forward'.</property>
+            <property name="label" translatable="yes">If you received a cash disbursement as a result of the stock split, enter the details of that payment here. Otherwise, just click "Next".</property>
             <property name="justify">center</property>
             <property name="wrap">True</property>
           </object>
@@ -417,7 +417,7 @@
       <object class="GtkLabel" id="finish_page_label">
         <property name="visible">True</property>
         <property name="can_focus">False</property>
-        <property name="label" translatable="yes">If you are finished creating the stock split or merger, press `Apply'. You may also press `Back' to review your choices, or `Cancel' to quit without making any changes.</property>
+        <property name="label" translatable="yes">If you are finished creating the stock split or merger, press "Apply". You may also press "Back" to review your choices, or "Cancel" to quit without making any changes.</property>
         <property name="wrap">True</property>
       </object>
       <packing>
diff --git a/gnucash/import-export/aqb/assistant-ab-initial.glade b/gnucash/import-export/aqb/assistant-ab-initial.glade
index 45cfca0c0..1dc8f58e6 100644
--- a/gnucash/import-export/aqb/assistant-ab-initial.glade
+++ b/gnucash/import-export/aqb/assistant-ab-initial.glade
@@ -27,7 +27,7 @@ You first need to apply for Online Banking access at your bank. If your bank  de
 * The Internet address of your bank's Online Banking server
 * For HBCI Online Banking, information about the cryptographic public key of your bank ("Ini-Letter").
 
-This information will be needed in the following. Press "Forward" now.
+This information will be needed in the following. Press "Next" now.
 
 NOTE: NO WARRANTIES FOR ANYTHING. Some banks run a poorly implemented Online Banking server. You should not rely on time-critical transfers through Online Banking, because sometimes the bank does not give you correct feedback when a transfer is rejected.
 
diff --git a/gnucash/import-export/csv-exp/assistant-csv-export.c b/gnucash/import-export/csv-exp/assistant-csv-export.c
index 75ab2f479..664e694fb 100644
--- a/gnucash/import-export/csv-exp/assistant-csv-export.c
+++ b/gnucash/import-export/csv-exp/assistant-csv-export.c
@@ -76,27 +76,28 @@ void csv_export_end_date_cb (GtkWidget *radio, gpointer user_data);
 void csv_export_file_chooser_file_activated_cb (GtkFileChooser *chooser, CsvExportInfo *info);
 void csv_export_file_chooser_selection_changed_cb (GtkFileChooser *chooser, CsvExportInfo *info);
 
+/* Fixme: Can we simplify the work of translators by splitting in invariant and variant paragraphs? */
 static const gchar *finish_tree_string = N_(
             /* Translators: %s is the file name string. */
-            "The account tree will be exported to the file '%s' when you click 'Apply'.\n\n"
-            "You can also verify your selections by clicking on 'Back' or 'Cancel' to Abort Export.\n");
+            "The account tree will be exported to the file '%s' when you click \"Apply\".\n\n"
+            "You can also verify your selections by clicking on \"Back\" or \"Cancel\" to abort the export.\n");
 
 static const gchar *finish_trans_string = N_(
             /* Translators: %s is the file name string and %u the number of accounts. */
-            "When you click 'Apply', the transactions will be exported to the file '%s' and"
+            "When you click \"Apply\", the transactions will be exported to the file '%s' and"
             " the number of accounts exported will be %u.\n\n"
-            "You can also verify your selections by clicking on 'Back' or 'Cancel' to Abort Export.\n");
+            "You can also verify your selections by clicking on \"Back\" or \"Cancel\" to abort the export.\n");
 
 static const gchar *finish_trans_search_gl_string = N_(
             /* Translators: %s is the file name string. */
-            "When you click 'Apply', the transactions will be exported to the file '%s'.\n\n"
-            "You can also verify your selections by clicking on 'Back' or 'Cancel' to Abort Export.\n");
+            "When you click \"Apply\", the transactions will be exported to the file '%s'.\n\n"
+            "You can also verify your selections by clicking on \"Back\" or \"Cancel\" to abort the export.\n");
 
 static const gchar *start_tree_string = N_(
             "This assistant will help you export the Account Tree to a file\n"
             " with the separator specified below.\n\n"
-            "Select the settings you require for the file and then click 'Forward' to proceed"
-            " or 'Cancel' to Abort Export.\n");
+            "Select the settings you require for the file and then click \"Next\" to proceed"
+            " or \"Cancel\" to abort the export.\n");
 
 static const gchar *start_trans_string = N_(
             "This assistant will help you export the Transactions to a file\n"
@@ -105,8 +106,8 @@ static const gchar *start_trans_string = N_(
             " require further manipulation to get them in a format you can use.\n\n"
             "Each Transaction will appear once in the export and will be listed in"
             " the order the accounts were processed\n\n"
-            "Select the settings you require for the file and then click 'Forward' to proceed"
-            " or 'Cancel' to Abort Export.\n");
+            "Select the settings you require for the file and then click \"Next\" to proceed"
+            " or \"Cancel\" to abort the export.\n");
 
 static const gchar *start_trans_simple_string = N_(
             "This assistant will help you export the Transactions to a file\n"
@@ -117,8 +118,8 @@ static const gchar *start_trans_simple_string = N_(
             " were processed\n\n"
             "By selecting the simple layout, the output will be equivalent to a single"
             " row register view and as such some of the transfer detail could be lost.\n\n"
-            "Select the settings you require for the file and then click 'Forward' to proceed"
-            " or 'Cancel' to Abort Export.\n");
+            "Select the settings you require for the file and then click \"Next\" to proceed"
+            " or \"Cancel\" to abort the export.\n");
 
 
 /**************************************************
@@ -189,7 +190,7 @@ csv_export_file_chooser_selection_changed_cb (GtkFileChooser *chooser,
 {
     GtkAssistant *assistant = GTK_ASSISTANT(info->assistant);
 
-    /* Enable the forward button based on a valid filename */
+    /* Enable the "Next" button based on a valid filename */
     gtk_assistant_set_page_complete (assistant, info->file_page,
         csv_export_assistant_check_filename (chooser, info));
 }
@@ -419,7 +420,7 @@ csv_export_account_changed_cb (GtkTreeSelection *selection,
 
     info->csva.num_accounts = update_accounts_tree (info);
 
-    /* Enable the Forward Assistant Button if we have accounts */
+    /* Enable the "Next" Assistant Button if we have accounts */
     if (info->csva.num_accounts > 0)
         gtk_assistant_set_page_complete (assistant, info->account_page, TRUE);
     else
@@ -686,7 +687,7 @@ csv_export_assistant_account_page_prepare (GtkAssistant *assistant,
 {
     CsvExportInfo *info = user_data;
 
-    /* Enable the Forward Assistant Button if we have accounts */
+    /* Enable the "Next" Assistant Button if we have accounts */
     if (info->csva.num_accounts > 0)
         gtk_assistant_set_page_complete (assistant, info->account_page, TRUE);
     else
@@ -705,7 +706,7 @@ csv_export_assistant_file_page_prepare (GtkAssistant *assistant,
         gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER(info->file_chooser), info->starting_dir);
     gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER(info->file_chooser), "");
 
-    /* Disable the Forward Assistant Button */
+    /* Disable the "Next" Assistant Button */
     gtk_assistant_set_page_complete (assistant, info->file_page, FALSE);
 }
 
diff --git a/gnucash/import-export/csv-imp/assistant-csv-account-import.c b/gnucash/import-export/csv-imp/assistant-csv-account-import.c
index 443c8f5b1..f8c9940f6 100644
--- a/gnucash/import-export/csv-imp/assistant-csv-account-import.c
+++ b/gnucash/import-export/csv-imp/assistant-csv-account-import.c
@@ -205,7 +205,7 @@ csv_import_file_chooser_selection_changed_cb (GtkFileChooser *chooser,
     GtkAssistant *assistant = GTK_ASSISTANT(info->assistant);
     gtk_assistant_set_page_complete (assistant, info->account_page, FALSE);
 
-    /* Enable the forward button based on a valid filename */
+    /* Enable the "Next" button based on a valid filename */
     gtk_assistant_set_page_complete (assistant, info->file_page,
         csv_import_assistant_check_filename (chooser, info));
 }
@@ -255,14 +255,14 @@ void csv_import_hrows_cb (GtkWidget *spin, gpointer user_data)
 /*******************************************************
  * csv_import_assistant_enable_account_forward
  *
- * enaable forward button on account_page if store has rows
+ * enable "Next" button on account_page if store has rows
  *******************************************************/
 static void csv_import_assistant_enable_account_forward (CsvImportInfo *info)
 {
     GtkAssistant *assistant = GTK_ASSISTANT(info->assistant);
     gboolean store_has_rows = TRUE;
 
-    /* if the store is empty, disable forward button */
+    /* if the store is empty, disable "Next" button */
     if (gtk_tree_model_iter_n_children (GTK_TREE_MODEL(info->store), NULL) == 0)
         store_has_rows = FALSE;
 
@@ -320,7 +320,7 @@ void csv_import_sep_cb (GtkWidget *radio, gpointer user_data)
     else
         gtk_spin_button_set_value (GTK_SPIN_BUTTON(info->header_row_spin), 0); //reset header spin to 0
 
-    /* if the store has rows, enable forward button */
+    /* if the store has rows, enable "Next" button */
     csv_import_assistant_enable_account_forward (info);
 }
 
@@ -439,7 +439,7 @@ csv_import_assistant_file_page_prepare (GtkAssistant *assistant,
     if (info->starting_dir)
         gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER(info->file_chooser), info->starting_dir);
 
-    /* Disable the Forward Assistant Button */
+    /* Disable the "Next" Assistant Button */
     gtk_assistant_set_page_complete (assistant, info->file_page, FALSE);
 }
 
@@ -451,7 +451,7 @@ csv_import_assistant_account_page_prepare (GtkAssistant *assistant,
     CsvImportInfo *info = user_data;
     csv_import_result res;
 
-    /* Disable the Forward Assistant Button */
+    /* Disable the "Next" Assistant Button */
     gtk_assistant_set_page_complete (assistant, info->account_page, FALSE);
 
     /* test read one line */
@@ -477,7 +477,7 @@ csv_import_assistant_account_page_prepare (GtkAssistant *assistant,
     else
         gtk_spin_button_set_value (GTK_SPIN_BUTTON(info->header_row_spin), 0); //reset header spin to 0
 
-    /* if the store has rows, enable forward button */
+    /* if the store has rows, enable "Next" button */
     csv_import_assistant_enable_account_forward (info);
 }
 
diff --git a/gnucash/import-export/csv-imp/assistant-csv-price-import.cpp b/gnucash/import-export/csv-imp/assistant-csv-price-import.cpp
index 0842257ac..c539a4256 100644
--- a/gnucash/import-export/csv-imp/assistant-csv-price-import.cpp
+++ b/gnucash/import-export/csv-imp/assistant-csv-price-import.cpp
@@ -678,7 +678,7 @@ CsvImpPriceAssist::~CsvImpPriceAssist ()
  * Code related to the file chooser page
  **************************************************/
 
-/* check_for_valid_filename for a valid file to activate the forward button
+/* check_for_valid_filename for a valid file to activate the "Next" button
  */
 bool
 CsvImpPriceAssist::check_for_valid_filename ()
@@ -727,7 +727,7 @@ CsvImpPriceAssist::file_activated_cb ()
 void
 CsvImpPriceAssist::file_selection_changed_cb ()
 {
-    /* Enable the forward button based on a valid filename */
+    /* Enable the "Next" button based on a valid filename */
     gtk_assistant_set_page_complete (csv_imp_asst, file_page,
         check_for_valid_filename ());
 }
@@ -1741,7 +1741,7 @@ void CsvImpPriceAssist::preview_validate_settings ()
 void
 CsvImpPriceAssist::assist_file_page_prepare ()
 {
-    /* Disable the Forward Assistant Button */
+    /* Disable the "Next" Assistant Button */
     gtk_assistant_set_page_complete (csv_imp_asst, file_page, false);
     gtk_assistant_set_page_complete (csv_imp_asst, preview_page, false);
 
@@ -1796,7 +1796,7 @@ CsvImpPriceAssist::assist_preview_page_prepare ()
         // set over_write to false as default
         price_imp->over_write (false);
 
-        /* Disable the Forward Assistant Button */
+        /* Disable the "Next" Assistant Button */
         gtk_assistant_set_page_complete (csv_imp_asst, preview_page, false);
 
         /* Load the data into the treeview. */
diff --git a/gnucash/import-export/csv-imp/assistant-csv-trans-import.cpp b/gnucash/import-export/csv-imp/assistant-csv-trans-import.cpp
index 255142fad..de5cbcb78 100644
--- a/gnucash/import-export/csv-imp/assistant-csv-trans-import.cpp
+++ b/gnucash/import-export/csv-imp/assistant-csv-trans-import.cpp
@@ -682,7 +682,7 @@ CsvImpTransAssist::~CsvImpTransAssist ()
  * Code related to the file chooser page
  **************************************************/
 
-/* check_for_valid_filename for a valid file to activate the forward button
+/* check_for_valid_filename for a valid file to activate the "Next" button
  */
 bool
 CsvImpTransAssist::check_for_valid_filename ()
@@ -731,7 +731,7 @@ CsvImpTransAssist::file_activated_cb ()
 void
 CsvImpTransAssist::file_selection_changed_cb ()
 {
-    /* Enable the forward button based on a valid filename */
+    /* Enable the "Next" button based on a valid filename */
     gtk_assistant_set_page_complete (csv_imp_asst, file_page,
         check_for_valid_filename ());
 }
@@ -1885,7 +1885,7 @@ CsvImpTransAssist::assist_file_page_prepare ()
         g_free (starting_dir);
     }
 
-    /* Disable the Forward Assistant Button */
+    /* Disable the "Next" Assistant Button */
     gtk_assistant_set_page_complete (csv_imp_asst, account_match_page, false);
 }
 
@@ -1933,7 +1933,7 @@ CsvImpTransAssist::assist_preview_page_prepare ()
 
         tx_imp->req_mapped_accts (false);
 
-        /* Disable the Forward Assistant Button */
+        /* Disable the "Next" Assistant Button */
         gtk_assistant_set_page_complete (csv_imp_asst, preview_page, false);
 
         /* Load the data into the treeview. */
@@ -1962,7 +1962,7 @@ CsvImpTransAssist::assist_account_match_page_prepare ()
     gtk_widget_set_sensitive (account_match_view, true);
     gtk_widget_set_sensitive (account_match_btn, true);
 
-    /* Enable the Forward Assistant Button */
+    /* Enable the "Next" Assistant Button */
     gtk_assistant_set_page_complete (csv_imp_asst, account_match_page,
                csv_tximp_acct_match_check_all (store));
 }
diff --git a/gnucash/import-export/qif-imp/assistant-qif-import.c b/gnucash/import-export/qif-imp/assistant-qif-import.c
index 3e89180cf..693d77b96 100644
--- a/gnucash/import-export/qif-imp/assistant-qif-import.c
+++ b/gnucash/import-export/qif-imp/assistant-qif-import.c
@@ -1590,7 +1590,7 @@ gnc_ui_qif_import_load_file_prepare (GtkAssistant  *assistant, gpointer user_dat
     /* Get the file name. */
     path_to_load = gtk_entry_get_text(GTK_ENTRY(wind->filename_entry));
 
-    /* Calculate status for the Assistant Forward Button */
+    /* Calculate status for the Assistant "Next" Button */
     if (strlen(path_to_load) != 0)
     {
        page_status = gnc_ui_qif_import_load_file_complete(assistant, user_data);
@@ -1938,7 +1938,7 @@ gnc_ui_qif_import_load_progress_start_cb(GtkButton * button,
         }
     }
 
-    /* Enable the assistant Forward button */
+    /* Enable the assistant "Next" button */
     gtk_assistant_set_page_complete (assistant, page, TRUE);
 
     /* Set Pause and Start buttons */
@@ -1993,7 +1993,7 @@ gnc_ui_qif_import_load_progress_prepare (GtkAssistant  *assistant, gpointer user
     gtk_widget_set_sensitive(wind->load_pause, FALSE);
     gtk_widget_set_sensitive(wind->load_start, TRUE);
 
-    /* Disable the assistant Forward button */
+    /* Disable the assistant "Next" button */
     gtk_assistant_set_page_complete (assistant, page, FALSE);
 }
 
@@ -2124,12 +2124,12 @@ gnc_ui_qif_import_acct_valid_cb(GtkWidget * widget,
 
     if (!acct_name || acct_name[0] == 0)
     {
-        /* Disable the assistant Forward Button */
+        /* Disable the assistant "Next" Button */
         gtk_assistant_set_page_complete (assistant, page, FALSE);
     }
     else
     {
-        /* Enable the assistant Forward Button */
+        /* Enable the assistant "Next" Button */
         gtk_assistant_set_page_complete (assistant, page, TRUE);
     }
 }
@@ -2160,7 +2160,7 @@ gnc_ui_qif_import_loaded_files_prepare (GtkAssistant *assistant,
     scm_name = scm_from_utf8_string(acct_name ? acct_name : "");
     scm_call_2(fix_default, wind->selected_file, scm_name);
 
-    /* Enable the assistant Forward Button */
+    /* Enable the assistant "Next" Button */
     gtk_assistant_set_page_complete (assistant, page, TRUE);
 
     update_file_page(wind);
@@ -2297,7 +2297,7 @@ gnc_ui_qif_import_account_doc_prepare (GtkAssistant *assistant,
 
     PINFO("Total Number of Assistant Pages is %d", gtk_assistant_get_n_pages (assistant));
 
-    /* Enable the Assistant Forward Button */
+    /* Enable the Assistant "Next" Button */
     gtk_assistant_set_page_complete (assistant, page, TRUE);
 
     /* Jump to Summary page if load_stop TRUE */
@@ -2334,7 +2334,7 @@ gnc_ui_qif_import_account_match_prepare(GtkAssistant *assistant,
     update_memo_page(wind);
     gnc_unset_busy_cursor(NULL);
 
-    /* Enable the Assistant Forward Button */
+    /* Enable the Assistant "Next" Button */
     gtk_assistant_set_page_complete (assistant, page, TRUE);
 }
 
@@ -2380,7 +2380,7 @@ gnc_ui_qif_import_catagory_doc_prepare (GtkAssistant *assistant,
 
     PINFO("Total Number of Assistant Pages is %d", gtk_assistant_get_n_pages (assistant));
 
-    /* Enable the Assistant Forward Button */
+    /* Enable the Assistant "Next" Button */
     gtk_assistant_set_page_complete (assistant, page, TRUE);
 
     /* Jump to Summary page if load_stop TRUE */
@@ -2415,7 +2415,7 @@ gnc_ui_qif_import_catagory_match_prepare(GtkAssistant *assistant,
     gint num = gtk_assistant_get_current_page (assistant);
     GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
 
-    /* Enable the Assistant Forward Button */
+    /* Enable the Assistant "Next" Button */
     gtk_assistant_set_page_complete (assistant, page, TRUE);
 
     /* If there are no category mappings, jump this step. */
@@ -2465,7 +2465,7 @@ gnc_ui_qif_import_memo_doc_prepare (GtkAssistant *assistant,
 
     PINFO("Total Number of Assistant Pages is %d", gtk_assistant_get_n_pages (assistant));
 
-    /* Enable the Assistant Forward Button */
+    /* Enable the Assistant "Next" Button */
     gtk_assistant_set_page_complete (assistant, page, TRUE);
 
     /* Jump to Summary page if load_stop TRUE */
@@ -2500,7 +2500,7 @@ gnc_ui_qif_import_memo_match_prepare (GtkAssistant *assistant,
     gint num = gtk_assistant_get_current_page (assistant);
     GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
 
-    /* Enable the Assistant Forward Button */
+    /* Enable the Assistant "Next" Button */
     gtk_assistant_set_page_complete (assistant, page, TRUE);
 
     /* If there are no memo mappings, jump this step. */
@@ -2567,7 +2567,7 @@ gnc_ui_qif_import_currency_prepare(GtkAssistant *assistant,
         gtk_widget_hide (wind->book_option_message);
     }
 
-    /* Enable the Assistant Forward Button */
+    /* Enable the Assistant "Next" Button */
     gtk_assistant_set_page_complete (assistant, page, TRUE);
 }
 
@@ -2633,7 +2633,7 @@ gnc_ui_qif_import_commodity_doc_prepare (GtkAssistant *assistant,
 
     PINFO("Total Number of Assistant Pages is %d", gtk_assistant_get_n_pages (assistant));
 
-    /* Enable the Assistant Forward Button */
+    /* Enable the Assistant "Next" Button */
     gtk_assistant_set_page_complete (assistant, page, TRUE);
 
     /* Jump to Summary page if load_stop TRUE */
@@ -3002,7 +3002,7 @@ gnc_ui_qif_import_convert_progress_start_cb(GtkButton * button,
             wind->load_stop = TRUE;
         }
     }
-    /* Enable the Assistant Forward Button */
+    /* Enable the Assistant "Next" Button */
     gtk_assistant_set_page_complete (assistant, page, TRUE);
 
     /* Set Pause and Start buttons */
@@ -3054,7 +3054,7 @@ gnc_ui_qif_import_convert_progress_prepare(GtkAssistant *assistant,
     gtk_widget_set_sensitive(wind->convert_pause, FALSE);
     gtk_widget_set_sensitive(wind->convert_start, TRUE);
 
-    /* Disable the assistant Forward button */
+    /* Disable the assistant "Next" button */
     gtk_assistant_set_page_complete (assistant, page, FALSE);
 
     /* Before creating transactions, if this is a new book, let user specify
@@ -3083,7 +3083,7 @@ gnc_ui_qif_import_duplicates_doc_prepare (GtkAssistant *assistant,
 
     PINFO("Total Number of Assistant Pages is %d", gtk_assistant_get_n_pages (assistant));
 
-    /* Enable the Assistant Forward Button */
+    /* Enable the Assistant "Next" Button */
     gtk_assistant_set_page_complete (assistant, page, TRUE);
 
     /* Jump to Summary page if load_stop TRUE */
@@ -3180,7 +3180,7 @@ gnc_ui_qif_import_duplicates_match_prepare (GtkAssistant *assistant,
     else
         gtk_assistant_set_current_page (assistant, num + 1 );
 
-    /* Enable the Assistant Forward Button */
+    /* Enable the Assistant "Next" Button */
     gtk_assistant_set_page_complete (assistant, page, TRUE);
 }
 
@@ -3199,7 +3199,7 @@ gnc_ui_qif_import_end_page_prepare (GtkAssistant *assistant,
     gint num = gtk_assistant_get_current_page (assistant);
     GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
 
-    /* Enable the Assistant Forward Button */
+    /* Enable the Assistant "Next" Button */
     gtk_assistant_set_page_complete (assistant, page, TRUE);
 }
 
@@ -3287,7 +3287,7 @@ gnc_ui_qif_import_summary_page_prepare (GtkAssistant *assistant,
 
     g_free(text);
 
-    /* Enable the Assistant Forward Button */
+    /* Enable the Assistant "Next" Button */
     gtk_assistant_set_page_complete (assistant, page, TRUE);
 }
 

commit 8d71fcaf2f5b3196187044501ca0c47aeba2ee0a
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Fri May 3 11:42:47 2019 +0100

    Bug 797223 - Preference missing tooltip
    
    The Preferences 'Register/Tab order includes Transfer on Memorised
    Transaction' was not displaying its tooltip even though it was in the
    glade file. Recreated the Register notebook page and the business page
    as it also had a missing tooltip.

diff --git a/gnucash/gtkbuilder/business-prefs.glade b/gnucash/gtkbuilder/business-prefs.glade
index 84a3d0894..de2e89473 100644
--- a/gnucash/gtkbuilder/business-prefs.glade
+++ b/gnucash/gtkbuilder/business-prefs.glade
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.20.0 -->
+<!-- Generated with glade 3.22.1 -->
 <interface>
   <requires lib="gtk+" version="3.10"/>
   <object class="GtkAdjustment" id="cust_days_in_adj">
@@ -40,6 +40,9 @@
     <property name="visible">True</property>
     <property name="can_focus">False</property>
     <property name="title" translatable="yes">Preferences</property>
+    <child>
+      <placeholder/>
+    </child>
     <child>
       <object class="GtkGrid" id="business_prefs">
         <property name="visible">True</property>
@@ -47,37 +50,27 @@
         <property name="border_width">6</property>
         <property name="column_spacing">12</property>
         <child>
-          <object class="GtkLabel" id="label53">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-          </object>
-          <packing>
-            <property name="left_attach">0</property>
-            <property name="top_attach">4</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkLabel" id="label54">
+          <object class="GtkLabel">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
             <property name="halign">start</property>
-            <property name="label" translatable="yes"><b>Invoices</b></property>
+            <property name="label" translatable="yes"><b>General</b></property>
             <property name="use_markup">True</property>
           </object>
           <packing>
             <property name="left_attach">0</property>
-            <property name="top_attach">5</property>
+            <property name="top_attach">0</property>
           </packing>
         </child>
         <child>
-          <object class="GtkCheckButton" id="pref/dialogs.business.bill/tax-included">
-            <property name="label" translatable="yes">Ta_x included</property>
+          <object class="GtkCheckButton" id="pref/dialogs.business.invoice/enable-toolbuttons">
+            <property name="label" translatable="yes">Enable extra _buttons</property>
             <property name="visible">True</property>
             <property name="can_focus">True</property>
             <property name="receives_default">False</property>
             <property name="has_tooltip">True</property>
-            <property name="tooltip_markup">Whether tax is included by default in entries on Bills. This setting is inherited by new customers and vendors.</property>
-            <property name="tooltip_text" translatable="yes">Whether tax is included by default in entries on Bills. This setting is inherited by new customers and vendors.</property>
+            <property name="tooltip_markup">If active, extra toolbar buttons for common business functions are shown as well. Otherwise they are not shown.</property>
+            <property name="tooltip_text" translatable="yes">If active, extra toolbar buttons for common business functions are shown as well. Otherwise they are not shown.</property>
             <property name="halign">start</property>
             <property name="margin_left">12</property>
             <property name="use_underline">True</property>
@@ -85,51 +78,37 @@
           </object>
           <packing>
             <property name="left_attach">0</property>
-            <property name="top_attach">13</property>
+            <property name="top_attach">1</property>
           </packing>
         </child>
         <child>
-          <object class="GtkSpinButton" id="pref/dialogs.business.bill/days-in-advance">
+          <object class="GtkCheckButton" id="pref/dialogs.business.invoice/use-new-window">
+            <property name="label" translatable="yes">_Open in new window</property>
             <property name="visible">True</property>
             <property name="can_focus">True</property>
+            <property name="receives_default">False</property>
             <property name="has_tooltip">True</property>
-            <property name="tooltip_markup">How many days in the future to warn about Bills coming due.</property>
-            <property name="tooltip_text" translatable="yes">How many days in the future to warn about Bills coming due.</property>
-            <property name="invisible_char">●</property>
-            <property name="primary_icon_activatable">False</property>
-            <property name="secondary_icon_activatable">False</property>
-            <property name="adjustment">days_in_adj</property>
-            <property name="climb_rate">1</property>
-            <property name="numeric">True</property>
-          </object>
-          <packing>
-            <property name="left_attach">2</property>
-            <property name="top_attach">12</property>
-            <property name="width">2</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkLabel" id="label15">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="label" translatable="yes">_Days in advance:</property>
+            <property name="tooltip_markup">If checked, each invoice will be opened in its own top level window. If clear, the invoice will be opened in the current window.</property>
+            <property name="tooltip_text" translatable="yes">If checked, each invoice will be opened in its own top level window. If clear, the invoice will be opened in the current window.</property>
+            <property name="halign">start</property>
+            <property name="margin_left">12</property>
             <property name="use_underline">True</property>
-            <property name="mnemonic_widget">pref/dialogs.business.bill/days-in-advance</property>
+            <property name="draw_indicator">True</property>
           </object>
           <packing>
-            <property name="left_attach">1</property>
-            <property name="top_attach">12</property>
+            <property name="left_attach">0</property>
+            <property name="top_attach">2</property>
           </packing>
         </child>
         <child>
-          <object class="GtkCheckButton" id="pref/dialogs.business.bill/notify-when-due">
-            <property name="label" translatable="yes">_Notify when due</property>
+          <object class="GtkCheckButton" id="pref/dialogs.business.invoice/accumulate-splits">
+            <property name="label" translatable="yes">_Accumulate splits on post</property>
             <property name="visible">True</property>
             <property name="can_focus">True</property>
             <property name="receives_default">False</property>
             <property name="has_tooltip">True</property>
-            <property name="tooltip_markup">Whether to display the list of Bills Due at startup.</property>
-            <property name="tooltip_text" translatable="yes">Whether to display the list of Bills Due at startup.</property>
+            <property name="tooltip_markup">Whether multiple entries in an invoice which transfer to the same account should be accumulated into a single split by default. This setting can be changed in the Post dialog.</property>
+            <property name="tooltip_text" translatable="yes">Whether multiple entries in an invoice which transfer to the same account should be accumulated into a single split by default. This setting can be changed in the Post dialog.</property>
             <property name="halign">start</property>
             <property name="margin_left">12</property>
             <property name="use_underline">True</property>
@@ -137,41 +116,41 @@
           </object>
           <packing>
             <property name="left_attach">0</property>
-            <property name="top_attach">12</property>
+            <property name="top_attach">3</property>
           </packing>
         </child>
         <child>
-          <object class="GtkLabel" id="label51">
+          <object class="GtkLabel">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
-            <property name="halign">start</property>
-            <property name="label" translatable="yes"><b>Bills</b></property>
-            <property name="use_markup">True</property>
           </object>
           <packing>
             <property name="left_attach">0</property>
-            <property name="top_attach">11</property>
+            <property name="top_attach">4</property>
           </packing>
         </child>
         <child>
-          <object class="GtkLabel" id="label50">
+          <object class="GtkLabel">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
+            <property name="halign">start</property>
+            <property name="label" translatable="yes"><b>Invoices</b></property>
+            <property name="use_markup">True</property>
           </object>
           <packing>
             <property name="left_attach">0</property>
-            <property name="top_attach">9</property>
+            <property name="top_attach">5</property>
           </packing>
         </child>
         <child>
-          <object class="GtkCheckButton" id="pref/dialogs.business.invoice/tax-included">
-            <property name="label" translatable="yes">_Tax included</property>
+          <object class="GtkCheckButton" id="pref/dialogs.business.invoice/notify-when-due">
+            <property name="label" translatable="yes">Not_ify when due</property>
             <property name="visible">True</property>
             <property name="can_focus">True</property>
             <property name="receives_default">False</property>
             <property name="has_tooltip">True</property>
-            <property name="tooltip_markup">Whether tax is included by default in entries on Invoices. This setting is inherited by new customers and vendors.</property>
-            <property name="tooltip_text" translatable="yes">Whether tax is included by default in entries on Invoices. This setting is inherited by new customers and vendors.</property>
+            <property name="tooltip_markup">Whether to display the list of Bills Due at startup.</property>
+            <property name="tooltip_text" translatable="yes">Whether to display the list of Bills Due at startup.</property>
             <property name="halign">start</property>
             <property name="margin_left">12</property>
             <property name="use_underline">True</property>
@@ -179,37 +158,31 @@
           </object>
           <packing>
             <property name="left_attach">0</property>
-            <property name="top_attach">8</property>
+            <property name="top_attach">6</property>
           </packing>
         </child>
         <child>
-          <object class="GtkCheckButton" id="pref/dialogs.business.invoice/accumulate-splits">
-            <property name="label" translatable="yes">_Accumulate splits on post</property>
+          <object class="GtkLabel">
             <property name="visible">True</property>
-            <property name="can_focus">True</property>
-            <property name="receives_default">False</property>
-            <property name="has_tooltip">True</property>
-            <property name="tooltip_markup">Whether multiple entries in an invoice which transfer to the same account should be accumulated into a single split by default. This setting can be changed in the Post dialog.</property>
-            <property name="tooltip_text" translatable="yes">Whether multiple entries in an invoice which transfer to the same account should be accumulated into a single split by default. This setting can be changed in the Post dialog.</property>
+            <property name="can_focus">False</property>
             <property name="halign">start</property>
             <property name="margin_left">12</property>
-            <property name="use_underline">True</property>
-            <property name="draw_indicator">True</property>
+            <property name="label" translatable="yes">Report for printing:</property>
           </object>
           <packing>
             <property name="left_attach">0</property>
-            <property name="top_attach">3</property>
+            <property name="top_attach">7</property>
           </packing>
         </child>
         <child>
-          <object class="GtkCheckButton" id="pref/dialogs.business.invoice/use-new-window">
-            <property name="label" translatable="yes">_Open in new window</property>
+          <object class="GtkCheckButton" id="pref/dialogs.business.invoice/tax-included">
+            <property name="label" translatable="yes">_Tax included</property>
             <property name="visible">True</property>
             <property name="can_focus">True</property>
             <property name="receives_default">False</property>
             <property name="has_tooltip">True</property>
-            <property name="tooltip_markup">If checked, each invoice will be opened in its own top level window. If clear, the invoice will be opened in the current window.</property>
-            <property name="tooltip_text" translatable="yes">If checked, each invoice will be opened in its own top level window. If clear, the invoice will be opened in the current window.</property>
+            <property name="tooltip_markup">Whether tax is included by default in entries on Bills. This setting is inherited by new customers and vendors.</property>
+            <property name="tooltip_text" translatable="yes">Whether tax is included by default in entries on Bills. This setting is inherited by new customers and vendors.</property>
             <property name="halign">start</property>
             <property name="margin_left">12</property>
             <property name="use_underline">True</property>
@@ -217,31 +190,18 @@
           </object>
           <packing>
             <property name="left_attach">0</property>
-            <property name="top_attach">2</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkLabel" id="label1">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="halign">start</property>
-            <property name="label" translatable="yes"><b>General</b></property>
-            <property name="use_markup">True</property>
-          </object>
-          <packing>
-            <property name="left_attach">0</property>
-            <property name="top_attach">0</property>
+            <property name="top_attach">8</property>
           </packing>
         </child>
         <child>
-          <object class="GtkCheckButton" id="pref/dialogs.business.invoice/enable-toolbuttons">
-            <property name="label" translatable="yes">Enable extra _buttons</property>
+          <object class="GtkCheckButton" id="pref/dialogs.business.invoice/auto-pay">
+            <property name="label" translatable="yes" comments="See the tooltip "At post time..." for details.">_Process payments on posting</property>
             <property name="visible">True</property>
             <property name="can_focus">True</property>
             <property name="receives_default">False</property>
             <property name="has_tooltip">True</property>
-            <property name="tooltip_markup">If active, extra toolbar buttons for common business functions are shown as well. Otherwise they are not shown.</property>
-            <property name="tooltip_text" translatable="yes">If active, extra toolbar buttons for common business functions are shown as well. Otherwise they are not shown.</property>
+            <property name="tooltip_markup">At post time, automatically attempt to pay customer documents with outstanding pre-payments and counter documents. The pre-payments and documents obviously have to be against the same customer. Counter documents are documents with opposite sign. For example for an invoice, customer credit notes and negative invoices are considered counter documents.</property>
+            <property name="tooltip_text" translatable="yes">At post time, automatically attempt to pay customer documents with outstanding pre-payments and counter documents. The pre-payments and documents obviously have to be against the same customer. Counter documents are documents with opposite sign. For example for an invoice, customer credit notes and negative invoices are considered counter documents.</property>
             <property name="halign">start</property>
             <property name="margin_left">12</property>
             <property name="use_underline">True</property>
@@ -249,50 +209,41 @@
           </object>
           <packing>
             <property name="left_attach">0</property>
-            <property name="top_attach">1</property>
+            <property name="top_attach">9</property>
           </packing>
         </child>
         <child>
-          <object class="GtkComboBox" id="pref/dialogs.business.invoice/invoice-printreport">
+          <object class="GtkLabel">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
-            <property name="has_tooltip">True</property>
-            <property name="tooltip_markup">The invoice report to be used for printing.</property>
-            <property name="tooltip_text" translatable="yes">The invoice report to be used for printing.</property>
-            <property name="model">liststore_printinvoice</property>
-            <child>
-              <object class="GtkCellRendererText" id="cellrenderertext2"/>
-              <attributes>
-                <attribute name="text">0</attribute>
-              </attributes>
-            </child>
           </object>
           <packing>
-            <property name="left_attach">1</property>
-            <property name="top_attach">7</property>
-            <property name="width">3</property>
+            <property name="left_attach">0</property>
+            <property name="top_attach">10</property>
           </packing>
         </child>
         <child>
-          <object class="GtkLabel" id="label2">
+          <object class="GtkLabel">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
             <property name="halign">start</property>
-            <property name="margin_left">12</property>
-            <property name="label" translatable="yes">Report for printing:</property>
+            <property name="label" translatable="yes"><b>Bills</b></property>
+            <property name="use_markup">True</property>
           </object>
           <packing>
             <property name="left_attach">0</property>
-            <property name="top_attach">7</property>
+            <property name="top_attach">11</property>
           </packing>
         </child>
         <child>
-          <object class="GtkCheckButton" id="pref/dialogs.business.invoice/auto-pay">
-            <property name="label" translatable="yes" comments="See the tooltip "At post time..." for details.">_Process payments on posting</property>
+          <object class="GtkCheckButton" id="pref/dialogs.business.bill/notify-when-due">
+            <property name="label" translatable="yes">_Notify when due</property>
             <property name="visible">True</property>
             <property name="can_focus">True</property>
             <property name="receives_default">False</property>
-            <property name="tooltip_text" translatable="yes">At post time, automatically attempt to pay customer documents with outstanding pre-payments and counter documents. The pre-payments and documents obviously have to be against the same customer. Counter documents are documents with opposite sign. For example for an invoice, customer credit notes and negative invoices are considered counter documents.</property>
+            <property name="has_tooltip">True</property>
+            <property name="tooltip_markup">Whether to display the list of Bills Due at startup.</property>
+            <property name="tooltip_text" translatable="yes">Whether to display the list of Bills Due at startup.</property>
             <property name="halign">start</property>
             <property name="margin_left">12</property>
             <property name="use_underline">True</property>
@@ -300,16 +251,18 @@
           </object>
           <packing>
             <property name="left_attach">0</property>
-            <property name="top_attach">9</property>
+            <property name="top_attach">12</property>
           </packing>
         </child>
         <child>
-          <object class="GtkCheckButton" id="pref/dialogs.business.bill/auto-pay">
-            <property name="label" translatable="yes" comments="See the tooltip "At post time..." for details.">Pro_cess payments on posting</property>
+          <object class="GtkCheckButton" id="pref/dialogs.business.bill/tax-included">
+            <property name="label" translatable="yes">Ta_x included</property>
             <property name="visible">True</property>
             <property name="can_focus">True</property>
             <property name="receives_default">False</property>
-            <property name="tooltip_text" translatable="yes">At post time, automatically attempt to pay vendor documents with outstanding pre-payments and counter documents. The pre-payments and documents obviously have to be against the same vendor. Counter documents are documents with opposite sign. For example for a bill, vendor credit notes and negative bills are considered counter documents.</property>
+            <property name="has_tooltip">True</property>
+            <property name="tooltip_markup">Whether tax is included by default in entries on Invoices. This setting is inherited by new customers and vendors.</property>
+            <property name="tooltip_text" translatable="yes">Whether tax is included by default in entries on Invoices. This setting is inherited by new customers and vendors.</property>
             <property name="halign">start</property>
             <property name="margin_left">12</property>
             <property name="use_underline">True</property>
@@ -317,16 +270,18 @@
           </object>
           <packing>
             <property name="left_attach">0</property>
-            <property name="top_attach">14</property>
+            <property name="top_attach">13</property>
           </packing>
         </child>
         <child>
-          <object class="GtkCheckButton" id="pref/dialogs.business.invoice/notify-when-due">
-            <property name="label" translatable="yes">Not_ify when due</property>
+          <object class="GtkCheckButton" id="pref/dialogs.business.bill/auto-pay">
+            <property name="label" translatable="yes" comments="See the tooltip "At post time..." for details.">Pro_cess payments on posting</property>
             <property name="visible">True</property>
             <property name="can_focus">True</property>
             <property name="receives_default">False</property>
-            <property name="tooltip_markup" translatable="yes">Whether to display the list of Invoices Due at startup.</property>
+            <property name="has_tooltip">True</property>
+            <property name="tooltip_markup">At post time, automatically attempt to pay vendor documents with outstanding pre-payments and counter documents. The pre-payments and documents obviously have to be against the same vendor. Counter documents are documents with opposite sign. For example for a bill, vendor credit notes and negative bills are considered counter documents.</property>
+            <property name="tooltip_text" translatable="yes">At post time, automatically attempt to pay vendor documents with outstanding pre-payments and counter documents. The pre-payments and documents obviously have to be against the same vendor. Counter documents are documents with opposite sign. For example for a bill, vendor credit notes and negative bills are considered counter documents.</property>
             <property name="halign">start</property>
             <property name="margin_left">12</property>
             <property name="use_underline">True</property>
@@ -334,14 +289,66 @@
           </object>
           <packing>
             <property name="left_attach">0</property>
-            <property name="top_attach">6</property>
+            <property name="top_attach">14</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkLabel">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="label" translatable="yes">_Days in advance:</property>
+            <property name="use_underline">True</property>
+            <property name="mnemonic_widget">pref/dialogs.business.bill/days-in-advance</property>
+          </object>
+          <packing>
+            <property name="left_attach">1</property>
+            <property name="top_attach">12</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkSpinButton" id="pref/dialogs.business.bill/days-in-advance">
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="has_tooltip">True</property>
+            <property name="tooltip_markup">How many days in the future to warn about Bills coming due.</property>
+            <property name="tooltip_text" translatable="yes">How many days in the future to warn about Bills coming due.</property>
+            <property name="adjustment">days_in_adj</property>
+            <property name="climb_rate">1</property>
+          </object>
+          <packing>
+            <property name="left_attach">2</property>
+            <property name="top_attach">12</property>
+            <property name="width">2</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkComboBox" id="pref/dialogs.business.invoice/invoice-printreport">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="has_tooltip">True</property>
+            <property name="tooltip_markup">The invoice report to be used for printing.</property>
+            <property name="tooltip_text" translatable="yes">The invoice report to be used for printing.</property>
+            <property name="model">liststore_printinvoice</property>
+            <child>
+              <object class="GtkCellRendererText" id="cellrenderertext2"/>
+              <attributes>
+                <attribute name="text">0</attribute>
+              </attributes>
+            </child>
+          </object>
+          <packing>
+            <property name="left_attach">1</property>
+            <property name="top_attach">7</property>
+            <property name="width">3</property>
           </packing>
         </child>
         <child>
           <object class="GtkSpinButton" id="pref/dialogs.business.invoice/days-in-advance">
             <property name="visible">True</property>
             <property name="can_focus">True</property>
-            <property name="tooltip_markup" translatable="yes">How many days in the future to warn about Bills coming due.</property>
+            <property name="has_tooltip">True</property>
+            <property name="tooltip_markup">How many days in the future to warn about Invoices coming due.</property>
+            <property name="tooltip_text" translatable="yes">How many days in the future to warn about Invoices coming due.</property>
             <property name="adjustment">cust_days_in_adj</property>
           </object>
           <packing>
@@ -351,7 +358,7 @@
           </packing>
         </child>
         <child>
-          <object class="GtkLabel" id="label3">
+          <object class="GtkLabel">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
             <property name="label" translatable="yes">_Days in advance:</property>
@@ -471,9 +478,6 @@
         <child>
           <placeholder/>
         </child>
-        <child>
-          <placeholder/>
-        </child>
       </object>
     </child>
   </object>
diff --git a/gnucash/gtkbuilder/dialog-preferences.glade b/gnucash/gtkbuilder/dialog-preferences.glade
index 9d0636546..939bcdc0e 100644
--- a/gnucash/gtkbuilder/dialog-preferences.glade
+++ b/gnucash/gtkbuilder/dialog-preferences.glade
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.20.2 -->
+<!-- Generated with glade 3.22.1 -->
 <interface>
   <requires lib="gtk+" version="3.10"/>
   <object class="GtkAdjustment" id="auto_decimal_places_adj">
@@ -105,6 +105,9 @@
     <property name="default_height">400</property>
     <property name="type_hint">normal</property>
     <signal name="response" handler="gnc_preferences_response_cb" swapped="no"/>
+    <child>
+      <placeholder/>
+    </child>
     <child internal-child="vbox">
       <object class="GtkBox" id="dialog-vbox2">
         <property name="visible">True</property>
@@ -2008,7 +2011,7 @@ many months before the current month:</property>
                 <property name="border_width">6</property>
                 <property name="column_spacing">12</property>
                 <child>
-                  <object class="GtkLabel" id="label56">
+                  <object class="GtkLabel">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
                     <property name="halign">start</property>
@@ -2040,56 +2043,64 @@ many months before the current month:</property>
                   </packing>
                 </child>
                 <child>
-                  <object class="GtkLabel" id="label66">
+                  <object class="GtkCheckButton" id="pref/general.register/auto-raise-lists">
+                    <property name="label" translatable="yes">_Auto-raise lists</property>
                     <property name="visible">True</property>
-                    <property name="can_focus">False</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">False</property>
+                    <property name="has_tooltip">True</property>
+                    <property name="tooltip_markup">Automatically raise the list of accounts or actions during input.</property>
+                    <property name="tooltip_text" translatable="yes">Automatically raise the list of accounts or actions during input.</property>
+                    <property name="halign">start</property>
+                    <property name="margin_left">12</property>
+                    <property name="use_underline">True</property>
+                    <property name="draw_indicator">True</property>
                   </object>
                   <packing>
                     <property name="left_attach">0</property>
-                    <property name="top_attach">3</property>
+                    <property name="top_attach">2</property>
                   </packing>
                 </child>
                 <child>
-                  <object class="GtkCheckButton" id="pref/general.register/auto-raise-lists">
-                    <property name="label" translatable="yes">_Auto-raise lists</property>
+                  <object class="GtkCheckButton" id="pref/general.register/tab-to-transfer-on-memorised">
+                    <property name="label" translatable="yes">Tab order in_cludes Transfer on Memorised Transactions</property>
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
                     <property name="receives_default">False</property>
                     <property name="has_tooltip">True</property>
-                    <property name="tooltip_markup">Automatically raise the list of accounts or actions during input.</property>
-                    <property name="tooltip_text" translatable="yes">Automatically raise the list of accounts or actions during input.</property>
+                    <property name="tooltip_markup">Move to Transfer field when memorised transaction auto filled.</property>
+                    <property name="tooltip_text" translatable="yes">Move to Transfer field when memorised transaction auto filled.</property>
                     <property name="halign">start</property>
                     <property name="margin_left">12</property>
                     <property name="use_underline">True</property>
-                    <property name="active">True</property>
                     <property name="draw_indicator">True</property>
                   </object>
                   <packing>
                     <property name="left_attach">0</property>
-                    <property name="top_attach">2</property>
+                    <property name="top_attach">3</property>
                   </packing>
                 </child>
                 <child>
-                  <object class="GtkLabel" id="label75">
+                  <object class="GtkLabel">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="halign">start</property>
-                    <property name="label" translatable="yes"><b>Reconciling</b></property>
-                    <property name="use_markup">True</property>
                   </object>
                   <packing>
                     <property name="left_attach">0</property>
-                    <property name="top_attach">5</property>
+                    <property name="top_attach">4</property>
                   </packing>
                 </child>
                 <child>
-                  <object class="GtkLabel" id="label76">
+                  <object class="GtkLabel">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
+                    <property name="halign">start</property>
+                    <property name="label" translatable="yes"><b>Reconciling</b></property>
+                    <property name="use_markup">True</property>
                   </object>
                   <packing>
                     <property name="left_attach">0</property>
-                    <property name="top_attach">10</property>
+                    <property name="top_attach">5</property>
                   </packing>
                 </child>
                 <child>
@@ -2169,56 +2180,56 @@ many months before the current month:</property>
                   </packing>
                 </child>
                 <child>
-                  <object class="GtkCheckButton" id="pref/general.register/draw-vertical-lines">
-                    <property name="label" translatable="yes">Draw _vertical lines between columns</property>
+                  <object class="GtkLabel">
                     <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="receives_default">False</property>
-                    <property name="has_tooltip">True</property>
-                    <property name="tooltip_markup">Show vertical borders on the cells.</property>
-                    <property name="tooltip_text" translatable="yes">Show vertical borders on the cells.</property>
-                    <property name="halign">start</property>
-                    <property name="margin_left">12</property>
-                    <property name="use_underline">True</property>
-                    <property name="draw_indicator">True</property>
+                    <property name="can_focus">False</property>
                   </object>
                   <packing>
                     <property name="left_attach">0</property>
-                    <property name="top_attach">15</property>
+                    <property name="top_attach">10</property>
                   </packing>
                 </child>
                 <child>
-                  <object class="GtkLabel" id="label46">
+                  <object class="GtkLabel">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
+                    <property name="halign">start</property>
+                    <property name="label" translatable="yes"><b>Graphics</b></property>
+                    <property name="use_markup">True</property>
                   </object>
                   <packing>
                     <property name="left_attach">0</property>
-                    <property name="top_attach">16</property>
+                    <property name="top_attach">11</property>
                   </packing>
                 </child>
                 <child>
-                  <object class="GtkLabel" id="label47">
+                  <object class="GtkCheckButton" id="pref/general.register/use-gnucash-color-theme">
+                    <property name="label" translatable="yes">_Use GnuCash built-in color theme</property>
                     <property name="visible">True</property>
-                    <property name="can_focus">False</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">False</property>
+                    <property name="has_tooltip">True</property>
+                    <property name="tooltip_markup">GnuCash uses a yellow/green theme by default for register windows. Uncheck this if you want to use the system color theme instead.</property>
+                    <property name="tooltip_text" translatable="yes">GnuCash uses a yellow/green theme by default for register windows. Uncheck this if you want to use the system color theme instead.</property>
                     <property name="halign">start</property>
-                    <property name="label" translatable="yes"><b>Layout</b></property>
-                    <property name="use_markup">True</property>
+                    <property name="margin_left">12</property>
+                    <property name="use_underline">True</property>
+                    <property name="draw_indicator">True</property>
                   </object>
                   <packing>
                     <property name="left_attach">0</property>
-                    <property name="top_attach">17</property>
+                    <property name="top_attach">12</property>
                   </packing>
                 </child>
                 <child>
-                  <object class="GtkCheckButton" id="pref/general.register/future-after-blank-transaction">
-                    <property name="label" translatable="yes">_Future transactions after blank transaction</property>
+                  <object class="GtkCheckButton" id="pref/general.register/alternate-color-by-transaction">
+                    <property name="label" translatable="yes">Double _mode colors alternate with transactions</property>
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
                     <property name="receives_default">False</property>
                     <property name="has_tooltip">True</property>
-                    <property name="tooltip_markup">If checked, transactions with a date in the future will be displayed at the bottom of the register after the blank transaction. If clear, the blank transaction will be at the bottom of the register after all transactions.</property>
-                    <property name="tooltip_text" translatable="yes">If checked, transactions with a date in the future will be displayed at the bottom of the register after the blank transaction. If clear, the blank transaction will be at the bottom of the register after all transactions.</property>
+                    <property name="tooltip_markup">Alternate the primary and secondary colors by transaction instead of by alternating by row.</property>
+                    <property name="tooltip_text" translatable="yes">Alternate the primary and secondary colors by transaction instead of by alternating by row.</property>
                     <property name="halign">start</property>
                     <property name="margin_left">12</property>
                     <property name="use_underline">True</property>
@@ -2226,7 +2237,7 @@ many months before the current month:</property>
                   </object>
                   <packing>
                     <property name="left_attach">0</property>
-                    <property name="top_attach">18</property>
+                    <property name="top_attach">13</property>
                   </packing>
                 </child>
                 <child>
@@ -2249,14 +2260,14 @@ many months before the current month:</property>
                   </packing>
                 </child>
                 <child>
-                  <object class="GtkCheckButton" id="pref/general.register/alternate-color-by-transaction">
-                    <property name="label" translatable="yes">Double _mode colors alternate with transactions</property>
+                  <object class="GtkCheckButton" id="pref/general.register/draw-vertical-lines">
+                    <property name="label" translatable="yes">Draw _vertical lines between columns</property>
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
                     <property name="receives_default">False</property>
                     <property name="has_tooltip">True</property>
-                    <property name="tooltip_markup">Alternate the primary and secondary colors by transaction instead of by alternating by row.</property>
-                    <property name="tooltip_text" translatable="yes">Alternate the primary and secondary colors by transaction instead of by alternating by row.</property>
+                    <property name="tooltip_markup">Show vertical borders on the cells.</property>
+                    <property name="tooltip_text" translatable="yes">Show vertical borders on the cells.</property>
                     <property name="halign">start</property>
                     <property name="margin_left">12</property>
                     <property name="use_underline">True</property>
@@ -2264,69 +2275,49 @@ many months before the current month:</property>
                   </object>
                   <packing>
                     <property name="left_attach">0</property>
-                    <property name="top_attach">13</property>
+                    <property name="top_attach">15</property>
                   </packing>
                 </child>
                 <child>
-                  <object class="GtkCheckButton" id="pref/general.register/use-gnucash-color-theme">
-                    <property name="label" translatable="yes">_Use GnuCash built-in color theme</property>
+                  <object class="GtkLabel">
                     <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="receives_default">False</property>
-                    <property name="has_tooltip">True</property>
-                    <property name="tooltip_markup">GnuCash uses a yellow/green theme by default for register windows. Uncheck this if you want to use the system color theme instead.</property>
-                    <property name="tooltip_text" translatable="yes">GnuCash uses a yellow/green theme by default for register windows. Uncheck this if you want to use the system color theme instead.</property>
-                    <property name="halign">start</property>
-                    <property name="margin_left">12</property>
-                    <property name="use_underline">True</property>
-                    <property name="draw_indicator">True</property>
+                    <property name="can_focus">False</property>
                   </object>
                   <packing>
                     <property name="left_attach">0</property>
-                    <property name="top_attach">12</property>
+                    <property name="top_attach">16</property>
                   </packing>
                 </child>
                 <child>
-                  <object class="GtkLabel" id="label45">
+                  <object class="GtkLabel">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
                     <property name="halign">start</property>
-                    <property name="label" translatable="yes"><b>Graphics</b></property>
+                    <property name="label" translatable="yes"><b>Layout</b></property>
                     <property name="use_markup">True</property>
                   </object>
                   <packing>
                     <property name="left_attach">0</property>
-                    <property name="top_attach">11</property>
+                    <property name="top_attach">17</property>
                   </packing>
                 </child>
                 <child>
-                  <object class="GtkCheckButton" id="pref/general.register/tab-to-transfer-on-memorised">
-                    <property name="label" translatable="yes">Tab order in_cludes Transfer on Memorised Transactions</property>
+                  <object class="GtkCheckButton" id="pref/general.register/future-after-blank-transaction">
+                    <property name="label" translatable="yes">_Future transactions after blank transaction</property>
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
                     <property name="receives_default">False</property>
                     <property name="has_tooltip">True</property>
-                    <property name="tooltip_markup">Move to Transfer field when memorised transaction auto filled.</property>
-                    <property name="tooltip_text" translatable="yes">Move to Transfer field when memorised transaction auto filled.</property>
+                    <property name="tooltip_markup">If checked, transactions with a date in the future will be displayed at the bottom of the register after the blank transaction. If clear, the blank transaction will be at the bottom of the register after all transactions.</property>
+                    <property name="tooltip_text" translatable="yes">If checked, transactions with a date in the future will be displayed at the bottom of the register after the blank transaction. If clear, the blank transaction will be at the bottom of the register after all transactions.</property>
                     <property name="halign">start</property>
                     <property name="margin_left">12</property>
                     <property name="use_underline">True</property>
-                    <property name="active">True</property>
                     <property name="draw_indicator">True</property>
                   </object>
                   <packing>
                     <property name="left_attach">0</property>
-                    <property name="top_attach">3</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkLabel" id="label121">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                  </object>
-                  <packing>
-                    <property name="left_attach">0</property>
-                    <property name="top_attach">4</property>
+                    <property name="top_attach">18</property>
                   </packing>
                 </child>
               </object>
@@ -2847,7 +2838,7 @@ many months before the current month:</property>
                   </object>
                   <packing>
                     <property name="left_attach">0</property>
-                    <property name="top_attach">6</property>
+                    <property name="top_attach">7</property>
                   </packing>
                 </child>
                 <child>
@@ -2873,7 +2864,17 @@ many months before the current month:</property>
                   </object>
                   <packing>
                     <property name="left_attach">0</property>
-                    <property name="top_attach">7</property>
+                    <property name="top_attach">8</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkLabel">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                  </object>
+                  <packing>
+                    <property name="left_attach">0</property>
+                    <property name="top_attach">6</property>
                   </packing>
                 </child>
                 <child>
@@ -2894,6 +2895,9 @@ many months before the current month:</property>
                 <child>
                   <placeholder/>
                 </child>
+                <child>
+                  <placeholder/>
+                </child>
               </object>
               <packing>
                 <property name="position">7</property>
@@ -3338,8 +3342,5 @@ many months before the current month:</property>
       <action-widget response="-11">helpbutton2</action-widget>
       <action-widget response="-7">closebutton2</action-widget>
     </action-widgets>
-    <child>
-      <placeholder/>
-    </child>
   </object>
 </interface>

commit 38dfc6ecd201bdf3628a27ff2d007bcf6aff295c
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Fri May 3 11:37:42 2019 +0100

    Use the commodity on selected parent rows in price tree view
    
    If the parent row for prices in a price tree view is used for a new
    price the security value can be wrong so get the commodity of this row
    and use it for a temporary price which is cloned for editing.

diff --git a/gnucash/gnome-utils/gnc-tree-view-price.c b/gnucash/gnome-utils/gnc-tree-view-price.c
index 35df37e7f..90e7c51b4 100644
--- a/gnucash/gnome-utils/gnc-tree-view-price.c
+++ b/gnucash/gnome-utils/gnc-tree-view-price.c
@@ -766,7 +766,7 @@ get_selected_prices_helper (GtkTreeModel *s_model,
 }
 
 /*
- * Given an price tree view, return a list of the selected commodities. The
+ * Given a price tree view, return a list of the selected prices. The
  * price tree must be in multiple selection mode.
  *
  * Note: It is the responsibility of the caller to free the returned
@@ -782,3 +782,47 @@ gnc_tree_view_price_get_selected_prices (GncTreeViewPrice *view)
     gtk_tree_selection_selected_foreach(selection, get_selected_prices_helper, &return_list);
     return return_list;
 }
+
+static void
+get_selected_commodity_helper (GtkTreeModel *s_model,
+                               GtkTreePath *s_path,
+                               GtkTreeIter *s_iter,
+                               gpointer data)
+{
+    GList **return_list = data;
+    GtkTreeModel *model, *f_model;
+    GtkTreeIter iter, f_iter;
+    gnc_commodity *commodity;
+
+    gtk_tree_model_sort_convert_iter_to_child_iter (GTK_TREE_MODEL_SORT (s_model),
+            &f_iter, s_iter);
+
+    f_model = gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(s_model));
+    gtk_tree_model_filter_convert_iter_to_child_iter (GTK_TREE_MODEL_FILTER (f_model),
+            &iter, &f_iter);
+
+    model = gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(f_model));
+    commodity = gnc_tree_model_price_get_commodity (GNC_TREE_MODEL_PRICE(model), &iter);
+
+    if (commodity)
+        *return_list = g_list_append(*return_list, commodity);
+}
+
+/*
+ * Given a price tree view, return a list of the selected rows that have
+ * commodities but are not prices, the parent rows for prices. The
+ * price tree must be in multiple selection mode.
+ *
+ * Note: It is the responsibility of the caller to free the returned
+ * list.
+ */
+GList *
+gnc_tree_view_price_get_selected_commodities (GncTreeViewPrice *view)
+{
+    GtkTreeSelection *selection;
+    GList *return_list = NULL;
+
+    selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(view));
+    gtk_tree_selection_selected_foreach (selection, get_selected_commodity_helper, &return_list);
+    return return_list;
+}
diff --git a/gnucash/gnome-utils/gnc-tree-view-price.h b/gnucash/gnome-utils/gnc-tree-view-price.h
index 1f7cd9f75..d61a0dcf7 100644
--- a/gnucash/gnome-utils/gnc-tree-view-price.h
+++ b/gnucash/gnome-utils/gnc-tree-view-price.h
@@ -208,6 +208,19 @@ void gnc_tree_view_price_set_selected_price (GncTreeViewPrice *view,
 GList * gnc_tree_view_price_get_selected_prices (GncTreeViewPrice *view);
 
 
+/** This function returns a list of commodities associated with the
+ *  selected rows that are not prices but are the parent rows for
+ *  prices in the price tree view.
+ *
+ *  @note It only makes sense to call this function when the price
+ *  tree is set to select multiple items.
+ *
+ *  @param view A pointer to an price tree view.
+ *
+ *  @return A list of commodities, or NULL if no commodity was selected.
+ */
+GList * gnc_tree_view_price_get_selected_commodities (GncTreeViewPrice *view);
+
 /** @} */
 
 G_END_DECLS
diff --git a/gnucash/gnome/dialog-price-edit-db.c b/gnucash/gnome/dialog-price-edit-db.c
index 29586d9c0..3936e5e59 100644
--- a/gnucash/gnome/dialog-price-edit-db.c
+++ b/gnucash/gnome/dialog-price-edit-db.c
@@ -353,6 +353,8 @@ selection_changed_cb (GtkTreeSelection *selection, gpointer data)
     gboolean have_rows = (g_list_length (rows) > 0 ? TRUE : FALSE);
 
     change_source_flag (PRICE_REMOVE_SOURCE_COMM, have_rows, pdb_dialog);
+    g_list_foreach (rows, (GFunc) gtk_tree_path_free, NULL);
+    g_list_free (rows);
 }
 
 static GDate
@@ -513,16 +515,33 @@ gnc_prices_dialog_add_clicked (GtkWidget *widget, gpointer data)
     PricesDialog *pdb_dialog = data;
     GNCPrice *price = NULL;
     GList *price_list;
+    GList *comm_list;
+    gboolean unref_price = FALSE;
 
     ENTER(" ");
-    price_list = gnc_tree_view_price_get_selected_prices(pdb_dialog->price_tree);
-    if (price_list)
+    price_list = gnc_tree_view_price_get_selected_prices (pdb_dialog->price_tree);
+    comm_list = gnc_tree_view_price_get_selected_commodities (pdb_dialog->price_tree);
+
+    if (price_list) // selected row is on a price
     {
         price = price_list->data;
-        g_list_free(price_list);
+        g_list_free (price_list);
+    }
+    else if (comm_list) // selection contains price parent rows
+    {
+        if (g_list_length (comm_list) == 1) // make sure it is only one parent
+        {
+            price = gnc_price_create (pdb_dialog->book);
+            gnc_price_set_commodity (price, comm_list->data);
+            unref_price = TRUE;
+        }
+        g_list_free (comm_list);
     }
     gnc_price_edit_dialog (pdb_dialog->window, pdb_dialog->session,
                            price, GNC_PRICE_NEW);
+
+    if (unref_price)
+        gnc_price_unref (price);
     LEAVE(" ");
 }
 
@@ -570,12 +589,25 @@ gnc_prices_dialog_selection_changed (GtkTreeSelection *treeselection,
                                      gpointer data)
 {
     PricesDialog *pdb_dialog = data;
+    GtkTreeModel *model;
     GList *price_list;
+    GList *rows;
     gint length;
 
     ENTER(" ");
-    price_list = gnc_tree_view_price_get_selected_prices(pdb_dialog->price_tree);
-    length = g_list_length(price_list);
+    price_list = gnc_tree_view_price_get_selected_prices (pdb_dialog->price_tree);
+    length = g_list_length (price_list);
+    g_list_free (price_list);
+
+    model = gtk_tree_view_get_model (GTK_TREE_VIEW(pdb_dialog->price_tree));
+    rows = gtk_tree_selection_get_selected_rows (treeselection, &model);
+
+    // if selected rows greater than length, parents must of been selected also
+    if (g_list_length (rows) > length)
+        length = 0;
+
+    g_list_foreach (rows, (GFunc) gtk_tree_path_free, NULL);
+    g_list_free (rows);
 
     gtk_widget_set_sensitive (pdb_dialog->edit_button,
                               length == 1);

commit c782e7a4da1b88d36a6a6a3d99e5d4df10e8ee04
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Fri May 3 11:31:26 2019 +0100

    Bug 797051 - Follow up - Change defaults for new price
    
    Set the default date of a new price to today and the value to 0

diff --git a/gnucash/gnome/dialog-price-editor.c b/gnucash/gnome/dialog-price-editor.c
index 5b88992f4..202c7df66 100644
--- a/gnucash/gnome/dialog-price-editor.c
+++ b/gnucash/gnome/dialog-price-editor.c
@@ -618,9 +618,10 @@ gnc_price_edit_dialog (GtkWidget * parent,
         if (price)
         {
             price = gnc_price_clone(price, pedit_dialog->book);
-//  } else {
-//      price = gnc_price_create (pedit_dialog->book);
+
             gnc_price_set_source (price, PRICE_SOURCE_EDIT_DLG);
+            gnc_price_set_time64 (price, gnc_time (NULL));
+            gnc_price_set_value (price, gnc_numeric_zero ());
         }
 
         pedit_dialog->is_new = TRUE;

commit 7c9f01ff3bca7f7c4b506dcd19413298eedd99da
Author: John Ralls <jralls at ceridwen.us>
Date:   Thu May 2 11:27:23 2019 -0700

    GetUserDefaultLocaleName returns a Windows-style locale too.

diff --git a/gnucash/gnucash-bin.c b/gnucash/gnucash-bin.c
index 757c24f86..c6bc3bd53 100644
--- a/gnucash/gnucash-bin.c
+++ b/gnucash/gnucash-bin.c
@@ -791,6 +791,7 @@ set_win32_thread_locale()
 	sys_locale = g_utf16_to_utf8((gunichar2*)lpLocaleName,
 				     LOCALE_NAME_MAX_LENGTH,
 				     NULL, NULL, NULL);
+	sys_locale[2] = '_';
 	setlocale (LC_ALL, sys_locale);
 	return;
     }

commit 653d8cb5c3ba4b65bba29cb009452dcc922a9168
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Fri Apr 26 21:16:14 2019 +0800

    [general-ledger] remove dependency on transaction.scm

diff --git a/gnucash/report/standard-reports/general-ledger.scm b/gnucash/report/standard-reports/general-ledger.scm
index 2e2231695..521b89263 100644
--- a/gnucash/report/standard-reports/general-ledger.scm
+++ b/gnucash/report/standard-reports/general-ledger.scm
@@ -34,7 +34,6 @@
 (use-modules (gnucash utilities)) 
 (use-modules (gnucash gnc-module))
 (use-modules (gnucash gettext))
-(use-modules (gnucash report standard-reports transaction))
 
 (gnc:module-load "gnucash/report/report-system" 0)
 
@@ -52,7 +51,7 @@
 ;; options generator
 
 (define (general-ledger-options-generator)
-  (let* ((options (trep-options-generator)))
+  (let ((options (gnc:trep-options-generator)))
 
     (define pagename-sorting (N_ "Sorting"))
     (define (set-option! section name value)

commit ff3a34711a5af7a7d3026fc26b9f5498932035ae
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Fri Apr 26 21:17:33 2019 +0800

    [income-gst-statement] remove dependency on transaction.scm

diff --git a/gnucash/report/standard-reports/income-gst-statement.scm b/gnucash/report/standard-reports/income-gst-statement.scm
index b85eb9ebf..be947db4c 100644
--- a/gnucash/report/standard-reports/income-gst-statement.scm
+++ b/gnucash/report/standard-reports/income-gst-statement.scm
@@ -32,7 +32,6 @@
 (use-modules (gnucash gnc-module))
 (use-modules (gnucash gettext))
 (gnc:module-load "gnucash/report/report-system" 0)
-(use-modules (gnucash report standard-reports transaction))
 
 ;; Define the strings here to avoid typos and make changes easier.
 (define reportname (N_ "Income and GST Statement"))
@@ -57,11 +56,12 @@ accounts must be of type ASSET for taxes paid on expenses, and type LIABILITY fo
    (gnc:html-markup-br)
    (gnc:html-markup-br)))
 
-(define (income-gst-statement-renderer rpt)
-  (trep-renderer rpt
-                 #:custom-calculated-cells gst-calculated-cells
-                 #:empty-report-message TAX-SETUP-DESC
-                 #:custom-split-filter gst-custom-split-filter))
+(define (gst-statement-renderer rpt)
+  (gnc:trep-renderer
+   rpt
+   #:custom-calculated-cells gst-calculated-cells
+   #:empty-report-message TAX-SETUP-DESC
+   #:custom-split-filter gst-custom-split-filter))
 
 (define (gst-custom-split-filter split)
   ;; split -> bool
@@ -74,7 +74,7 @@ accounts must be of type ASSET for taxes paid on expenses, and type LIABILITY fo
 (define (gst-statement-options-generator)
 
   ;; Retrieve the list of options specified within the transaction report
-  (define options (trep-options-generator))
+  (define options (gnc:trep-options-generator))
 
   ;; Delete Accounts selector
   (gnc:unregister-option options gnc:pagename-accounts (N_ "Accounts"))
@@ -112,7 +112,7 @@ for taxes paid on expenses, and type LIABILITY for taxes collected on sales.")
     (list (N_ "Net Balance")                  "t" (N_ "Display the net balance (sales without tax - purchases without tax)") #f)
     (list (N_ "Tax payable")                  "u" (N_ "Display the tax payable (tax on sales - tax on purchases)") #f)))
 
-  ;; Enable secret option to delete transactions with >1 split
+  ;; Enable option to retrieve unique transactions only
   (gnc:option-set-value (gnc:lookup-option options "__trep" "unique-transactions") #t)
   ;; Disable account filtering
   (gnc:option-make-internal! options gnc:pagename-accounts "Filter Type")
@@ -134,48 +134,45 @@ for taxes paid on expenses, and type LIABILITY for taxes collected on sales.")
 
 (define (gst-calculated-cells options)
   (define (opt-val section name)
-    (let ((option (gnc:lookup-option options section name)))
-      (if option
-          (gnc:option-value option)
-          (gnc:error "gnc:lookup-option error: " section "/" name))))
+    (gnc:option-value (gnc:lookup-option options section name)))
+  (define (accfilter accounts type)
+    (filter
+     (lambda (acc)
+       (eqv? (xaccAccountGetType acc) type))
+     accounts))
   (letrec*
-      ((myadd (lambda (X Y) (if X (if Y (gnc:monetary+ X Y) X) Y)))           ; custom monetary adder which understands #f
-       (myneg (lambda (X) (and X (gnc:monetary-neg X))))                      ; custom monetary negator which understands #f
+      ((myadd (lambda (X Y) (if X (if Y (gnc:monetary+ X Y) X) Y)))
+       (myneg (lambda (X) (and X (gnc:monetary-neg X))))
        (accounts (opt-val gnc:pagename-accounts "Accounts"))
        (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))    accounts))
-       (accounts-purchases     (filter (lambda (acc) (eq? (xaccAccountGetType acc) ACCT-TYPE-EXPENSE))   accounts))
-       (common-currency (and (opt-val gnc:pagename-general "Common Currency")             ; if a common currency was specified,
-                             (opt-val gnc:pagename-general "Report's currency")))         ; use it
-       (split-date (lambda (s) (xaccTransGetDate (xaccSplitGetParent s))))
-       (split-currency (lambda (s) (xaccAccountGetCommodity (xaccSplitGetAccount s))))
+       (accounts-tax-collected (accfilter tax-accounts ACCT-TYPE-LIABILITY))
+       (accounts-tax-paid      (accfilter tax-accounts ACCT-TYPE-ASSET))
+       (accounts-sales         (accfilter accounts ACCT-TYPE-INCOME))
+       (accounts-purchases     (accfilter accounts ACCT-TYPE-EXPENSE))
+       (common-currency (and (opt-val gnc:pagename-general "Common Currency")
+                             (opt-val gnc:pagename-general "Report's currency")))
+       (split->date (lambda (s) (xaccTransGetDate (xaccSplitGetParent s))))
+       (split->currency (lambda (s) (xaccAccountGetCommodity (xaccSplitGetAccount s))))
        (split-adder (lambda (split accountlist)
-                      (let* (;; 1. from split, get the trans
-                             (transaction (xaccSplitGetParent split))
-                             ;; 2. from trans, get all splits
-                             (splits-in-transaction (xaccTransGetSplitList transaction))
-                             ;; 3. but only from accounts specified
-                             (include-split? (lambda (s) (member (xaccSplitGetAccount s) accountlist)))
-                             (filtered-splits (filter include-split? splits-in-transaction))
-                             ;; 4. get the filtered split amount
-                             (split-get-monetary (lambda (s)
-                                                   (gnc:make-gnc-monetary
-                                                    (split-currency s)
-                                                    (if (xaccTransGetVoidStatus transaction)
-                                                        (xaccSplitVoidFormerAmount s)
-                                                        (xaccSplitGetAmount s)))))
-                             ;; 5. amount - always convert to
-                             ;; either report currency or the original split currency
-                             (split-monetary-converted (lambda (s)
-                                                         (gnc:exchange-by-pricedb-nearest
-                                                          (split-get-monetary s)
-                                                          (or common-currency
-                                                              (split-currency split))
-                                                          (time64CanonicalDayTime
-                                                           (split-date s)))))
-                             (list-of-values (map split-monetary-converted filtered-splits)))
+                      (let* ((txn (xaccSplitGetParent split))
+                             (filtered-splits (filter
+                                               (lambda (s)
+                                                 (member (xaccSplitGetAccount s)
+                                                         accountlist))
+                                               (xaccTransGetSplitList txn)))
+                             (split->monetary (lambda (s)
+                                                (gnc:make-gnc-monetary
+                                                 (split->currency s)
+                                                 (if (xaccTransGetVoidStatus txn)
+                                                     (xaccSplitVoidFormerAmount s)
+                                                     (xaccSplitGetAmount s)))))
+                             (split->converted
+                              (lambda (s)
+                                (gnc:exchange-by-pricedb-nearest
+                                 (split->monetary s)
+                                 (or common-currency (split->currency split))
+                                 (time64CanonicalDayTime (split->date s)))))
+                             (list-of-values (map split->converted filtered-splits)))
                         (fold myadd #f list-of-values))))
        (account-adder (lambda (acc) (lambda (s) (split-adder s (list acc)))))
        (account-adder-neg (lambda (acc) (lambda (s) (myneg (split-adder s (list acc))))))
@@ -283,4 +280,4 @@ for taxes paid on expenses, and type LIABILITY for taxes collected on sales.")
  'name reportname
  'report-guid "5bf27f249a0d11e7abc4cec278b6b50a"
  'options-generator gst-statement-options-generator
- 'renderer income-gst-statement-renderer)
+ 'renderer gst-statement-renderer)

commit b87d693a77d89e8c55bc76c0587d287e093c2f75
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Fri Apr 26 21:17:13 2019 +0800

    [trep-engine] modularise trep-engine

diff --git a/gnucash/report/report-system/CMakeLists.txt b/gnucash/report/report-system/CMakeLists.txt
index a06f4c43b..9fee1071a 100644
--- a/gnucash/report/report-system/CMakeLists.txt
+++ b/gnucash/report/report-system/CMakeLists.txt
@@ -76,6 +76,7 @@ set (report_system_SCHEME_3
     options-utilities.scm
     report-utilities.scm
     report.scm
+    trep-engine.scm
 )
 
 set(GUILE_DEPENDS
diff --git a/gnucash/report/report-system/report-system.scm b/gnucash/report/report-system/report-system.scm
index 9ce7da797..387135e51 100644
--- a/gnucash/report/report-system/report-system.scm
+++ b/gnucash/report/report-system/report-system.scm
@@ -743,6 +743,10 @@
 (export gnc:strify)
 (export gnc:pk)
 
+;; trep-engine.scm
+(export gnc:trep-options-generator)
+(export gnc:trep-renderer)
+
 (load-from-path "commodity-utilities")
 (load-from-path "html-barchart")
 (load-from-path "html-document")
@@ -761,5 +765,6 @@
 (load-from-path "options-utilities")
 (load-from-path "report-utilities")
 (load-from-path "report")
+(load-from-path "trep-engine")
 
 (gnc-hook-add-scm-dangler HOOK-SAVE-OPTIONS gnc:save-style-sheet-options)
diff --git a/gnucash/report/standard-reports/transaction.scm b/gnucash/report/report-system/trep-engine.scm
similarity index 55%
copy from gnucash/report/standard-reports/transaction.scm
copy to gnucash/report/report-system/trep-engine.scm
index d1b3b94fa..b4947700b 100644
--- a/gnucash/report/standard-reports/transaction.scm
+++ b/gnucash/report/report-system/trep-engine.scm
@@ -1,5 +1,5 @@
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; transaction-report.scm : Report on all transactions in account(s)
+;; trep-engine.scm : Transaction Report engine
 ;;
 ;; Original report by Robert Merkel <rgmerk at mira.net>
 ;; Contributions by Bryan Larsen <blarsen at ada-works.com>
@@ -15,21 +15,20 @@
 ;; - common currency - optionally show original currency amount
 ;;   and enable multiple data columns
 ;; - add support for indenting for better grouping
-;; - add defaults suitable for a reconciliation report
-;;   including alternative date filtering strategy
 ;; - add subtotal summary grid
 ;; - by default, exclude closing transactions from the report
+;; - converted to module in 2019
+;;
+;; 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:
 ;;
@@ -39,20 +38,11 @@
 ;;
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
-(define-module (gnucash report standard-reports transaction))
-
-(use-modules (gnucash utilities))
-(use-modules (srfi srfi-1))
-(use-modules (srfi srfi-11))
-(use-modules (srfi srfi-13))
-(use-modules (ice-9 regex))
-(use-modules (gnucash gnc-module))
 (use-modules (gnucash gettext))
-
-(gnc:module-load "gnucash/report/report-system" 0)
+(use-modules (srfi srfi-11))
+(use-modules (srfi srfi-1))
 
 ;; Define the strings here to avoid typos and make changes easier.
-(define reportname (N_ "Transaction Report"))
 
 ;;Accounts
 (define optname-accounts (N_ "Accounts"))
@@ -73,7 +63,8 @@
 (define optname-show-account-code (N_ "Show Account Code"))
 (define optname-show-account-description (N_ "Show Account Description"))
 (define optname-show-informal-headers (N_ "Show Informal Debit/Credit Headers"))
-(define optname-show-subtotals-only (N_ "Show subtotals only (hide transactional data)"))
+(define optname-show-subtotals-only
+  (N_ "Show subtotals only (hide transactional data)"))
 (define optname-indenting (N_ "Add indenting columns"))
 (define optname-sec-sortkey (N_ "Secondary Key"))
 (define optname-sec-subtotal (N_ "Secondary Subtotal"))
@@ -92,9 +83,11 @@
 ;;Filtering
 (define pagename-filter (N_ "Filter"))
 (define optname-account-matcher (N_ "Account Name Filter"))
-(define optname-account-matcher-regex (N_ "Use regular expressions for account name filter"))
+(define optname-account-matcher-regex
+  (N_ "Use regular expressions for account name filter"))
 (define optname-transaction-matcher (N_ "Transaction Filter"))
-(define optname-transaction-matcher-regex (N_ "Use regular expressions for transaction filter"))
+(define optname-transaction-matcher-regex
+  (N_ "Use regular expressions for transaction filter"))
 (define optname-reconcile-status (N_ "Reconcile Status"))
 (define optname-void-transactions (N_ "Void Transactions"))
 (define optname-closing-transactions (N_ "Closing transactions"))
@@ -111,19 +104,28 @@
 match the time interval and account selection specified \
 in the Options panel."))
 
-(define DATE-SORTING-TYPES (list 'date 'reconciled-date))
+(define DATE-SORTING-TYPES
+  (list 'date 'reconciled-date))
+
+(define ACCOUNT-SORTING-TYPES
+  (list 'account-name 'corresponding-acc-name
+        'account-code 'corresponding-acc-code))
 
-(define ACCOUNT-SORTING-TYPES (list 'account-name 'corresponding-acc-name
-                                    'account-code 'corresponding-acc-code))
+(define SORTKEY-INFORMAL-HEADERS
+  (list 'account-name 'account-code))
 
-(define SORTKEY-INFORMAL-HEADERS (list 'account-name 'account-code))
+(define reconcile-list
+  (list (cons #\n (_ "Unreconciled"))
+        (cons #\c (_ "Cleared"))
+        (cons #\y (_ "Reconciled"))
+        (cons #\f (_ "Frozen"))
+        (cons #\v (_ "Voided"))))
 
 (define (sortkey-list split-action?)
-  ;;
   ;; Defines the different sorting keys, as an association-list
   ;; together with the subtotal functions. Each entry:
   ;;  'sortkey             - sort parameter sent via qof-query
-  ;;  'split-sortvalue     - function which retrieves number/string used for comparing splits
+  ;;  'split-sortvalue     - function retrieves number/string for comparing splits
   ;;  'text                - text displayed in Display tab
   ;;  'tip                 - tooltip displayed in Display tab
   ;;  'renderer-fn         - helper function to select subtotal/subheading renderer
@@ -132,214 +134,245 @@ in the Options panel."))
   ;;       #f means the sortkey cannot be subtotalled
   ;;       otherwise it converts split->string
   ;;
-  (list (cons 'account-name  (list (cons 'sortkey (list SPLIT-ACCT-FULLNAME))
-                                   (cons 'split-sortvalue (lambda (a) (gnc-account-get-full-name (xaccSplitGetAccount a))))
-                                   (cons 'text (_ "Account Name"))
-                                   (cons 'tip (_ "Sort & subtotal by account name."))
-                                   (cons 'renderer-fn (lambda (a) (xaccSplitGetAccount a)))))
-
-        (cons 'account-code (list (cons 'sortkey (list SPLIT-ACCOUNT ACCOUNT-CODE-))
-                                  (cons 'split-sortvalue (lambda (a) (xaccAccountGetCode (xaccSplitGetAccount a))))
-                                  (cons 'text (_ "Account Code"))
-                                  (cons 'tip (_ "Sort & subtotal by account code."))
-                                  (cons 'renderer-fn (lambda (a) (xaccSplitGetAccount a)))))
-
-        (cons 'date         (list (cons 'sortkey (list SPLIT-TRANS TRANS-DATE-POSTED))
-                                  (cons 'split-sortvalue (lambda (s) (xaccTransGetDate (xaccSplitGetParent s))))
-                                  (cons 'text (_ "Date"))
-                                  (cons 'tip (_ "Sort by date."))
-                                  (cons 'renderer-fn #f)))
-
-        (cons 'reconciled-date (list (cons 'sortkey (list SPLIT-DATE-RECONCILED))
-                                     (cons 'split-sortvalue (lambda (s) (xaccSplitGetDateReconciled s)))
-                                     (cons 'text (_ "Reconciled Date"))
-                                     (cons 'tip (_ "Sort by the Reconciled Date."))
-                                     (cons 'renderer-fn #f)))
-
-        (cons 'reconciled-status (list (cons 'sortkey #f)
-                                       (cons 'split-sortvalue (lambda (s) (length (memq (xaccSplitGetReconcile s)
-                                                                                        '(#\n #\c #\y #\f #\v)))))
-                                       (cons 'text (_ "Reconciled Status"))
-                                       (cons 'tip (_ "Sort by the Reconciled Status"))
-                                       (cons 'renderer-fn (lambda (s) (case (xaccSplitGetReconcile s)
-                                                                        ((#\y) (_ "Reconciled"))
-                                                                        ((#\c) (_ "Cleared"))
-                                                                        ((#\n) (_ "Unreconciled"))
-                                                                        ((#\f) (_ "Frozen"))
-                                                                        ((#\v) (_ "Voided"))
-                                                                        (else (_ "Unknown")))))))
-
-        (cons 'register-order (list (cons 'sortkey (list QUERY-DEFAULT-SORT))
-                                    (cons 'split-sortvalue #f)
-                                    (cons 'text (_ "Register Order"))
-                                    (cons 'tip (_ "Sort as in the register."))
-                                    (cons 'renderer-fn #f)))
-
-        (cons 'corresponding-acc-name (list (cons 'sortkey (list SPLIT-CORR-ACCT-NAME))
-                                            (cons 'split-sortvalue (lambda (a) (xaccSplitGetCorrAccountFullName a)))
-                                            (cons 'text (_ "Other Account Name"))
-                                            (cons 'tip (_ "Sort by account transferred from/to's name."))
-                                            (cons 'renderer-fn (lambda (a) (xaccSplitGetAccount (xaccSplitGetOtherSplit a))))))
-
-        (cons 'corresponding-acc-code (list (cons 'sortkey (list SPLIT-CORR-ACCT-CODE))
-                                            (cons 'split-sortvalue (lambda (a) (xaccSplitGetCorrAccountCode a)))
-                                            (cons 'text (_ "Other Account Code"))
-                                            (cons 'tip (_ "Sort by account transferred from/to's code."))
-                                            (cons 'renderer-fn (lambda (a) (xaccSplitGetAccount (xaccSplitGetOtherSplit a))))))
-
-        (cons 'amount        (list (cons 'sortkey (list SPLIT-VALUE))
-                                   (cons 'split-sortvalue (lambda (a) (gnc-numeric-to-scm (xaccSplitGetValue a))))
-                                   (cons 'text (_ "Amount"))
-                                   (cons 'tip (_ "Sort by amount."))
-                                   (cons 'renderer-fn #f)))
-
-        (cons 'description   (list (cons 'sortkey (list SPLIT-TRANS TRANS-DESCRIPTION))
-                                   (cons 'split-sortvalue (lambda (s) (xaccTransGetDescription (xaccSplitGetParent s))))
-                                   (cons 'text (_ "Description"))
-                                   (cons 'tip (_ "Sort by description."))
-                                   (cons 'renderer-fn (lambda (s) (xaccTransGetDescription (xaccSplitGetParent s))))))
+  (list (list 'account-name
+              (cons 'sortkey (list SPLIT-ACCT-FULLNAME))
+              (cons 'split-sortvalue
+                    (compose gnc-account-get-full-name xaccSplitGetAccount))
+              (cons 'text (_ "Account Name"))
+              (cons 'tip (_ "Sort & subtotal by account name."))
+              (cons 'renderer-fn xaccSplitGetAccount))
+
+        (list 'account-code
+              (cons 'sortkey (list SPLIT-ACCOUNT ACCOUNT-CODE-))
+              (cons 'split-sortvalue (compose xaccAccountGetCode xaccSplitGetAccount))
+              (cons 'text (_ "Account Code"))
+              (cons 'tip (_ "Sort & subtotal by account code."))
+              (cons 'renderer-fn xaccSplitGetAccount))
+
+        (list 'date
+              (cons 'sortkey (list SPLIT-TRANS TRANS-DATE-POSTED))
+              (cons 'split-sortvalue (compose xaccTransGetDate xaccSplitGetParent))
+              (cons 'text (_ "Date"))
+              (cons 'tip (_ "Sort by date."))
+              (cons 'renderer-fn #f))
+
+        (list 'reconciled-date
+              (cons 'sortkey (list SPLIT-DATE-RECONCILED))
+              (cons 'split-sortvalue xaccSplitGetDateReconciled)
+              (cons 'text (_ "Reconciled Date"))
+              (cons 'tip (_ "Sort by the Reconciled Date."))
+              (cons 'renderer-fn #f))
+
+        (list 'reconciled-status
+              (cons 'sortkey #f)
+              (cons 'split-sortvalue (lambda (s)
+                                       (length (memv (xaccSplitGetReconcile s)
+                                                     (map car reconcile-list)))))
+              (cons 'text (_ "Reconciled Status"))
+              (cons 'tip (_ "Sort by the Reconciled Status"))
+              (cons 'renderer-fn (lambda (s)
+                                   (assv-ref reconcile-list
+                                             (xaccSplitGetReconcile s)))))
+
+        (list 'register-order
+              (cons 'sortkey (list QUERY-DEFAULT-SORT))
+              (cons 'split-sortvalue #f)
+              (cons 'text (_ "Register Order"))
+              (cons 'tip (_ "Sort as in the register."))
+              (cons 'renderer-fn #f))
+
+        (list 'corresponding-acc-name
+              (cons 'sortkey (list SPLIT-CORR-ACCT-NAME))
+              (cons 'split-sortvalue xaccSplitGetCorrAccountFullName)
+              (cons 'text (_ "Other Account Name"))
+              (cons 'tip (_ "Sort by account transferred from/to's name."))
+              (cons 'renderer-fn (compose xaccSplitGetAccount xaccSplitGetOtherSplit)))
+
+        (list 'corresponding-acc-code
+              (cons 'sortkey (list SPLIT-CORR-ACCT-CODE))
+              (cons 'split-sortvalue xaccSplitGetCorrAccountCode)
+              (cons 'text (_ "Other Account Code"))
+              (cons 'tip (_ "Sort by account transferred from/to's code."))
+              (cons 'renderer-fn (compose xaccSplitGetAccount xaccSplitGetOtherSplit)))
+
+        (list 'amount
+              (cons 'sortkey (list SPLIT-VALUE))
+              (cons 'split-sortvalue xaccSplitGetValue)
+              (cons 'text (_ "Amount"))
+              (cons 'tip (_ "Sort by amount."))
+              (cons 'renderer-fn #f))
+
+        (list 'description
+              (cons 'sortkey (list SPLIT-TRANS TRANS-DESCRIPTION))
+              (cons 'split-sortvalue (compose xaccTransGetDescription
+                                              xaccSplitGetParent))
+              (cons 'text (_ "Description"))
+              (cons 'tip (_ "Sort by description."))
+              (cons 'renderer-fn (compose xaccTransGetDescription xaccSplitGetParent)))
 
         (if split-action?
-            (cons 'number    (list (cons 'sortkey (list SPLIT-ACTION))
-                                   (cons 'split-sortvalue (lambda (a) (xaccSplitGetAction a)))
-                                   (cons 'text (_ "Number/Action"))
-                                   (cons 'tip (_ "Sort by check number/action."))
-                                   (cons 'renderer-fn #f)))
-
-            (cons 'number    (list (cons 'sortkey (list SPLIT-TRANS TRANS-NUM))
-                                   (cons 'split-sortvalue (lambda (a) (xaccTransGetNum (xaccSplitGetParent a))))
-                                   (cons 'text (_ "Number"))
-                                   (cons 'tip (_ "Sort by check/transaction number."))
-                                   (cons 'renderer-fn #f))))
-
-        (cons 't-number      (list (cons 'sortkey (list SPLIT-TRANS TRANS-NUM))
-                                   (cons 'split-sortvalue (lambda (a) (xaccTransGetNum (xaccSplitGetParent a))))
-                                   (cons 'text (_ "Transaction Number"))
-                                   (cons 'tip (_ "Sort by transaction number."))
-                                   (cons 'renderer-fn #f)))
-
-        (cons 'memo          (list (cons 'sortkey (list SPLIT-MEMO))
-                                   (cons 'split-sortvalue (lambda (s) (xaccSplitGetMemo s)))
-                                   (cons 'text (_ "Memo"))
-                                   (cons 'tip (_ "Sort by memo."))
-                                   (cons 'renderer-fn (lambda (s) (xaccSplitGetMemo s)))))
-
-        (cons 'notes         (list (cons 'sortkey #f)
-                                   (cons 'split-sortvalue (lambda (s) (xaccTransGetNotes (xaccSplitGetParent s))))
-                                   (cons 'text (_ "Notes"))
-                                   (cons 'tip (_ "Sort by transaction notes."))
-                                   (cons 'renderer-fn (lambda (s) (xaccTransGetNotes (xaccSplitGetParent s))))))
-
-        (cons 'none          (list (cons 'sortkey '())
-                                   (cons 'split-sortvalue #f)
-                                   (cons 'text (_ "None"))
-                                   (cons 'tip (_ "Do not sort."))
-                                   (cons 'renderer-fn #f)))))
-
-(define (time64-year t64)    (gnc:date-get-year (gnc-localtime t64)))
-(define (time64-quarter t64) (+ (* 10 (gnc:date-get-year (gnc-localtime t64)))  (gnc:date-get-quarter (gnc-localtime t64))))
-(define (time64-month t64)   (+ (* 100 (gnc:date-get-year (gnc-localtime t64))) (gnc:date-get-month (gnc-localtime t64))))
-(define (time64-week t64)    (gnc:date-get-week (gnc-localtime t64)))
-(define (time64-day t64)     (+ (* 500 (gnc:date-get-year (gnc-localtime t64))) (gnc:date-get-year-day (gnc-localtime t64))))
-(define (time64->daily-string t) (qof-print-date t))
-(define (split->time64 s) (xaccTransGetDate (xaccSplitGetParent s)))
+            (list 'number
+                  (cons 'sortkey (list SPLIT-ACTION))
+                  (cons 'split-sortvalue xaccSplitGetAction)
+                  (cons 'text (_ "Number/Action"))
+                  (cons 'tip (_ "Sort by check number/action."))
+                  (cons 'renderer-fn #f))
+
+            (list 'number
+                  (cons 'sortkey (list SPLIT-TRANS TRANS-NUM))
+                  (cons 'split-sortvalue (compose xaccTransGetNum xaccSplitGetParent))
+                  (cons 'text (_ "Number"))
+                  (cons 'tip (_ "Sort by check/transaction number."))
+                  (cons 'renderer-fn #f)))
+
+        (list 't-number
+              (cons 'sortkey (list SPLIT-TRANS TRANS-NUM))
+              (cons 'split-sortvalue (compose xaccTransGetNum xaccSplitGetParent))
+              (cons 'text (_ "Transaction Number"))
+              (cons 'tip (_ "Sort by transaction number."))
+              (cons 'renderer-fn #f))
+
+        (list 'memo
+              (cons 'sortkey (list SPLIT-MEMO))
+              (cons 'split-sortvalue xaccSplitGetMemo)
+              (cons 'text (_ "Memo"))
+              (cons 'tip (_ "Sort by memo."))
+              (cons 'renderer-fn xaccSplitGetMemo))
+
+        (list 'notes
+              (cons 'sortkey #f)
+              (cons 'split-sortvalue (compose xaccTransGetNotes xaccSplitGetParent))
+              (cons 'text (_ "Notes"))
+              (cons 'tip (_ "Sort by transaction notes."))
+              (cons 'renderer-fn (compose xaccTransGetNotes xaccSplitGetParent)))
+
+        (list 'none
+              (cons 'sortkey '())
+              (cons 'split-sortvalue #f)
+              (cons 'text (_ "None"))
+              (cons 'tip (_ "Do not sort."))
+              (cons 'renderer-fn #f))))
+
+(define (time64-year t64)
+  (gnc:date-get-year (gnc-localtime t64)))
+(define (time64-quarter t64)
+  (+ (* 10 (gnc:date-get-year (gnc-localtime t64)))
+     (gnc:date-get-quarter (gnc-localtime t64))))
+(define (time64-month t64)
+  (+ (* 100 (gnc:date-get-year (gnc-localtime t64)))
+     (gnc:date-get-month (gnc-localtime t64))))
+(define (time64-week t64)
+  (gnc:date-get-week (gnc-localtime t64)))
+(define (time64-day t64)
+  (+ (* 500 (gnc:date-get-year (gnc-localtime t64)))
+     (gnc:date-get-year-day (gnc-localtime t64))))
+(define (split->time64 s)
+  (xaccTransGetDate (xaccSplitGetParent s)))
 
 (define date-subtotal-list
   ;; List for date option.
   ;; Defines the different date sorting keys, as an association-list. Each entry:
-  ;;  'split-sortvalue     - function which retrieves number/string used for comparing splits
+  ;;  'split-sortvalue     - func retrieves number/string used for comparing splits
   ;;  'text                - text displayed in Display tab
   ;;  'tip                 - tooltip displayed in Display tab
-  ;;  'renderer-fn         - func retrieve string for subtotal/subheading renderer
+  ;;  'renderer-fn         - func retrieves string for subtotal/subheading renderer
   ;;         #f means the date sortkey is not grouped
   ;;         otherwise it converts split->string
   (list
-   (cons 'none (list
-                (cons 'split-sortvalue #f)
-                (cons 'date-sortvalue #f)
-                (cons 'text (_ "None"))
-                (cons 'tip (_ "None."))
-                (cons 'renderer-fn #f)))
-
-   (cons 'daily (list
-                  (cons 'split-sortvalue (lambda (s) (time64-day (split->time64 s))))
-                  (cons 'date-sortvalue time64-day)
-                  (cons 'text (_ "Daily"))
-                  (cons 'tip (_ "Daily."))
-                  (cons 'renderer-fn (lambda (s) (time64->daily-string (split->time64 s))))))
-
-   (cons 'weekly (list
-                  (cons 'split-sortvalue (lambda (s) (time64-week (split->time64 s))))
-                  (cons 'date-sortvalue time64-week)
-                  (cons 'text (_ "Weekly"))
-                  (cons 'tip (_ "Weekly."))
-                  (cons 'renderer-fn (lambda (s) (gnc:date-get-week-year-string (gnc-localtime (split->time64 s)))))))
-
-   (cons 'monthly (list
-                   (cons 'split-sortvalue (lambda (s) (time64-month (split->time64 s))))
-                   (cons 'date-sortvalue time64-month)
-                   (cons 'text (_ "Monthly"))
-                   (cons 'tip (_ "Monthly."))
-                   (cons 'renderer-fn (lambda (s) (gnc:date-get-month-year-string (gnc-localtime (split->time64 s)))))))
-
-   (cons 'quarterly (list
-                     (cons 'split-sortvalue (lambda (s) (time64-quarter (split->time64 s))))
-                     (cons 'date-sortvalue time64-quarter)
-                     (cons 'text (_ "Quarterly"))
-                     (cons 'tip (_ "Quarterly."))
-                     (cons 'renderer-fn (lambda (s) (gnc:date-get-quarter-year-string (gnc-localtime (split->time64 s)))))))
-
-   (cons 'yearly (list
-                  (cons 'split-sortvalue (lambda (s) (time64-year (split->time64 s))))
-                  (cons 'date-sortvalue time64-year)
-                  (cons 'text (_ "Yearly"))
-                  (cons 'tip (_ "Yearly."))
-                  (cons 'renderer-fn (lambda (s) (gnc:date-get-year-string (gnc-localtime (split->time64 s)))))))))
+   (list 'none
+         (cons 'split-sortvalue #f)
+         (cons 'date-sortvalue #f)
+         (cons 'text (_ "None"))
+         (cons 'tip (_ "None."))
+         (cons 'renderer-fn #f))
+
+   (list 'daily
+         (cons 'split-sortvalue (lambda (s) (time64-day (split->time64 s))))
+         (cons 'date-sortvalue time64-day)
+         (cons 'text (_ "Daily"))
+         (cons 'tip (_ "Daily."))
+         (cons 'renderer-fn (lambda (s) (qof-print-date (split->time64 s)))))
+
+   (list 'weekly
+         (cons 'split-sortvalue (lambda (s) (time64-week (split->time64 s))))
+         (cons 'date-sortvalue time64-week)
+         (cons 'text (_ "Weekly"))
+         (cons 'tip (_ "Weekly."))
+         (cons 'renderer-fn (compose gnc:date-get-week-year-string
+                                     gnc-localtime
+                                     split->time64)))
+
+   (list 'monthly
+         (cons 'split-sortvalue (lambda (s) (time64-month (split->time64 s))))
+         (cons 'date-sortvalue time64-month)
+         (cons 'text (_ "Monthly"))
+         (cons 'tip (_ "Monthly."))
+         (cons 'renderer-fn (compose gnc:date-get-month-year-string
+                                     gnc-localtime
+                                     split->time64)))
+
+   (list 'quarterly
+         (cons 'split-sortvalue (lambda (s) (time64-quarter (split->time64 s))))
+         (cons 'date-sortvalue time64-quarter)
+         (cons 'text (_ "Quarterly"))
+         (cons 'tip (_ "Quarterly."))
+         (cons 'renderer-fn (compose gnc:date-get-quarter-year-string
+                                     gnc-localtime
+                                     split->time64)))
+
+   (list 'yearly
+         (cons 'split-sortvalue (lambda (s) (time64-year (split->time64 s))))
+         (cons 'date-sortvalue time64-year)
+         (cons 'text (_ "Yearly"))
+         (cons 'tip (_ "Yearly."))
+         (cons 'renderer-fn (compose gnc:date-get-year-string
+                                     gnc-localtime
+                                     split->time64)))))
 
 (define filter-list
   (list
-   (cons 'none (list
-                (cons 'text (_ "None"))
-                (cons 'tip (_ "Do not do any filtering."))))
+   (list 'none
+         (cons 'text (_ "None"))
+         (cons 'tip (_ "Do not do any filtering.")))
 
-   (cons 'include (list
-                   (cons 'text (_ "Include Transactions to/from Filter Accounts"))
-                   (cons 'tip (_ "Include transactions to/from filter accounts only."))))
+   (list 'include
+         (cons 'text (_ "Include Transactions to/from Filter Accounts"))
+         (cons 'tip (_ "Include transactions to/from filter accounts only.")))
 
-   (cons 'exclude (list
-                   (cons 'text (_ "Exclude Transactions to/from Filter Accounts"))
-                   (cons 'tip (_ "Exclude transactions to/from all filter accounts."))))))
+   (list 'exclude
+         (cons 'text (_ "Exclude Transactions to/from Filter Accounts"))
+         (cons 'tip (_ "Exclude transactions to/from all filter accounts.")))))
 
 (define show-void-list
   (list
-   (cons 'non-void-only (list
-                         (cons 'text (_ "Non-void only"))
-                         (cons 'tip (_ "Show only non-voided transactions."))))
+   (list 'non-void-only
+         (cons 'text (_ "Non-void only"))
+         (cons 'tip (_ "Show only non-voided transactions.")))
 
-   (cons 'void-only (list
-                     (cons 'text (_ "Void only"))
-                     (cons 'tip (_ "Show only voided transactions."))))
+   (list 'void-only
+         (cons 'text (_ "Void only"))
+         (cons 'tip (_ "Show only voided transactions.")))
 
-   (cons 'both (list
-                (cons 'text (_ "Both"))
-                (cons 'tip (_ "Show both (and include void transactions in totals)."))))))
+   (list 'both
+         (cons 'text (_ "Both"))
+         (cons 'tip (_ "Show both (and include void transactions in totals).")))))
 
 (define show-closing-list
   (list
-   (cons 'exclude-closing (list
-                           (cons 'text (_ "Exclude closing transactions"))
-                           (cons 'tip (_ "Exclude closing transactions from report."))
-                           (cons 'closing-match #f)))
+   (list 'exclude-closing
+         (cons 'text (_ "Exclude closing transactions"))
+         (cons 'tip (_ "Exclude closing transactions from report."))
+         (cons 'closing-match #f))
 
-   (cons 'include-both (list
-                        (cons 'text (_ "Show both closing and regular transactions"))
-                        (cons 'tip (_ "Show both (and include closing transactions in totals)."))
-                        (cons 'closing-match 'both)))
+   (list 'include-both
+         (cons 'text (_ "Show both closing and regular transactions"))
+         (cons 'tip (_ "Show both (and include closing transactions in totals)."))
+         (cons 'closing-match 'both))
 
-   (cons 'closing-only (list
-                        (cons 'text (_ "Show closing transactions only"))
-                        (cons 'tip (_ "Show only closing transactions."))
-                        (cons 'closing-match #t)))))
+   (list 'closing-only
+         (cons 'text (_ "Show closing transactions only"))
+         (cons 'tip (_ "Show only closing transactions."))
+         (cons 'closing-match #t))))
 
 (define reconcile-status-list
   ;; 'filter-types must be either #f (i.e. disable reconcile filter)
@@ -347,68 +380,60 @@ in the Options panel."))
   ;; e.g. CLEARED-NO for unreconciled
   ;;      (logior CLEARED-NO CLEARED-CLEARED) for unreconciled & cleared
   (list
-   (cons 'all
-         (list
-          (cons 'text (_ "All"))
-          (cons 'tip (_ "Show All Transactions"))
-          (cons 'filter-types #f)))
-
-   (cons 'unreconciled
-         (list
-          (cons 'text (_ "Unreconciled"))
-          (cons 'tip (_ "Unreconciled only"))
-          (cons 'filter-types CLEARED-NO)))
-
-   (cons 'cleared
-         (list
-          (cons 'text (_ "Cleared"))
-          (cons 'tip (_ "Cleared only"))
-          (cons 'filter-types CLEARED-CLEARED)))
-
-   (cons 'reconciled
-         (list
-          (cons 'text (_ "Reconciled"))
-          (cons 'tip (_ "Reconciled only"))
-          (cons 'filter-types CLEARED-RECONCILED)))))
+   (list 'all
+         (cons 'text (_ "All"))
+         (cons 'tip (_ "Show All Transactions"))
+         (cons 'filter-types #f))
+
+   (list 'unreconciled
+         (cons 'text (_ "Unreconciled"))
+         (cons 'tip (_ "Unreconciled only"))
+         (cons 'filter-types CLEARED-NO))
+
+   (list 'cleared
+         (cons 'text (_ "Cleared"))
+         (cons 'tip (_ "Cleared only"))
+         (cons 'filter-types CLEARED-CLEARED))
+
+   (list 'reconciled
+         (cons 'text (_ "Reconciled"))
+         (cons 'tip (_ "Reconciled only"))
+         (cons 'filter-types CLEARED-RECONCILED))))
 
 
 (define ascending-list
   (list
-   (cons 'ascend (list
-                  (cons 'text (_ "Ascending"))
-                  (cons 'tip (_ "Smallest to largest, earliest to latest."))))
-   (cons 'descend (list
-                   (cons 'text (_ "Descending"))
-                   (cons 'tip (_ "Largest to smallest, latest to earliest."))))))
+   (list 'ascend
+         (cons 'text (_ "Ascending"))
+         (cons 'tip (_ "Smallest to largest, earliest to latest.")))
+   (list 'descend
+         (cons 'text (_ "Descending"))
+         (cons 'tip (_ "Largest to smallest, latest to earliest.")))))
 
 (define sign-reverse-list
   (list
-   (cons 'global
-         (list
-          (cons 'text (_ "Use Global Preference"))
-          (cons 'tip (_ "Use reversing option specified in global preference."))
-          (cons 'acct-types #f)))
-   (cons 'none
-         (list
-          (cons 'text (_ "None"))
-          (cons 'tip (_ "Don't change any displayed amounts."))
-          (cons 'acct-types '())))
-   (cons 'income-expense
-         (list
-          (cons 'text (_ "Income and Expense"))
-          (cons 'tip (_ "Reverse amount display for Income and Expense Accounts."))
-          (cons 'acct-types (list ACCT-TYPE-INCOME ACCT-TYPE-EXPENSE))))
-   (cons 'credit-accounts
-         (list
-          (cons 'text (_ "Credit Accounts"))
-          (cons 'tip (_ "Reverse amount display for Liability, Payable, Equity, \
+   (list 'global
+         (cons 'text (_ "Use Global Preference"))
+         (cons 'tip (_ "Use reversing option specified in global preference."))
+         (cons 'acct-types #f))
+   (list 'none
+         (cons 'text (_ "None"))
+         (cons 'tip (_ "Don't change any displayed amounts."))
+         (cons 'acct-types '()))
+   (list 'income-expense
+         (cons 'text (_ "Income and Expense"))
+         (cons 'tip (_ "Reverse amount display for Income and Expense Accounts."))
+         (cons 'acct-types (list ACCT-TYPE-INCOME ACCT-TYPE-EXPENSE)))
+   (list 'credit-accounts
+         (cons 'text (_ "Credit Accounts"))
+         (cons 'tip (_ "Reverse amount display for Liability, Payable, Equity, \
 Credit Card, and Income accounts."))
-          (cons 'acct-types (list ACCT-TYPE-LIABILITY ACCT-TYPE-PAYABLE
-                                  ACCT-TYPE-EQUITY ACCT-TYPE-CREDIT
-                                  ACCT-TYPE-INCOME))))))
+         (cons 'acct-types (list ACCT-TYPE-LIABILITY ACCT-TYPE-PAYABLE
+                                 ACCT-TYPE-EQUITY ACCT-TYPE-CREDIT
+                                 ACCT-TYPE-INCOME)))))
 
 (define (keylist-get-info keylist key info)
-  (cdr (assq info (cdr (assq key keylist)))))
+  (assq-ref (assq-ref keylist key) info))
 
 (define (keylist->vectorlist keylist)
   (map
@@ -435,67 +460,16 @@ Credit Card, and Income accounts."))
        (not (keylist-get-info (sortkey-list split-action?) sortkey 'sortkey))))
 
 ;;
-;; Set defaults for reconcilation report
-;;
-(define (reconcile-report-options-generator)
-  (define options (trep-options-generator))
-  (gnc:option-set-value (gnc:lookup-option options pagename-sorting optname-prime-sortkey) 'reconciled-status)
-  (gnc:option-set-value (gnc:lookup-option options pagename-sorting optname-sec-sortkey)   'date)
-  (gnc:option-set-value (gnc:lookup-option options pagename-sorting optname-sec-date-subtotal) 'none)
-  ;; the start date should really be the last-reconcile-date but this information is not
-  ;; easily accessible from scheme:
-  (gnc:option-set-value (gnc:lookup-option options gnc:pagename-general optname-startdate) (cons 'relative 'start-prev-quarter))
-  (gnc:option-set-value (gnc:lookup-option options gnc:pagename-general optname-enddate)   (cons 'relative 'today))
-  (gnc:option-set-value (gnc:lookup-option options gnc:pagename-display (N_ "Reconciled Date")) #t)
-  (gnc:option-set-value (gnc:lookup-option options gnc:pagename-display (N_ "Running Balance")) #f)
-  (gnc:option-set-value (gnc:lookup-option options gnc:pagename-display (N_ "Memo")) #f)
-  (gnc:option-make-internal! options gnc:pagename-display "Running Balance")
-  options)
-
-(define reconcile-report-instructions
-  (gnc:make-html-text
-   (_ "The reconcile report is designed to be similar to the formal reconciliation tool.
-Please select the account from Report Options. Please note the dates specified in the options
-will apply to the Reconciliation Date.")
-   (gnc:html-markup-br)
-   (gnc:html-markup-br)))
-
-;; if split is reconciled, retrieve its reconciled date; if not yet reconciled, return #f
-(define (split->reconcile-date split)
-  (and (char=? (xaccSplitGetReconcile split) #\y)
-       (xaccSplitGetDateReconciled split)))
-
-(define (reconcile-report-calculated-cells options)
-  (define (opt-val section name)
-    (gnc:option-value (gnc:lookup-option options section name)))
-  (letrec
-      ((split-amount (lambda (s) (if (gnc:split-voided? s)
-                                     (xaccSplitVoidFormerAmount s)
-                                     (xaccSplitGetAmount s))))
-       (split-currency (lambda (s) (xaccAccountGetCommodity (xaccSplitGetAccount s))))
-       (amount (lambda (s) (gnc:make-gnc-monetary (split-currency s) (split-amount s))))
-       (debit-amount (lambda (s) (and (positive? (split-amount s))
-                                      (amount s))))
-       (credit-amount (lambda (s) (and (not (positive? (split-amount s)))
-                                       (gnc:monetary-neg (amount s))))))
-    ;; similar to default-calculated-cells but disable dual-subtotals.
-    (list (vector (_ "Funds In")
-                  debit-amount #f #t #f
-                  (const ""))
-          (vector (_ "Funds Out")
-                  credit-amount #f #t #f
-                  (const "")))))
-;;
 ;; Default Transaction Report
 ;;
-(define (trep-options-generator)
-
+(define (gnc:trep-options-generator)
   (define options (gnc:new-options))
-  (define BOOK-SPLIT-ACTION (qof-book-use-split-action-for-num-field (gnc-get-current-book)))
+  (define BOOK-SPLIT-ACTION
+    (qof-book-use-split-action-for-num-field (gnc-get-current-book)))
   (define (gnc:register-trep-option new-option)
     (gnc:register-option options new-option))
 
-  ;; (Feb 2018) Note to future hackers - this trep-options-generator
+  ;; (Feb 2018) Note to future hackers - this gnc:trep-options-generator
   ;; defines a long set of options to be assigned as an object in
   ;; the report. This long list (52 at Feb 2018 count) of options
   ;; may be modified in a derived report (see income-gst-statement.scm)
@@ -515,13 +489,10 @@ will apply to the Reconciliation Date.")
     "e" (_ "Convert all transactions into a common currency.") #f
     #f
     (lambda (x)
-      (begin
-        (gnc-option-db-set-option-selectable-by-name options
-                                                     gnc:pagename-general
-                                                     optname-currency x)
-        (gnc-option-db-set-option-selectable-by-name options
-                                                     gnc:pagename-general
-                                                     optname-orig-currency x)))))
+      (gnc-option-db-set-option-selectable-by-name
+       options gnc:pagename-general optname-currency x)
+      (gnc-option-db-set-option-selectable-by-name
+       options gnc:pagename-general optname-orig-currency x))))
 
   (gnc:options-add-currency!
    options gnc:pagename-general optname-currency "f")
@@ -534,7 +505,8 @@ will apply to the Reconciliation Date.")
   (gnc:register-trep-option
    (gnc:make-simple-boolean-option
     gnc:pagename-general optname-table-export
-    "g" (_ "Formats the table suitable for cut & paste exporting with extra cells.") #f))
+    "g" (_ "Formats the table suitable for cut & paste exporting with extra cells.")
+    #f))
 
   (gnc:register-trep-option
    (gnc:make-multichoice-option
@@ -665,11 +637,13 @@ be excluded from periodic reporting.")
 
     (define (apply-selectable-by-name-sorting-options)
       (let* ((prime-sortkey-enabled (not (eq? prime-sortkey 'none)))
-             (prime-sortkey-subtotal-enabled (SUBTOTAL-ENABLED? prime-sortkey BOOK-SPLIT-ACTION))
-             (prime-date-sortingtype-enabled (member prime-sortkey DATE-SORTING-TYPES))
+             (prime-sortkey-subtotal-enabled
+              (SUBTOTAL-ENABLED? prime-sortkey BOOK-SPLIT-ACTION))
+             (prime-date-sortingtype-enabled (memq prime-sortkey DATE-SORTING-TYPES))
              (sec-sortkey-enabled (not (eq? sec-sortkey 'none)))
-             (sec-sortkey-subtotal-enabled (SUBTOTAL-ENABLED? sec-sortkey BOOK-SPLIT-ACTION))
-             (sec-date-sortingtype-enabled (member sec-sortkey DATE-SORTING-TYPES)))
+             (sec-sortkey-subtotal-enabled
+              (SUBTOTAL-ENABLED? sec-sortkey BOOK-SPLIT-ACTION))
+             (sec-date-sortingtype-enabled (memq sec-sortkey DATE-SORTING-TYPES)))
 
         (gnc-option-db-set-option-selectable-by-name
          options pagename-sorting optname-prime-subtotal
@@ -718,8 +692,8 @@ be excluded from periodic reporting.")
 
         (gnc-option-db-set-option-selectable-by-name
          options pagename-sorting optname-show-informal-headers
-         (or (member prime-sortkey (list 'account-name 'account-code))
-             (member sec-sortkey (list 'account-name 'account-code))))
+         (or (memq prime-sortkey (list 'account-name 'account-code))
+             (memq sec-sortkey (list 'account-name 'account-code))))
 
         (gnc-option-db-set-option-selectable-by-name
          options pagename-sorting optname-prime-date-subtotal
@@ -917,11 +891,11 @@ be excluded from periodic reporting.")
       (list (N_ "Running Balance")              "n"  (_ "Display a running balance?") #f)
       (list (N_ "Totals")                       "o"  (_ "Display the totals?") #t)))
 
-    (if BOOK-SPLIT-ACTION
-        (gnc:register-trep-option
-         (gnc:make-simple-boolean-option
-          gnc:pagename-display (N_ "Trans Number")
-          "b2" (_ "Display the trans number?") #f)))
+    (when BOOK-SPLIT-ACTION
+      (gnc:register-trep-option
+       (gnc:make-simple-boolean-option
+        gnc:pagename-display (N_ "Trans Number")
+        "b2" (_ "Display the trans number?") #f)))
 
     ;; Add an option to display the memo, and disable the notes option
     ;; when memos are not included.
@@ -1016,10 +990,12 @@ be excluded from periodic reporting.")
       (if option
           (gnc:option-value option)
           (gnc:error "gnc:lookup-option error: " section "/" name))))
-  (define BOOK-SPLIT-ACTION (qof-book-use-split-action-for-num-field (gnc-get-current-book)))
+  (define BOOK-SPLIT-ACTION
+    (qof-book-use-split-action-for-num-field (gnc-get-current-book)))
 
   (define (build-columns-used)
-    (define detail-is-single? (eq? (opt-val gnc:pagename-display optname-detail-level) 'single))
+    (define detail-is-single?
+      (eq? (opt-val gnc:pagename-display optname-detail-level) 'single))
     (define amount-setting (opt-val gnc:pagename-display (N_ "Amount")))
     (list (cons 'date (opt-val gnc:pagename-display (N_ "Date")))
           (cons 'reconciled-date (opt-val gnc:pagename-display (N_ "Reconciled Date")))
@@ -1028,8 +1004,9 @@ be excluded from periodic reporting.")
                          (opt-val gnc:pagename-display (N_ "Num"))))
           (cons 'description (opt-val gnc:pagename-display (N_ "Description")))
           (cons 'account-name (opt-val gnc:pagename-display (N_ "Account Name")))
-          (cons 'other-account-name (and detail-is-single?
-                                         (opt-val gnc:pagename-display (N_ "Other Account Name"))))
+          (cons 'other-account-name
+                (and detail-is-single?
+                     (opt-val gnc:pagename-display (N_ "Other Account Name"))))
           (cons 'shares (opt-val gnc:pagename-display (N_ "Shares")))
           (cons 'price (opt-val gnc:pagename-display (N_ "Price")))
           (cons 'amount-single (eq? amount-setting 'single))
@@ -1039,40 +1016,49 @@ be excluded from periodic reporting.")
                 (and (opt-val gnc:pagename-general optname-common-currency)
                      (opt-val gnc:pagename-general optname-orig-currency)))
           (cons 'indenting (opt-val pagename-sorting optname-indenting))
-          (cons 'subtotals-only (and (opt-val pagename-sorting optname-show-subtotals-only)
-                                     (or (primary-get-info 'renderer-fn)
-                                         (secondary-get-info 'renderer-fn))))
+          (cons 'subtotals-only
+                (and (opt-val pagename-sorting optname-show-subtotals-only)
+                     (or (primary-get-info 'renderer-fn)
+                         (secondary-get-info 'renderer-fn))))
           (cons 'running-balance (opt-val gnc:pagename-display (N_ "Running Balance")))
-          (cons 'account-full-name (opt-val gnc:pagename-display (N_ "Use Full Account Name")))
+          (cons 'account-full-name
+                (opt-val gnc:pagename-display (N_ "Use Full Account Name")))
           (cons 'memo (opt-val gnc:pagename-display (N_ "Memo")))
           (cons 'account-code (opt-val gnc:pagename-display (N_ "Account Code")))
-          (cons 'other-account-code (and detail-is-single?
-                                         (opt-val gnc:pagename-display (N_ "Other Account Code"))))
-          (cons 'other-account-full-name (and detail-is-single?
-                                              (opt-val gnc:pagename-display (N_ "Use Full Other Account Name"))))
+          (cons 'other-account-code
+                (and detail-is-single?
+                     (opt-val gnc:pagename-display (N_ "Other Account Code"))))
+          (cons 'other-account-full-name
+                (and detail-is-single?
+                     (opt-val gnc:pagename-display (N_ "Use Full Other Account Name"))))
           (cons 'sort-account-code (opt-val pagename-sorting (N_ "Show Account Code")))
-          (cons 'sort-account-full-name (opt-val pagename-sorting (N_ "Show Full Account Name")))
-          (cons 'sort-account-description (opt-val pagename-sorting (N_ "Show Account Description")))
+          (cons 'sort-account-full-name
+                (opt-val pagename-sorting (N_ "Show Full Account Name")))
+          (cons 'sort-account-description
+                (opt-val pagename-sorting (N_ "Show Account Description")))
           (cons 'notes (opt-val gnc:pagename-display (N_ "Notes")))))
 
   (define (primary-get-info info)
     (let ((sortkey (opt-val pagename-sorting optname-prime-sortkey)))
-      (if (member sortkey DATE-SORTING-TYPES)
-          (keylist-get-info date-subtotal-list (opt-val pagename-sorting optname-prime-date-subtotal) info)
+      (if (memq sortkey DATE-SORTING-TYPES)
+          (keylist-get-info
+           date-subtotal-list
+           (opt-val pagename-sorting optname-prime-date-subtotal) info)
           (and (SUBTOTAL-ENABLED? sortkey BOOK-SPLIT-ACTION)
                (opt-val pagename-sorting optname-prime-subtotal)
                (keylist-get-info (sortkey-list BOOK-SPLIT-ACTION) sortkey info)))))
 
   (define (secondary-get-info info)
     (let ((sortkey (opt-val pagename-sorting optname-sec-sortkey)))
-      (if (member sortkey DATE-SORTING-TYPES)
-          (keylist-get-info date-subtotal-list (opt-val pagename-sorting optname-sec-date-subtotal) info)
+      (if (memq sortkey DATE-SORTING-TYPES)
+          (keylist-get-info
+           date-subtotal-list
+           (opt-val pagename-sorting optname-sec-date-subtotal) info)
           (and (SUBTOTAL-ENABLED? sortkey BOOK-SPLIT-ACTION)
                (opt-val pagename-sorting optname-sec-subtotal)
                (keylist-get-info (sortkey-list BOOK-SPLIT-ACTION) sortkey info)))))
 
   (let* ((work-to-do (length splits))
-         (work-done 0)
          (table (gnc:make-html-table))
          (used-columns (build-columns-used))
          (opt-use-links? (opt-val gnc:pagename-display "Enable links"))
@@ -1080,7 +1066,8 @@ be excluded from periodic reporting.")
           (keylist-get-info sign-reverse-list
                             (opt-val gnc:pagename-display (N_ "Sign Reverses"))
                             'acct-types))
-         (is-multiline? (eq? (opt-val gnc:pagename-display optname-detail-level) 'multi-line))
+         (is-multiline? (eq? (opt-val gnc:pagename-display optname-detail-level)
+                             'multi-line))
          (export? (opt-val gnc:pagename-general optname-table-export)))
 
     (define (column-uses? param)
@@ -1093,16 +1080,19 @@ be excluded from periodic reporting.")
                (add-if (column-uses? 'date)
                        (vector (_ "Date")
                                (lambda (split transaction-row?)
-                                 (if transaction-row?
-                                     (gnc:make-html-table-cell/markup
-                                      "date-cell"
-                                      (qof-print-date (xaccTransGetDate (xaccSplitGetParent split))))
-                                     ""))))
+                                 (and transaction-row?
+                                      (gnc:make-html-table-cell/markup
+                                       "date-cell"
+                                       (qof-print-date
+                                        (xaccTransGetDate
+                                         (xaccSplitGetParent split))))))))
 
                (add-if (column-uses? 'reconciled-date)
                        (vector (_ "Reconciled Date")
                                (lambda (split transaction-row?)
-                                 (let ((reconcile-date (split->reconcile-date split)))
+                                 (let ((reconcile-date
+                                        (and (char=? (xaccSplitGetReconcile split) #\y)
+                                             (xaccSplitGetDateReconciled split))))
                                    (and reconcile-date
                                         (gnc:make-html-table-cell/markup
                                          "date-cell"
@@ -1110,32 +1100,34 @@ be excluded from periodic reporting.")
 
                (add-if (column-uses? 'num)
                        (vector (if (and BOOK-SPLIT-ACTION
-                                        (opt-val gnc:pagename-display (N_ "Trans Number")))
+                                        (opt-val gnc:pagename-display
+                                                 (N_ "Trans Number")))
                                    (_ "Num/T-Num")
                                    (_ "Num"))
                                (lambda (split transaction-row?)
                                  (let* ((trans (xaccSplitGetParent split))
                                         (num (gnc-get-num-action trans split))
                                         (t-num (if (and BOOK-SPLIT-ACTION
-                                                        (opt-val gnc:pagename-display (N_ "Trans Number")))
+                                                        (opt-val
+                                                         gnc:pagename-display
+                                                         (N_ "Trans Number")))
                                                    (gnc-get-num-action trans #f)
                                                    ""))
                                         (num-string (if (string-null? t-num)
                                                         num
                                                         (string-append num "/" t-num))))
-                                   (if transaction-row?
-                                       (gnc:make-html-table-cell/markup "text-cell" num-string)
-                                       "")))))
+                                   (and transaction-row?
+                                        (gnc:make-html-table-cell/markup
+                                         "text-cell" num-string))))))
 
                (add-if (column-uses? 'description)
                        (vector (_ "Description")
                                (lambda (split transaction-row?)
                                  (define trans (xaccSplitGetParent split))
-                                 (if transaction-row?
-                                     (gnc:make-html-table-cell/markup
-                                      "text-cell"
-                                      (xaccTransGetDescription trans))
-                                     ""))))
+                                 (and transaction-row?
+                                      (gnc:make-html-table-cell/markup
+                                       "text-cell"
+                                       (xaccTransGetDescription trans))))))
 
                (add-if (column-uses? 'memo)
                        (vector (if (column-uses? 'notes)
@@ -1151,11 +1143,11 @@ be excluded from periodic reporting.")
                (add-if (or (column-uses? 'account-name) (column-uses? 'account-code))
                        (vector (_ "Account")
                                (lambda (split transaction-row?)
-                                 (define account (xaccSplitGetAccount split))
-                                 (account-namestring account
-                                                     (column-uses? 'account-code)
-                                                     (column-uses? 'account-name)
-                                                     (column-uses? 'account-full-name)))))
+                                 (account-namestring
+                                  (xaccSplitGetAccount split)
+                                  (column-uses? 'account-code)
+                                  (column-uses? 'account-name)
+                                  (column-uses? 'account-full-name)))))
 
                (add-if (or (column-uses? 'other-account-name)
                            (column-uses? 'other-account-code))
@@ -1180,20 +1172,24 @@ be excluded from periodic reporting.")
                (add-if (column-uses? 'price)
                        (vector (_ "Price")
                                (lambda (split transaction-row?)
-                                 ;; share price is retrieved as an exact rational; convert for
-                                 ;; presentation to decimal, rounded to the currency SCU, optionally
-                                 ;; increasing precision by 2 significant digits.
-                                 (let* ((currency (xaccTransGetCurrency (xaccSplitGetParent split)))
+                                 ;; share price is retrieved as an
+                                 ;; exact rational; convert for
+                                 ;; presentation to decimal, rounded
+                                 ;; to the currency SCU, optionally
+                                 ;; increasing precision by 2
+                                 ;; significant digits.
+                                 (let* ((currency (xaccTransGetCurrency
+                                                   (xaccSplitGetParent split)))
                                         (scu (gnc-commodity-get-fraction currency))
                                         (price (xaccSplitGetSharePrice split))
-                                        (price-decimal (gnc-numeric-convert price
-                                                                            (if (< scu 10000)
-                                                                                (* scu 100)
-                                                                                scu)
-                                                                            GNC-HOW-RND-ROUND)))
+                                        (price-decimal
+                                         (gnc-numeric-convert
+                                          price (min 10000 (* 100 scu))
+                                          GNC-HOW-RND-ROUND)))
                                    (gnc:make-html-table-cell/markup
                                     "number-cell"
-                                    (gnc:make-gnc-monetary currency price-decimal)))))))))
+                                    (gnc:make-gnc-monetary
+                                     currency price-decimal)))))))))
 
         (if (or (column-uses? 'subtotals-only)
                 (and (null? left-cols-list)
@@ -1214,7 +1210,7 @@ be excluded from periodic reporting.")
           ((split-amount (lambda (s) (if (gnc:split-voided? s)
                                          (xaccSplitVoidFormerAmount s)
                                          (xaccSplitGetAmount s))))
-           (split-currency (lambda (s) (xaccAccountGetCommodity (xaccSplitGetAccount s))))
+           (split-currency (compose xaccAccountGetCommodity xaccSplitGetAccount))
            (row-currency (lambda (s) (if (column-uses? 'common-currency)
                                          (opt-val gnc:pagename-general optname-currency)
                                          (split-currency s))))
@@ -1226,36 +1222,49 @@ be excluded from periodic reporting.")
                                 (if (column-uses? 'common-currency)
                                     (format #f " (~a)"
                                             (gnc-commodity-get-mnemonic
-                                             (opt-val gnc:pagename-general optname-currency)))
+                                             (opt-val gnc:pagename-general
+                                                      optname-currency)))
                                     ""))))
            ;; For conversion to row-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
-           (converted-amount (lambda (s) (gnc:exchange-by-pricedb-nearest
-                                          (gnc:make-gnc-monetary (split-currency s) (split-amount s))
-                                          (row-currency s)
-                                          (time64CanonicalDayTime
-                                           (xaccTransGetDate (xaccSplitGetParent s))))))
+           (converted-amount (lambda (s)
+                               (gnc:exchange-by-pricedb-nearest
+                                (gnc:make-gnc-monetary (split-currency s)
+                                                       (split-amount s))
+                                (row-currency s)
+                                (time64CanonicalDayTime
+                                 (xaccTransGetDate (xaccSplitGetParent s))))))
            (converted-debit-amount (lambda (s) (and (positive? (split-amount s))
                                                     (converted-amount s))))
-           (converted-credit-amount (lambda (s) (and (not (positive? (split-amount s)))
-                                                     (gnc:monetary-neg (converted-amount s)))))
-           (original-amount (lambda (s) (gnc:make-gnc-monetary (split-currency s) (split-amount s))))
-           (original-debit-amount (lambda (s) (and (positive? (split-amount s))
-                                                   (original-amount s))))
-           (original-credit-amount (lambda (s) (and (not (positive? (split-amount s)))
-                                                    (gnc:monetary-neg (original-amount s)))))
-           (running-balance (lambda (s) (gnc:make-gnc-monetary (split-currency s) (xaccSplitGetBalance s)))))
+           (converted-credit-amount (lambda (s)
+                                      (and (not (positive? (split-amount s)))
+                                           (gnc:monetary-neg (converted-amount s)))))
+           (original-amount (lambda (s)
+                              (gnc:make-gnc-monetary
+                               (split-currency s) (split-amount s))))
+           (original-debit-amount (lambda (s)
+                                    (and (positive? (split-amount s))
+                                         (original-amount s))))
+           (original-credit-amount (lambda (s)
+                                     (and (not (positive? (split-amount s)))
+                                          (gnc:monetary-neg (original-amount s)))))
+           (running-balance (lambda (s)
+                              (gnc:make-gnc-monetary
+                               (split-currency s) (xaccSplitGetBalance s)))))
         (append
          ;; each column will be a vector
          ;; (vector heading
-         ;;         calculator-function                          ;; (calculator-function split) to obtain amount
-         ;;         reverse-column?                              ;; #t to allow reverse signs
-         ;;         subtotal?                                    ;; #t to allow subtotals (ie must be #f for running balance)
-         ;;         start-dual-column?                           ;; #t for the debit side of a dual column (i.e. debit/credit)
-         ;;                                                      ;; which means the next column must be the credit side
-         ;;         friendly-heading-fn                          ;; (friendly-heading-fn account) to retrieve friendly name for account debit/credit
+         ;;         calculator-function (calculator-function split) to obtain amount
+         ;;         reverse-column?     #t to allow reverse signs
+         ;;         subtotal?           #t to allow subtotals (ie must be #f for
+         ;;                             running balance)
+         ;;         start-dual-column?  #t for the debit side of a dual column
+         ;;                             (i.e. debit/credit) which means the next
+         ;;                             column must be the credit side
+         ;;         friendly-heading-fn (friendly-heading-fn account) to retrieve
+         ;;                             friendly name for account debit/credit
 
          (if (column-uses? 'amount-single)
              (list (vector (header-commodity (_ "Amount"))
@@ -1346,7 +1355,7 @@ be excluded from periodic reporting.")
             (gnc:html-make-empty-cells left-indent)
             (if (and (opt-val pagename-sorting optname-show-informal-headers)
                      (column-uses? 'amount-double)
-                     (member sortkey SORTKEY-INFORMAL-HEADERS))
+                     (memq sortkey SORTKEY-INFORMAL-HEADERS))
                 (append
                  (if export?
                      (cons
@@ -1369,19 +1378,25 @@ be excluded from periodic reporting.")
                   1 (+ right-indent width-left-columns width-right-columns)
                   data))))))))
 
-    (define (add-subtotal-row subtotal-string subtotal-collectors subtotal-style level row col)
+    (define (add-subtotal-row subtotal-string subtotal-collectors
+                              subtotal-style level row col)
       (let* ((left-indent (case level
                             ((total) 0)
                             ((primary) primary-indent)
                             ((secondary) (+ primary-indent secondary-indent))))
              (right-indent (- indent-level left-indent))
              (merge-list (map (lambda (cell) (vector-ref cell 4)) calculated-cells))
-             (columns (map (lambda (coll) (coll 'format gnc:make-gnc-monetary #f)) subtotal-collectors))
-             (list-of-commodities (delete-duplicates (map gnc:gnc-monetary-commodity (concatenate columns))
-                                                     gnc-commodity-equal)))
+             (columns (map (lambda (coll)
+                             (coll 'format gnc:make-gnc-monetary #f))
+                           subtotal-collectors))
+             (list-of-commodities
+              (delete-duplicates
+               (map gnc:gnc-monetary-commodity (concatenate columns))
+               gnc-commodity-equal)))
 
         (define (retrieve-commodity list-of-monetary commodity)
-          (find (lambda (mon) (gnc-commodity-equal commodity (gnc:gnc-monetary-commodity mon)))
+          (find (lambda (mon)
+                  (gnc-commodity-equal commodity (gnc:gnc-monetary-commodity mon)))
                 list-of-monetary))
 
         (define (first-column string)
@@ -1390,7 +1405,8 @@ be excluded from periodic reporting.")
                (gnc:make-html-table-cell/markup "total-label-cell" string)
                (gnc:html-make-empty-cells (+ right-indent width-left-columns -1)))
               (list
-               (gnc:make-html-table-cell/size/markup 1 (+ right-indent width-left-columns) "total-label-cell" string))))
+               (gnc:make-html-table-cell/size/markup
+                1 (+ right-indent width-left-columns) "total-label-cell" string))))
 
         (define (data-columns commodity)
           (let loop ((merging? #f)
@@ -1399,7 +1415,8 @@ be excluded from periodic reporting.")
                      (merge-list merge-list)
                      (result '()))
             (if (null? columns)
-                ;; we've processed all columns. return the (reversed) list of html-table-cells.
+                ;; we've processed all columns. return the (reversed)
+                ;; list of html-table-cells.
                 (reverse result)
                 (let* ((mon (retrieve-commodity (car columns) commodity))
                        (this-column (and mon (gnc:gnc-monetary-amount mon))))
@@ -1427,9 +1444,7 @@ be excluded from periodic reporting.")
                             #f
                             (cdr columns)
                             (cdr merge-list)
-                            (cons* (or credit-col "")
-                                   (or debit-col "")
-                                   result))))
+                            (cons* credit-col debit-col result))))
 
                    ;; Not merging nor completed merge. Just add amount to result.
                    (else
@@ -1437,14 +1452,16 @@ be excluded from periodic reporting.")
                           #f
                           (cdr columns)
                           (cdr merge-list)
-                          (cons (gnc:make-html-table-cell/markup "total-number-cell" mon)
+                          (cons (gnc:make-html-table-cell/markup
+                                 "total-number-cell" mon)
                                 result))))))))
 
         ;; take the first column of each commodity, add onto the subtotal grid
-        (set! grid (grid-add grid row col
-                             (map (lambda (commodity)
-                                    (retrieve-commodity (car columns) commodity))
-                                  list-of-commodities)))
+        (set! grid
+          (grid-add grid row col
+                    (map (lambda (commodity)
+                           (retrieve-commodity (car columns) commodity))
+                         list-of-commodities)))
 
         ;; each commodity subtotal gets a separate line in the html-table
         ;; each line comprises: indenting, first-column, data-columns
@@ -1462,28 +1479,25 @@ be excluded from periodic reporting.")
     (define (total-string str) (string-append (_ "Total For ") str))
 
     ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
     ;; renderers
-
     ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
     ;; 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?)
+    (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))
-               ""))))
+          (with-output-to-string
+            (lambda ()
+              (when show-account-code?
+                (display (xaccAccountGetCode account))
+                (display " "))
+              (when show-account-name?
+                (display
+                 (if show-account-full-name?
+                     (gnc-account-get-full-name account)
+                     (xaccAccountGetName account))))))))
 
     ;; retrieve date renderer from the date-subtotal-list
     (define (render-date date-subtotal-key split)
@@ -1491,17 +1505,19 @@ be excluded from periodic reporting.")
 
     ;; generate account name, optionally with anchor to account register
     (define (render-account sortkey split anchor?)
-      (let* ((account ((keylist-get-info (sortkey-list BOOK-SPLIT-ACTION) sortkey 'renderer-fn) split))
+      (let* ((account ((keylist-get-info (sortkey-list BOOK-SPLIT-ACTION)
+                                         sortkey 'renderer-fn) split))
              (name (account-namestring account
                                        (column-uses? 'sort-account-code)
                                        #t
                                        (column-uses? 'sort-account-full-name)))
              (description (if (and (column-uses? 'sort-account-description)
-                                   (not (string-null? (xaccAccountGetDescription account))))
+                                   (not (string-null?
+                                         (xaccAccountGetDescription account))))
                               (string-append ": " (xaccAccountGetDescription account))
                               "")))
         (if (and anchor? opt-use-links?
-                 (not (null? account))) ;html anchor for 2-split transactions only
+                 (pair? account)) ;html anchor for 2-split transactions only
             (gnc:make-html-text
              (gnc:html-markup-anchor (gnc:account-anchor-text account) name)
              description)
@@ -1521,9 +1537,9 @@ be excluded from periodic reporting.")
                                           ((primary) optname-prime-date-subtotal)
                                           ((secondary) optname-sec-date-subtotal)))))
         (cond
-         ((member sortkey DATE-SORTING-TYPES)
+         ((memq sortkey DATE-SORTING-TYPES)
           (render-date date-subtotal-key split))
-         ((member sortkey ACCOUNT-SORTING-TYPES)
+         ((memq sortkey ACCOUNT-SORTING-TYPES)
           (render-account sortkey split anchor?))
          (else
           (render-generic sortkey split)))))
@@ -1532,19 +1548,17 @@ be excluded from periodic reporting.")
       (_ "Grand Total"))
 
     ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-    ;;
     ;; add-split-row
-    ;;
     ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
     (define (add-split-row split cell-calculators row-style transaction-row?)
       (let* ((account (xaccSplitGetAccount split))
              (reversible-account? (if account-types-to-reverse
-                                      (member (xaccAccountGetType account)
-                                              account-types-to-reverse)
+                                      (memv (xaccAccountGetType account)
+                                            account-types-to-reverse)
                                       (gnc-reverse-balance account)))
              (cells (map (lambda (cell)
-                           (let* ((split->monetary (vector-ref cell 1)))
+                           (let ((split->monetary (vector-ref cell 1)))
                              (vector (split->monetary split)
                                      (vector-ref cell 2) ;reverse?
                                      (vector-ref cell 3) ;subtotal?
@@ -1597,145 +1611,142 @@ be excluded from periodic reporting.")
     (define total-collectors
       (map (lambda (x) (gnc:make-commodity-collector)) calculated-cells))
 
-    (define (do-rows-with-subtotals splits odd-row?)
-      (define primary-subtotal-comparator (primary-get-info 'split-sortvalue))
-      (define secondary-subtotal-comparator (secondary-get-info 'split-sortvalue))
+    (define grid (make-grid))
+    (define primary-subtotal-comparator (primary-get-info 'split-sortvalue))
+    (define secondary-subtotal-comparator (secondary-get-info 'split-sortvalue))
 
-      (gnc:report-percent-done (* 100 (/ work-done work-to-do)))
+    (gnc:html-table-set-col-headers!
+     table (concatenate (list
+                         (gnc:html-make-empty-cells indent-level)
+                         headings-left-columns
+                         headings-right-columns)))
 
-      (set! work-done (+ 1 work-done))
+    (when (primary-get-info 'renderer-fn)
+      (add-subheading (render-summary (car splits) 'primary #t)
+                      def:primary-subtotal-style (car splits) 'primary))
+
+    (when (secondary-get-info 'renderer-fn)
+      (add-subheading (render-summary (car splits) 'secondary #t)
+                      def:secondary-subtotal-style (car splits) 'secondary))
+
+    (let loop ((splits splits)
+               (odd-row? #t)
+               (work-done 0))
+
+      (gnc:report-percent-done (* 100 (/ work-done work-to-do)))
 
       (if (null? splits)
 
-          (if (opt-val gnc:pagename-display "Totals")
-              (begin
-                (gnc:html-table-append-row/markup!
-                 table def:grand-total-style
-                 (list
-                  (gnc:make-html-table-cell/size
-                   1 (+ indent-level width-left-columns width-right-columns)
-                   (gnc:make-html-text (gnc:html-markup-hr)))))
+          (when (opt-val gnc:pagename-display "Totals")
+            (gnc:html-table-append-row/markup!
+             table def:grand-total-style
+             (list
+              (gnc:make-html-table-cell/size
+               1 (+ indent-level width-left-columns width-right-columns)
+               (gnc:make-html-text (gnc:html-markup-hr)))))
 
-                (add-subtotal-row (render-grand-total) total-collectors def:grand-total-style 'total 'row-total 'col-total)))
+            (add-subtotal-row
+             (render-grand-total) total-collectors
+             def:grand-total-style 'total 'row-total 'col-total))
 
           (let* ((current (car splits))
                  (rest (cdr splits))
-                 (next (if (null? rest) #f (car rest)))
+                 (next (and (pair? rest) (car rest)))
                  (split-values (add-split-row
                                 current
                                 calculated-cells
-                                (if is-multiline? def:normal-row-style
-                                    (if odd-row?
-                                        def:normal-row-style
-                                        def:alternate-row-style))
+                                (if (or odd-row? is-multiline?)
+                                    def:normal-row-style
+                                    def:alternate-row-style)
                                 #t)))
 
-            (if is-multiline?
-                (for-each
-                 (lambda (othersplits)
-                   (add-split-row othersplits calculated-cells def:alternate-row-style #f))
-                 (delete current (xaccTransGetSplitList (xaccSplitGetParent current)))))
-
-            (for-each
-             (lambda (collector value)
-               (if value
-                   (collector 'add (gnc:gnc-monetary-commodity value) (gnc:gnc-monetary-amount value))))
-             primary-subtotal-collectors split-values)
+            (when is-multiline?
+              (for-each
+               (lambda (othersplit)
+                 (add-split-row othersplit calculated-cells
+                                def:alternate-row-style #f))
+               (delete current (xaccTransGetSplitList
+                                (xaccSplitGetParent current)))))
 
             (for-each
-             (lambda (collector value)
-               (if value
-                   (collector 'add (gnc:gnc-monetary-commodity value) (gnc:gnc-monetary-amount value))))
-             secondary-subtotal-collectors split-values)
-
-            (for-each
-             (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-comparator
-                     (or (not next)
-                         (and next
-                              (not (equal? (primary-subtotal-comparator current)
-                                           (primary-subtotal-comparator next))))))
-
-                (begin
-                  (if secondary-subtotal-comparator
-                      (begin
-                        (add-subtotal-row (total-string
-                                           (render-summary current 'secondary #f))
-                                          secondary-subtotal-collectors
-                                          def:secondary-subtotal-style
-                                          'secondary
-                                          (cons (primary-subtotal-comparator current)
-                                                (render-summary current 'primary #f))
-                                          (cons (secondary-subtotal-comparator current)
-                                                (render-summary current 'secondary #f)))
-                        (for-each (lambda (coll) (coll 'reset #f #f))
-                                  secondary-subtotal-collectors)))
-                  (add-subtotal-row (total-string
-                                     (render-summary current 'primary #f))
-                                    primary-subtotal-collectors
-                                    def:primary-subtotal-style
-                                    'primary
-                                    (cons (primary-subtotal-comparator current)
-                                          (render-summary current 'primary #f))
-                                    'col-total)
-                  (for-each (lambda (coll) (coll 'reset #f #f))
-                            primary-subtotal-collectors)
-                  (if next
-                      (begin
-                        (add-subheading (render-summary next 'primary #t)
-                                        def:primary-subtotal-style next 'primary)
-                        (if secondary-subtotal-comparator
-                            (add-subheading (render-summary next 'secondary #t)
-                                            def:secondary-subtotal-style next 'secondary)))))
-
-                (if (and secondary-subtotal-comparator
+             (lambda (prime-collector sec-collector tot-collector value)
+               (when value
+                 (let ((comm (gnc:gnc-monetary-commodity value))
+                       (val (gnc:gnc-monetary-amount value)))
+                 (prime-collector 'add comm val)
+                 (sec-collector 'add comm val)
+                 (tot-collector 'add comm val))))
+             primary-subtotal-collectors
+             secondary-subtotal-collectors
+             total-collectors
+             split-values)
+
+            (cond
+             ((and primary-subtotal-comparator
+                   (or (not next)
+                       (not (equal? (primary-subtotal-comparator current)
+                                    (primary-subtotal-comparator next)))))
+              (when secondary-subtotal-comparator
+                (add-subtotal-row (total-string
+                                   (render-summary current 'secondary #f))
+                                  secondary-subtotal-collectors
+                                  def:secondary-subtotal-style
+                                  'secondary
+                                  (cons (primary-subtotal-comparator current)
+                                        (render-summary current 'primary #f))
+                                  (cons (secondary-subtotal-comparator current)
+                                        (render-summary current 'secondary #f)))
+                (for-each
+                 (lambda (coll)
+                   (coll 'reset #f #f))
+                 secondary-subtotal-collectors))
+              (add-subtotal-row (total-string
+                                 (render-summary current 'primary #f))
+                                primary-subtotal-collectors
+                                def:primary-subtotal-style
+                                'primary
+                                (cons (primary-subtotal-comparator current)
+                                      (render-summary current 'primary #f))
+                                'col-total)
+              (for-each
+               (lambda (coll)
+                 (coll 'reset #f #f))
+               primary-subtotal-collectors)
+              (when next
+                (add-subheading (render-summary next 'primary #t)
+                                def:primary-subtotal-style next 'primary)
+                (when secondary-subtotal-comparator
+                  (add-subheading (render-summary next 'secondary #t)
+                                  def:secondary-subtotal-style next
+                                  'secondary))))
+
+             (else
+              (when (and secondary-subtotal-comparator
                          (or (not next)
-                             (and next
-                                  (not (equal? (secondary-subtotal-comparator current)
-                                               (secondary-subtotal-comparator next))))))
-                    (begin (add-subtotal-row (total-string
-                                              (render-summary current 'secondary #f))
-                                             secondary-subtotal-collectors
-                                             def:secondary-subtotal-style
-                                             'secondary
-                                             (if primary-subtotal-comparator
-                                                 (cons (primary-subtotal-comparator current)
-                                                       (render-summary current 'primary #f))
-                                                 (cons #f ""))
-                                             (cons (secondary-subtotal-comparator current)
-                                                   (render-summary current 'secondary #f)))
-                           (for-each (lambda (coll) (coll 'reset #f #f))
-                                     secondary-subtotal-collectors)
-                           (if next
-                               (add-subheading (render-summary next 'secondary #t)
-                                               def:secondary-subtotal-style next 'secondary)))))
-
-            (do-rows-with-subtotals rest (not odd-row?)))))
-
-    (define grid (make-grid))
-
-    (gnc:html-table-set-col-headers! table (concatenate (list
-                                                         (gnc:html-make-empty-cells indent-level)
-                                                         headings-left-columns
-                                                         headings-right-columns)))
-
-    (if (primary-get-info 'renderer-fn)
-        (add-subheading (render-summary (car splits) 'primary #t)
-                        def:primary-subtotal-style (car splits) 'primary))
-
-    (if (secondary-get-info 'renderer-fn)
-        (add-subheading (render-summary (car splits) 'secondary #t)
-                        def:secondary-subtotal-style (car splits) 'secondary))
-
-    (do-rows-with-subtotals splits #t)
+                             (not (equal? (secondary-subtotal-comparator current)
+                                          (secondary-subtotal-comparator next)))))
+                (add-subtotal-row (total-string
+                                   (render-summary current 'secondary #f))
+                                  secondary-subtotal-collectors
+                                  def:secondary-subtotal-style
+                                  'secondary
+                                  (if primary-subtotal-comparator
+                                      (cons (primary-subtotal-comparator current)
+                                            (render-summary current 'primary #f))
+                                      (cons #f ""))
+                                  (cons (secondary-subtotal-comparator current)
+                                        (render-summary current 'secondary #f)))
+                (for-each
+                 (lambda (coll)
+                   (coll 'reset #f #f))
+                 secondary-subtotal-collectors)
+                (when next
+                  (add-subheading (render-summary next 'secondary #t)
+                                  def:secondary-subtotal-style next 'secondary)))))
 
-    (values table
-            grid)))
+            (loop rest (not odd-row?) (1+ work-done)))))
 
+    (values table grid)))
 
 ;; grid data structure
 (define (make-grid)
@@ -1743,11 +1754,14 @@ be excluded from periodic reporting.")
 (define (cell-match? cell row col)
   (and (or (not row) (equal? row (vector-ref cell 0)))
        (or (not col) (equal? col (vector-ref cell 1)))))
-(define (grid-get grid row col)    ; grid filter - get all row/col - if #f then retrieve whole row/col
+(define (grid-get grid row col)
+  ;; grid filter - get all row/col - if #f then retrieve whole row/col
   (filter
-   (lambda (cell) (cell-match? cell row col))
+   (lambda (cell)
+     (cell-match? cell row col))
    grid))
-(define (grid-del grid row col)    ; grid filter - del all row/col - if #f then delete whole row/col - CAREFUL!
+(define (grid-del grid row col)
+  ;; grid filter - del all row/col - if #f then delete whole row/col
   (filter
    (lambda (cell)
      (not (cell-match? cell row col)))
@@ -1756,10 +1770,13 @@ be excluded from periodic reporting.")
   (delete-duplicates (map (lambda (cell) (vector-ref cell 0)) grid)))
 (define (grid-cols grid)
   (delete-duplicates (map (lambda (cell) (vector-ref cell 1)) grid)))
-(define (grid-add grid row col data)            ;-> misonomer - we don't 'add' to existing data,
-  (set! grid (grid-del grid row col))           ;we simply delete old data stored at row/col and 
-  (set! grid (cons (vector row col data) grid)) ;add again. this is fine because the grid should
-  grid)                                         ;never have duplicate data in the trep.
+(define (grid-add grid row col data)
+  ;;misonomer - we don't 'add' to existing data, we delete old data
+  ;;stored at row/col and add again. this is fine because the grid
+  ;;should never have duplicate data in the trep.
+  (set! grid (grid-del grid row col))
+  (set! grid (cons (vector row col data) grid))
+  grid)
 (define (grid->html-table grid list-of-rows list-of-cols)
   (define row-average-enabled? (> (length list-of-cols) 1))
   (define (monetary-div monetary divisor)
@@ -1768,7 +1785,8 @@ be excluded from periodic reporting.")
                 (currency (gnc:gnc-monetary-commodity monetary))
                 (scu (gnc-commodity-get-fraction currency)))
            (gnc:make-gnc-monetary
-            currency (gnc-numeric-convert (/ amount divisor) scu GNC-HOW-RND-ROUND)))))
+            currency (gnc-numeric-convert
+                      (/ amount divisor) scu GNC-HOW-RND-ROUND)))))
   (define (row->num-of-commodities row)
     ;; for a row, find the maximum number of commodities being stored
     (apply max
@@ -1780,8 +1798,11 @@ be excluded from periodic reporting.")
   (define (make-table-cell row col commodity-idx divisor)
     (let ((cell (grid-get grid row col)))
       (if (null? cell) ""
-          (gnc:make-html-table-cell/markup "number-cell"
-                                           (monetary-div (list-ref-safe (vector-ref (car cell) 2) commodity-idx) divisor)))))
+          (gnc:make-html-table-cell/markup
+           "number-cell"
+           (monetary-div
+            (list-ref-safe (vector-ref (car cell) 2) commodity-idx)
+            divisor)))))
   (define (make-row row commodity-idx)
     (append
      (list (cond
@@ -1792,35 +1813,40 @@ be excluded from periodic reporting.")
           list-of-cols)
      (list (make-table-cell row 'col-total commodity-idx 1))
      (if row-average-enabled?
-         (list (make-table-cell row 'col-total commodity-idx (length list-of-cols)))
+         (list (make-table-cell
+                row 'col-total commodity-idx (length list-of-cols)))
          '())))
   (let ((table (gnc:make-html-table)))
     (gnc:html-table-set-caption! table optname-grid)
-    (gnc:html-table-set-col-headers! table (append (list "") (map cdr list-of-cols) (list (_ "Total"))
-                                                   (if row-average-enabled? (list (_ "Average")) '())))
-    (gnc:html-table-set-style! table "th"
-                               'attribute (list "class" "column-heading-right"))
+    (gnc:html-table-set-col-headers!
+     table (append (list "")
+                   (map cdr list-of-cols)
+                   (list (_ "Total"))
+                   (if row-average-enabled? (list (_ "Average")) '())))
+    (gnc:html-table-set-style!
+     table "th"
+     'attribute (list "class" "column-heading-right"))
     (for-each
      (lambda (row)
-       (for-each (lambda (commodity-idx)
-                   (gnc:html-table-append-row! table (make-row row commodity-idx)))
-                 (iota (row->num-of-commodities row))))
+       (for-each
+        (lambda (commodity-idx)
+          (gnc:html-table-append-row!
+           table (make-row row commodity-idx)))
+        (iota (row->num-of-commodities row))))
      (if (memq 'row-total (grid-rows grid))
          (append list-of-rows '(row-total))
          list-of-rows))
     table))
 
-;; ;;;;;;;;;;;;;;;;;;;;
-;; Here comes the renderer function for this report.
-
-
-(define* (trep-renderer report-obj #:key custom-calculated-cells empty-report-message
-                        custom-split-filter split->date split->date-include-false?)
-  ;; the trep-renderer is a define* function which, at minimum, takes the report object
+(define* (gnc:trep-renderer
+          report-obj #:key custom-calculated-cells empty-report-message
+          custom-split-filter split->date split->date-include-false?)
+  ;; the trep-renderer is a define* function which, at minimum, takes
+  ;; the report object
   ;;
   ;; the optional arguments are:
   ;; #:custom-calculated-cells - a list of vectors to define customized data columns
-  ;; #:empty-report-message - a str or html-object which is displayed at the initial report opening
+  ;; #:empty-report-message - a str or html-object displayed at the initial run
   ;; #:custom-split-filter - a split->bool function to add to the split filter
   ;; #:split->date - a split->time64 which overrides the default posted date filter
   ;;     (see reconcile report)
@@ -1830,32 +1856,30 @@ be excluded from periodic reporting.")
   ;;     transaction->invoice->payment date.
 
   (define options (gnc:report-options report-obj))
-  (define (opt-val section name) (gnc:option-value (gnc:lookup-option options section name)))
-  (define BOOK-SPLIT-ACTION (qof-book-use-split-action-for-num-field (gnc-get-current-book)))
-
+  (define (opt-val section name)
+    (gnc:option-value (gnc:lookup-option options section name)))
+  (define BOOK-SPLIT-ACTION
+    (qof-book-use-split-action-for-num-field (gnc-get-current-book)))
   (define (is-filter-member split account-list)
     (let* ((txn (xaccSplitGetParent split))
            (splitcount (xaccTransCountSplits txn))
-           (other-account (xaccSplitGetAccount (xaccSplitGetOtherSplit split)))
-           (splits-equal? (lambda (s1 s2) (xaccSplitEqual s1 s2 #t #f #f)))
-           (other-splits (delete split (xaccTransGetSplitList txn) splits-equal?))
-           (other-accounts (map xaccSplitGetAccount other-splits))
            (is-in-account-list? (lambda (acc) (member acc account-list))))
       (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) (is-in-account-list? other-account))
-        ;; A multi-split transaction - run over all splits
-        ((> splitcount 2) (or-map is-in-account-list? other-accounts))
-        ;; Single transaction splits
-        (else #f))))
+       ((= splitcount 2)
+        (is-in-account-list?
+         (xaccSplitGetAccount (xaccSplitGetOtherSplit split))))
+       ((> splitcount 2)
+        (or-map is-in-account-list?
+                (map xaccSplitGetAccount
+                     (delete split (xaccTransGetSplitList txn)))))
+       (else #f))))
 
-  (gnc:report-starting reportname)
+  (gnc:report-starting (opt-val gnc:pagename-general gnc:optname-reportname))
 
   (let* ((document (gnc:make-html-document))
          (account-matcher (opt-val pagename-filter optname-account-matcher))
-         (account-matcher-regexp (and (opt-val pagename-filter optname-account-matcher-regex)
+         (account-matcher-regexp (and (opt-val pagename-filter
+                                               optname-account-matcher-regex)
                                       (catch 'regular-expression-syntax
                                         (lambda () (make-regexp account-matcher))
                                         (const 'invalid-regex))))
@@ -1863,8 +1887,10 @@ be excluded from periodic reporting.")
          (c_account_1 (filter
                        (lambda (acc)
                          (if (regexp? account-matcher-regexp)
-                             (regexp-exec account-matcher-regexp (gnc-account-get-full-name acc))
-                             (string-contains (gnc-account-get-full-name acc) account-matcher)))
+                             (regexp-exec account-matcher-regexp
+                                          (gnc-account-get-full-name acc))
+                             (string-contains (gnc-account-get-full-name acc)
+                                              account-matcher)))
                        c_account_0))
          (c_account_2 (opt-val gnc:pagename-accounts optname-filterby))
          (filter-mode (opt-val gnc:pagename-accounts optname-filtertype))
@@ -1875,13 +1901,15 @@ be excluded from periodic reporting.")
                    (gnc:date-option-absolute-time
                     (opt-val gnc:pagename-general optname-enddate))))
          (transaction-matcher (opt-val pagename-filter optname-transaction-matcher))
-         (transaction-matcher-regexp (and (opt-val pagename-filter optname-transaction-matcher-regex)
-                                          (catch 'regular-expression-syntax
-                                            (lambda () (make-regexp transaction-matcher))
-                                            (const 'invalid-regex))))
-         (reconcile-status-filter (keylist-get-info reconcile-status-list
-                                                    (opt-val pagename-filter optname-reconcile-status)
-                                                    'filter-types))
+         (transaction-matcher-regexp
+          (and (opt-val pagename-filter optname-transaction-matcher-regex)
+               (catch 'regular-expression-syntax
+                 (lambda () (make-regexp transaction-matcher))
+                 (const 'invalid-regex))))
+         (reconcile-status-filter
+          (keylist-get-info reconcile-status-list
+                            (opt-val pagename-filter optname-reconcile-status)
+                            'filter-types))
          (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 optname-prime-sortorder))
@@ -1890,22 +1918,29 @@ be excluded from periodic reporting.")
          (secondary-order (opt-val pagename-sorting optname-sec-sortorder))
          (secondary-date-subtotal (opt-val pagename-sorting optname-sec-date-subtotal))
          (void-status (opt-val pagename-filter optname-void-transactions))
-         (closing-match (keylist-get-info show-closing-list
-                                          (opt-val pagename-filter optname-closing-transactions)
-                                          'closing-match))
+         (closing-match (keylist-get-info
+                         show-closing-list
+                         (opt-val pagename-filter optname-closing-transactions)
+                         'closing-match))
          (splits '())
-         (custom-sort? (or (and (member primary-key DATE-SORTING-TYPES)   ; this will remain
-                                (not (eq? primary-date-subtotal 'none)))  ; until qof-query
-                           (and (member secondary-key DATE-SORTING-TYPES) ; is upgraded
+         (custom-sort? (or (and (memq primary-key DATE-SORTING-TYPES)
+                                (not (eq? primary-date-subtotal 'none)))
+                           (and (memq secondary-key DATE-SORTING-TYPES)
                                 (not (eq? secondary-date-subtotal 'none)))
                            (or (CUSTOM-SORTING? primary-key BOOK-SPLIT-ACTION)
                                (CUSTOM-SORTING? secondary-key BOOK-SPLIT-ACTION))))
          (subtotal-table? (and (opt-val gnc:pagename-display optname-grid)
                                (if (memq primary-key DATE-SORTING-TYPES)
-                                   (keylist-get-info date-subtotal-list primary-date-subtotal 'renderer-fn)
+                                   (keylist-get-info date-subtotal-list
+                                                     primary-date-subtotal 'renderer-fn)
                                    (opt-val pagename-sorting optname-prime-subtotal))
-                               (eq? (opt-val gnc:pagename-display (N_ "Amount")) 'single)))
+                               (eq? (opt-val gnc:pagename-display (N_ "Amount"))
+                                    'single)))
          (infobox-display (opt-val gnc:pagename-general optname-infobox-display))
+         (match? (lambda (str)
+                   (if transaction-matcher-regexp
+                       (regexp-exec transaction-matcher-regexp str)
+                       (string-contains str transaction-matcher))))
          (query (qof-query-create-for-splits)))
 
     (define (generic-less? split-X split-Y sortkey date-subtotal-key ascend?)
@@ -1914,12 +1949,16 @@ be excluded from periodic reporting.")
       ;; ascend? specifies whether ascending or descending
       (let* ((comparator-function
               (if (memq sortkey DATE-SORTING-TYPES)
-                  (let ((date (keylist-get-info (sortkey-list BOOK-SPLIT-ACTION) sortkey 'split-sortvalue))
-                        (date-comparator (keylist-get-info date-subtotal-list date-subtotal-key 'date-sortvalue)))
+                  (let ((date (keylist-get-info
+                               (sortkey-list BOOK-SPLIT-ACTION)
+                               sortkey 'split-sortvalue))
+                        (date-comparator
+                         (keylist-get-info date-subtotal-list
+                                           date-subtotal-key 'date-sortvalue)))
                     (lambda (s)
-                      (and date-comparator
-                           (date-comparator (date s)))))
-                  (or (keylist-get-info (sortkey-list BOOK-SPLIT-ACTION) sortkey 'split-sortvalue)
+                      (and date-comparator (date-comparator (date s)))))
+                  (or (keylist-get-info (sortkey-list BOOK-SPLIT-ACTION)
+                                        sortkey 'split-sortvalue)
                       (lambda (s) #f))))
              (value-of-X (comparator-function split-X))
              (value-of-Y (comparator-function split-Y))
@@ -1942,171 +1981,144 @@ be excluded from periodic reporting.")
     (define (date-comparator? X Y)
       (generic-less? X Y 'date 'none #t))
 
-    (if (or (or (null? c_account_1) (and-map not c_account_1))
-            (eq? account-matcher-regexp 'invalid-regex)
-            (eq? transaction-matcher-regexp 'invalid-regex))
-
-        ;; error condition: no accounts specified or obtained after filtering
-        (begin
+    (cond
+     ((or (null? c_account_1)
+          (eq? account-matcher-regexp 'invalid-regex)
+          (eq? transaction-matcher-regexp 'invalid-regex))
+
+      ;; error condition: no accounts specified or obtained after filtering
+      (gnc:html-document-add-object!
+       document
+       (gnc:html-make-no-account-warning
+        report-title (gnc:report-id report-obj)))
+
+      ;; if an empty-report-message is passed by a derived report to
+      ;; the renderer, display it here.
+      (when empty-report-message
+        (gnc:html-document-add-object!
+         document
+         empty-report-message))
+
+      (when (memq infobox-display '(always no-match))
+        (gnc:html-document-add-object!
+         document
+         (gnc:html-render-options-changed options))))
+
+     (else
+      (qof-query-set-book query (gnc-get-current-book))
+      (xaccQueryAddAccountMatch query c_account_1 QOF-GUID-MATCH-ANY QOF-QUERY-AND)
+      (unless split->date
+        (xaccQueryAddDateMatchTT query #t begindate #t enddate QOF-QUERY-AND))
+      (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))
+      (when reconcile-status-filter
+        (xaccQueryAddClearedMatch query reconcile-status-filter QOF-QUERY-AND))
+      (when (boolean? closing-match)
+        (xaccQueryAddClosingTransMatch query closing-match QOF-QUERY-AND))
+      (unless custom-sort?
+        (qof-query-set-sort-order
+         query
+         (keylist-get-info (sortkey-list BOOK-SPLIT-ACTION) primary-key 'sortkey)
+         (keylist-get-info (sortkey-list BOOK-SPLIT-ACTION) secondary-key 'sortkey)
+         '())
+        (qof-query-set-sort-increasing
+         query (eq? primary-order 'ascend) (eq? secondary-order 'ascend)
+         #t))
+
+      (if (opt-val "__trep" "unique-transactions")
+          (set! splits (xaccQueryGetSplitsUniqueTrans query))
+          (set! splits (qof-query-run query)))
+
+      (qof-query-destroy query)
+
+      ;; Combined Filter:
+      ;; - include/exclude using split->date according to date options
+      ;; - include/exclude splits to/from selected accounts
+      ;; - substring/regex matcher for Transaction Description/Notes/Memo
+      ;; - custom-split-filter, a split->bool function for derived reports
+      (set! splits
+        (filter
+         (lambda (split)
+           (let* ((trans (xaccSplitGetParent split)))
+             (and (or (not split->date)
+                      (let ((date (split->date split)))
+                        (if date
+                            (<= begindate date enddate)
+                            split->date-include-false?)))
+                  (case filter-mode
+                    ((none) #t)
+                    ((include) (is-filter-member split c_account_2))
+                    ((exclude) (not (is-filter-member split c_account_2))))
+                  (or (string-null? transaction-matcher)
+                      (match? (xaccTransGetDescription trans))
+                      (match? (xaccTransGetNotes trans))
+                      (match? (xaccSplitGetMemo split)))
+                  (or (not custom-split-filter)
+                      (custom-split-filter split)))))
+         splits))
+
+      (when custom-sort?
+        (set! splits (stable-sort! splits date-comparator?))
+        (set! splits (stable-sort! splits secondary-comparator?))
+        (set! splits (stable-sort! splits primary-comparator?)))
 
+      (cond
+       ((null? splits)
+        ;; error condition: no splits found
+        (gnc:html-document-add-object!
+         document
+         (gnc:html-make-generic-warning
+          report-title (gnc:report-id report-obj)
+          NO-MATCHING-TRANS-HEADER NO-MATCHING-TRANS-TEXT))
+
+        (when (memq infobox-display '(always no-match))
           (gnc:html-document-add-object!
            document
-           (gnc:html-make-no-account-warning
-            report-title (gnc:report-id report-obj)))
+           (gnc:html-render-options-changed options))))
 
-          ;; if an empty-report-message is passed by a derived report to
-          ;; the renderer, display it here.
-          (if empty-report-message
-              (gnc:html-document-add-object!
-               document
-               empty-report-message))
+       (else
+        (let-values (((table grid)
+                      (make-split-table splits options custom-calculated-cells)))
+
+          (gnc:html-document-set-title! document report-title)
 
-          (if (memq infobox-display '(always no-match))
+          (gnc:html-document-add-object!
+           document
+           (gnc:make-html-text
+            (gnc:html-markup-h3
+             (format #f
+                     (_ "From ~a to ~a")
+                     (qof-print-date begindate)
+                     (qof-print-date enddate)))))
+
+          (when (eq? infobox-display 'always)
+            (gnc:html-document-add-object!
+             document
+             (gnc:html-render-options-changed options)))
+
+          (when subtotal-table?
+            (let* ((generic<?
+                    (lambda (a b)
+                      (cond ((string? (car a)) (string<? (car a) (car b)))
+                            ((number? (car a)) (< (car a) (car b)))
+                            (else (gnc:error "unknown sortvalue")))))
+                   (list-of-rows
+                    (stable-sort! (delete 'row-total (grid-rows grid))
+                                  generic<?))
+                   (list-of-cols
+                    (stable-sort! (delete 'col-total (grid-cols grid))
+                                  generic<?)))
               (gnc:html-document-add-object!
-               document
-               (gnc:html-render-options-changed options))))
-
-        (begin
-
-          (qof-query-set-book query (gnc-get-current-book))
-          (xaccQueryAddAccountMatch query c_account_1 QOF-GUID-MATCH-ANY QOF-QUERY-AND)
-          (if (not split->date)
-              (xaccQueryAddDateMatchTT query #t begindate #t enddate QOF-QUERY-AND))
-          (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))
-          (if reconcile-status-filter
-              (xaccQueryAddClearedMatch query reconcile-status-filter QOF-QUERY-AND))
-          (if (boolean? closing-match)
-              (xaccQueryAddClosingTransMatch query closing-match QOF-QUERY-AND))
-          (if (not custom-sort?)
-              (begin
-                (qof-query-set-sort-order query
-                                          (keylist-get-info (sortkey-list BOOK-SPLIT-ACTION) primary-key 'sortkey)
-                                          (keylist-get-info (sortkey-list BOOK-SPLIT-ACTION) secondary-key 'sortkey)
-                                          '())
-                (qof-query-set-sort-increasing query
-                                               (eq? primary-order 'ascend)
-                                               (eq? secondary-order 'ascend)
-                                               #t)))
-
-          (if (opt-val "__trep" "unique-transactions")
-              (set! splits (xaccQueryGetSplitsUniqueTrans query))
-              (set! splits (qof-query-run query)))
-
-          (qof-query-destroy query)
-
-          ;; Combined Filter:
-          ;; - include/exclude using split->date according to date options
-          ;; - include/exclude splits to/from selected accounts
-          ;; - substring/regex matcher for Transaction Description/Notes/Memo
-          ;; - custom-split-filter, a split->bool function for derived reports
-          (set! splits (filter
-                        (lambda (split)
-                          (let* ((trans (xaccSplitGetParent split))
-                                 (match? (lambda (str)
-                                           (if transaction-matcher-regexp
-                                               (regexp-exec transaction-matcher-regexp str)
-                                               (string-contains str transaction-matcher)))))
-                            (and (or (not split->date)                  ; #f = ignore custom date filter
-                                     (let ((date (split->date split)))  ; cache split->date time64 or #f.
-                                       (if date                         ; if a split->date exists,
-                                           (<= begindate date enddate)  ; then check for inclusion;
-                                           split->date-include-false?))); else behave according to parameter
-                                 (case filter-mode
-                                   ((none) #t)
-                                   ((include) (is-filter-member split c_account_2))
-                                   ((exclude) (not (is-filter-member split c_account_2))))
-                                 (or (string-null? transaction-matcher) ; null-string = ignore filters
-                                     (match? (xaccTransGetDescription trans))
-                                     (match? (xaccTransGetNotes trans))
-                                     (match? (xaccSplitGetMemo split)))
-                                 (or (not custom-split-filter)     ; #f = ignore custom-split-filter
-                                     (custom-split-filter split))
-                                 )))
-                        splits))
-
-          (when custom-sort?
-            (set! splits (stable-sort! splits date-comparator?))
-            (set! splits (stable-sort! splits secondary-comparator?))
-            (set! splits (stable-sort! splits primary-comparator?)))
-
-          (if (null? splits)
-
-              ;; error condition: no splits found
-              (begin
-
-                (gnc:html-document-add-object!
-                 document
-                 (gnc:html-make-generic-warning
-                  report-title (gnc:report-id report-obj)
-                  NO-MATCHING-TRANS-HEADER NO-MATCHING-TRANS-TEXT))
-
-                (if (memq infobox-display '(always no-match))
-                    (gnc:html-document-add-object!
-                     document
-                     (gnc:html-render-options-changed options))))
-
-              (let-values (((table grid) (make-split-table splits options custom-calculated-cells)))
-
-                (gnc:html-document-set-title! document report-title)
-
-                (gnc:html-document-add-object!
-                 document
-                 (gnc:make-html-text
-                  (gnc:html-markup-h3
-                   (format #f
-                            (_ "From ~a to ~a")
-                            (qof-print-date begindate)
-                            (qof-print-date enddate)))))
-
-                (if (eq? infobox-display 'always)
-                    (gnc:html-document-add-object!
-                     document
-                     (gnc:html-render-options-changed options)))
-
-                (if subtotal-table?
-                    (let* ((generic<? (lambda (a b)
-                                        (cond ((string? (car a)) (string<? (car a) (car b)))
-                                              ((number? (car a)) (< (car a) (car b)))
-                                              (else (gnc:error "unknown sortvalue")))))
-                           (list-of-rows (stable-sort! (delete 'row-total (grid-rows grid)) generic<?))
-                           (list-of-cols (stable-sort! (delete 'col-total (grid-cols grid)) generic<?)))
-                      (gnc:html-document-add-object!
-                       document (grid->html-table grid list-of-rows list-of-cols))))
-
-                (unless (and subtotal-table?
-                             (opt-val pagename-sorting optname-show-subtotals-only))
-                  (gnc:html-document-add-object! document table))))))
+               document (grid->html-table grid list-of-rows list-of-cols))))
+
+          (unless (and subtotal-table?
+                       (opt-val pagename-sorting optname-show-subtotals-only))
+            (gnc:html-document-add-object! document table)))))))
 
     (gnc:report-finished)
 
     document))
-
-(define trep-guid "2fe3b9833af044abb929a88d5a59620f")
-(export trep-guid)
-(export trep-renderer)
-(export trep-options-generator)
-
-;; Define the report.
-(gnc:define-report
- 'version 1
- 'name (_ "Reconciliation Report")
- 'report-guid "e45218c6d76f11e7b5ef0800277ef320"
- 'options-generator reconcile-report-options-generator
- ;; the renderer is the same as trep, however we're using a different split-date strategy.
- ;; we're comparing reconcile date for inclusion, and if split is unreconciled, include it anyway.
- 'renderer (lambda (rpt) (trep-renderer rpt
-                                        #:custom-calculated-cells reconcile-report-calculated-cells
-                                        #:split->date split->reconcile-date
-                                        #:split->date-include-false? #t
-                                        #:empty-report-message reconcile-report-instructions)))
-
-;; Define the report.
-(gnc:define-report
- 'version 1
- 'name reportname
- 'report-guid trep-guid
- 'options-generator trep-options-generator
- 'renderer trep-renderer)
diff --git a/gnucash/report/standard-reports/transaction.scm b/gnucash/report/standard-reports/transaction.scm
index d1b3b94fa..868526193 100644
--- a/gnucash/report/standard-reports/transaction.scm
+++ b/gnucash/report/standard-reports/transaction.scm
@@ -1,24 +1,7 @@
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; 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"
-;; Refactored by Christopher Lam (2017)
-;; - introduced account/transaction substring/regex matcher
-;; - add custom sorter in scheme
-;; - common currency - optionally show original currency amount
-;;   and enable multiple data columns
-;; - add support for indenting for better grouping
-;; - add defaults suitable for a reconciliation report
-;;   including alternative date filtering strategy
-;; - add subtotal summary grid
-;; - by default, exclude closing transactions from the report
+;; calls transaction report functions in trep-engine.scm
 ;;
 ;; This program is free software; you can redistribute it and/or    
 ;; modify it under the terms of the GNU General Public License as   
@@ -41,2072 +24,13 @@
 
 (define-module (gnucash report standard-reports transaction))
 
-(use-modules (gnucash utilities))
-(use-modules (srfi srfi-1))
-(use-modules (srfi srfi-11))
-(use-modules (srfi srfi-13))
-(use-modules (ice-9 regex))
 (use-modules (gnucash gnc-module))
 (use-modules (gnucash gettext))
-
 (gnc:module-load "gnucash/report/report-system" 0)
 
-;; Define the strings here to avoid typos and make changes easier.
-(define reportname (N_ "Transaction Report"))
-
-;;Accounts
-(define optname-accounts (N_ "Accounts"))
-(define optname-filterby (N_ "Filter By..."))
-(define optname-filtertype (N_ "Filter Type"))
-
-;;Display
-(define optname-detail-level (N_ "Detail Level"))
-(define optname-grid (N_ "Subtotal Table"))
-
-;;Sorting
-(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-show-account-description (N_ "Show Account Description"))
-(define optname-show-informal-headers (N_ "Show Informal Debit/Credit Headers"))
-(define optname-show-subtotals-only (N_ "Show subtotals only (hide transactional data)"))
-(define optname-indenting (N_ "Add indenting columns"))
-(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"))
-
-;;General
-(define optname-startdate (N_ "Start Date"))
-(define optname-enddate (N_ "End Date"))
-(define optname-table-export (N_ "Table for Exporting"))
-(define optname-common-currency (N_ "Common Currency"))
-(define optname-orig-currency (N_ "Show original currency amount"))
-(define optname-currency (N_ "Report's currency"))
-(define optname-infobox-display (N_ "Add options summary"))
-
-;;Filtering
-(define pagename-filter (N_ "Filter"))
-(define optname-account-matcher (N_ "Account Name Filter"))
-(define optname-account-matcher-regex (N_ "Use regular expressions for account name filter"))
-(define optname-transaction-matcher (N_ "Transaction Filter"))
-(define optname-transaction-matcher-regex (N_ "Use regular expressions for transaction filter"))
-(define optname-reconcile-status (N_ "Reconcile Status"))
-(define optname-void-transactions (N_ "Void Transactions"))
-(define optname-closing-transactions (N_ "Closing transactions"))
-
-;;Styles
-(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")
-
-(define NO-MATCHING-TRANS-HEADER (_ "No matching transactions found"))
-(define NO-MATCHING-TRANS-TEXT (_ "No transactions were found that \
-match the time interval and account selection specified \
-in the Options panel."))
-
-(define DATE-SORTING-TYPES (list 'date 'reconciled-date))
-
-(define ACCOUNT-SORTING-TYPES (list 'account-name 'corresponding-acc-name
-                                    'account-code 'corresponding-acc-code))
-
-(define SORTKEY-INFORMAL-HEADERS (list 'account-name 'account-code))
-
-(define (sortkey-list split-action?)
-  ;;
-  ;; Defines the different sorting keys, as an association-list
-  ;; together with the subtotal functions. Each entry:
-  ;;  'sortkey             - sort parameter sent via qof-query
-  ;;  'split-sortvalue     - function which retrieves number/string used for comparing splits
-  ;;  'text                - text displayed in Display tab
-  ;;  'tip                 - tooltip displayed in Display tab
-  ;;  'renderer-fn         - helper function to select subtotal/subheading renderer
-  ;;       behaviour varies according to sortkey.
-  ;;       account-types converts split->account
-  ;;       #f means the sortkey cannot be subtotalled
-  ;;       otherwise it converts split->string
-  ;;
-  (list (cons 'account-name  (list (cons 'sortkey (list SPLIT-ACCT-FULLNAME))
-                                   (cons 'split-sortvalue (lambda (a) (gnc-account-get-full-name (xaccSplitGetAccount a))))
-                                   (cons 'text (_ "Account Name"))
-                                   (cons 'tip (_ "Sort & subtotal by account name."))
-                                   (cons 'renderer-fn (lambda (a) (xaccSplitGetAccount a)))))
-
-        (cons 'account-code (list (cons 'sortkey (list SPLIT-ACCOUNT ACCOUNT-CODE-))
-                                  (cons 'split-sortvalue (lambda (a) (xaccAccountGetCode (xaccSplitGetAccount a))))
-                                  (cons 'text (_ "Account Code"))
-                                  (cons 'tip (_ "Sort & subtotal by account code."))
-                                  (cons 'renderer-fn (lambda (a) (xaccSplitGetAccount a)))))
-
-        (cons 'date         (list (cons 'sortkey (list SPLIT-TRANS TRANS-DATE-POSTED))
-                                  (cons 'split-sortvalue (lambda (s) (xaccTransGetDate (xaccSplitGetParent s))))
-                                  (cons 'text (_ "Date"))
-                                  (cons 'tip (_ "Sort by date."))
-                                  (cons 'renderer-fn #f)))
-
-        (cons 'reconciled-date (list (cons 'sortkey (list SPLIT-DATE-RECONCILED))
-                                     (cons 'split-sortvalue (lambda (s) (xaccSplitGetDateReconciled s)))
-                                     (cons 'text (_ "Reconciled Date"))
-                                     (cons 'tip (_ "Sort by the Reconciled Date."))
-                                     (cons 'renderer-fn #f)))
-
-        (cons 'reconciled-status (list (cons 'sortkey #f)
-                                       (cons 'split-sortvalue (lambda (s) (length (memq (xaccSplitGetReconcile s)
-                                                                                        '(#\n #\c #\y #\f #\v)))))
-                                       (cons 'text (_ "Reconciled Status"))
-                                       (cons 'tip (_ "Sort by the Reconciled Status"))
-                                       (cons 'renderer-fn (lambda (s) (case (xaccSplitGetReconcile s)
-                                                                        ((#\y) (_ "Reconciled"))
-                                                                        ((#\c) (_ "Cleared"))
-                                                                        ((#\n) (_ "Unreconciled"))
-                                                                        ((#\f) (_ "Frozen"))
-                                                                        ((#\v) (_ "Voided"))
-                                                                        (else (_ "Unknown")))))))
-
-        (cons 'register-order (list (cons 'sortkey (list QUERY-DEFAULT-SORT))
-                                    (cons 'split-sortvalue #f)
-                                    (cons 'text (_ "Register Order"))
-                                    (cons 'tip (_ "Sort as in the register."))
-                                    (cons 'renderer-fn #f)))
-
-        (cons 'corresponding-acc-name (list (cons 'sortkey (list SPLIT-CORR-ACCT-NAME))
-                                            (cons 'split-sortvalue (lambda (a) (xaccSplitGetCorrAccountFullName a)))
-                                            (cons 'text (_ "Other Account Name"))
-                                            (cons 'tip (_ "Sort by account transferred from/to's name."))
-                                            (cons 'renderer-fn (lambda (a) (xaccSplitGetAccount (xaccSplitGetOtherSplit a))))))
-
-        (cons 'corresponding-acc-code (list (cons 'sortkey (list SPLIT-CORR-ACCT-CODE))
-                                            (cons 'split-sortvalue (lambda (a) (xaccSplitGetCorrAccountCode a)))
-                                            (cons 'text (_ "Other Account Code"))
-                                            (cons 'tip (_ "Sort by account transferred from/to's code."))
-                                            (cons 'renderer-fn (lambda (a) (xaccSplitGetAccount (xaccSplitGetOtherSplit a))))))
-
-        (cons 'amount        (list (cons 'sortkey (list SPLIT-VALUE))
-                                   (cons 'split-sortvalue (lambda (a) (gnc-numeric-to-scm (xaccSplitGetValue a))))
-                                   (cons 'text (_ "Amount"))
-                                   (cons 'tip (_ "Sort by amount."))
-                                   (cons 'renderer-fn #f)))
-
-        (cons 'description   (list (cons 'sortkey (list SPLIT-TRANS TRANS-DESCRIPTION))
-                                   (cons 'split-sortvalue (lambda (s) (xaccTransGetDescription (xaccSplitGetParent s))))
-                                   (cons 'text (_ "Description"))
-                                   (cons 'tip (_ "Sort by description."))
-                                   (cons 'renderer-fn (lambda (s) (xaccTransGetDescription (xaccSplitGetParent s))))))
-
-        (if split-action?
-            (cons 'number    (list (cons 'sortkey (list SPLIT-ACTION))
-                                   (cons 'split-sortvalue (lambda (a) (xaccSplitGetAction a)))
-                                   (cons 'text (_ "Number/Action"))
-                                   (cons 'tip (_ "Sort by check number/action."))
-                                   (cons 'renderer-fn #f)))
-
-            (cons 'number    (list (cons 'sortkey (list SPLIT-TRANS TRANS-NUM))
-                                   (cons 'split-sortvalue (lambda (a) (xaccTransGetNum (xaccSplitGetParent a))))
-                                   (cons 'text (_ "Number"))
-                                   (cons 'tip (_ "Sort by check/transaction number."))
-                                   (cons 'renderer-fn #f))))
-
-        (cons 't-number      (list (cons 'sortkey (list SPLIT-TRANS TRANS-NUM))
-                                   (cons 'split-sortvalue (lambda (a) (xaccTransGetNum (xaccSplitGetParent a))))
-                                   (cons 'text (_ "Transaction Number"))
-                                   (cons 'tip (_ "Sort by transaction number."))
-                                   (cons 'renderer-fn #f)))
-
-        (cons 'memo          (list (cons 'sortkey (list SPLIT-MEMO))
-                                   (cons 'split-sortvalue (lambda (s) (xaccSplitGetMemo s)))
-                                   (cons 'text (_ "Memo"))
-                                   (cons 'tip (_ "Sort by memo."))
-                                   (cons 'renderer-fn (lambda (s) (xaccSplitGetMemo s)))))
-
-        (cons 'notes         (list (cons 'sortkey #f)
-                                   (cons 'split-sortvalue (lambda (s) (xaccTransGetNotes (xaccSplitGetParent s))))
-                                   (cons 'text (_ "Notes"))
-                                   (cons 'tip (_ "Sort by transaction notes."))
-                                   (cons 'renderer-fn (lambda (s) (xaccTransGetNotes (xaccSplitGetParent s))))))
-
-        (cons 'none          (list (cons 'sortkey '())
-                                   (cons 'split-sortvalue #f)
-                                   (cons 'text (_ "None"))
-                                   (cons 'tip (_ "Do not sort."))
-                                   (cons 'renderer-fn #f)))))
-
-(define (time64-year t64)    (gnc:date-get-year (gnc-localtime t64)))
-(define (time64-quarter t64) (+ (* 10 (gnc:date-get-year (gnc-localtime t64)))  (gnc:date-get-quarter (gnc-localtime t64))))
-(define (time64-month t64)   (+ (* 100 (gnc:date-get-year (gnc-localtime t64))) (gnc:date-get-month (gnc-localtime t64))))
-(define (time64-week t64)    (gnc:date-get-week (gnc-localtime t64)))
-(define (time64-day t64)     (+ (* 500 (gnc:date-get-year (gnc-localtime t64))) (gnc:date-get-year-day (gnc-localtime t64))))
-(define (time64->daily-string t) (qof-print-date t))
-(define (split->time64 s) (xaccTransGetDate (xaccSplitGetParent s)))
-
-(define date-subtotal-list
-  ;; List for date option.
-  ;; Defines the different date sorting keys, as an association-list. Each entry:
-  ;;  'split-sortvalue     - function which retrieves number/string used for comparing splits
-  ;;  'text                - text displayed in Display tab
-  ;;  'tip                 - tooltip displayed in Display tab
-  ;;  'renderer-fn         - func retrieve string for subtotal/subheading renderer
-  ;;         #f means the date sortkey is not grouped
-  ;;         otherwise it converts split->string
-  (list
-   (cons 'none (list
-                (cons 'split-sortvalue #f)
-                (cons 'date-sortvalue #f)
-                (cons 'text (_ "None"))
-                (cons 'tip (_ "None."))
-                (cons 'renderer-fn #f)))
-
-   (cons 'daily (list
-                  (cons 'split-sortvalue (lambda (s) (time64-day (split->time64 s))))
-                  (cons 'date-sortvalue time64-day)
-                  (cons 'text (_ "Daily"))
-                  (cons 'tip (_ "Daily."))
-                  (cons 'renderer-fn (lambda (s) (time64->daily-string (split->time64 s))))))
-
-   (cons 'weekly (list
-                  (cons 'split-sortvalue (lambda (s) (time64-week (split->time64 s))))
-                  (cons 'date-sortvalue time64-week)
-                  (cons 'text (_ "Weekly"))
-                  (cons 'tip (_ "Weekly."))
-                  (cons 'renderer-fn (lambda (s) (gnc:date-get-week-year-string (gnc-localtime (split->time64 s)))))))
-
-   (cons 'monthly (list
-                   (cons 'split-sortvalue (lambda (s) (time64-month (split->time64 s))))
-                   (cons 'date-sortvalue time64-month)
-                   (cons 'text (_ "Monthly"))
-                   (cons 'tip (_ "Monthly."))
-                   (cons 'renderer-fn (lambda (s) (gnc:date-get-month-year-string (gnc-localtime (split->time64 s)))))))
-
-   (cons 'quarterly (list
-                     (cons 'split-sortvalue (lambda (s) (time64-quarter (split->time64 s))))
-                     (cons 'date-sortvalue time64-quarter)
-                     (cons 'text (_ "Quarterly"))
-                     (cons 'tip (_ "Quarterly."))
-                     (cons 'renderer-fn (lambda (s) (gnc:date-get-quarter-year-string (gnc-localtime (split->time64 s)))))))
-
-   (cons 'yearly (list
-                  (cons 'split-sortvalue (lambda (s) (time64-year (split->time64 s))))
-                  (cons 'date-sortvalue time64-year)
-                  (cons 'text (_ "Yearly"))
-                  (cons 'tip (_ "Yearly."))
-                  (cons 'renderer-fn (lambda (s) (gnc:date-get-year-string (gnc-localtime (split->time64 s)))))))))
-
-(define filter-list
-  (list
-   (cons 'none (list
-                (cons 'text (_ "None"))
-                (cons 'tip (_ "Do not do any filtering."))))
-
-   (cons 'include (list
-                   (cons 'text (_ "Include Transactions to/from Filter Accounts"))
-                   (cons 'tip (_ "Include transactions to/from filter accounts only."))))
-
-   (cons 'exclude (list
-                   (cons 'text (_ "Exclude Transactions to/from Filter Accounts"))
-                   (cons 'tip (_ "Exclude transactions to/from all filter accounts."))))))
-
-(define show-void-list
-  (list
-   (cons 'non-void-only (list
-                         (cons 'text (_ "Non-void only"))
-                         (cons 'tip (_ "Show only non-voided transactions."))))
-
-   (cons 'void-only (list
-                     (cons 'text (_ "Void only"))
-                     (cons 'tip (_ "Show only voided transactions."))))
-
-   (cons 'both (list
-                (cons 'text (_ "Both"))
-                (cons 'tip (_ "Show both (and include void transactions in totals)."))))))
-
-(define show-closing-list
-  (list
-   (cons 'exclude-closing (list
-                           (cons 'text (_ "Exclude closing transactions"))
-                           (cons 'tip (_ "Exclude closing transactions from report."))
-                           (cons 'closing-match #f)))
-
-   (cons 'include-both (list
-                        (cons 'text (_ "Show both closing and regular transactions"))
-                        (cons 'tip (_ "Show both (and include closing transactions in totals)."))
-                        (cons 'closing-match 'both)))
-
-   (cons 'closing-only (list
-                        (cons 'text (_ "Show closing transactions only"))
-                        (cons 'tip (_ "Show only closing transactions."))
-                        (cons 'closing-match #t)))))
-
-(define reconcile-status-list
-  ;; 'filter-types must be either #f (i.e. disable reconcile filter)
-  ;; or a value defined as defined in Query.c
-  ;; e.g. CLEARED-NO for unreconciled
-  ;;      (logior CLEARED-NO CLEARED-CLEARED) for unreconciled & cleared
-  (list
-   (cons 'all
-         (list
-          (cons 'text (_ "All"))
-          (cons 'tip (_ "Show All Transactions"))
-          (cons 'filter-types #f)))
-
-   (cons 'unreconciled
-         (list
-          (cons 'text (_ "Unreconciled"))
-          (cons 'tip (_ "Unreconciled only"))
-          (cons 'filter-types CLEARED-NO)))
-
-   (cons 'cleared
-         (list
-          (cons 'text (_ "Cleared"))
-          (cons 'tip (_ "Cleared only"))
-          (cons 'filter-types CLEARED-CLEARED)))
-
-   (cons 'reconciled
-         (list
-          (cons 'text (_ "Reconciled"))
-          (cons 'tip (_ "Reconciled only"))
-          (cons 'filter-types CLEARED-RECONCILED)))))
-
-
-(define ascending-list
-  (list
-   (cons 'ascend (list
-                  (cons 'text (_ "Ascending"))
-                  (cons 'tip (_ "Smallest to largest, earliest to latest."))))
-   (cons 'descend (list
-                   (cons 'text (_ "Descending"))
-                   (cons 'tip (_ "Largest to smallest, latest to earliest."))))))
-
-(define sign-reverse-list
-  (list
-   (cons 'global
-         (list
-          (cons 'text (_ "Use Global Preference"))
-          (cons 'tip (_ "Use reversing option specified in global preference."))
-          (cons 'acct-types #f)))
-   (cons 'none
-         (list
-          (cons 'text (_ "None"))
-          (cons 'tip (_ "Don't change any displayed amounts."))
-          (cons 'acct-types '())))
-   (cons 'income-expense
-         (list
-          (cons 'text (_ "Income and Expense"))
-          (cons 'tip (_ "Reverse amount display for Income and Expense Accounts."))
-          (cons 'acct-types (list ACCT-TYPE-INCOME ACCT-TYPE-EXPENSE))))
-   (cons 'credit-accounts
-         (list
-          (cons 'text (_ "Credit Accounts"))
-          (cons 'tip (_ "Reverse amount display for Liability, Payable, Equity, \
-Credit Card, and Income accounts."))
-          (cons 'acct-types (list ACCT-TYPE-LIABILITY ACCT-TYPE-PAYABLE
-                                  ACCT-TYPE-EQUITY ACCT-TYPE-CREDIT
-                                  ACCT-TYPE-INCOME))))))
-
-(define (keylist-get-info keylist key info)
-  (cdr (assq info (cdr (assq key keylist)))))
-
-(define (keylist->vectorlist keylist)
-  (map
-   (lambda (item)
-     (vector
-      (car item)
-      (keylist-get-info keylist (car item) 'text)
-      (keylist-get-info keylist (car item) 'tip)))
-   keylist))
-
-(define (SUBTOTAL-ENABLED? sortkey split-action?)
-  ;; this returns whether sortkey *can* be subtotalled/grouped.
-  ;; it checks whether a renderer-fn is defined.
-  (keylist-get-info (sortkey-list split-action?) sortkey 'renderer-fn))
-
-(define (CUSTOM-SORTING? sortkey split-action?)
-  ;; sortkey -> bool
-  ;;
-  ;; this returns which sortkeys which *must* use the custom sorter.
-  ;; it filters whereby a split-sortvalue is defined (i.e. the splits
-  ;; can be compared according to their 'sortvalue) but the QofQuery
-  ;; sortkey is not defined (i.e. their 'sortkey is #f).
-  (and (keylist-get-info (sortkey-list split-action?) sortkey 'split-sortvalue)
-       (not (keylist-get-info (sortkey-list split-action?) sortkey 'sortkey))))
-
-;;
-;; Set defaults for reconcilation report
-;;
-(define (reconcile-report-options-generator)
-  (define options (trep-options-generator))
-  (gnc:option-set-value (gnc:lookup-option options pagename-sorting optname-prime-sortkey) 'reconciled-status)
-  (gnc:option-set-value (gnc:lookup-option options pagename-sorting optname-sec-sortkey)   'date)
-  (gnc:option-set-value (gnc:lookup-option options pagename-sorting optname-sec-date-subtotal) 'none)
-  ;; the start date should really be the last-reconcile-date but this information is not
-  ;; easily accessible from scheme:
-  (gnc:option-set-value (gnc:lookup-option options gnc:pagename-general optname-startdate) (cons 'relative 'start-prev-quarter))
-  (gnc:option-set-value (gnc:lookup-option options gnc:pagename-general optname-enddate)   (cons 'relative 'today))
-  (gnc:option-set-value (gnc:lookup-option options gnc:pagename-display (N_ "Reconciled Date")) #t)
-  (gnc:option-set-value (gnc:lookup-option options gnc:pagename-display (N_ "Running Balance")) #f)
-  (gnc:option-set-value (gnc:lookup-option options gnc:pagename-display (N_ "Memo")) #f)
-  (gnc:option-make-internal! options gnc:pagename-display "Running Balance")
-  options)
-
-(define reconcile-report-instructions
-  (gnc:make-html-text
-   (_ "The reconcile report is designed to be similar to the formal reconciliation tool.
-Please select the account from Report Options. Please note the dates specified in the options
-will apply to the Reconciliation Date.")
-   (gnc:html-markup-br)
-   (gnc:html-markup-br)))
-
-;; if split is reconciled, retrieve its reconciled date; if not yet reconciled, return #f
-(define (split->reconcile-date split)
-  (and (char=? (xaccSplitGetReconcile split) #\y)
-       (xaccSplitGetDateReconciled split)))
-
-(define (reconcile-report-calculated-cells options)
-  (define (opt-val section name)
-    (gnc:option-value (gnc:lookup-option options section name)))
-  (letrec
-      ((split-amount (lambda (s) (if (gnc:split-voided? s)
-                                     (xaccSplitVoidFormerAmount s)
-                                     (xaccSplitGetAmount s))))
-       (split-currency (lambda (s) (xaccAccountGetCommodity (xaccSplitGetAccount s))))
-       (amount (lambda (s) (gnc:make-gnc-monetary (split-currency s) (split-amount s))))
-       (debit-amount (lambda (s) (and (positive? (split-amount s))
-                                      (amount s))))
-       (credit-amount (lambda (s) (and (not (positive? (split-amount s)))
-                                       (gnc:monetary-neg (amount s))))))
-    ;; similar to default-calculated-cells but disable dual-subtotals.
-    (list (vector (_ "Funds In")
-                  debit-amount #f #t #f
-                  (const ""))
-          (vector (_ "Funds Out")
-                  credit-amount #f #t #f
-                  (const "")))))
-;;
-;; Default Transaction Report
-;;
-(define (trep-options-generator)
-
-  (define options (gnc:new-options))
-  (define BOOK-SPLIT-ACTION (qof-book-use-split-action-for-num-field (gnc-get-current-book)))
-  (define (gnc:register-trep-option new-option)
-    (gnc:register-option options new-option))
-
-  ;; (Feb 2018) Note to future hackers - this trep-options-generator
-  ;; defines a long set of options to be assigned as an object in
-  ;; the report. This long list (52 at Feb 2018 count) of options
-  ;; may be modified in a derived report (see income-gst-statement.scm)
-  ;; via gnc:make-internal! and gnc-unregister-option to hide
-  ;; and remove options, respectively. If an option is unregistered,
-  ;; don't forget to re-register them via gnc:register-option, unless
-  ;; your derived report truly does not require them.
-
-  ;; General options
-
-  (gnc:options-add-date-interval!
-   options gnc:pagename-general optname-startdate optname-enddate "a")
-
-  (gnc:register-trep-option
-   (gnc:make-complex-boolean-option
-    gnc:pagename-general optname-common-currency
-    "e" (_ "Convert all transactions into a common currency.") #f
-    #f
-    (lambda (x)
-      (begin
-        (gnc-option-db-set-option-selectable-by-name options
-                                                     gnc:pagename-general
-                                                     optname-currency x)
-        (gnc-option-db-set-option-selectable-by-name options
-                                                     gnc:pagename-general
-                                                     optname-orig-currency x)))))
-
-  (gnc:options-add-currency!
-   options gnc:pagename-general optname-currency "f")
-
-  (gnc:register-trep-option
-   (gnc:make-simple-boolean-option
-    gnc:pagename-general optname-orig-currency
-    "f1" (_ "Also show original currency amounts") #f))
-
-  (gnc:register-trep-option
-   (gnc:make-simple-boolean-option
-    gnc:pagename-general optname-table-export
-    "g" (_ "Formats the table suitable for cut & paste exporting with extra cells.") #f))
-
-  (gnc:register-trep-option
-   (gnc:make-multichoice-option
-    gnc:pagename-general optname-infobox-display
-    "h" (_ "Add summary of options.")
-    'no-match
-    ;; This is an alist of conditions for displaying the infobox
-    ;; 'no-match for empty-report
-    ;; 'match for generated report
-    (list (vector 'no-match
-                  (_ "If no transactions matched")
-                  (_ "Display summary if no transactions were matched."))
-          (vector 'always
-                  (_ "Always")
-                  (_ "Always display summary."))
-          (vector 'never
-                  (_ "Never")
-                  (_ "Disable report summary.")))))
-
-  ;; Filtering Options
-
-  (gnc:register-trep-option
-   (gnc:make-string-option
-    pagename-filter optname-account-matcher
-    "a5" (_ "Show only accounts whose full name matches this filter e.g. ':Travel' will match \
-Expenses:Travel:Holiday and Expenses:Business:Travel. It can be left blank, which will \
-disable the filter.")
-    ""))
-
-  (gnc:register-trep-option
-   (gnc:make-simple-boolean-option
-    pagename-filter optname-account-matcher-regex
-    "a6"
-    (_ "By default the account filter will search substring only. Set this to true to \
-enable full POSIX regular expressions capabilities. 'Car|Flights' will match both \
-Expenses:Car and Expenses:Flights. Use a period (.) to match a single character e.g. \
-'20../.' will match 'Travel 2017/1 London'. ")
-    #f))
-
-  (gnc:register-trep-option
-   (gnc:make-string-option
-    pagename-filter optname-transaction-matcher
-    "i1" (_ "Show only transactions where description, notes, or memo matches this filter.
-e.g. '#gift' will find all transactions with #gift in description, notes or memo. It can be left \
-blank, which will disable the filter.")
-    ""))
-
-  (gnc:register-trep-option
-   (gnc:make-simple-boolean-option
-    pagename-filter optname-transaction-matcher-regex
-    "i2"
-    (_ "By default the transaction filter will search substring only. Set this to true to \
-enable full POSIX regular expressions capabilities. '#work|#family' will match both \
-tags within description, notes or memo. ")
-    #f))
-
-  (gnc:register-trep-option
-   (gnc:make-multichoice-option
-    pagename-filter optname-reconcile-status
-    "j1" (_ "Filter by reconcile status.")
-    'all
-    (keylist->vectorlist reconcile-status-list)))
-
-  (gnc:register-trep-option
-   (gnc:make-multichoice-option
-    pagename-filter optname-void-transactions
-    "k" (N_ "How to handle void transactions.")
-    'non-void-only
-    (keylist->vectorlist show-void-list)))
-
-  (gnc:register-trep-option
-   (gnc:make-multichoice-option
-    pagename-filter optname-closing-transactions
-    "l" (_ "By default most users should not include closing \
-transactions in a transaction report. Closing transactions are \
-transfers from income and expense accounts to equity, and must usually \
-be excluded from periodic reporting.")
-    'exclude-closing
-    (keylist->vectorlist show-closing-list)))
-
-  ;; Accounts options
-
-  ;; account to do report on
-  (gnc:register-trep-option
-   (gnc:make-account-list-option
-    gnc:pagename-accounts optname-accounts
-    "a" (_ "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-account-list-option
-    gnc:pagename-accounts optname-filterby
-    "c1" (_ "Filter on these accounts.")
-    (lambda ()
-      '())
-    #f #t))
-
-  (gnc:register-trep-option
-   (gnc:make-multichoice-callback-option
-    gnc:pagename-accounts optname-filtertype
-    "c" (_ "Filter account.")
-    'none
-    (keylist->vectorlist filter-list)
-    #f
-    (lambda (x)
-      (gnc-option-db-set-option-selectable-by-name
-       options gnc:pagename-accounts optname-filterby
-       (not (eq? x 'none))))))
-
-  ;; Sorting options
-
-  (let ((ascending-choice-list (keylist->vectorlist ascending-list))
-        (key-choice-list (keylist->vectorlist (sortkey-list BOOK-SPLIT-ACTION)))
-        (date-subtotal-choice-list (keylist->vectorlist date-subtotal-list))
-        (prime-sortkey 'account-name)
-        (prime-sortkey-subtotal-true #t)
-        (prime-date-subtotal 'monthly)
-        (sec-sortkey 'register-order)
-        (sec-sortkey-subtotal-true #f)
-        (sec-date-subtotal 'monthly))
-
-    (define (apply-selectable-by-name-sorting-options)
-      (let* ((prime-sortkey-enabled (not (eq? prime-sortkey 'none)))
-             (prime-sortkey-subtotal-enabled (SUBTOTAL-ENABLED? prime-sortkey BOOK-SPLIT-ACTION))
-             (prime-date-sortingtype-enabled (member prime-sortkey DATE-SORTING-TYPES))
-             (sec-sortkey-enabled (not (eq? sec-sortkey 'none)))
-             (sec-sortkey-subtotal-enabled (SUBTOTAL-ENABLED? sec-sortkey BOOK-SPLIT-ACTION))
-             (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-show-account-description
-         (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-indenting
-         (or (and prime-sortkey-subtotal-enabled prime-sortkey-subtotal-true)
-             (and sec-sortkey-subtotal-enabled sec-sortkey-subtotal-true)
-             (and prime-date-sortingtype-enabled (not (eq? 'none prime-date-subtotal)))
-             (and sec-date-sortingtype-enabled (not (eq? 'none sec-date-subtotal)))))
-
-        (gnc-option-db-set-option-selectable-by-name
-         options pagename-sorting optname-show-subtotals-only
-         (or (and prime-sortkey-subtotal-enabled prime-sortkey-subtotal-true)
-             (and sec-sortkey-subtotal-enabled sec-sortkey-subtotal-true)
-             (and prime-date-sortingtype-enabled (not (eq? 'none prime-date-subtotal)))
-             (and sec-date-sortingtype-enabled (not (eq? 'none sec-date-subtotal)))))
-
-        (gnc-option-db-set-option-selectable-by-name
-         options pagename-sorting optname-show-informal-headers
-         (or (member prime-sortkey (list 'account-name 'account-code))
-             (member sec-sortkey (list 'account-name 'account-code))))
-
-        (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" (_ "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"
-      (_ "Show the full account name for subtotals and subheadings?")
-      #f))
-
-    (gnc:register-trep-option
-     (gnc:make-simple-boolean-option
-      pagename-sorting optname-show-account-code
-      "j2"
-      (_ "Show the account code for subtotals and subheadings?")
-      #f))
-
-    (gnc:register-trep-option
-     (gnc:make-simple-boolean-option
-      pagename-sorting optname-show-account-description
-      "j3"
-      (_ "Show the account description for subheadings?")
-      #f))
-
-    (gnc:register-trep-option
-     (gnc:make-simple-boolean-option
-      pagename-sorting optname-show-informal-headers
-      "j4"
-      (_ "Show the informal headers for debit/credit accounts?")
-      #f))
-
-    (gnc:register-trep-option
-     (gnc:make-simple-boolean-option
-      pagename-sorting optname-indenting
-      "j5"
-      (_ "Add indenting columns with grouping and subtotals?")
-      #t))
-
-    (gnc:register-trep-option
-     (gnc:make-simple-boolean-option
-      pagename-sorting optname-show-subtotals-only
-      "j6"
-      (_ "Show subtotals only, hiding transactional detail?")
-      #f))
-
-    (gnc:register-trep-option
-     (gnc:make-complex-boolean-option
-      pagename-sorting optname-prime-subtotal
-      "e5"
-      (_ "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-callback-option
-      pagename-sorting optname-prime-date-subtotal
-      "e2" (_ "Do a date subtotal.")
-      prime-date-subtotal
-      date-subtotal-choice-list #f
-      (lambda (x)
-        (set! prime-date-subtotal x)
-        (apply-selectable-by-name-sorting-options))))
-
-    (gnc:register-trep-option
-     (gnc:make-multichoice-option
-      pagename-sorting optname-prime-sortorder
-      "e" (_ "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"
-      (_ "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"
-      (_ "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-callback-option
-      pagename-sorting optname-sec-date-subtotal
-      "i2" (_ "Do a date subtotal.")
-      sec-date-subtotal
-      date-subtotal-choice-list #f
-      (lambda (x)
-        (set! sec-date-subtotal x)
-        (apply-selectable-by-name-sorting-options))))
-
-    (gnc:register-trep-option
-     (gnc:make-multichoice-option
-      pagename-sorting optname-sec-sortorder
-      "i" (_ "Order of Secondary sorting.")
-      'ascend
-      ascending-choice-list)))
-
-  ;; Display options
-
-  (let ((disp-memo? #t)
-        (disp-accname? #t)
-        (disp-other-accname? #f)
-        (detail-is-single? #t)
-        (amount-value 'single))
-
-    (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")
-       detail-is-single?)
-
-      (gnc-option-db-set-option-selectable-by-name
-       options gnc:pagename-display (N_ "Sign Reverses")
-       (eq? amount-value 'single))
-
-      (gnc-option-db-set-option-selectable-by-name
-       options gnc:pagename-display optname-grid
-       (eq? amount-value 'single))
-
-      (gnc-option-db-set-option-selectable-by-name
-       options gnc:pagename-display "Enable links"
-       (not (eq? amount-value 'none)))
-
-      (gnc-option-db-set-option-selectable-by-name
-       options gnc:pagename-display (N_ "Use Full Other Account Name")
-       (and disp-other-accname? detail-is-single?))
-
-      (gnc-option-db-set-option-selectable-by-name
-       options gnc:pagename-display (N_ "Other Account Code")
-       detail-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"  (_ "Display the date?") #t)
-      (list (N_ "Reconciled Date")              "a2" (_ "Display the reconciled date?") #f)
-      (if BOOK-SPLIT-ACTION
-          (list (N_ "Num/Action")               "b"  (_ "Display the check number?") #t)
-          (list (N_ "Num")                      "b"  (_ "Display the check number?") #t))
-      (list (N_ "Description")                  "c"  (_ "Display the description?") #t)
-      (list (N_ "Notes")                        "d2" (_ "Display the notes if the memo is unavailable?") #t)
-      ;; account name option appears here
-      (list (N_ "Use Full Account Name")        "f"  (_ "Display the full account name?") #t)
-      (list (N_ "Account Code")                 "g"  (_ "Display the account code?") #f)
-      ;; other account name option appears here
-      (list (N_ "Use Full Other Account Name")  "i"  (_ "Display the full account name?") #f)
-      (list (N_ "Other Account Code")           "j"  (_ "Display the other account code?") #f)
-      (list (N_ "Shares")                       "k"  (_ "Display the number of shares?") #f)
-      (list (N_ "Price")                        "l"  (_ "Display the shares price?") #f)
-      ;; note the "Amount" multichoice option in between here
-      (list optname-grid                        "m5" (_ "Display a subtotal summary table. This requires Display/Amount being 'single") #f)
-      (list (N_ "Running Balance")              "n"  (_ "Display a running balance?") #f)
-      (list (N_ "Totals")                       "o"  (_ "Display the totals?") #t)))
-
-    (if BOOK-SPLIT-ACTION
-        (gnc:register-trep-option
-         (gnc:make-simple-boolean-option
-          gnc:pagename-display (N_ "Trans Number")
-          "b2" (_ "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"  (_ "Display the memo?") #t
-      disp-memo?
-      (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"  (_ "Display the account name?") #t
-      disp-accname?
-      (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"  (_ "Display the other account name? (if this is a split transaction, this parameter is guessed).") #f
-      disp-other-accname?
-      (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" (_ "Amount of detail to display per transaction.")
-      'single
-      (list (vector 'multi-line
-                    (_ "Multi-Line")
-                    (_ "Display all splits in a transaction on a separate line."))
-            (vector 'single
-                    (_ "Single")
-                    (_ "Display one line per transaction, merging multiple splits where required.")))
-      #f
-      (lambda (x)
-        (set! detail-is-single? (eq? x 'single))
-        (apply-selectable-by-name-display-options))))
-
-    (gnc:register-trep-option
-     (gnc:make-multichoice-callback-option
-      gnc:pagename-display (N_ "Amount")
-      "m" (_ "Display the amount?")
-      amount-value
-      (list
-       (vector 'none   (_ "None") (_ "No amount display."))
-       (vector 'single (_ "Single") (_ "Single Column Display."))
-       (vector 'double (_ "Double") (_ "Two Column Display.")))
-      #f
-      (lambda (x)
-        (set! amount-value x)
-        (apply-selectable-by-name-display-options))))
-
-    (gnc:register-trep-option
-     (gnc:make-simple-boolean-option
-      gnc:pagename-display (N_ "Enable links")
-      "m2" (_ "Enable hyperlinks in amounts.") #t))
-
-    (gnc:register-trep-option
-     (gnc:make-multichoice-option
-      gnc:pagename-display (N_ "Sign Reverses")
-      "m1" (_ "Reverse amount display for certain account types.")
-      'global
-      (keylist->vectorlist sign-reverse-list))))
-
-  ;; this hidden option will toggle whether the default
-  ;; qof-query is run, or a different query which ensures
-  ;; no transaction is duplicated. It can be enabled in
-  ;; a derived report (eg income-gst-statement.scm)
-  (gnc:register-trep-option
-   (gnc:make-internal-option "__trep" "unique-transactions" #f))
-
-  (gnc:options-set-default-section options gnc:pagename-general)
-  options)
-
-;; ;;;;;;;;;;;;;;;;;;;;
-;; Here comes the big function that builds the whole table.
-
-(define (make-split-table splits options custom-calculated-cells)
-
-  (define (opt-val section name)
-    (let ((option (gnc:lookup-option options section name)))
-      (if option
-          (gnc:option-value option)
-          (gnc:error "gnc:lookup-option error: " section "/" name))))
-  (define BOOK-SPLIT-ACTION (qof-book-use-split-action-for-num-field (gnc-get-current-book)))
-
-  (define (build-columns-used)
-    (define detail-is-single? (eq? (opt-val gnc:pagename-display optname-detail-level) 'single))
-    (define amount-setting (opt-val gnc:pagename-display (N_ "Amount")))
-    (list (cons 'date (opt-val gnc:pagename-display (N_ "Date")))
-          (cons 'reconciled-date (opt-val gnc:pagename-display (N_ "Reconciled Date")))
-          (cons 'num (if BOOK-SPLIT-ACTION
-                         (opt-val gnc:pagename-display (N_ "Num/Action"))
-                         (opt-val gnc:pagename-display (N_ "Num"))))
-          (cons 'description (opt-val gnc:pagename-display (N_ "Description")))
-          (cons 'account-name (opt-val gnc:pagename-display (N_ "Account Name")))
-          (cons 'other-account-name (and detail-is-single?
-                                         (opt-val gnc:pagename-display (N_ "Other Account Name"))))
-          (cons 'shares (opt-val gnc:pagename-display (N_ "Shares")))
-          (cons 'price (opt-val gnc:pagename-display (N_ "Price")))
-          (cons 'amount-single (eq? amount-setting 'single))
-          (cons 'amount-double (eq? amount-setting 'double))
-          (cons 'common-currency (opt-val gnc:pagename-general optname-common-currency))
-          (cons 'amount-original-currency
-                (and (opt-val gnc:pagename-general optname-common-currency)
-                     (opt-val gnc:pagename-general optname-orig-currency)))
-          (cons 'indenting (opt-val pagename-sorting optname-indenting))
-          (cons 'subtotals-only (and (opt-val pagename-sorting optname-show-subtotals-only)
-                                     (or (primary-get-info 'renderer-fn)
-                                         (secondary-get-info 'renderer-fn))))
-          (cons 'running-balance (opt-val gnc:pagename-display (N_ "Running Balance")))
-          (cons 'account-full-name (opt-val gnc:pagename-display (N_ "Use Full Account Name")))
-          (cons 'memo (opt-val gnc:pagename-display (N_ "Memo")))
-          (cons 'account-code (opt-val gnc:pagename-display (N_ "Account Code")))
-          (cons 'other-account-code (and detail-is-single?
-                                         (opt-val gnc:pagename-display (N_ "Other Account Code"))))
-          (cons 'other-account-full-name (and detail-is-single?
-                                              (opt-val gnc:pagename-display (N_ "Use Full Other Account Name"))))
-          (cons 'sort-account-code (opt-val pagename-sorting (N_ "Show Account Code")))
-          (cons 'sort-account-full-name (opt-val pagename-sorting (N_ "Show Full Account Name")))
-          (cons 'sort-account-description (opt-val pagename-sorting (N_ "Show Account Description")))
-          (cons 'notes (opt-val gnc:pagename-display (N_ "Notes")))))
-
-  (define (primary-get-info info)
-    (let ((sortkey (opt-val pagename-sorting optname-prime-sortkey)))
-      (if (member sortkey DATE-SORTING-TYPES)
-          (keylist-get-info date-subtotal-list (opt-val pagename-sorting optname-prime-date-subtotal) info)
-          (and (SUBTOTAL-ENABLED? sortkey BOOK-SPLIT-ACTION)
-               (opt-val pagename-sorting optname-prime-subtotal)
-               (keylist-get-info (sortkey-list BOOK-SPLIT-ACTION) sortkey info)))))
-
-  (define (secondary-get-info info)
-    (let ((sortkey (opt-val pagename-sorting optname-sec-sortkey)))
-      (if (member sortkey DATE-SORTING-TYPES)
-          (keylist-get-info date-subtotal-list (opt-val pagename-sorting optname-sec-date-subtotal) info)
-          (and (SUBTOTAL-ENABLED? sortkey BOOK-SPLIT-ACTION)
-               (opt-val pagename-sorting optname-sec-subtotal)
-               (keylist-get-info (sortkey-list BOOK-SPLIT-ACTION) sortkey info)))))
-
-  (let* ((work-to-do (length splits))
-         (work-done 0)
-         (table (gnc:make-html-table))
-         (used-columns (build-columns-used))
-         (opt-use-links? (opt-val gnc:pagename-display "Enable links"))
-         (account-types-to-reverse
-          (keylist-get-info sign-reverse-list
-                            (opt-val gnc:pagename-display (N_ "Sign Reverses"))
-                            'acct-types))
-         (is-multiline? (eq? (opt-val gnc:pagename-display optname-detail-level) 'multi-line))
-         (export? (opt-val gnc:pagename-general optname-table-export)))
-
-    (define (column-uses? param)
-      (cdr (assq param used-columns)))
-
-    (define left-columns
-      (let* ((add-if (lambda (pred? . items) (if pred? items '())))
-             (left-cols-list
-              (append
-               (add-if (column-uses? 'date)
-                       (vector (_ "Date")
-                               (lambda (split transaction-row?)
-                                 (if transaction-row?
-                                     (gnc:make-html-table-cell/markup
-                                      "date-cell"
-                                      (qof-print-date (xaccTransGetDate (xaccSplitGetParent split))))
-                                     ""))))
-
-               (add-if (column-uses? 'reconciled-date)
-                       (vector (_ "Reconciled Date")
-                               (lambda (split transaction-row?)
-                                 (let ((reconcile-date (split->reconcile-date split)))
-                                   (and reconcile-date
-                                        (gnc:make-html-table-cell/markup
-                                         "date-cell"
-                                         (qof-print-date reconcile-date)))))))
-
-               (add-if (column-uses? 'num)
-                       (vector (if (and BOOK-SPLIT-ACTION
-                                        (opt-val gnc:pagename-display (N_ "Trans Number")))
-                                   (_ "Num/T-Num")
-                                   (_ "Num"))
-                               (lambda (split transaction-row?)
-                                 (let* ((trans (xaccSplitGetParent split))
-                                        (num (gnc-get-num-action trans split))
-                                        (t-num (if (and BOOK-SPLIT-ACTION
-                                                        (opt-val gnc:pagename-display (N_ "Trans Number")))
-                                                   (gnc-get-num-action trans #f)
-                                                   ""))
-                                        (num-string (if (string-null? t-num)
-                                                        num
-                                                        (string-append num "/" t-num))))
-                                   (if transaction-row?
-                                       (gnc:make-html-table-cell/markup "text-cell" num-string)
-                                       "")))))
-
-               (add-if (column-uses? 'description)
-                       (vector (_ "Description")
-                               (lambda (split transaction-row?)
-                                 (define trans (xaccSplitGetParent split))
-                                 (if transaction-row?
-                                     (gnc:make-html-table-cell/markup
-                                      "text-cell"
-                                      (xaccTransGetDescription trans))
-                                     ""))))
-
-               (add-if (column-uses? 'memo)
-                       (vector (if (column-uses? 'notes)
-                                   (string-append (_ "Memo") "/" (_ "Notes"))
-                                   (_ "Memo"))
-                               (lambda (split transaction-row?)
-                                 (define trans (xaccSplitGetParent split))
-                                 (define memo (xaccSplitGetMemo split))
-                                 (if (and (string-null? memo) (column-uses? 'notes))
-                                     (xaccTransGetNotes trans)
-                                     memo))))
-
-               (add-if (or (column-uses? 'account-name) (column-uses? 'account-code))
-                       (vector (_ "Account")
-                               (lambda (split transaction-row?)
-                                 (define account (xaccSplitGetAccount split))
-                                 (account-namestring account
-                                                     (column-uses? 'account-code)
-                                                     (column-uses? 'account-name)
-                                                     (column-uses? 'account-full-name)))))
-
-               (add-if (or (column-uses? 'other-account-name)
-                           (column-uses? 'other-account-code))
-                       (vector (_ "Transfer from/to")
-                               (lambda (split transaction-row?)
-                                 (and (< 1 (xaccTransCountSplits
-                                            (xaccSplitGetParent split)))
-                                      (account-namestring
-                                       (xaccSplitGetAccount
-                                        (xaccSplitGetOtherSplit split))
-                                       (column-uses? 'other-account-code)
-                                       (column-uses? 'other-account-name)
-                                       (column-uses? 'other-account-full-name))))))
-
-               (add-if (column-uses? 'shares)
-                       (vector (_ "Shares")
-                               (lambda (split transaction-row?)
-                                 (gnc:make-html-table-cell/markup
-                                  "number-cell"
-                                  (xaccSplitGetAmount split)))))
-
-               (add-if (column-uses? 'price)
-                       (vector (_ "Price")
-                               (lambda (split transaction-row?)
-                                 ;; share price is retrieved as an exact rational; convert for
-                                 ;; presentation to decimal, rounded to the currency SCU, optionally
-                                 ;; increasing precision by 2 significant digits.
-                                 (let* ((currency (xaccTransGetCurrency (xaccSplitGetParent split)))
-                                        (scu (gnc-commodity-get-fraction currency))
-                                        (price (xaccSplitGetSharePrice split))
-                                        (price-decimal (gnc-numeric-convert price
-                                                                            (if (< scu 10000)
-                                                                                (* scu 100)
-                                                                                scu)
-                                                                            GNC-HOW-RND-ROUND)))
-                                   (gnc:make-html-table-cell/markup
-                                    "number-cell"
-                                    (gnc:make-gnc-monetary currency price-decimal)))))))))
-
-        (if (or (column-uses? 'subtotals-only)
-                (and (null? left-cols-list)
-                     (or (opt-val gnc:pagename-display "Totals")
-                         (primary-get-info 'renderer-fn)
-                         (secondary-get-info 'renderer-fn))))
-            (list (vector "" (lambda (s t) #f)))
-            left-cols-list)))
-
-    ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-    ;;
-    ;; calculated-cells
-    ;;
-    ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-    (define default-calculated-cells
-      (letrec
-          ((split-amount (lambda (s) (if (gnc:split-voided? s)
-                                         (xaccSplitVoidFormerAmount s)
-                                         (xaccSplitGetAmount s))))
-           (split-currency (lambda (s) (xaccAccountGetCommodity (xaccSplitGetAccount s))))
-           (row-currency (lambda (s) (if (column-uses? 'common-currency)
-                                         (opt-val gnc:pagename-general optname-currency)
-                                         (split-currency s))))
-           (friendly-debit (lambda (a) (gnc:get-debit-string (xaccAccountGetType a))))
-           (friendly-credit (lambda (a) (gnc:get-credit-string (xaccAccountGetType a))))
-           (header-commodity (lambda (str)
-                               (string-append
-                                str
-                                (if (column-uses? 'common-currency)
-                                    (format #f " (~a)"
-                                            (gnc-commodity-get-mnemonic
-                                             (opt-val gnc:pagename-general optname-currency)))
-                                    ""))))
-           ;; For conversion to row-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
-           (converted-amount (lambda (s) (gnc:exchange-by-pricedb-nearest
-                                          (gnc:make-gnc-monetary (split-currency s) (split-amount s))
-                                          (row-currency s)
-                                          (time64CanonicalDayTime
-                                           (xaccTransGetDate (xaccSplitGetParent s))))))
-           (converted-debit-amount (lambda (s) (and (positive? (split-amount s))
-                                                    (converted-amount s))))
-           (converted-credit-amount (lambda (s) (and (not (positive? (split-amount s)))
-                                                     (gnc:monetary-neg (converted-amount s)))))
-           (original-amount (lambda (s) (gnc:make-gnc-monetary (split-currency s) (split-amount s))))
-           (original-debit-amount (lambda (s) (and (positive? (split-amount s))
-                                                   (original-amount s))))
-           (original-credit-amount (lambda (s) (and (not (positive? (split-amount s)))
-                                                    (gnc:monetary-neg (original-amount s)))))
-           (running-balance (lambda (s) (gnc:make-gnc-monetary (split-currency s) (xaccSplitGetBalance s)))))
-        (append
-         ;; each column will be a vector
-         ;; (vector heading
-         ;;         calculator-function                          ;; (calculator-function split) to obtain amount
-         ;;         reverse-column?                              ;; #t to allow reverse signs
-         ;;         subtotal?                                    ;; #t to allow subtotals (ie must be #f for running balance)
-         ;;         start-dual-column?                           ;; #t for the debit side of a dual column (i.e. debit/credit)
-         ;;                                                      ;; which means the next column must be the credit side
-         ;;         friendly-heading-fn                          ;; (friendly-heading-fn account) to retrieve friendly name for account debit/credit
-
-         (if (column-uses? 'amount-single)
-             (list (vector (header-commodity (_ "Amount"))
-                           converted-amount #t #t #f
-                           (lambda (a) "")))
-             '())
-
-         (if (column-uses? 'amount-double)
-             (list (vector (header-commodity (_ "Debit"))
-                           converted-debit-amount #f #t #t
-                           friendly-debit)
-                   (vector (header-commodity (_ "Credit"))
-                           converted-credit-amount #f #t #f
-                           friendly-credit))
-             '())
-
-         (if (and (column-uses? 'amount-original-currency)
-                  (column-uses? 'amount-single))
-             (list (vector (_ "Amount")
-                           original-amount #t #t #f
-                           (lambda (a) "")))
-             '())
-
-         (if (and (column-uses? 'amount-original-currency)
-                  (column-uses? 'amount-double))
-             (list (vector (_ "Debit")
-                           original-debit-amount #f #t #t
-                           friendly-debit)
-                   (vector (_ "Credit")
-                           original-credit-amount #f #t #f
-                           friendly-credit))
-             '())
-
-         (if (column-uses? 'running-balance)
-             (list (vector (_ "Running Balance")
-                           running-balance #t #f #f
-                           (lambda (a) "")))
-             '()))))
-
-    (define calculated-cells
-      ;; this part will check whether custom-calculated-cells were specified. this
-      ;; describes a custom function which consumes an options list, and generates
-      ;; a vectorlist similar to default-calculated-cells as above.
-      (if custom-calculated-cells
-          (custom-calculated-cells options)
-          default-calculated-cells))
-
-    (define headings-left-columns
-      (map (lambda (column)
-             (vector-ref column 0))
-           left-columns))
-
-    (define headings-right-columns
-      (map (lambda (column)
-             (vector-ref column 0))
-           calculated-cells))
-
-    (define width-left-columns (length left-columns))
-    (define width-right-columns (length calculated-cells))
-
-    (define primary-indent
-      (if (and (column-uses? 'indenting)
-               (primary-get-info 'renderer-fn))
-          1 0))
-
-    (define secondary-indent
-      (if (and (column-uses? 'indenting)
-               (secondary-get-info 'renderer-fn))
-          1 0))
-
-    (define indent-level
-      (+ primary-indent secondary-indent))
-
-    (define (add-subheading data subheading-style split level)
-      (let* ((sortkey (opt-val pagename-sorting
-                               (case level
-                                 ((primary) optname-prime-sortkey)
-                                 ((secondary) optname-sec-sortkey))))
-             (left-indent (case level
-                            ((primary total) 0)
-                            ((secondary) primary-indent)))
-             (right-indent (- indent-level left-indent)))
-
-        (unless (column-uses? 'subtotals-only)
-          (gnc:html-table-append-row/markup!
-           table subheading-style
-           (append
-            (gnc:html-make-empty-cells left-indent)
-            (if (and (opt-val pagename-sorting optname-show-informal-headers)
-                     (column-uses? 'amount-double)
-                     (member sortkey SORTKEY-INFORMAL-HEADERS))
-                (append
-                 (if export?
-                     (cons
-                      (gnc:make-html-table-cell data)
-                      (gnc:html-make-empty-cells
-                       (+ right-indent width-left-columns -1)))
-                     (list
-                      (gnc:make-html-table-cell/size
-                       1 (+ right-indent width-left-columns) data)))
-                 (map (lambda (cell)
-                        (gnc:make-html-text
-                         (gnc:html-markup-b
-                          ((vector-ref cell 5)
-                           ((keylist-get-info (sortkey-list BOOK-SPLIT-ACTION)
-                                              sortkey 'renderer-fn)
-                            split)))))
-                      calculated-cells))
-                (list
-                 (gnc:make-html-table-cell/size
-                  1 (+ right-indent width-left-columns width-right-columns)
-                  data))))))))
-
-    (define (add-subtotal-row subtotal-string subtotal-collectors subtotal-style level row col)
-      (let* ((left-indent (case level
-                            ((total) 0)
-                            ((primary) primary-indent)
-                            ((secondary) (+ primary-indent secondary-indent))))
-             (right-indent (- indent-level left-indent))
-             (merge-list (map (lambda (cell) (vector-ref cell 4)) calculated-cells))
-             (columns (map (lambda (coll) (coll 'format gnc:make-gnc-monetary #f)) subtotal-collectors))
-             (list-of-commodities (delete-duplicates (map gnc:gnc-monetary-commodity (concatenate columns))
-                                                     gnc-commodity-equal)))
-
-        (define (retrieve-commodity list-of-monetary commodity)
-          (find (lambda (mon) (gnc-commodity-equal commodity (gnc:gnc-monetary-commodity mon)))
-                list-of-monetary))
-
-        (define (first-column string)
-          (if export?
-              (cons
-               (gnc:make-html-table-cell/markup "total-label-cell" string)
-               (gnc:html-make-empty-cells (+ right-indent width-left-columns -1)))
-              (list
-               (gnc:make-html-table-cell/size/markup 1 (+ right-indent width-left-columns) "total-label-cell" string))))
-
-        (define (data-columns commodity)
-          (let loop ((merging? #f)
-                     (last-column #f)
-                     (columns columns)
-                     (merge-list merge-list)
-                     (result '()))
-            (if (null? columns)
-                ;; we've processed all columns. return the (reversed) list of html-table-cells.
-                (reverse result)
-                (let* ((mon (retrieve-commodity (car columns) commodity))
-                       (this-column (and mon (gnc:gnc-monetary-amount mon))))
-                  (cond
-
-                   ;; We're merging. If a subtotal exists, send to next loop iteration.
-                   ((car merge-list)
-                    (loop #t
-                          this-column
-                          (cdr columns)
-                          (cdr merge-list)
-                          result))
-
-                   ;; We're completing merge. Display debit-credit in correct column.
-                   (merging?
-                    (let* ((sum (and (or last-column this-column)
-                                     (- (or last-column 0) (or this-column 0))))
-                           (sum-table-cell (and sum (gnc:make-html-table-cell/markup
-                                                     "total-number-cell"
-                                                     (gnc:make-gnc-monetary
-                                                      commodity (abs sum)))))
-                           (debit-col (and sum (positive? sum) sum-table-cell))
-                           (credit-col (and sum (not (positive? sum)) sum-table-cell)))
-                      (loop #f
-                            #f
-                            (cdr columns)
-                            (cdr merge-list)
-                            (cons* (or credit-col "")
-                                   (or debit-col "")
-                                   result))))
-
-                   ;; Not merging nor completed merge. Just add amount to result.
-                   (else
-                    (loop #f
-                          #f
-                          (cdr columns)
-                          (cdr merge-list)
-                          (cons (gnc:make-html-table-cell/markup "total-number-cell" mon)
-                                result))))))))
-
-        ;; take the first column of each commodity, add onto the subtotal grid
-        (set! grid (grid-add grid row col
-                             (map (lambda (commodity)
-                                    (retrieve-commodity (car columns) commodity))
-                                  list-of-commodities)))
-
-        ;; each commodity subtotal gets a separate line in the html-table
-        ;; each line comprises: indenting, first-column, data-columns
-        (let loop ((first-column-string subtotal-string)
-                   (list-of-commodities list-of-commodities))
-          (unless (null? list-of-commodities)
-            (gnc:html-table-append-row/markup!
-             table subtotal-style
-             (append
-              (gnc:html-make-empty-cells left-indent)
-              (first-column first-column-string)
-              (data-columns (car list-of-commodities))))
-            (loop "" (cdr list-of-commodities))))))
-
-    (define (total-string str) (string-append (_ "Total For ") str))
-
-    ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-    ;; renderers
-
-    ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-    ;; 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))
-               ""))))
-
-    ;; retrieve date renderer from the date-subtotal-list
-    (define (render-date date-subtotal-key split)
-      ((keylist-get-info date-subtotal-list date-subtotal-key 'renderer-fn) split))
-
-    ;; generate account name, optionally with anchor to account register
-    (define (render-account sortkey split anchor?)
-      (let* ((account ((keylist-get-info (sortkey-list BOOK-SPLIT-ACTION) sortkey 'renderer-fn) split))
-             (name (account-namestring account
-                                       (column-uses? 'sort-account-code)
-                                       #t
-                                       (column-uses? 'sort-account-full-name)))
-             (description (if (and (column-uses? 'sort-account-description)
-                                   (not (string-null? (xaccAccountGetDescription account))))
-                              (string-append ": " (xaccAccountGetDescription account))
-                              "")))
-        (if (and anchor? opt-use-links?
-                 (not (null? account))) ;html anchor for 2-split transactions only
-            (gnc:make-html-text
-             (gnc:html-markup-anchor (gnc:account-anchor-text account) name)
-             description)
-            name)))
-
-    ;; generic renderer. retrieve renderer-fn which should return a str
-    (define (render-generic sortkey split)
-      ((keylist-get-info (sortkey-list BOOK-SPLIT-ACTION) sortkey 'renderer-fn) split))
-
-    (define (render-summary split level anchor?)
-      (let ((sortkey (opt-val pagename-sorting
-                              (case level
-                                ((primary) optname-prime-sortkey)
-                                ((secondary) optname-sec-sortkey))))
-            (date-subtotal-key (opt-val pagename-sorting
-                                        (case level
-                                          ((primary) optname-prime-date-subtotal)
-                                          ((secondary) optname-sec-date-subtotal)))))
-        (cond
-         ((member sortkey DATE-SORTING-TYPES)
-          (render-date date-subtotal-key split))
-         ((member sortkey ACCOUNT-SORTING-TYPES)
-          (render-account sortkey split anchor?))
-         (else
-          (render-generic sortkey split)))))
-
-    (define (render-grand-total)
-      (_ "Grand Total"))
-
-    ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-    ;;
-    ;; add-split-row
-    ;;
-    ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-    (define (add-split-row split cell-calculators row-style transaction-row?)
-      (let* ((account (xaccSplitGetAccount split))
-             (reversible-account? (if account-types-to-reverse
-                                      (member (xaccAccountGetType account)
-                                              account-types-to-reverse)
-                                      (gnc-reverse-balance account)))
-             (cells (map (lambda (cell)
-                           (let* ((split->monetary (vector-ref cell 1)))
-                             (vector (split->monetary split)
-                                     (vector-ref cell 2) ;reverse?
-                                     (vector-ref cell 3) ;subtotal?
-                                     )))
-                         cell-calculators)))
-
-        (unless (column-uses? 'subtotals-only)
-          (gnc:html-table-append-row/markup!
-           table row-style
-           (append
-            (gnc:html-make-empty-cells indent-level)
-            (map (lambda (left-col)
-                   ((vector-ref left-col 1)
-                    split transaction-row?))
-                 left-columns)
-            (map (lambda (cell)
-                   (let* ((cell-monetary (vector-ref cell 0))
-                          (reverse? (and (vector-ref cell 1)
-                                         reversible-account?))
-                          (cell-content (and cell-monetary
-                                             (if reverse?
-                                                 (gnc:monetary-neg cell-monetary)
-                                                 cell-monetary))))
-                     (and cell-content
-                          (gnc:make-html-table-cell/markup
-                           "number-cell"
-                           (if opt-use-links?
-                               (gnc:html-split-anchor split cell-content)
-                               cell-content)))))
-                 cells))))
-
-        (map (lambda (cell)
-               (let ((cell-monetary (vector-ref cell 0))
-                     (subtotal? (vector-ref cell 2)))
-                 (and subtotal? cell-monetary)))
-             cells)))
-
-    ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-    ;; do-rows-with-subtotals
-
-    ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-    (define primary-subtotal-collectors
-      (map (lambda (x) (gnc:make-commodity-collector)) calculated-cells))
-
-    (define secondary-subtotal-collectors
-      (map (lambda (x) (gnc:make-commodity-collector)) calculated-cells))
-
-    (define total-collectors
-      (map (lambda (x) (gnc:make-commodity-collector)) calculated-cells))
-
-    (define (do-rows-with-subtotals splits odd-row?)
-      (define primary-subtotal-comparator (primary-get-info 'split-sortvalue))
-      (define secondary-subtotal-comparator (secondary-get-info 'split-sortvalue))
-
-      (gnc:report-percent-done (* 100 (/ work-done work-to-do)))
-
-      (set! work-done (+ 1 work-done))
-
-      (if (null? splits)
-
-          (if (opt-val gnc:pagename-display "Totals")
-              (begin
-                (gnc:html-table-append-row/markup!
-                 table def:grand-total-style
-                 (list
-                  (gnc:make-html-table-cell/size
-                   1 (+ indent-level width-left-columns width-right-columns)
-                   (gnc:make-html-text (gnc:html-markup-hr)))))
-
-                (add-subtotal-row (render-grand-total) total-collectors def:grand-total-style 'total 'row-total 'col-total)))
-
-          (let* ((current (car splits))
-                 (rest (cdr splits))
-                 (next (if (null? rest) #f (car rest)))
-                 (split-values (add-split-row
-                                current
-                                calculated-cells
-                                (if is-multiline? def:normal-row-style
-                                    (if odd-row?
-                                        def:normal-row-style
-                                        def:alternate-row-style))
-                                #t)))
-
-            (if is-multiline?
-                (for-each
-                 (lambda (othersplits)
-                   (add-split-row othersplits calculated-cells def:alternate-row-style #f))
-                 (delete current (xaccTransGetSplitList (xaccSplitGetParent current)))))
-
-            (for-each
-             (lambda (collector value)
-               (if value
-                   (collector 'add (gnc:gnc-monetary-commodity value) (gnc:gnc-monetary-amount value))))
-             primary-subtotal-collectors split-values)
-
-            (for-each
-             (lambda (collector value)
-               (if value
-                   (collector 'add (gnc:gnc-monetary-commodity value) (gnc:gnc-monetary-amount value))))
-             secondary-subtotal-collectors split-values)
-
-            (for-each
-             (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-comparator
-                     (or (not next)
-                         (and next
-                              (not (equal? (primary-subtotal-comparator current)
-                                           (primary-subtotal-comparator next))))))
-
-                (begin
-                  (if secondary-subtotal-comparator
-                      (begin
-                        (add-subtotal-row (total-string
-                                           (render-summary current 'secondary #f))
-                                          secondary-subtotal-collectors
-                                          def:secondary-subtotal-style
-                                          'secondary
-                                          (cons (primary-subtotal-comparator current)
-                                                (render-summary current 'primary #f))
-                                          (cons (secondary-subtotal-comparator current)
-                                                (render-summary current 'secondary #f)))
-                        (for-each (lambda (coll) (coll 'reset #f #f))
-                                  secondary-subtotal-collectors)))
-                  (add-subtotal-row (total-string
-                                     (render-summary current 'primary #f))
-                                    primary-subtotal-collectors
-                                    def:primary-subtotal-style
-                                    'primary
-                                    (cons (primary-subtotal-comparator current)
-                                          (render-summary current 'primary #f))
-                                    'col-total)
-                  (for-each (lambda (coll) (coll 'reset #f #f))
-                            primary-subtotal-collectors)
-                  (if next
-                      (begin
-                        (add-subheading (render-summary next 'primary #t)
-                                        def:primary-subtotal-style next 'primary)
-                        (if secondary-subtotal-comparator
-                            (add-subheading (render-summary next 'secondary #t)
-                                            def:secondary-subtotal-style next 'secondary)))))
-
-                (if (and secondary-subtotal-comparator
-                         (or (not next)
-                             (and next
-                                  (not (equal? (secondary-subtotal-comparator current)
-                                               (secondary-subtotal-comparator next))))))
-                    (begin (add-subtotal-row (total-string
-                                              (render-summary current 'secondary #f))
-                                             secondary-subtotal-collectors
-                                             def:secondary-subtotal-style
-                                             'secondary
-                                             (if primary-subtotal-comparator
-                                                 (cons (primary-subtotal-comparator current)
-                                                       (render-summary current 'primary #f))
-                                                 (cons #f ""))
-                                             (cons (secondary-subtotal-comparator current)
-                                                   (render-summary current 'secondary #f)))
-                           (for-each (lambda (coll) (coll 'reset #f #f))
-                                     secondary-subtotal-collectors)
-                           (if next
-                               (add-subheading (render-summary next 'secondary #t)
-                                               def:secondary-subtotal-style next 'secondary)))))
-
-            (do-rows-with-subtotals rest (not odd-row?)))))
-
-    (define grid (make-grid))
-
-    (gnc:html-table-set-col-headers! table (concatenate (list
-                                                         (gnc:html-make-empty-cells indent-level)
-                                                         headings-left-columns
-                                                         headings-right-columns)))
-
-    (if (primary-get-info 'renderer-fn)
-        (add-subheading (render-summary (car splits) 'primary #t)
-                        def:primary-subtotal-style (car splits) 'primary))
-
-    (if (secondary-get-info 'renderer-fn)
-        (add-subheading (render-summary (car splits) 'secondary #t)
-                        def:secondary-subtotal-style (car splits) 'secondary))
-
-    (do-rows-with-subtotals splits #t)
-
-    (values table
-            grid)))
-
-
-;; grid data structure
-(define (make-grid)
-  '())
-(define (cell-match? cell row col)
-  (and (or (not row) (equal? row (vector-ref cell 0)))
-       (or (not col) (equal? col (vector-ref cell 1)))))
-(define (grid-get grid row col)    ; grid filter - get all row/col - if #f then retrieve whole row/col
-  (filter
-   (lambda (cell) (cell-match? cell row col))
-   grid))
-(define (grid-del grid row col)    ; grid filter - del all row/col - if #f then delete whole row/col - CAREFUL!
-  (filter
-   (lambda (cell)
-     (not (cell-match? cell row col)))
-   grid))
-(define (grid-rows grid)
-  (delete-duplicates (map (lambda (cell) (vector-ref cell 0)) grid)))
-(define (grid-cols grid)
-  (delete-duplicates (map (lambda (cell) (vector-ref cell 1)) grid)))
-(define (grid-add grid row col data)            ;-> misonomer - we don't 'add' to existing data,
-  (set! grid (grid-del grid row col))           ;we simply delete old data stored at row/col and 
-  (set! grid (cons (vector row col data) grid)) ;add again. this is fine because the grid should
-  grid)                                         ;never have duplicate data in the trep.
-(define (grid->html-table grid list-of-rows list-of-cols)
-  (define row-average-enabled? (> (length list-of-cols) 1))
-  (define (monetary-div monetary divisor)
-    (and monetary
-         (let* ((amount (gnc:gnc-monetary-amount monetary))
-                (currency (gnc:gnc-monetary-commodity monetary))
-                (scu (gnc-commodity-get-fraction currency)))
-           (gnc:make-gnc-monetary
-            currency (gnc-numeric-convert (/ amount divisor) scu GNC-HOW-RND-ROUND)))))
-  (define (row->num-of-commodities row)
-    ;; for a row, find the maximum number of commodities being stored
-    (apply max
-           (map (lambda (col)
-                  (let ((cell (grid-get grid row col)))
-                    (if (null? cell) 0
-                        (length (vector-ref (car cell) 2)))))
-                (cons 'col-total list-of-cols))))
-  (define (make-table-cell row col commodity-idx divisor)
-    (let ((cell (grid-get grid row col)))
-      (if (null? cell) ""
-          (gnc:make-html-table-cell/markup "number-cell"
-                                           (monetary-div (list-ref-safe (vector-ref (car cell) 2) commodity-idx) divisor)))))
-  (define (make-row row commodity-idx)
-    (append
-     (list (cond
-            ((positive? commodity-idx) "")
-            ((eq? row 'row-total) (_ "Grand Total"))
-            (else (cdr row))))
-     (map (lambda (col) (make-table-cell row col commodity-idx 1))
-          list-of-cols)
-     (list (make-table-cell row 'col-total commodity-idx 1))
-     (if row-average-enabled?
-         (list (make-table-cell row 'col-total commodity-idx (length list-of-cols)))
-         '())))
-  (let ((table (gnc:make-html-table)))
-    (gnc:html-table-set-caption! table optname-grid)
-    (gnc:html-table-set-col-headers! table (append (list "") (map cdr list-of-cols) (list (_ "Total"))
-                                                   (if row-average-enabled? (list (_ "Average")) '())))
-    (gnc:html-table-set-style! table "th"
-                               'attribute (list "class" "column-heading-right"))
-    (for-each
-     (lambda (row)
-       (for-each (lambda (commodity-idx)
-                   (gnc:html-table-append-row! table (make-row row commodity-idx)))
-                 (iota (row->num-of-commodities row))))
-     (if (memq 'row-total (grid-rows grid))
-         (append list-of-rows '(row-total))
-         list-of-rows))
-    table))
-
-;; ;;;;;;;;;;;;;;;;;;;;
-;; Here comes the renderer function for this report.
-
-
-(define* (trep-renderer report-obj #:key custom-calculated-cells empty-report-message
-                        custom-split-filter split->date split->date-include-false?)
-  ;; the trep-renderer is a define* function which, at minimum, takes the report object
-  ;;
-  ;; the optional arguments are:
-  ;; #:custom-calculated-cells - a list of vectors to define customized data columns
-  ;; #:empty-report-message - a str or html-object which is displayed at the initial report opening
-  ;; #:custom-split-filter - a split->bool function to add to the split filter
-  ;; #:split->date - a split->time64 which overrides the default posted date filter
-  ;;     (see reconcile report)
-  ;; #:split->date-include-false? - addendum to above, specifies filter behaviour if
-  ;;     split->date returns #f. useful to include unreconciled splits in reconcile
-  ;;     report. it can be useful for alternative date filtering, e.g. filter by
-  ;;     transaction->invoice->payment date.
-
-  (define options (gnc:report-options report-obj))
-  (define (opt-val section name) (gnc:option-value (gnc:lookup-option options section name)))
-  (define BOOK-SPLIT-ACTION (qof-book-use-split-action-for-num-field (gnc-get-current-book)))
-
-  (define (is-filter-member split account-list)
-    (let* ((txn (xaccSplitGetParent split))
-           (splitcount (xaccTransCountSplits txn))
-           (other-account (xaccSplitGetAccount (xaccSplitGetOtherSplit split)))
-           (splits-equal? (lambda (s1 s2) (xaccSplitEqual s1 s2 #t #f #f)))
-           (other-splits (delete split (xaccTransGetSplitList txn) splits-equal?))
-           (other-accounts (map xaccSplitGetAccount other-splits))
-           (is-in-account-list? (lambda (acc) (member acc account-list))))
-      (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) (is-in-account-list? other-account))
-        ;; A multi-split transaction - run over all splits
-        ((> splitcount 2) (or-map is-in-account-list? other-accounts))
-        ;; Single transaction splits
-        (else #f))))
-
-  (gnc:report-starting reportname)
-
-  (let* ((document (gnc:make-html-document))
-         (account-matcher (opt-val pagename-filter optname-account-matcher))
-         (account-matcher-regexp (and (opt-val pagename-filter optname-account-matcher-regex)
-                                      (catch 'regular-expression-syntax
-                                        (lambda () (make-regexp account-matcher))
-                                        (const 'invalid-regex))))
-         (c_account_0 (opt-val gnc:pagename-accounts optname-accounts))
-         (c_account_1 (filter
-                       (lambda (acc)
-                         (if (regexp? account-matcher-regexp)
-                             (regexp-exec account-matcher-regexp (gnc-account-get-full-name acc))
-                             (string-contains (gnc-account-get-full-name acc) account-matcher)))
-                       c_account_0))
-         (c_account_2 (opt-val gnc:pagename-accounts optname-filterby))
-         (filter-mode (opt-val gnc:pagename-accounts optname-filtertype))
-         (begindate (gnc:time64-start-day-time
-                     (gnc:date-option-absolute-time
-                      (opt-val gnc:pagename-general optname-startdate))))
-         (enddate (gnc:time64-end-day-time
-                   (gnc:date-option-absolute-time
-                    (opt-val gnc:pagename-general optname-enddate))))
-         (transaction-matcher (opt-val pagename-filter optname-transaction-matcher))
-         (transaction-matcher-regexp (and (opt-val pagename-filter optname-transaction-matcher-regex)
-                                          (catch 'regular-expression-syntax
-                                            (lambda () (make-regexp transaction-matcher))
-                                            (const 'invalid-regex))))
-         (reconcile-status-filter (keylist-get-info reconcile-status-list
-                                                    (opt-val pagename-filter optname-reconcile-status)
-                                                    'filter-types))
-         (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 optname-prime-sortorder))
-         (primary-date-subtotal (opt-val pagename-sorting optname-prime-date-subtotal))
-         (secondary-key (opt-val pagename-sorting optname-sec-sortkey))
-         (secondary-order (opt-val pagename-sorting optname-sec-sortorder))
-         (secondary-date-subtotal (opt-val pagename-sorting optname-sec-date-subtotal))
-         (void-status (opt-val pagename-filter optname-void-transactions))
-         (closing-match (keylist-get-info show-closing-list
-                                          (opt-val pagename-filter optname-closing-transactions)
-                                          'closing-match))
-         (splits '())
-         (custom-sort? (or (and (member primary-key DATE-SORTING-TYPES)   ; this will remain
-                                (not (eq? primary-date-subtotal 'none)))  ; until qof-query
-                           (and (member secondary-key DATE-SORTING-TYPES) ; is upgraded
-                                (not (eq? secondary-date-subtotal 'none)))
-                           (or (CUSTOM-SORTING? primary-key BOOK-SPLIT-ACTION)
-                               (CUSTOM-SORTING? secondary-key BOOK-SPLIT-ACTION))))
-         (subtotal-table? (and (opt-val gnc:pagename-display optname-grid)
-                               (if (memq primary-key DATE-SORTING-TYPES)
-                                   (keylist-get-info date-subtotal-list primary-date-subtotal 'renderer-fn)
-                                   (opt-val pagename-sorting optname-prime-subtotal))
-                               (eq? (opt-val gnc:pagename-display (N_ "Amount")) 'single)))
-         (infobox-display (opt-val gnc:pagename-general optname-infobox-display))
-         (query (qof-query-create-for-splits)))
-
-    (define (generic-less? split-X split-Y sortkey date-subtotal-key ascend?)
-      ;; compare splits X and Y, whereby
-      ;; sortkey and date-subtotal-key specify the options used
-      ;; ascend? specifies whether ascending or descending
-      (let* ((comparator-function
-              (if (memq sortkey DATE-SORTING-TYPES)
-                  (let ((date (keylist-get-info (sortkey-list BOOK-SPLIT-ACTION) sortkey 'split-sortvalue))
-                        (date-comparator (keylist-get-info date-subtotal-list date-subtotal-key 'date-sortvalue)))
-                    (lambda (s)
-                      (and date-comparator
-                           (date-comparator (date s)))))
-                  (or (keylist-get-info (sortkey-list BOOK-SPLIT-ACTION) sortkey 'split-sortvalue)
-                      (lambda (s) #f))))
-             (value-of-X (comparator-function split-X))
-             (value-of-Y (comparator-function split-Y))
-             (op (if (string? value-of-X)
-                     (if ascend? string<? string>?)
-                     (if ascend? < >))))
-        (and value-of-X (op value-of-X value-of-Y))))
-
-    (define (primary-comparator? X Y)
-      (generic-less? X Y primary-key
-                     primary-date-subtotal
-                     (eq? primary-order 'ascend)))
-
-    (define (secondary-comparator? X Y)
-      (generic-less? X Y secondary-key
-                     secondary-date-subtotal
-                     (eq? secondary-order 'ascend)))
-
-    ;; This will, by default, sort the split list by ascending posted-date.
-    (define (date-comparator? X Y)
-      (generic-less? X Y 'date 'none #t))
-
-    (if (or (or (null? c_account_1) (and-map not c_account_1))
-            (eq? account-matcher-regexp 'invalid-regex)
-            (eq? transaction-matcher-regexp 'invalid-regex))
-
-        ;; error condition: no accounts specified or obtained after filtering
-        (begin
-
-          (gnc:html-document-add-object!
-           document
-           (gnc:html-make-no-account-warning
-            report-title (gnc:report-id report-obj)))
-
-          ;; if an empty-report-message is passed by a derived report to
-          ;; the renderer, display it here.
-          (if empty-report-message
-              (gnc:html-document-add-object!
-               document
-               empty-report-message))
-
-          (if (memq infobox-display '(always no-match))
-              (gnc:html-document-add-object!
-               document
-               (gnc:html-render-options-changed options))))
-
-        (begin
-
-          (qof-query-set-book query (gnc-get-current-book))
-          (xaccQueryAddAccountMatch query c_account_1 QOF-GUID-MATCH-ANY QOF-QUERY-AND)
-          (if (not split->date)
-              (xaccQueryAddDateMatchTT query #t begindate #t enddate QOF-QUERY-AND))
-          (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))
-          (if reconcile-status-filter
-              (xaccQueryAddClearedMatch query reconcile-status-filter QOF-QUERY-AND))
-          (if (boolean? closing-match)
-              (xaccQueryAddClosingTransMatch query closing-match QOF-QUERY-AND))
-          (if (not custom-sort?)
-              (begin
-                (qof-query-set-sort-order query
-                                          (keylist-get-info (sortkey-list BOOK-SPLIT-ACTION) primary-key 'sortkey)
-                                          (keylist-get-info (sortkey-list BOOK-SPLIT-ACTION) secondary-key 'sortkey)
-                                          '())
-                (qof-query-set-sort-increasing query
-                                               (eq? primary-order 'ascend)
-                                               (eq? secondary-order 'ascend)
-                                               #t)))
-
-          (if (opt-val "__trep" "unique-transactions")
-              (set! splits (xaccQueryGetSplitsUniqueTrans query))
-              (set! splits (qof-query-run query)))
-
-          (qof-query-destroy query)
-
-          ;; Combined Filter:
-          ;; - include/exclude using split->date according to date options
-          ;; - include/exclude splits to/from selected accounts
-          ;; - substring/regex matcher for Transaction Description/Notes/Memo
-          ;; - custom-split-filter, a split->bool function for derived reports
-          (set! splits (filter
-                        (lambda (split)
-                          (let* ((trans (xaccSplitGetParent split))
-                                 (match? (lambda (str)
-                                           (if transaction-matcher-regexp
-                                               (regexp-exec transaction-matcher-regexp str)
-                                               (string-contains str transaction-matcher)))))
-                            (and (or (not split->date)                  ; #f = ignore custom date filter
-                                     (let ((date (split->date split)))  ; cache split->date time64 or #f.
-                                       (if date                         ; if a split->date exists,
-                                           (<= begindate date enddate)  ; then check for inclusion;
-                                           split->date-include-false?))); else behave according to parameter
-                                 (case filter-mode
-                                   ((none) #t)
-                                   ((include) (is-filter-member split c_account_2))
-                                   ((exclude) (not (is-filter-member split c_account_2))))
-                                 (or (string-null? transaction-matcher) ; null-string = ignore filters
-                                     (match? (xaccTransGetDescription trans))
-                                     (match? (xaccTransGetNotes trans))
-                                     (match? (xaccSplitGetMemo split)))
-                                 (or (not custom-split-filter)     ; #f = ignore custom-split-filter
-                                     (custom-split-filter split))
-                                 )))
-                        splits))
-
-          (when custom-sort?
-            (set! splits (stable-sort! splits date-comparator?))
-            (set! splits (stable-sort! splits secondary-comparator?))
-            (set! splits (stable-sort! splits primary-comparator?)))
-
-          (if (null? splits)
-
-              ;; error condition: no splits found
-              (begin
-
-                (gnc:html-document-add-object!
-                 document
-                 (gnc:html-make-generic-warning
-                  report-title (gnc:report-id report-obj)
-                  NO-MATCHING-TRANS-HEADER NO-MATCHING-TRANS-TEXT))
-
-                (if (memq infobox-display '(always no-match))
-                    (gnc:html-document-add-object!
-                     document
-                     (gnc:html-render-options-changed options))))
-
-              (let-values (((table grid) (make-split-table splits options custom-calculated-cells)))
-
-                (gnc:html-document-set-title! document report-title)
-
-                (gnc:html-document-add-object!
-                 document
-                 (gnc:make-html-text
-                  (gnc:html-markup-h3
-                   (format #f
-                            (_ "From ~a to ~a")
-                            (qof-print-date begindate)
-                            (qof-print-date enddate)))))
-
-                (if (eq? infobox-display 'always)
-                    (gnc:html-document-add-object!
-                     document
-                     (gnc:html-render-options-changed options)))
-
-                (if subtotal-table?
-                    (let* ((generic<? (lambda (a b)
-                                        (cond ((string? (car a)) (string<? (car a) (car b)))
-                                              ((number? (car a)) (< (car a) (car b)))
-                                              (else (gnc:error "unknown sortvalue")))))
-                           (list-of-rows (stable-sort! (delete 'row-total (grid-rows grid)) generic<?))
-                           (list-of-cols (stable-sort! (delete 'col-total (grid-cols grid)) generic<?)))
-                      (gnc:html-document-add-object!
-                       document (grid->html-table grid list-of-rows list-of-cols))))
-
-                (unless (and subtotal-table?
-                             (opt-val pagename-sorting optname-show-subtotals-only))
-                  (gnc:html-document-add-object! document table))))))
-
-    (gnc:report-finished)
-
-    document))
-
-(define trep-guid "2fe3b9833af044abb929a88d5a59620f")
-(export trep-guid)
-(export trep-renderer)
-(export trep-options-generator)
-
-;; Define the report.
-(gnc:define-report
- 'version 1
- 'name (_ "Reconciliation Report")
- 'report-guid "e45218c6d76f11e7b5ef0800277ef320"
- 'options-generator reconcile-report-options-generator
- ;; the renderer is the same as trep, however we're using a different split-date strategy.
- ;; we're comparing reconcile date for inclusion, and if split is unreconciled, include it anyway.
- 'renderer (lambda (rpt) (trep-renderer rpt
-                                        #:custom-calculated-cells reconcile-report-calculated-cells
-                                        #:split->date split->reconcile-date
-                                        #:split->date-include-false? #t
-                                        #:empty-report-message reconcile-report-instructions)))
-
-;; Define the report.
 (gnc:define-report
  'version 1
- 'name reportname
- 'report-guid trep-guid
- 'options-generator trep-options-generator
- 'renderer trep-renderer)
+ 'name (N_ "Transaction Report")
+ 'report-guid "2fe3b9833af044abb929a88d5a59620f"
+ 'options-generator gnc:trep-options-generator
+ 'renderer gnc:trep-renderer)
diff --git a/po/POTFILES.in b/po/POTFILES.in
index f090c8fad..a4cabf716 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -462,6 +462,7 @@ gnucash/report/report-system/report-collectors.scm
 gnucash/report/report-system/report.scm
 gnucash/report/report-system/report-system.scm
 gnucash/report/report-system/report-utilities.scm
+gnucash/report/report-system/trep-engine.scm
 gnucash/report/standard-reports/account-piecharts.scm
 gnucash/report/standard-reports/account-summary.scm
 gnucash/report/standard-reports/advanced-portfolio.scm

commit 14b325593310492fe652b4ba2c2ae8929a8e9d70
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Fri Apr 26 22:36:08 2019 +0800

    [reconcile-report] pull reconcile-report into separate file

diff --git a/gnucash/report/standard-reports/CMakeLists.txt b/gnucash/report/standard-reports/CMakeLists.txt
index af94b30cb..429e7a43f 100644
--- a/gnucash/report/standard-reports/CMakeLists.txt
+++ b/gnucash/report/standard-reports/CMakeLists.txt
@@ -27,6 +27,7 @@ set (standard_reports_SCHEME_2
     net-charts.scm
     portfolio.scm
     price-scatter.scm
+    reconcile-report.scm
     register.scm
     sx-summary.scm
     transaction.scm
diff --git a/gnucash/report/standard-reports/reconcile-report.scm b/gnucash/report/standard-reports/reconcile-report.scm
new file mode 100644
index 000000000..fc5eb8b23
--- /dev/null
+++ b/gnucash/report/standard-reports/reconcile-report.scm
@@ -0,0 +1,109 @@
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; reconcile-report.scm : Reconciliation report
+;;
+;; calls functions defined in trep-engine.scm with defaults suitable
+;; for a reconciliation report including alternative date filtering
+;; strategy
+;;
+;; 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 reconcile-report))
+
+(use-modules (gnucash gettext))
+(use-modules (gnucash gnc-module))
+(gnc:module-load "gnucash/report/report-system" 0)
+
+(define (reconcile-report-options-generator)
+  (let ((options (gnc:trep-options-generator)))
+    (gnc:option-set-value
+     (gnc:lookup-option options "Sorting" "Primary Key") 'reconciled-status)
+    (gnc:option-set-value
+     (gnc:lookup-option options "Sorting" "Secondary Key")   'date)
+    (gnc:option-set-value
+     (gnc:lookup-option options "Sorting" "Secondary Subtotal for Date Key") 'none)
+    (gnc:option-set-value
+     (gnc:lookup-option options gnc:pagename-general "Start Date")
+     (cons 'relative 'start-prev-quarter))
+    (gnc:option-set-value
+     (gnc:lookup-option options gnc:pagename-general "End Date")
+     (cons 'relative 'today))
+    (gnc:option-set-value
+     (gnc:lookup-option options gnc:pagename-display "Reconciled Date") #t)
+    (gnc:option-set-value
+     (gnc:lookup-option options gnc:pagename-display "Running Balance") #f)
+    (gnc:option-set-value
+     (gnc:lookup-option options gnc:pagename-display "Memo") #f)
+    (gnc:option-make-internal! options gnc:pagename-display "Running Balance")
+    options))
+
+(define reconcile-report-instructions
+  (gnc:make-html-text
+   (_ "The reconcile report is designed to be similar to the formal \
+reconciliation tool.  Please select the account from Report \
+Options. Please note the dates specified in the options will apply \
+to the Reconciliation Date.")
+   (gnc:html-markup-br)
+   (gnc:html-markup-br)))
+
+(define (split->reconcile-date split)
+  (and (char=? (xaccSplitGetReconcile split) #\y)
+       (xaccSplitGetDateReconciled split)))
+
+(define (reconcile-report-calculated-cells options)
+  (letrec
+      ((split-amount (lambda (s)
+                       (if (gnc:split-voided? s)
+                           (xaccSplitVoidFormerAmount s)
+                           (xaccSplitGetAmount s))))
+       (split-currency (compose xaccAccountGetCommodity xaccSplitGetAccount))
+       (amount (lambda (s)
+                 (gnc:make-gnc-monetary (split-currency s) (split-amount s))))
+       (debit-amount (lambda (s)
+                       (and (positive? (split-amount s))
+                            (amount s))))
+       (credit-amount (lambda (s)
+                        (and (not (positive? (split-amount s)))
+                             (gnc:monetary-neg (amount s))))))
+    ;; similar to default-calculated-cells but disable dual-subtotals.
+    (list (vector (_ "Funds In")
+                  debit-amount #f #t #f
+                  (const ""))
+          (vector (_ "Funds Out")
+                  credit-amount #f #t #f
+                  (const "")))))
+
+(define (reconcile-report-renderer rpt)
+  (gnc:trep-renderer
+   rpt
+   #:custom-calculated-cells reconcile-report-calculated-cells
+   #:split->date split->reconcile-date
+   #:split->date-include-false? #t
+   #:empty-report-message reconcile-report-instructions))
+
+(gnc:define-report
+ 'version 1
+ 'name (_ "Reconciliation Report")
+ 'report-guid "e45218c6d76f11e7b5ef0800277ef320"
+ 'options-generator reconcile-report-options-generator
+ ;; the renderer is the same as trep, however we're using a different
+ ;; split-date strategy.  we're comparing reconcile date for
+ ;; inclusion, and if split is unreconciled, include it anyway.
+ 'renderer reconcile-report-renderer)
+
diff --git a/gnucash/report/standard-reports/test/test-transaction.scm b/gnucash/report/standard-reports/test/test-transaction.scm
index f2a24e1f1..31a791caa 100644
--- a/gnucash/report/standard-reports/test/test-transaction.scm
+++ b/gnucash/report/standard-reports/test/test-transaction.scm
@@ -2,6 +2,7 @@
 (gnc:module-begin-syntax (gnc:module-load "gnucash/app-utils" 0))
 (use-modules (gnucash engine test test-extras))
 (use-modules (gnucash report standard-reports transaction))
+(use-modules (gnucash report standard-reports reconcile-report))
 (use-modules (gnucash report stylesheets))
 (use-modules (gnucash report report-system))
 (use-modules (gnucash report report-system test test-extras))
@@ -890,9 +891,8 @@
 
 
     (let* ((options (default-testing-options)))
-      (let ((sxml (options->sxml options "null test")))
-        (test-assert "sxml"
-          sxml))
+      (test-assert "reconcile-report basic run"
+        (options->sxml options "null test"))
       (set-option! options "General" "Start Date" (cons 'absolute (gnc-dmy2time64 01 03 1970)))
       (set-option! options "General" "End Date" (cons 'absolute (gnc-dmy2time64 31 03 1970)))
       (let ((sxml (options->sxml options "filter reconcile date")))
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 742e71a18..f090c8fad 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -485,6 +485,7 @@ gnucash/report/standard-reports/income-statement.scm
 gnucash/report/standard-reports/net-charts.scm
 gnucash/report/standard-reports/portfolio.scm
 gnucash/report/standard-reports/price-scatter.scm
+gnucash/report/standard-reports/reconcile-report.scm
 gnucash/report/standard-reports/register.scm
 gnucash/report/standard-reports/standard-reports.scm
 gnucash/report/standard-reports/sx-summary.scm

commit 29416292a939b8354226aff2bd4a4395ea3c9859
Author: Mike Evans <mikee at saxicola.co.uk>
Date:   Wed May 1 11:46:42 2019 +0100

    Remove FIX ME
    
    Since it works fine and I can't remember why I put it in.

diff --git a/bindings/python/gnucash_core.py b/bindings/python/gnucash_core.py
index 38415abe8..80dcbf678 100644
--- a/bindings/python/gnucash_core.py
+++ b/bindings/python/gnucash_core.py
@@ -239,7 +239,7 @@ class Book(GnuCashCoreClass):
 
     def InvoiceNextID(self, customer):
       ''' Return the next invoice ID.
-      This works but I'm not entirely happy with it.  FIX ME'''
+      '''
       from gnucash.gnucash_core_c import gncInvoiceNextID
       return gncInvoiceNextID(self.get_instance(),customer.GetEndOwner().get_instance()[1])
 

commit c28196fb066b61ca63eab96406d4c84e20a45720
Author: Mike Evans <mikee at saxicola.co.uk>
Date:   Wed Apr 17 11:46:52 2019 +0100

    Fix indents,

diff --git a/gnucash/gnome/dialog-invoice.c b/gnucash/gnome/dialog-invoice.c
index d939167ee..610f71372 100644
--- a/gnucash/gnome/dialog-invoice.c
+++ b/gnucash/gnome/dialog-invoice.c
@@ -760,12 +760,12 @@ gnc_dialog_post_invoice(InvoiceWindow *iw, char *message,
     *ddue = *postdate;
     *memo = NULL;
     {
-    GncGUID *guid = NULL;
-    owner_inst = qofOwnerGetOwner (gncOwnerGetEndOwner (&(iw->owner)));
-    qof_instance_get (owner_inst,
-              "invoice-last-posted-account", &guid,
-              NULL);
-    *acc = xaccAccountLookup (guid, iw->book);
+        GncGUID *guid = NULL;
+        owner_inst = qofOwnerGetOwner (gncOwnerGetEndOwner (&(iw->owner)));
+        qof_instance_get (owner_inst,
+                  "invoice-last-posted-account", &guid,
+                  NULL);
+        *acc = xaccAccountLookup (guid, iw->book);
     }
     /* Get the default for the accumulate option */
     *accumulate = gnc_prefs_get_bool(GNC_PREFS_GROUP_INVOICE, GNC_PREF_ACCUM_SPLITS);
@@ -957,12 +957,12 @@ gnc_invoice_post(InvoiceWindow *iw, struct post_invoice_params *post_params)
      */
     owner_inst = qofOwnerGetOwner (gncOwnerGetEndOwner (&(iw->owner)));
     {
-    const GncGUID *guid = qof_instance_get_guid (QOF_INSTANCE (acc));
-    qof_begin_edit (owner_inst);
-    qof_instance_set (owner_inst,
-              "invoice-last-posted-account", guid,
-              NULL);
-    qof_commit_edit (owner_inst);
+        const GncGUID *guid = qof_instance_get_guid (QOF_INSTANCE (acc));
+        qof_begin_edit (owner_inst);
+        qof_instance_set (owner_inst,
+                  "invoice-last-posted-account", guid,
+                  NULL);
+        qof_commit_edit (owner_inst);
     }
 
     /* ... post it ... */

commit 126dc3a79088fbb5a376afb0f7f08bd2f1a8bccb
Author: Mike Evans <mikee at saxicola.co.uk>
Date:   Sun Apr 14 14:13:25 2019 +0100

    Bug-797168 Proposed fix.

diff --git a/gnucash/gnome/dialog-invoice.c b/gnucash/gnome/dialog-invoice.c
index 49094daad..d939167ee 100644
--- a/gnucash/gnome/dialog-invoice.c
+++ b/gnucash/gnome/dialog-invoice.c
@@ -760,12 +760,12 @@ gnc_dialog_post_invoice(InvoiceWindow *iw, char *message,
     *ddue = *postdate;
     *memo = NULL;
     {
-	GncGUID *guid = NULL;
-	owner_inst = qofOwnerGetOwner (gncOwnerGetEndOwner (&(iw->owner)));
-	qof_instance_get (owner_inst,
-			  "invoice-last-posted-account", &guid,
-			  NULL);
-	*acc = xaccAccountLookup (guid, iw->book);
+    GncGUID *guid = NULL;
+    owner_inst = qofOwnerGetOwner (gncOwnerGetEndOwner (&(iw->owner)));
+    qof_instance_get (owner_inst,
+              "invoice-last-posted-account", &guid,
+              NULL);
+    *acc = xaccAccountLookup (guid, iw->book);
     }
     /* Get the default for the accumulate option */
     *accumulate = gnc_prefs_get_bool(GNC_PREFS_GROUP_INVOICE, GNC_PREF_ACCUM_SPLITS);
@@ -957,12 +957,12 @@ gnc_invoice_post(InvoiceWindow *iw, struct post_invoice_params *post_params)
      */
     owner_inst = qofOwnerGetOwner (gncOwnerGetEndOwner (&(iw->owner)));
     {
-	const GncGUID *guid = qof_instance_get_guid (QOF_INSTANCE (acc));
-	qof_begin_edit (owner_inst);
-	qof_instance_set (owner_inst,
-			  "invoice-last-posted-account", guid,
-			  NULL);
-	qof_commit_edit (owner_inst);
+    const GncGUID *guid = qof_instance_get_guid (QOF_INSTANCE (acc));
+    qof_begin_edit (owner_inst);
+    qof_instance_set (owner_inst,
+              "invoice-last-posted-account", guid,
+              NULL);
+    qof_commit_edit (owner_inst);
     }
 
     /* ... post it ... */
@@ -1931,10 +1931,22 @@ gnc_invoice_update_window (InvoiceWindow *iw, GtkWidget *widget)
         //    GtkWidget *hide;
 
         /* Setup viewer for read-only access */
-        /*
+        gtk_widget_set_sensitive (acct_entry, FALSE);
         gtk_widget_set_sensitive (iw->id_entry, FALSE);
         gtk_widget_set_sensitive (iw->terms_menu, FALSE);
-        gtk_widget_set_sensitive (iw->notes_text, FALSE); *//* XXX: should notes remain writable? */
+        gtk_widget_set_sensitive (iw->owner_box, FALSE);
+        gtk_widget_set_sensitive (iw->job_box, FALSE);
+        gtk_widget_set_sensitive (iw->billing_id_entry, FALSE);
+        gtk_widget_set_sensitive (iw->notes_text, FALSE); /* XXX: should notes remain writable?*/
+    }
+    else           /* ! posted */
+    {
+        gtk_widget_set_sensitive (acct_entry, TRUE);
+        gtk_widget_set_sensitive (iw->terms_menu, TRUE);
+        gtk_widget_set_sensitive (iw->owner_box, TRUE);
+        gtk_widget_set_sensitive (iw->job_box, TRUE);
+        gtk_widget_set_sensitive (iw->billing_id_entry, TRUE);
+        gtk_widget_set_sensitive (iw->notes_text, TRUE);
     }
 
     if (widget)
@@ -2351,6 +2363,8 @@ gnc_invoice_create_page (InvoiceWindow *iw, gpointer page)
     /* Make the opened and posted dates insensitive in this window */
     gtk_widget_set_sensitive (iw->opened_date, FALSE);
     gtk_widget_set_sensitive (iw->posted_date, FALSE);
+    /* Also the invoice ID */
+    gtk_widget_set_sensitive (iw->id_entry, FALSE);
 
     /* Build the ledger */
     ledger_type = GNCENTRY_INVOICE_VIEWER;
@@ -3344,7 +3358,7 @@ gnc_invoice_show_docs_due (GtkWindow *parent, QofBook *book, double days_in_adva
     if (param_list == NULL)
     {
         /* Translators: This abbreviation is the column heading for
-	   the condition "Is this invoice a Credit Note?" */
+       the condition "Is this invoice a Credit Note?" */
         param_list = gnc_search_param_prepend (param_list, _("CN?"), NULL, type,
                                                INVOICE_IS_CN, NULL);
         param_list = gnc_search_param_prepend (param_list, _("Amount"), NULL, type,

commit bfbb89f6e28c3cb904a89201cae234af20184577
Author: John Ralls <jralls at ceridwen.us>
Date:   Tue Apr 30 15:00:06 2019 -0700

    Rewire and corrected Doxygen comment for gnc_get_locale() c++ function.
    
    There's no point in going through the cache dance on MinGW, that will
    just throw.

diff --git a/libgnucash/core-utils/gnc-locale-utils.cpp b/libgnucash/core-utils/gnc-locale-utils.cpp
index 28678c4e2..b7928e618 100644
--- a/libgnucash/core-utils/gnc-locale-utils.cpp
+++ b/libgnucash/core-utils/gnc-locale-utils.cpp
@@ -27,51 +27,48 @@ extern "C"
 #include <boost/locale.hpp>
 #include "gnc-locale-utils.hpp"
 
-/* This function addresses two separate problems: First, if we set
- * std::locale::global then all streams automagically imbue
- * themselves with it and we have to re-imbue all of the backends and
- * logging streams with std::locale::classic() so that data and log
- * files aren't localized. Second, calling std::locale("") is slow,
- * so we want to do it only once. Worse, the standard C++ library in
- * Mingw64 chokes on at least some Microsoft-style locale strings
- * (e.g. "Spanish_Spain") but libc's setlocale(LC_ALL, NULL) emits
- * them even if originally fed a Unix-style locale ("es_ES").
+/** Cache the UI locale
  *
- * The solution is this function which caches the setlocale() locale
- * the first time it's called and which uses a boost::locale
- * generator, which does know what to do with (sometimes adjusted)
- * Microsoft locale strings.
+ * We don't want to set the default locale because we need
+ * std::locale::classic for consistency in stored data. We also don't
+ * want to call std::locale("") more than once, it's slow... and we
+ * don't want to call it on MinGW32 at all because that supports only
+ * std::locale::classic and throws if you try to construct anything
+ * else. Boost::locale doesn't support std::locale::facet required by
+ * boost::datetime (go figure).
+ *
+ * @return a copy of std::locale::classic() on MinGW32 and a copy of
+ * the cached result of std::locale("") otherwise.
  */
 const std::locale&
 gnc_get_locale()
 {
-  static std::locale cached;
-  static bool tried_already = false;
-  if (!tried_already)
-  {
-    boost::locale::generator gen;
-    tried_already = true;
-      try
-      {
-	cached = std::locale("");
-      }
-      catch (const std::runtime_error& err)
-      {
 #ifdef __MINGW32__
-	  char* locale = g_win32_getlocale();
+    return std::locale::classic(); // Nothing else supported.
 #else
-	  char* locale = g_strdup(setlocale(LC_ALL, ""));
-#endif
+    static std::locale cached;
+    static bool tried_already = false;
+    if (!tried_already)
+    {
+	tried_already = true;
+	try
+	{
+	    cached = std::locale("");
+	}
+	catch (const std::runtime_error& err)
+	{
+	    char* locale = g_strdup(setlocale(LC_ALL, ""));
 
-	  g_log(G_LOG_DOMAIN, G_LOG_LEVEL_WARNING,
-		"Failed to create C++ default locale from"
-		"%s because %s. Using the 'C' locale for C++.",
-		locale, err.what());
-	  g_free(locale);
-	  cached = std::locale::classic();
-      }
-  }
-  return cached;
+	    g_log(G_LOG_DOMAIN, G_LOG_LEVEL_WARNING,
+		  "Failed to create C++ default locale from"
+		  "%s because %s. Using the 'C' locale for C++.",
+		  locale, err.what());
+	    g_free(locale);
+	    cached = std::locale::classic();
+	}
+    }
+    return cached;
+#endif
 }
 
 

commit 529a6cb06735b21528c8cee0a76f7d396c678078
Author: John Ralls <jralls at ceridwen.us>
Date:   Tue Apr 30 14:56:43 2019 -0700

    Call setlocale(LC_ALL, "") exactly once.
    
    And in Windows only with the value from the environment if there is one.
    Calling it with "" in Windows ignores the environment and sets it to the
    system settings.

diff --git a/gnucash/gnucash-bin.c b/gnucash/gnucash-bin.c
index a0df6f675..757c24f86 100644
--- a/gnucash/gnucash-bin.c
+++ b/gnucash/gnucash-bin.c
@@ -102,7 +102,7 @@ static const char  *add_quotes_file  = NULL;
 static char        *namespace_regexp = NULL;
 static const char  *file_to_load     = NULL;
 static gchar      **args_remaining   = NULL;
-static     gchar *sys_locale = NULL;
+static gchar       *sys_locale       = NULL;
 
 static GOptionEntry options[] =
 {
@@ -617,23 +617,7 @@ inner_main (void *closure, int argc, char **argv)
 
     main_mod = scm_c_resolve_module("gnucash utilities");
     scm_set_current_module(main_mod);
-#ifdef __MINGW32__
-    /* Guile initialization calls setlocale(LC_ALL, "") which on
-     * windows resets the locale to what the user has set in the
-     * registry. Put it back to what we set from the environment or
-     * environment file.
-     */
-    if (sys_locale)
-    {
-	setlocale (LC_ALL, sys_locale);
-	g_free (sys_locale);
-	sys_locale = NULL;
-    }
-    else
-    {
-	setlocale (LC_ALL, "C");
-    }
-#endif
+
     /* Check whether the settings need a version update */
     gnc_gsettings_version_upgrade ();
 
@@ -927,12 +911,9 @@ main(int argc, char ** argv)
      * To be on the safe side, only do this if not on OS X,
      * to avoid unintentionally messing up the locale settings */
     PINFO ("System locale returned %s", sys_locale ? sys_locale : "(null)");
-    PINFO ("Effective locale set to %s.", setlocale (LC_ALL, ""));
-#ifndef __MINGW32__
-    /* We need it for later on Windows, see inner_main(). */
+    PINFO ("Effective locale set to %s.", setlocale (LC_ALL, NULL));
     g_free (sys_locale);
     sys_locale = NULL;
-#endif
 #endif
 
     /* If asked via a command line parameter, fetch quotes only */
diff --git a/libgnucash/scm/utilities.scm b/libgnucash/scm/utilities.scm
index 76b09ba51..99e561c8a 100644
--- a/libgnucash/scm/utilities.scm
+++ b/libgnucash/scm/utilities.scm
@@ -50,12 +50,6 @@
 (read-enable 'positions)
 (debug-set! stack    200000)
 
-;; Initalialize localization, otherwise reports may output
-;; invalid characters
-(setlocale LC_ALL "")
-
-;;;; Status output functions.
-
 (define (strify items)
   (string-join (map (lambda (x) (format #f "~A" x)) items) ""))
 

commit d30cf25c456beefb2dd735958cf47da35dd9d237
Author: John Ralls <jralls at ceridwen.us>
Date:   Tue Apr 30 14:53:46 2019 -0700

    Call setlocale() with the right form of locale code on Windows.
    
    Perversely Windows uses the form xx-YY for its own localization
    functions but xx_YY for the posix ones including setlocale().

diff --git a/gnucash/gnucash-bin.c b/gnucash/gnucash-bin.c
index ed1261e4c..a0df6f675 100644
--- a/gnucash/gnucash-bin.c
+++ b/gnucash/gnucash-bin.c
@@ -792,12 +792,10 @@ set_win32_thread_locale()
 	if (IsValidLocaleName(wlocale))
 	{
 	    LCID lcid = LocaleNameToLCID(wlocale, LOCALE_ALLOW_NEUTRAL_NAMES);
-	    printf ("win32_thread_locale setting %s from unix environment.\n",
-		    locale);
 	    SetThreadLocale(lcid);
+	    locale[2] = '_';
 	    setlocale (LC_ALL, locale);
 	    sys_locale = locale;
-	    g_free(locale);
 	    g_free(wlocale);
 	    return;
 	}
@@ -900,8 +898,6 @@ main(int argc, char ** argv)
         g_setenv ("LC_ALL", "C", TRUE);
         setlocale (LC_ALL, "C");
       }
-    else
-      printf ("Locale set to %s\n", sys_locale);
 #ifdef HAVE_GETTEXT
     {
         gchar *localedir = gnc_path_get_localedir();

commit 114efe593614b5d38f8b9fdd6a70704bae946e94
Author: John Ralls <jralls at ceridwen.us>
Date:   Mon Apr 29 14:58:56 2019 -0700

    Transcode non-constant strings before passing them to scm_eval_string.
    
    Instead of using scm_c_eval_string, which transcodes with
    scm_from_locale_string. That doesn't work on Windows.

diff --git a/gnucash/report/report-gnome/gnc-plugin-page-report.c b/gnucash/report/report-gnome/gnc-plugin-page-report.c
index 2ff828e1e..be2997629 100644
--- a/gnucash/report/report-gnome/gnc-plugin-page-report.c
+++ b/gnucash/report/report-gnome/gnc-plugin-page-report.c
@@ -932,8 +932,7 @@ gnc_plugin_page_report_recreate_page (GtkWidget *window,
             LEAVE("bad value");
             return NULL;
         }
-
-        scm_id = scm_c_eval_string(option_string);
+        scm_id = scm_eval_string(scm_from_utf8_string(option_string));
         g_free(option_string);
 
         if (!scm_integer_p(scm_id))
diff --git a/libgnucash/app-utils/gnc-gsettings.c b/libgnucash/app-utils/gnc-gsettings.c
index d2f0fc69d..9c144aa7c 100644
--- a/libgnucash/app-utils/gnc-gsettings.c
+++ b/libgnucash/app-utils/gnc-gsettings.c
@@ -809,7 +809,7 @@ static void gnc_gsettings_migrate_from_gconf (void)
     command = g_strconcat ("(use-modules (migrate-prefs))(migration-prepare \"",
                            base_dir, "\")", NULL);
     DEBUG ("command = %s", command);
-    migration_ok = scm_is_true (scm_c_eval_string (command));
+    migration_ok = scm_is_true (scm_eval_string (scm_from_utf8_string (command)));
     g_free (command);
     if (!migration_ok)
     {
@@ -867,7 +867,7 @@ static void gnc_gsettings_migrate_from_gconf (void)
     command = g_strconcat ("(use-modules (migrate-prefs))(migration-cleanup \"",
                            base_dir, "\")", NULL);
     DEBUG ("command = %s", command);
-    migration_ok = scm_is_true (scm_c_eval_string (command));
+    migration_ok = scm_is_true (scm_eval_string (scm_from_utf8_string (command)));
     g_free (command);
     if (!migration_ok) /* Cleanup step failed, not critical */
         PWARN ("Cleanup step failed. You may need to delete %s/.gnc-migration-tmp manually.", base_dir);
diff --git a/libgnucash/app-utils/test/test-scm-query-string.cpp b/libgnucash/app-utils/test/test-scm-query-string.cpp
index b9f2a82e3..e7d381641 100644
--- a/libgnucash/app-utils/test/test-scm-query-string.cpp
+++ b/libgnucash/app-utils/test/test-scm-query-string.cpp
@@ -55,7 +55,7 @@ test_query (Query *q, SCM val2str)
     str2 = gnc_scm_to_utf8_string (str_q);
     if (str2)
     {
-        res_q = scm_c_eval_string (str2);
+        res_q = scm_eval_string (str_q);
     }
     else
     {

commit 1c1fa36023395ab6f69ba312de652a1841d96c3b
Author: Frank H. Ellenberger <frank.h.ellenberger at gmail.com>
Date:   Mon Apr 29 23:16:03 2019 +0200

    de.po: update PO-Revision-Date
    
    Follow up of commit 6b10c2f

diff --git a/po/de.po b/po/de.po
index 60d097c63..afa010464 100644
--- a/po/de.po
+++ b/po/de.po
@@ -24,7 +24,7 @@ msgstr ""
 "Report-Msgid-Bugs-To: https://bugs.gnucash.org/enter_bug.cgi?"
 "product=GnuCash&component=Translations\n"
 "POT-Creation-Date: 2019-04-08 17:37+0200\n"
-"PO-Revision-Date: 2019-04-20 18:18+0200\n"
+"PO-Revision-Date: 2019-04-29 23:15+0200\n"
 "Last-Translator: Christian Stimming <christian at cstimming.de>\n"
 "Language-Team: GnuCash-de <gnucash-de at gnucash.org>\n"
 "Language: de\n"

commit 6b10c2f28492bf2c9926d79f20e9ab90694549f3
Author: pianoslum <pianoslum at mailbox.org>
Date:   Mon Apr 29 21:36:25 2019 +0200

    Fix small typo in German translation

diff --git a/po/de.po b/po/de.po
index 8ce19ce5b..60d097c63 100644
--- a/po/de.po
+++ b/po/de.po
@@ -20003,7 +20003,7 @@ msgstr ""
 
 #: gnucash/import-export/csv-imp/gnc-import-tx.cpp:478
 msgid "Please select a description column."
-msgstr "Bitte wählen Sie eine Beschreibunsspalte."
+msgstr "Bitte wählen Sie eine Beschreibungsspalte."
 
 #: gnucash/import-export/csv-imp/gnc-import-tx.cpp:484
 msgid "Please select a deposit or withdrawal column."

commit a711497130cfa212483bfae49b543d2d32be7f5c
Author: John Ralls <jralls at ceridwen.us>
Date:   Sun Apr 28 21:53:56 2019 -0700

    Fix Travis failure.
    
    Maybe. Can't reproduce it so trying something that looks reasonable.

diff --git a/gnucash/gnucash-bin.c b/gnucash/gnucash-bin.c
index 659f17381..ed1261e4c 100644
--- a/gnucash/gnucash-bin.c
+++ b/gnucash/gnucash-bin.c
@@ -824,7 +824,7 @@ set_win32_thread_locale()
 static void
 redirect_stdout (void)
 {
-#ifdef __MINGW32__ && __MSWIN_CONSOLE__
+#if defined __MINGW32__ && __MSWIN_CONSOLE__
     static const WORD MAX_CONSOLE_LINES = 500;
    int hConHandle;
     long lStdHandle;

commit e42c81134158c30a31cef8727bc44c9b46e746d7
Author: John Ralls <jralls at ceridwen.us>
Date:   Sun Apr 28 14:33:46 2019 -0700

    Make TreeView toggle-buttons not activatable if no toggle callback.
    
    So that it's clear in the UI that clicking on the box won't do anything.
    The case that triggered this is the Get-online-quotes item in the
    Securities Editor tree view.

diff --git a/gnucash/gnome-utils/gnc-tree-view.c b/gnucash/gnome-utils/gnc-tree-view.c
index e1aa9ef46..6498c91f4 100644
--- a/gnucash/gnome-utils/gnc-tree-view.c
+++ b/gnucash/gnome-utils/gnc-tree-view.c
@@ -1723,6 +1723,10 @@ gnc_tree_view_add_toggle_column (GncTreeView *view,
     g_return_val_if_fail (GNC_IS_TREE_VIEW(view), NULL);
 
     renderer = gtk_cell_renderer_toggle_new ();
+    if (!toggle_edited_cb)
+    {
+        gtk_cell_renderer_toggle_set_activatable (GTK_CELL_RENDERER_TOGGLE (renderer), FALSE);
+    }
     column =
         gtk_tree_view_column_new_with_attributes (column_short_title,
                 renderer,

commit 3feb864691cf855f0fcd0240731eb05206ec2254
Author: John Ralls <jralls at ceridwen.us>
Date:   Sun Apr 28 16:59:51 2019 -0700

    Add an optionally-compiled diagnostic console on Windows.

diff --git a/gnucash/gnucash-bin.c b/gnucash/gnucash-bin.c
index 3278d3ae6..659f17381 100644
--- a/gnucash/gnucash-bin.c
+++ b/gnucash/gnucash-bin.c
@@ -58,11 +58,17 @@
 #include "guile-mappings.h"
 #ifdef __MINGW32__
 #include <Windows.h>
+#include <fcntl.h>
 #endif
 
 /* This static indicates the debugging module that this .o belongs to.  */
 static QofLogModule log_module = GNC_MOD_GUI;
 
+/* Change the following to have a console window attached to GnuCash
+ * for displaying stdout and stderr on Windows.
+ */
+#define __MSWIN_CONSOLE__ 0
+
 #ifdef HAVE_GETTEXT
 #  include <libintl.h>
 #  include <locale.h>
@@ -809,6 +815,53 @@ set_win32_thread_locale()
 }
 #endif
 
+/* Creates a console window on MSWindows to display stdout and stderr
+ * when __MSWIN_CONSOLE__ is defined at the top of the file.
+ *
+ * Useful for displaying the diagnostics printed before logging is
+ * started and if logging is redirected with --logto=stderr.
+ */
+static void
+redirect_stdout (void)
+{
+#ifdef __MINGW32__ && __MSWIN_CONSOLE__
+    static const WORD MAX_CONSOLE_LINES = 500;
+   int hConHandle;
+    long lStdHandle;
+    CONSOLE_SCREEN_BUFFER_INFO coninfo;
+    FILE *fp;
+
+    // allocate a console for this app
+    AllocConsole();
+
+    // set the screen buffer to be big enough to let us scroll text
+    GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &coninfo);
+    coninfo.dwSize.Y = MAX_CONSOLE_LINES;
+    SetConsoleScreenBufferSize(GetStdHandle(STD_OUTPUT_HANDLE), coninfo.dwSize);
+
+    // redirect unbuffered STDOUT to the console
+    lStdHandle = (long)GetStdHandle(STD_OUTPUT_HANDLE);
+    hConHandle = _open_osfhandle(lStdHandle, _O_TEXT);
+    fp = _fdopen( hConHandle, "w" );
+    *stdout = *fp;
+    setvbuf( stdout, NULL, _IONBF, 0 );
+
+    // redirect unbuffered STDIN to the console
+    lStdHandle = (long)GetStdHandle(STD_INPUT_HANDLE);
+    hConHandle = _open_osfhandle(lStdHandle, _O_TEXT);
+    fp = _fdopen( hConHandle, "r" );
+    *stdin = *fp;
+    setvbuf( stdin, NULL, _IONBF, 0 );
+
+    // redirect unbuffered STDERR to the console
+    lStdHandle = (long)GetStdHandle(STD_ERROR_HANDLE);
+    hConHandle = _open_osfhandle(lStdHandle, _O_TEXT);
+    fp = _fdopen( hConHandle, "w" );
+    *stderr = *fp;
+    setvbuf( stderr, NULL, _IONBF, 0 );
+#endif
+}
+
 int
 main(int argc, char ** argv)
 {
@@ -825,6 +878,7 @@ main(int argc, char ** argv)
         }
     }
 #endif
+    redirect_stdout ();
 
     /* This should be called before gettext is initialized
      * The user may have configured a different language via
@@ -846,7 +900,8 @@ main(int argc, char ** argv)
         g_setenv ("LC_ALL", "C", TRUE);
         setlocale (LC_ALL, "C");
       }
-#endif
+    else
+      printf ("Locale set to %s\n", sys_locale);
 #ifdef HAVE_GETTEXT
     {
         gchar *localedir = gnc_path_get_localedir();

commit 6c7ccbd9e77fd377c8eae97323fbdadd77d3192f
Author: John Ralls <jralls at ceridwen.us>
Date:   Sun Apr 28 16:34:58 2019 -0700

    Bug 797134 - Decimal separator: Windows configured as dot,...
    
    Gnucash shows comma.
    
    This was introduced by 8f88b7f2b. It turns out that Windows
    implementation of setlocale works only if the POSIX locale environment
    variables (i.e. LC_FOO or LANG) are set, otherwise it returns NULL. We
    were unknowingly relying on Guile to retrieve the Windows environment
    for us and that would do the wrong thing if the user had set the locale
    in the environment file, so 8f88b7f2b restored it... unfortunately to
    the C locale.
    
    This commit changes the set_win32_thread_locale function to work in
    both directions, setting both locales from the environment variables
    if any are set and calling setlocale with the result of
    GetUserDefaultLocaleName if not.

diff --git a/gnucash/gnucash-bin.c b/gnucash/gnucash-bin.c
index 12866092f..3278d3ae6 100644
--- a/gnucash/gnucash-bin.c
+++ b/gnucash/gnucash-bin.c
@@ -763,31 +763,49 @@ gnc_log_init()
 }
 
 #ifdef __MINGW32__
-/* Set the Win32 internal localization for the main thread if the
- * locale has been overridden in the environment. Note that this is
- * separate from what setlocale() does; that only affects POSIX
- * functions and does *not* set the Windows locale.
+/* If one of the Unix locale variables LC_ALL, LC_MESSAGES, or LANG is
+ * set in the environment check to see if it's a valid locale and if
+ * it is set both the Windows and POSIX locales to that. If not
+ * retrieve the Windows locale and set POSIX to match.
  */
 static void
 set_win32_thread_locale()
 {
-    gunichar2* wlocale = NULL;
+    WCHAR lpLocaleName[LOCALE_NAME_MAX_LENGTH];
     char *locale = NULL;
-    int len = 0;
-    if (((locale = getenv ("LC_ALL")) == NULL || locale[0] == '\0')
-      && ((locale = getenv ("LC_MESSAGES")) == NULL || locale[0] == '\0')
-      && ((locale = getenv ("LANG")) == NULL || locale[0] == '\0'))
-	return;
-    len = strchr(locale, '.') - locale;
-    locale[2] = '-';
-    wlocale = g_utf8_to_utf16 (locale, len, NULL, NULL, NULL);
-    if (IsValidLocaleName(wlocale))
+
+    if (((locale = getenv ("LC_ALL")) != NULL && locale[0] != '\0') ||
+      ((locale = getenv ("LC_MESSAGES")) != NULL && locale[0] != '\0') ||
+      ((locale = getenv ("LANG")) != NULL && locale[0] != '\0'))
+    {
+	gunichar2* wlocale = NULL;
+	int len = 0;
+	len = strchr(locale, '.') - locale;
+	locale[2] = '-';
+	wlocale = g_utf8_to_utf16 (locale, len, NULL, NULL, NULL);
+	if (IsValidLocaleName(wlocale))
+	{
+	    LCID lcid = LocaleNameToLCID(wlocale, LOCALE_ALLOW_NEUTRAL_NAMES);
+	    printf ("win32_thread_locale setting %s from unix environment.\n",
+		    locale);
+	    SetThreadLocale(lcid);
+	    setlocale (LC_ALL, locale);
+	    sys_locale = locale;
+	    g_free(locale);
+	    g_free(wlocale);
+	    return;
+	}
+	g_free(locale);
+	g_free(wlocale);
+    }
+    if (GetUserDefaultLocaleName(lpLocaleName, LOCALE_NAME_MAX_LENGTH))
     {
-	LCID lcid = LocaleNameToLCID(wlocale, LOCALE_ALLOW_NEUTRAL_NAMES);
-	SetThreadLocale(lcid);
+	sys_locale = g_utf16_to_utf8((gunichar2*)lpLocaleName,
+				     LOCALE_NAME_MAX_LENGTH,
+				     NULL, NULL, NULL);
+	setlocale (LC_ALL, sys_locale);
+	return;
     }
-    g_free(locale);
-    g_free(wlocale);
 }
 #endif
 
@@ -814,12 +832,12 @@ main(int argc, char ** argv)
      */
 #ifdef MAC_INTEGRATION
     set_mac_locale();
+#elif defined __MINGW32__
+    set_win32_thread_locale();
 #endif
     gnc_environment_setup();
-#ifndef MAC_INTEGRATION /* setlocale already done */
+#if ! defined MAC_INTEGRATION && ! defined __MINGW32__/* setlocale already done */
     sys_locale = g_strdup (setlocale (LC_ALL, ""));
-#ifdef __MINGW32__
-    set_win32_thread_locale();
 #endif
     if (!sys_locale)
       {



Summary of changes:
 CMakeLists.txt                                     |   27 +-
 README.dependencies                                |    2 +-
 bindings/python/gnucash_core.py                    |    2 +-
 common/config.h.cmake.in                           |    9 -
 gnucash/gnome-utils/assistant-xml-encoding.c       |   11 +-
 gnucash/gnome-utils/gnc-tree-view-price.c          |   46 +-
 gnucash/gnome-utils/gnc-tree-view-price.h          |   13 +
 gnucash/gnome-utils/gnc-tree-view.c                |    4 +
 gnucash/gnome-utils/gnome-utils.scm                |    8 +-
 gnucash/gnome/assistant-acct-period.c              |   10 +-
 gnucash/gnome/dialog-invoice.c                     |   73 +-
 gnucash/gnome/dialog-order.c                       |    6 -
 gnucash/gnome/dialog-price-edit-db.c               |   42 +-
 gnucash/gnome/dialog-price-editor.c                |   39 +-
 gnucash/gnucash-bin.c                              |  163 +-
 ...g.gnucash.dialogs.import.generic.gschema.xml.in |   11 +
 .../org.gnucash.dialogs.import.qif.gschema.xml.in  |   11 +
 .../gtkbuilder/assistant-csv-account-import.glade  |    6 +-
 .../gtkbuilder/assistant-csv-price-import.glade    |    8 +-
 .../gtkbuilder/assistant-csv-trans-import.glade    |   13 +-
 gnucash/gtkbuilder/assistant-qif-import.glade      |   95 +-
 gnucash/gtkbuilder/assistant-stock-split.glade     |    4 +-
 gnucash/gtkbuilder/business-prefs.glade            |  262 +--
 gnucash/gtkbuilder/dialog-account-picker.glade     |   46 +-
 gnucash/gtkbuilder/dialog-import.glade             |  144 +-
 gnucash/gtkbuilder/dialog-invoice.glade            | 1162 +++++-----
 gnucash/gtkbuilder/dialog-job.glade                |  295 ++-
 gnucash/gtkbuilder/dialog-order.glade              |  616 ++----
 gnucash/gtkbuilder/dialog-preferences.glade        |  167 +-
 gnucash/gtkbuilder/dialog-totd.glade               |   16 +-
 .../import-export/aqb/assistant-ab-initial.glade   |  163 +-
 gnucash/import-export/aqb/dialog-ab-daterange.c    |    2 +-
 gnucash/import-export/aqb/dialog-ab.glade          | 1068 ++++-----
 gnucash/import-export/aqb/gnc-gwen-gui.c           |   19 +-
 .../import-export/csv-exp/assistant-csv-export.c   |   33 +-
 .../csv-imp/assistant-csv-account-import.c         |   14 +-
 .../csv-imp/assistant-csv-price-import.cpp         |    8 +-
 .../csv-imp/assistant-csv-trans-import.cpp         |   10 +-
 gnucash/import-export/import-account-matcher.c     |  258 +--
 gnucash/import-export/import-account-matcher.h     |   38 +-
 .../import-export/qif-imp/assistant-qif-import.c   | 2258 +++++++++++---------
 .../import-export/qif-imp/dialog-account-picker.c  |   85 +-
 gnucash/python/init.py                             |    7 +-
 gnucash/register/register-gnome/gnucash-style.c    |    2 +-
 gnucash/report/locale-specific/us/taxtxf.scm       |  116 +-
 .../report-gnome/dialog-report-style-sheet.c       |    2 +-
 .../report/report-gnome/gnc-plugin-page-report.c   |    3 +-
 gnucash/report/report-gnome/report-gnome.scm       |  107 +-
 gnucash/report/report-system/CMakeLists.txt        |    1 +
 .../report/report-system/commodity-utilities.scm   |  851 ++++----
 gnucash/report/report-system/report-system.scm     |    6 +
 gnucash/report/report-system/report.scm            |    1 +
 .../report-system/test/test-commodity-utils.scm    |   24 +-
 .../trep-engine.scm}                               | 1606 +++++++-------
 gnucash/report/standard-reports/CMakeLists.txt     |    2 +
 gnucash/report/standard-reports/balsheet-pnl.scm   | 1268 +++++++++++
 gnucash/report/standard-reports/general-ledger.scm |    3 +-
 .../standard-reports/income-gst-statement.scm      |   91 +-
 .../report/standard-reports/reconcile-report.scm   |  109 +
 .../standard-reports/test/test-transaction.scm     |    6 +-
 gnucash/report/standard-reports/transaction.scm    | 2086 +-----------------
 gnucash/report/stylesheets/stylesheet-easy.scm     |  244 +--
 gnucash/report/stylesheets/stylesheet-fancy.scm    |  248 +--
 gnucash/report/stylesheets/stylesheet-footer.scm   |  251 +--
 .../report/stylesheets/stylesheet-head-or-tail.scm |  430 ++--
 gnucash/report/stylesheets/stylesheet-plain.scm    |  178 +-
 gnucash/report/stylesheets/stylesheets.scm         |    4 +-
 libgnucash/app-utils/gnc-gsettings.c               |    4 +-
 libgnucash/app-utils/options.scm                   |    8 +-
 .../app-utils/test/test-scm-query-string.cpp       |    2 +-
 libgnucash/core-utils/gnc-locale-utils.cpp         |   71 +-
 libgnucash/engine/gnc-int128.cpp                   |   56 +-
 libgnucash/engine/gnc-numeric.cpp                  |    2 +-
 libgnucash/engine/gnc-rational-rounding.hpp        |   71 +-
 libgnucash/engine/test/gtest-gnc-int128.cpp        |   28 +-
 libgnucash/engine/test/gtest-gnc-numeric.cpp       |    2 +-
 libgnucash/engine/test/utest-gnc-pricedb.c         |    2 +-
 libgnucash/quotes/gnc-fq-helper.in                 |    2 +-
 libgnucash/scm/price-quotes.scm                    |    8 +-
 libgnucash/scm/test/CMakeLists.txt                 |    1 +
 libgnucash/scm/utilities.scm                       |    6 -
 po/POTFILES.in                                     |    3 +
 po/de.po                                           |    5 +-
 83 files changed, 7106 insertions(+), 8078 deletions(-)
 copy gnucash/report/{standard-reports/transaction.scm => report-system/trep-engine.scm} (55%)
 create mode 100644 gnucash/report/standard-reports/balsheet-pnl.scm
 create mode 100644 gnucash/report/standard-reports/reconcile-report.scm



More information about the gnucash-changes mailing list