gnucash master: Multiple changes pushed

Geert Janssens gjanssens at code.gnucash.org
Thu Feb 6 11:10:48 EST 2020


Updated	 via  https://github.com/Gnucash/gnucash/commit/74c00731 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/ab5b7155 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/301db902 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/90e95ba8 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/7f794bb2 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/e523d528 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/a0fb7d3b (commit)
	 via  https://github.com/Gnucash/gnucash/commit/4f624087 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/e79e82ed (commit)
	 via  https://github.com/Gnucash/gnucash/commit/8365283f (commit)
	 via  https://github.com/Gnucash/gnucash/commit/bb986e47 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/c94b4331 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/ad094f43 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/dafff689 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/b0b6f2c6 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/a456c8a3 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/f1667e7b (commit)
	 via  https://github.com/Gnucash/gnucash/commit/a44bd34d (commit)
	 via  https://github.com/Gnucash/gnucash/commit/1e0983d0 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/0c5bded6 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/97eb3c7e (commit)
	 via  https://github.com/Gnucash/gnucash/commit/77c2bc2b (commit)
	 via  https://github.com/Gnucash/gnucash/commit/f59e3ca7 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/34609184 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/ec7e6c37 (commit)
	from  https://github.com/Gnucash/gnucash/commit/62c2203d (commit)



commit 74c007312ee4b89617503fdc8089da0e0acee65f
Author: Geert Janssens <geert at kobaltwit.be>
Date:   Thu Feb 6 17:10:18 2020 +0100

    Update lot-viewer report for master's guile refactoring

diff --git a/gnucash/report/reports/standard/lot-viewer.scm b/gnucash/report/reports/standard/lot-viewer.scm
index 515c69bbb..71b84a704 100644
--- a/gnucash/report/reports/standard/lot-viewer.scm
+++ b/gnucash/report/reports/standard/lot-viewer.scm
@@ -25,12 +25,10 @@
 (use-modules (srfi srfi-11))            ;for let-values
 (use-modules (ice-9 match))
 (use-modules (gnucash utilities))
-(use-modules (gnucash gnc-module))
-(use-modules (gnucash report business-reports))
-(use-modules (gnucash gettext))
-(use-modules (sw_core_utils))           ;for gnc-prefs-is-extra-enabled
+(use-modules (gnucash report))
+(use-modules (gnucash core-utils))           ;for gnc-prefs-is-extra-enabled
+(use-modules (gnucash engine))
 
-(gnc:module-load "gnucash/report/report-system" 0)
 
 (define reportname (N_ "Lot Viewer"))
 (define optname-from-date (N_ "Start Date"))

commit ab5b7155af2fccbbc725d67aed2ba585b1213433
Author: Geert Janssens <geert at kobaltwit.be>
Date:   Thu Feb 6 17:01:26 2020 +0100

    CMake - remove parameter repetition in else() and endif() statements
    
    Fix leftovers after the maint branch merge

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 28bc04584..e11c233b4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -526,7 +526,7 @@ else()
 endif()
 if (NOT HAVE_BOOST)
 message (SEND_ERROR "A suitable Boost is not installed, and is required. GnuCash requires that Boost be compatible and compiled with C++17. Boost 1.67 is the first compatible release but some distributions have patched earlier ones to work with C++17. Please install it and ensure that the following libraries are built: date_time, filesystem, locale, and regex.")
-endif ()
+endif()
 
 
 # Compiler flags
diff --git a/bindings/guile/CMakeLists.txt b/bindings/guile/CMakeLists.txt
index 0dca2e680..dcb0b7872 100644
--- a/bindings/guile/CMakeLists.txt
+++ b/bindings/guile/CMakeLists.txt
@@ -96,7 +96,7 @@ set (engine_SCHEME_2
 set(BACKEND_DEPENDS gncmod-backend-xml)
 if (WITH_SQL)
     list(APPEND BACKEND_DEPENDS gncmod-backend-dbi)
-endif(WITH_SQL)
+endif()
 
 set(GUILE_DEPENDS
   ${BACKEND_DEPENDS}
diff --git a/bindings/guile/test/CMakeLists.txt b/bindings/guile/test/CMakeLists.txt
index 41485785b..45e77bfbd 100644
--- a/bindings/guile/test/CMakeLists.txt
+++ b/bindings/guile/test/CMakeLists.txt
@@ -82,7 +82,7 @@ if (HAVE_SRFI64)
 
     gnc_add_scheme_tests("${scm_tests_with_srfi64_SOURCES}")
     add_dependencies(check scm-srfi64-extras)
-endif (HAVE_SRFI64)
+endif()
 
 
 set(test_scm_SCHEME
@@ -109,7 +109,7 @@ if (HAVE_SRFI64)
 
   gnc_add_scheme_tests("${test_scm_SCHEME}")
 
-endif (HAVE_SRFI64)
+endif()
 
 set(test_engine_SCHEME_DIST
     srfi64-extras.scm
diff --git a/gnucash/report/test/CMakeLists.txt b/gnucash/report/test/CMakeLists.txt
index f26142bc6..27fbdea0b 100644
--- a/gnucash/report/test/CMakeLists.txt
+++ b/gnucash/report/test/CMakeLists.txt
@@ -46,7 +46,7 @@ if (HAVE_SRFI64)
     )
 
   gnc_add_scheme_tests ("${scm_test_report_with_srfi64_SOURCES}")
-endif (HAVE_SRFI64)
+endif()
 
 gnc_add_scheme_test_targets(scm-test-report
   "test-report-extras.scm"
diff --git a/libgnucash/core-utils/CMakeLists.txt b/libgnucash/core-utils/CMakeLists.txt
index 7461b0729..d2ceff6a9 100644
--- a/libgnucash/core-utils/CMakeLists.txt
+++ b/libgnucash/core-utils/CMakeLists.txt
@@ -113,9 +113,9 @@ add_custom_target(gnc-vcs-info ALL
                              -D SHELL="${SHELL}"
                              -P ${CMAKE_SOURCE_DIR}/cmake/git2version-info.cmake
 )
-else(BUILDING_FROM_VCS)
+else()
   add_custom_target(gnc-vcs-info DEPENDS ${VCS_INFO_FILE})
-endif(BUILDING_FROM_VCS)
+endif()
 dist_add_generated (${BUILDING_FROM_VCS} gnc-vcs-info.h)
 
 # Dist files

commit 301db9020d65c4c8ec9109e53dd65a3c3ac42470
Merge: 62c2203d4 90e95ba8e
Author: Geert Janssens <geert at kobaltwit.be>
Date:   Thu Feb 6 16:50:08 2020 +0100

    Merge branch 'maint'

diff --cc CMakeLists.txt
index 7ff607d6e,07b71d945..28bc04584
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@@ -177,15 -183,18 +177,15 @@@ if (WIN32
    #set(LIBXSLT_XSLTPROC_EXECUTABLE ${CMAKE_PREFIX_PATH}/libxslt/bin/xsltproc)
  #Prevent creating a console window on startup.
    set(CMAKE_EXE_LINKER_FLAGS -mwindows)
- endif(WIN32)
+ endif()
  
 +find_package(Threads REQUIRED)
  find_package(PkgConfig REQUIRED)
  
  if (NOT PKG_CONFIG_FOUND)
     message (SEND_ERROR "pkg-config not found, but is required")
-  endif (NOT PKG_CONFIG_FOUND)
+  endif()
  
 -if (CMAKE_VERSION VERSION_LESS 3.6)
 -  include(GncPkgConfig)
 -endif()
 -
  # glib et al.
  pkg_check_modules (GLIB2 REQUIRED glib-2.0>=2.40)
  pkg_check_modules (GIO REQUIRED gio-2.0)
@@@ -197,22 -206,43 +197,22 @@@ pkg_check_modules (LIBXML2 REQUIRED lib
  pkg_check_modules (LIBXSLT REQUIRED libxslt)
  if (WITH_GNUCASH)
    if (WIN32 OR APPLE)
 -    if (NOT CMAKE_VERSION VERSION_LESS 3.6)
 -      pkg_check_modules (WEBKIT REQUIRED IMPORTED_TARGET webkitgtk-3.0)
 -    else()
 -      pkg_check_modules (WEBKIT REQUIRED webkitgtk-3.0)
 -      _pkg_create_imp_target(WEBKIT)
 -    endif()
 +    pkg_check_modules (WEBKIT REQUIRED IMPORTED_TARGET webkitgtk-3.0)
      set(WEBKIT1 1 CACHE INTERNAL "WebKitGtk")
-   else (WIN32 OR APPLE)
+   else()
 -    If (NOT CMAKE_VERSION VERSION_LESS 3.6)
 -      pkg_check_modules (WEBKIT IMPORTED_TARGET webkit2gtk-4.0)
 -    else()
 -      pkg_check_modules (WEBKIT webkit2gtk-4.0)
 -    endif()
 +    pkg_check_modules (WEBKIT IMPORTED_TARGET webkit2gtk-4.0)
      if (NOT WEBKIT_FOUND)
 -      if (NOT CMAKE_VERSION VERSION_LESS 3.6)
 -        pkg_check_modules (WEBKIT REQUIRED IMPORTED_TARGET webkit2gtk-3.0)
 -      else()
 -        pkg_check_modules (WEBKIT REQUIRED webkit2gtk-3.0)
 -      endif()
 +      pkg_check_modules (WEBKIT REQUIRED IMPORTED_TARGET webkit2gtk-3.0)
        set(WEBKIT2_3 1 CACHE INTERNAL "WebKit2Gtk3")
-     else (NOT WEBKIT_FOUND)
+     else()
        if (NOT WEBKIT2_3)
          set(WEBKIT2_4 1 CACHE INTERNAL "WebKit2Gtk4")
-       endif(NOT WEBKIT2_3)
-     endif (NOT WEBKIT_FOUND)
-   endif (WIN32 OR APPLE)
+       endif()
+     endif()
 -    if (CMAKE_VERSION VERSION_LESS 3.6)
 -      _pkg_create_imp_target(WEBKIT)
 -    endif()
+   endif()
  
 -  if (NOT CMAKE_VERSION VERSION_LESS 3.6)
 -    pkg_check_modules (GTK3 REQUIRED IMPORTED_TARGET gtk+-3.0>=3.10.0)
 -  else()
 -    pkg_check_modules (GTK3 REQUIRED gtk+-3.0>=3.10.0)
 -    _pkg_create_imp_target(GTK3)
 -  endif()
 +  pkg_check_modules (GTK3 REQUIRED IMPORTED_TARGET gtk+-3.0>=3.18.0)
- endif (WITH_GNUCASH)
+ endif()
  
  pkg_check_modules (ZLIB REQUIRED zlib)
  
@@@ -239,7 -269,28 +239,7 @@@ find_path (REGEX_INCLUDE_PATH NAMES reg
  find_library (REGEX_LIBRARY NAMES regex)
  
  # I18N
- find_package (Gettext 0.19.6 REQUIRED)
 -if (ALLOW_OLD_GETTEXT)
 -    find_package (Gettext REQUIRED)
 -else()
 -    find_package (Gettext 0.20)
 -    if (NOT GETTEXT_FOUND)
 -        message (FATAL_ERROR "Note the build can be configured with an older version of gettext by setting ALLOW_OLD_GETTEXT=ON but then some files will not be translated:
 -        - gnucash.desktop (requires at least gettext 0.19)
 -        - gnucash.appdata.xml (requires at least gettext 0.19.6)
 -        - tag developer_name from gnucash.appdata.xml (requires at least gettext 0.20)")
 -    endif()
 -endif()
 -
 -if (${GETTEXT_VERSION_STRING} VERSION_LESS 0.19)
 -    message (WARNING "Got gettext version ${GETTEXT_VERSION_STRING}, however you need at least gettext version 0.19 in order to handle translation of the gnucash.desktop file. The build will be configured with an untranslated gnucash.desktop file.")
 -endif()
 -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()
 -if (${GETTEXT_VERSION_STRING} VERSION_LESS 0.20)
 -    message (WARNING "Got gettext version ${GETTEXT_VERSION_STRING}, however you need at least gettext version 0.20 in order to handle the translation of 'GnuCash Project' from the gnucash.appdata file. That message will be missing in gnucash.pot.")
 -endif()
 -
++find_package (Gettext 0.20 REQUIRED)
  find_path (LIBINTL_INCLUDE_PATH NAMES libintl.h
  		  PATHS /usr/include /opt/gnome/include)
  find_library (LIBINTL_LIBRARY NAMES intl)
@@@ -320,11 -373,8 +320,11 @@@ execute_process (COMMAND ${GUILE_EXECUT
  if (GNC_TEXT_PORTS_RESULT EQUAL 0)
    message (STATUS "Using guile textual-ports")
    set (HAVE_TEXT_PORTS TRUE)
- endif ()
+ endif()
  
 +# Determine where to install our guile modules libraries.
 +find_guile_dirs()
 +
  # ############################################################
  if (WITH_AQBANKING)
    pkg_check_modules (GWENHYWFAR REQUIRED gwenhywfar>=4.9.99)
@@@ -509,24 -551,9 +509,24 @@@ find_package (Boost 1.67.0 COMPONENTS d
  if (Boost_FOUND)
    include_directories(${Boost_INCLUDE_DIRS})
    set(HAVE_BOOST 1)
- else ()
+ else()
 -  message (SEND_ERROR "Boost 1.54.0 or later is not installed, and is required. Please install it and ensure that the following libraries are built: chrono, date_time, filesystem, log, program_options, regex, signals, system, and test.")
 +  find_package (Boost 1.60.0 REQUIRED COMPONENTS date_time regex locale filesystem system)
 +  if (Boost_FOUND)
 +    include (CheckIncludeFileCXX)
 +    set(CMAKE_REQUIRED_FLAGS "-std=c++17")
 +    set(CMAKE_REQUIRED_INCLUDES ${Boost_INCLUDE_DIR})
 +    check_include_file_cxx("boost/locale.hpp" AUTO_PTR)
 +    unset(CMAKE_REQUIRED_FLAGS)
 +    unset(CMAKE_REQUIRED_INCLUDES)
 +    if(AUTO_PTR)
 +      include_directories(${Boost_INCLUDE_DIRS})
 +      set(HAVE_BOOST 1)
 +    endif()
 +  endif()
  endif()
 +if (NOT HAVE_BOOST)
 +message (SEND_ERROR "A suitable Boost is not installed, and is required. GnuCash requires that Boost be compatible and compiled with C++17. Boost 1.67 is the first compatible release but some distributions have patched earlier ones to work with C++17. Please install it and ensure that the following libraries are built: date_time, filesystem, locale, and regex.")
 +endif ()
  
  
  # Compiler flags
@@@ -554,11 -588,11 +554,11 @@@ if (UNIX
    set( CMAKE_CXX_FLAGS "-Werror -Wall -Wmissing-declarations -Wno-unused -Wno-error=parentheses ${CMAKE_CXX_FLAGS}")
    set( CMAKE_CXX_FLAGS "-Wno-error=deprecated-declarations ${REGISTER_CXXFLAG} ${CMAKE_CXX_FLAGS}")
    set( CMAKE_C_FLAGS_RELEASE "-O3 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 ${CMAKE_C_FLAGS}")
- endif (UNIX)
+ endif()
  if (MINGW)
 -  set( CMAKE_C_FLAGS "-Werror -Wdeclaration-after-statement -Wno-pointer-sign -Wall -Wunused -Wmissing-prototypes -Wmissing-declarations  -Wno-unused -Wno-error=deprecated-declarations -std=gnu11 ${CMAKE_C_FLAGS}")
 +  set( CMAKE_C_FLAGS "-Werror -Wdeclaration-after-statement -Wno-pointer-sign -Wall -Wunused -Wmissing-prototypes -Wmissing-declarations  -Wno-unused -Wno-error=deprecated-declarations ${CMAKE_C_FLAGS}")
    set( CMAKE_CXX_FLAGS "-DWINVER=0x0500 -D_EMULATE_GLIBC=0 ${CMAKE_CXX_FLAGS}") # Workaround for bug in gtest on mingw, see https://github.com/google/googletest/issues/893 and https://github.com/google/googletest/issues/920
- endif (MINGW)
+ endif()
  
  if (APPLE AND WITH_GNUCASH)
    set(CMAKE_MACOSX_RPATH ON)
@@@ -729,9 -763,9 +729,9 @@@ set(GNC_PLATFORM_DARWIN 1
  set(GNC_PLATFORM_OSX 1)
  set(PLATFORM_OSX 1)
  set(HAVE_OSX_KEYCHAIN 1)
- endif(APPLE)
+ endif()
  
 -if(GLIB2_VERSION VERSION_GREATER 2.46.0 OR GLIB2_VERSION VERSION_EQUAL 2.46.0)
 +if(GLIB2_VERSION VERSION_GREATER_EQUAL 2.46.0)
  set(HAVE_GLIB_2_46 1)
  endif()
  
diff --cc README.dependencies
index b1cb50ff1,d3dce1198..a7b9e9baf
--- a/README.dependencies
+++ b/README.dependencies
@@@ -56,16 -56,17 +56,16 @@@ still has.
  
  Libraries/Deps
  --------------
 -  required		Version
 -  --------		_______
 -  glib2			2.40.0
 -  gtk+3			3.14.0
 -  guile			2.2.0 or 2.0.0		Must be built with regex
 +  required              Version
 +  --------              _______
 +  gcc or clang          8.0 (gcc)/6.0(clang)    C++17 C/C++ compiler
 +  cmake                 3.10                    Build system manager
 +  glib2                 2.40.0
 +  gtk+3                 3.14.0
 +  guile                 2.2.0 or 2.0.0          Must be built with regex
                                                  support enabled
 -  libxml2		2.5.10
 -  gettext               0.20                    Can use older if you pass
 -                                                -DALLOW_OLD_GETTEXT to cmake;
 -                                                doesn't include all file types
 -                                                when building gnucash.pot.
 +  libxml2               2.5.10
-   gettext               0.19.6
++  gettext               0.20
    libxslt, including xsltproc
    ICU                                           International Components for
                                                  Unicode
diff --cc borrowed/CMakeLists.txt
index 3abf02e68,5360f297c..2bb574e74
--- a/borrowed/CMakeLists.txt
+++ b/borrowed/CMakeLists.txt
@@@ -4,7 -3,7 +4,7 @@@ add_subdirectory(chartjs
  add_subdirectory(guile-json)
  if (WITH_GNUCASH)
    add_subdirectory(gwengui-gtk3)
- endif (WITH_GNUCASH)
+ endif()
  
  set_local_dist(borrowed_DIST_local jenny/jenny.c CMakeLists.txt README)
 -set(borrowed_DIST ${borrowed_DIST_local} ${libc_DIST} ${guile-json_DIST} ${goffice_DIST} ${gwengui_gtk3_DIST} PARENT_SCOPE)
 +set(borrowed_DIST ${borrowed_DIST_local} ${chartjs_DIST} ${libc_DIST} ${guile-json_DIST} ${goffice_DIST} ${gwengui_gtk3_DIST} PARENT_SCOPE)
diff --cc common/cmake_modules/GncAddSchemeTargets.cmake
index 12d053b33,17336b0a2..218e49613
--- a/common/cmake_modules/GncAddSchemeTargets.cmake
+++ b/common/cmake_modules/GncAddSchemeTargets.cmake
@@@ -153,13 -75,15 +153,13 @@@ function(make_scheme_targets _TARGET _S
        endif()
      endforeach(scheme_file)
      add_custom_target(${_TARGET}-links ALL DEPENDS ${_SCHEME_LINKS})
-   endif(MAKE_LINKS)
+   endif()
  
    # Construct the guile source and compiled load paths
 -  set(_GUILE_LOAD_PATH "${current_srcdir}"
 -      "${current_bindir}" "${CMAKE_BINARY_DIR}/libgnucash/scm")  # to pick up generated build-config.scm
 +  set(_GUILE_LOAD_PATH "${current_srcdir}" "${current_bindir}" "${current_bindir}/deprecated")
    set(_GUILE_LOAD_COMPILED_PATH "${current_bindir}")
    # VERSION_GREATER_EQUAL introduced in CMake 3.7.
 -  if(MINGW64 AND (${GUILE_EFFECTIVE_VERSION} VERSION_GREATER 2.2 OR
 -	${GUILE_EFFECTIVE_VERSION} VERSION_EQUAL 2.2))
 +  if(MINGW64 AND (${GUILE_EFFECTIVE_VERSION} VERSION_GREATER_EQUAL 2.2))
      file(TO_CMAKE_PATH $ENV{GUILE_LOAD_PATH} guile_load_path)
      file(TO_CMAKE_PATH $ENV{GUILE_LOAD_COMPILED_PATH} guile_load_compiled_path)
      list(APPEND _GUILE_LOAD_PATH ${guile_load_path})
@@@ -237,87 -162,8 +237,87 @@@
    endforeach(source_file)
    if (__DEBUG)
      message("TARGET_FILES are ${_TARGET_FILES}")
-   endif(__DEBUG)
+   endif()
    add_custom_target(${_TARGET} ALL DEPENDS ${_TARGET_FILES})
 -  install(FILES ${_TARGET_FILES} DESTINATION ${SCHEME_INSTALLED_CACHE_DIR}/${_OUTPUT_DIR})
 -  install(FILES ${_SOURCE_FILES} DESTINATION ${SCHEME_INSTALLED_SOURCE_DIR}/${_OUTPUT_DIR})
 +  set(_TARGET_FILES "${_TARGET_FILES}" PARENT_SCOPE)
 +endfunction(make_scheme_targets)
 +
 +function(gnc_add_scheme_targets _TARGET _SOURCE_FILES _OUTPUT_DIR _GUILE_DEPENDS
 +    MAKE_LINKS)
 +  make_scheme_targets("${_TARGET}" "${_SOURCE_FILES}" "${_OUTPUT_DIR}"
 +                      "${_GUILE_DEPENDS}" "${MAKE_LINKS}")
 +  install(FILES ${_TARGET_FILES} DESTINATION ${CMAKE_INSTALL_PREFIX}/${GUILE_REL_SITECCACHEDIR}/${_OUTPUT_DIR})
 +  install(FILES ${_SOURCE_FILES} DESTINATION ${CMAKE_INSTALL_PREFIX}/${GUILE_REL_SITEDIR}/${_OUTPUT_DIR})
  endfunction(gnc_add_scheme_targets)
 +
 +function(gnc_add_scheme_test_targets _TARGET _SOURCE_FILES _OUTPUT_DIR _GUILE_DEPENDS
 +    MAKE_LINKS)
 +  make_scheme_targets("${_TARGET}" "${_SOURCE_FILES}" "${_OUTPUT_DIR}"
 +                      "${_GUILE_DEPENDS}" "${MAKE_LINKS}")
 +  add_dependencies(check ${_TARGET})
 +endfunction(gnc_add_scheme_test_targets)
 +
 +# Function to write boilerplate code for deprecated guile modules
 +# All but the _OLDMOD parameter are optional
 +# It will emit a deprecation warning and if _NEWMOD is also given
 +# that module will be loaded instead.
 +# If _NEWMOD is given, _DEPENDS should be set to the target for which
 +# that module is a source file.
 +# For example module (gnucash reports standard transaction)
 +# is defined in transaction.scm, which is a source file for
 +# cmake target scm-reports-standard so that should be set as _DEPENDS.
 +
 +# The function expects module names in the form "gnucash mod parts"
 +# If _DEPMSG is left blank, the module will emit a generic message,
 +# otherswise _DEPMSG will be emitted.
 +function(gnc_add_scheme_deprecated_module _OLDMOD _NEWMOD _DEPENDS _DEPMSG)
 +    string(STRIP _OLDMOD "${_OLDMOD}")
 +    string(REPLACE " " "-" _TARGET ${_OLDMOD})
 +    set(_TARGET "scm-deprecated-${_TARGET}")
 +
 +    string(REPLACE " " ";" MODPARTS "${_OLDMOD}")
 +    list(GET MODPARTS -1 DEPFILENAME)
 +    set(SOURCEFILE "${CMAKE_CURRENT_BINARY_DIR}/deprecated/${DEPFILENAME}.scm")
 +
 +    string(FIND "${_OLDMOD}" ${DEPFILENAME} POS REVERSE)
 +    if (${POS} LESS 2)
 +        set(MODPATH "gnucash/deprecated")
 +    else()
 +        list(REMOVE_AT MODPARTS -1)
 +        string(REPLACE ";" "/" MODPATH "${MODPARTS}")
 +        set(MODPATH "gnucash/deprecated/${MODPATH}")
 +    endif()
 +
 +    set(DEPPREFIX "* WARN <gnc-guile-deprecation> *: ")
 +    if (_DEPMSG)
 +        set(DEPWARNING "(issue-deprecation-warning \"${DEPPREFIX}${_DEPMSG}\")")
 +    else()
 +        set(DEPWARNING
 +            "(issue-deprecation-warning \"${DEPPREFIX}Module '(${_OLDMOD})' has been deprecated and will be removed in the future.\")")
 +        if (_NEWMOD)
 +            set(DEPWARNING "${DEPWARNING}
 +                (issue-deprecation-warning \"${DEPPREFIX}Use module '(${_NEWMOD})' instead.\")")
 +        endif()
 +    endif()
 +
 +    # Write the stub file
 +    file(WRITE ${SOURCEFILE} "
 +;; ${DEPFILENAME}.scm
 +;; Compatibility module for deprecated (${_OLDMOD}).
 +;; This file is autogenerated, do not modify by hand.
 +
 +(define-module (${_OLDMOD}))
 +
 +${DEPWARNING}
 +")
 +
 +    if (_NEWMOD)
 +        file(APPEND ${SOURCEFILE} "
 +(use-modules (${_NEWMOD}))
 +
 +(let ((i (module-public-interface (current-module))))
 +     (module-use! i (resolve-interface '(${_NEWMOD}))))")
 +    endif()
 +
 +    gnc_add_scheme_targets("${_TARGET}" "${SOURCEFILE}" "${MODPATH}" "${_DEPENDS}" FALSE)
 +endfunction(gnc_add_scheme_deprecated_module)
diff --cc common/cmake_modules/GncAddTest.cmake
index caa918f9c,31cc76217..9ae6d3d3b
--- a/common/cmake_modules/GncAddTest.cmake
+++ b/common/cmake_modules/GncAddTest.cmake
@@@ -24,10 -24,10 +24,10 @@@ function(get_guile_env
        set(fpath "${fpath}${dir}:")
      endforeach(dir)
      list(APPEND env "PATH=${fpath}")
 -    set(compiled_path "${LIBDIR_BUILD}/gnucash/scm/ccache/${GUILE_EFFECTIVE_VERSION}")
 +    set(compiled_path "${CMAKE_BINARY_DIR}/${GUILE_REL_SITECCACHEDIR}")
      string(REGEX REPLACE "^([A-Za-z]):" "/\\1" compiled_path ${compiled_path})
      list(APPEND env GUILE_LOAD_COMPILED_PATH=${compiled_path})
-   endif(MINGW64)
+   endif()
    list(APPEND env "GNC_MODULE_PATH=${_GNC_MODULE_PATH}")
    list(APPEND env "GUILE=${GUILE_EXECUTABLE}")
  
@@@ -49,24 -49,13 +49,24 @@@
        list(APPEND new_path ${load_item})
      endforeach(load_item)
      set(guile_load_path ${new_path})
 +
 +    set(new_path "")
 +    foreach(load_item ${guile_load_compiled_path})
 +      string(REGEX REPLACE "^([A-Za-z]):" "/\\1" load_item ${load_item})
 +      list(APPEND new_path ${load_item})
 +    endforeach(load_item)
 +    set(guile_load_compiled_path ${new_path})
-   endif (MINGW64)
+   endif()
    if (WIN32 AND NOT MINGW64)
 -    string(REPLACE ";" "\\\\;" GUILE_LOAD_PATH "${guile_load_path}")
 +      string(REPLACE ";" "\\\\;" GUILE_LOAD_PATH "${guile_load_path}")
 +      string(REPLACE ";" "\\\\;" GUILE_LOAD_COMPILED_PATH "${guile_load_compiled_path}")
    else()
 -    string(REPLACE ";" ":" GUILE_LOAD_PATH "${guile_load_path}")
 +      string(REPLACE ";" ":" GUILE_LOAD_PATH "${guile_load_path}")
 +      string(REPLACE ";" ":" GUILE_LOAD_COMPILED_PATH "${guile_load_compiled_path}")
    endif()
 -  list(APPEND env GUILE_LOAD_PATH=${GUILE_LOAD_PATH})
 +  list(APPEND env "GUILE_LOAD_PATH=${GUILE_LOAD_PATH}")
 +  list(APPEND env "GUILE_LOAD_COMPILED_PATH=${GUILE_LOAD_COMPILED_PATH}")
 +  list(APPEND env "GUILE_WARN_DEPRECATED=detailed")
    set(GUILE_ENV ${env} PARENT_SCOPE)
  endfunction()
  
diff --cc gnucash/CMakeLists.txt
index 3de5c204a,f1ecdafc5..8ae99ad98
--- a/gnucash/CMakeLists.txt
+++ b/gnucash/CMakeLists.txt
@@@ -48,11 -62,11 +48,11 @@@ target_compile_definitions(gnucash PRIV
  if (BUILDING_FROM_VCS)
    target_compile_definitions(gnucash PRIVATE -DGNC_VCS=\"git\")
    target_compile_definitions(gncmod-gnome-utils PRIVATE -DGNC_VCS=\"git\")
- endif (BUILDING_FROM_VCS)
+ endif()
  
  target_link_libraries (gnucash
 -   gncmod-ledger-core gncmod-report-gnome gnc-gnome gncmod-gnome-utils
 -   gncmod-app-utils gncmod-engine gnc-module gnc-core-utils gncmod-report-system
 +   gncmod-ledger-core gnc-gnome gncmod-gnome-utils gnc-app-utils
 +   gnc-engine gnc-module gnc-core-utils gncmod-report gnucash-guile
     PkgConfig::GTK3 ${GUILE_LDFLAGS} ${GLIB2_LDFLAGS} ${GTK_MAC_LDFLAGS}
  )
  
diff --cc gnucash/html/CMakeLists.txt
index 885357eaa,8abffd616..ac7315628
--- a/gnucash/html/CMakeLists.txt
+++ b/gnucash/html/CMakeLists.txt
@@@ -30,23 -30,9 +30,23 @@@ else (
    list(APPEND html_HEADERS gnc-html-webkit2.h)
    list(APPEND html_SOURCES gnc-html-webkit2.c)
    set(html_EXTRA_DIST gnc-html-webkit1.h gnc-html-webkit1.c)
- endif ()
+ endif()
  
 -set_dist_list(html_DIST CMakeLists.txt ${html_HEADERS} ${html_SOURCES} gnc-html.i ${html_EXTRA_DIST})
 +
 +
 +set (gnc_html_SCHEME html.scm)
 +
 +set(GUILE_OUTPUT_DIR   gnucash)
 +set(GUILE_DEPENDS      gncmod-html gnucash-guile)
 +
 +gnc_add_scheme_targets(scm-gnc-html
 +    "${gnc_html_SCHEME}"
 +    ${GUILE_OUTPUT_DIR}
 +    "${GUILE_DEPENDS}"
 +    FALSE
 +)
 +
 +set_dist_list(html_DIST CMakeLists.txt ${html_HEADERS} ${html_SOURCES} gnc-html.i ${html_EXTRA_DIST} html.scm)
  
  add_library (gncmod-html
    ${html_SOURCES}
diff --cc gnucash/import-export/aqb/CMakeLists.txt
index 81c71cab4,bd007d493..9ca0cc7da
--- a/gnucash/import-export/aqb/CMakeLists.txt
+++ b/gnucash/import-export/aqb/CMakeLists.txt
@@@ -89,9 -89,9 +89,9 @@@ endif(
      DESTINATION ${DATADIR_BUILD}/gnucash/ui)
    file(COPY ${aqbanking_GLADE}
      DESTINATION ${DATADIR_BUILD}/gnucash/gtkbuilder)
- endif(WITH_AQBANKING)
+ endif()
  
 -set_local_dist(aqbanking_DIST_local CMakeLists.txt migratable-prefs-aqbanking.xml
 +set_local_dist(aqbanking_DIST_local CMakeLists.txt
          ${aqbanking_SOURCES} ${aqbanking_noinst_HEADERS} ${aqbanking_EXTRA_DIST}
          ${aqbanking_GLADE} ${aqbanking_UI})
  
diff --cc gnucash/import-export/qif-imp/test/CMakeLists.txt
index e44f88539,18589cb76..005ba5c4f
--- a/gnucash/import-export/qif-imp/test/CMakeLists.txt
+++ b/gnucash/import-export/qif-imp/test/CMakeLists.txt
@@@ -21,15 -14,8 +21,15 @@@ gnc_add_test(test-link-qif-imp test-lin
  
  if (HAVE_SRFI64)
    gnc_add_scheme_tests("${scm_qifimp_test_with_srfi64_SOURCES}")
 +
 +  gnc_add_scheme_test_targets(scm-test-qif-imp-srfi64
 +    "${scm_qifimp_test_with_srfi64_SOURCES}"
 +    "tests"
 +    "${GUILE_DEPENDS};scm-srfi64-extras"
 +    FALSE
 +    )
    add_dependencies(check scm-qif-import-2 scm-qif-import)
- endif (HAVE_SRFI64)
+ endif()
  
  set_dist_list(test_qif_import_DIST CMakeLists.txt test-link.c
    ${scm_qifimp_test_with_srfi64_SOURCES})
diff --cc gnucash/report/eguile-utilities.scm
index 79a40f51d,f3e3e4923..ba48af432
--- a/gnucash/report/eguile-utilities.scm
+++ b/gnucash/report/eguile-utilities.scm
@@@ -22,13 -22,17 +22,14 @@@
  ;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  ;; 02111-1307 USA
  
 -(define-module (gnucash report eguile-utilities))
+ (use-modules (ice-9 match))
 -
  ; using all of these seems like overkill -- 
  ; not sure which are really required
 +(use-modules (gnucash engine))
  (use-modules (gnucash utilities))
 -(use-modules (gnucash gnc-module))
  (use-modules (gnucash app-utils))
  (use-modules (gnucash core-utils))
 -(gnc:module-load "gnucash/report/report-system" 0)
 -(gnc:module-load "gnucash/app-utils" 0)
 +(use-modules (gnucash report))
  
  (define-public (fmtnumber n)
    ;; Format a number (integer or real) into something printable
@@@ -46,57 -47,29 +44,58 @@@
  
  ;; 'Safe' versions of cdr and cadr that don't crash
  ;; if the list is empty  (is there a better way?)
- (define-public (safe-cdr l)
-   (if (null? l) '()
-       (cdr l)))
- (define-public (safe-cadr l)
-   (cond
-    ((null? l) '())
-    ((null? (cdr l)) '())
-    (else (cadr l))))
+ (define-public safe-cdr
+   (match-lambda
+     ((_ . x) x)
+     (_ '())))
+ 
+ (define-public safe-cadr
+   (match-lambda
+     ((_ x . _) x)
+     (_ '())))
  
 +; deprecated - use find-stylesheet or find-template instead
  (define-public (find-file fname)
    ;; Find the file 'fname', and return its full path.
 -  ;; First look in the user's .gnucash directory.
 +  ;; First look in the user's .config/gnucash directory.
    ;; Then look in Gnucash's standard report directory.
    ;; If no file is found, returns just 'fname' for use in error messages.
 -  ;; Note: this has been tested on Linux and Windows Vista so far...
 -  (let ((userpath (gnc-build-userdata-path fname))
 -        (syspath  (gnc-build-report-path fname)))
 -    ;; make sure there's a trailing delimiter
 -    (cond
 -     ((access? userpath R_OK) userpath)
 -     ((access? syspath R_OK) syspath)
 -     (else fname))))
 +  (let* ((stylesheetpath (find-stylesheet fname))
 +         (templatepath  (find-template fname)))
 +    ; make sure there's a trailing delimiter
 +      (issue-deprecation-warning "find-file is deprecated. Please use find-stylesheet or find-template instead.")
 +      (cond
 +       ((access? stylesheetpath R_OK) stylesheetpath)
 +       ((access? templatepath R_OK) templatepath)
 +       (else fname))))
 +
 +(define (find-internal ftype fname)
 +  ;; Find the file fname', and return its full path.
 +  ;; First look in the user's .config/gnucash directory.
 +  ;; Then look in Gnucash' gnucash/reports/'ftype' directory.
 +  ;; If no file is found, returns just 'fname' for use in error messages.
 +  (let* ((userpath (gnc-build-userdata-path fname))
 +         (frelpath (string-join (list (symbol->string ftype) fname) "/"))
 +         (syspath  (gnc-build-reports-path frelpath)))
 +        (if (access? userpath R_OK)
 +          userpath
 +          (if (access? syspath R_OK)
 +            syspath
 +            fname))))
 +
 +(define-public (find-stylesheet fname)
 +  ;; Find the stylesheet 'fname', and return its full path.
 +  ;; First look in the user's .config/gnucash directory.
 +  ;; Then look in Gnucash' gnucash/reports/stylesheets directory.
 +  ;; If no file is found, returns just 'fname' for use in error messages.
 +  (find-internal 'stylesheets fname))
 +
 +(define-public (find-template fname)
 +  ;; Find the template 'ftype'/'fname', and return its full path.
 +  ;; First look in the user's .config/gnucash directory.
 +  ;; Then look in Gnucash' gnucash/reports/templates directory.
 +  ;; If no file is found, returns just 'fname' for use in error messages.
 +  (find-internal 'templates fname))
  
  ; Define syntax for more readable for loops (the built-in for-each requires an
  ; explicit lambda and has the list expression all the way at the end).
diff --cc gnucash/report/report-utilities.scm
index 6f0044f1d,20cff240c..d5e146a8e
--- a/gnucash/report/report-utilities.scm
+++ b/gnucash/report/report-utilities.scm
@@@ -336,12 -423,34 +336,11 @@@
  ;; usage: (gnc:monetaries-add monetary1 monetary2 ...)
  ;; output: a monetary object
  (define (gnc:monetary+ . monetaries)
-   (let* ((coll (apply gnc:monetaries-add monetaries))
-          (list-of-monetaries (coll 'format gnc:make-gnc-monetary #f)))
-     (if (null? (cdr list-of-monetaries))
-         (car list-of-monetaries)
-         (throw "gnc:monetary+ expects 1 currency " (gnc:strify monetaries)))))
+   (let ((coll (apply gnc:monetaries-add monetaries)))
+     (match (coll 'format gnc:make-gnc-monetary #f)
+       ((mon) mon)
+       (_ (throw "gnc:monetary+ expects 1 currency " (gnc:strify monetaries))))))
  
 -;; get the account balance at the specified date. if include-children?
 -;; is true, the balances of all children (not just direct children)
 -;; are included in the calculation.
 -;; I think this (gnc:account-get-balance-at-date) is flawed in sub-acct handling.
 -;; Consider account structure:
 -;; Assets [USD] - bal=$0
 -;;    Bank [USD] - bal=$100
 -;;    Broker [USD] - bal=$200
 -;;       Cash [USD] - bal=$800
 -;;       Funds [FUND] - bal=3 FUND @ $1000 each = $3000
 -;; - Calling (gnc:account-get-balance-at-date BANK TODAY #f) returns 100
 -;; - Calling (gnc:account-get-balance-at-date BROKER TODAY #f) returns 200
 -;; - Calling (gnc:account-get-balance-at-date BROKER TODAY #t) returns 1000
 -;;   this is because although it counts all subaccounts bal $200 + $800 + 3FUND,
 -;;   it retrieves the parent account commodity USD $1000 only.
 -;; It needs to be deprecated.
 -(define (gnc:account-get-balance-at-date account date include-children?)
 -  (issue-deprecation-warning "this gnc:account-get-balance-at-date function is \
 -flawed. see report-utilities.scm. please update reports.")
 -  (let ((collector (gnc:account-get-comm-balance-at-date
 -                    account date include-children?)))
 -    (cadr (collector 'getpair (xaccAccountGetCommodity account) #f))))
 -
  ;; this function will scan through the account splitlist, building
  ;; a list of balances along the way at dates specified in dates-list.
  ;; in:  account
diff --cc gnucash/report/reports/standard/lot-viewer.scm
index 04ebd91ac,815fe9566..515c69bbb
--- a/gnucash/report/reports/standard/lot-viewer.scm
+++ b/gnucash/report/reports/standard/lot-viewer.scm
@@@ -19,9 -19,10 +19,10 @@@
  ;;
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  
 -(define-module (gnucash report standard-reports lot-viewer))
 +(define-module (gnucash reports standard lot-viewer))
  
  (use-modules (srfi srfi-1))
+ (use-modules (srfi srfi-11))            ;for let-values
  (use-modules (ice-9 match))
  (use-modules (gnucash utilities))
  (use-modules (gnucash gnc-module))
diff --cc gnucash/report/reports/standard/test/CMakeLists.txt
index 77c6ea94c,7c2e6b7fc..3fa778120
--- a/gnucash/report/reports/standard/test/CMakeLists.txt
+++ b/gnucash/report/reports/standard/test/CMakeLists.txt
@@@ -38,30 -37,17 +38,30 @@@ set(GUILE_DEPEND
    )
  
  if (HAVE_SRFI64)
 +  gnc_add_scheme_test_targets(scm-test-reports-standard-srfi64
 +    "${scm_test_with_srfi64_SOURCES}"
 +    "tests"
 +    "${GUILE_DEPENDS};scm-srfi64-extras"
 +    FALSE
 +    )
 +
    gnc_add_scheme_tests("${scm_test_with_srfi64_SOURCES}")
    if (HAVE_TEXT_PORTS)
 +    gnc_add_scheme_test_targets(scm-test-reports-standard-tp
 +      "${scm_test_with_textual_ports_SOURCES}"
 +      "tests"
 +      "${GUILE_DEPENDS};scm-srfi64-extras"
 +      FALSE
 +    )
      gnc_add_scheme_tests("${scm_test_with_textual_ports_SOURCES}")
-   endif (HAVE_TEXT_PORTS)
- endif (HAVE_SRFI64)
+   endif()
+ endif()
  
 -gnc_add_scheme_tests("${scm_test_standard_reports_SOURCES}")
 +gnc_add_scheme_tests("${scm_test_reports_standard_SOURCES}")
  
 -gnc_add_scheme_targets(scm-test-standard-reports
 -  "${scm_test_standard_reports_SOURCES}"
 -  gnucash/report/standard-reports/test
 +gnc_add_scheme_test_targets(scm-test-reports-standard
 +  "${scm_test_reports_standard_SOURCES}"
 +  "tests"
    "${GUILE_DEPENDS}"
    FALSE
  )
diff --cc libgnucash/app-utils/test/CMakeLists.txt
index 2316b9e10,484820c49..8c4da4e5f
--- a/libgnucash/app-utils/test/CMakeLists.txt
+++ b/libgnucash/app-utils/test/CMakeLists.txt
@@@ -64,15 -67,8 +64,15 @@@ gnc_add_scheme_test_targets(scm-test-c-
  gnc_add_scheme_tests("${test_app_utils_scheme_SOURCES}")
  
  if (HAVE_SRFI64)
 +  gnc_add_scheme_test_targets(scm-test-app-utils-srfi64
 +    "${test_app_utils_scheme_SRFI64_SOURCES}"
 +    "tests"
 +    "${GUILE_DEPENDS};scm-srfi64-extras"
 +    FALSE
 +    )
 +
    gnc_add_scheme_tests("${test_app_utils_scheme_SRFI64_SOURCES}")
- endif ()
+ endif()
  
  # Doesn't work yet:
  gnc_add_test_with_guile(test-app-utils "${test_app_utils_SOURCES}" APP_UTILS_TEST_INCLUDE_DIRS APP_UTILS_TEST_LIBS)
diff --cc libgnucash/backend/dbi/CMakeLists.txt
index c50a05e5c,668e3e096..9db2ebbe2
--- a/libgnucash/backend/dbi/CMakeLists.txt
+++ b/libgnucash/backend/dbi/CMakeLists.txt
@@@ -32,8 -32,8 +32,8 @@@ if (WITH_SQL
    set(WINSOCK_LIB "")
    if(MINGW64)
      set(WINSOCK_LIB "-lws2_32")
-   endif(MINGW64)
+   endif()
 -  target_link_libraries(gncmod-backend-dbi gnc-backend-sql gncmod-engine ${GTK2_LDFLAGS} ${Boost_REGEX_LIBRARY} ${LIBDBI_LIBRARY} ${WINSOCK_LIB})
 +  target_link_libraries(gncmod-backend-dbi gnc-backend-sql gnc-engine ${GTK2_LDFLAGS} ${Boost_REGEX_LIBRARY} ${LIBDBI_LIBRARY} ${WINSOCK_LIB})
  
    target_compile_definitions(gncmod-backend-dbi PRIVATE -DG_LOG_DOMAIN=\"gnc.backend.dbi\")
  
diff --cc libgnucash/engine/CMakeLists.txt
index 923d7db6c,62c760b28..beca640bb
--- a/libgnucash/engine/CMakeLists.txt
+++ b/libgnucash/engine/CMakeLists.txt
@@@ -265,7 -321,7 +265,7 @@@ set(engine_EXTRA_DIS
  
  if (NOT WIN32)
    list(APPEND engine_EXTRA_DIST qof-win32.cpp)
- endif (NOT WIN32)
+ endif()
  set_local_dist(engine_DIST_local CMakeLists.txt ${engine_SOURCES} ${engine_HEADERS}
 -                     ${engine_noinst_HEADERS} ${engine_SCHEME_0} ${engine_SCHEME_1} ${engine_EXTRA_DIST})
 +                     ${engine_noinst_HEADERS} ${engine_EXTRA_DIST})
  set(engine_DIST ${engine_DIST_local} ${engine_test_core_DIST} ${test_engine_DIST} PARENT_SCOPE)

commit 90e95ba8ef0d9cd2ed5db041c8d299e8096e4632
Author: Geert Janssens <geert at kobaltwit.be>
Date:   Thu Feb 6 16:16:31 2020 +0100

    CMake - remove parameter repetition in else() and endif() statements - part 2
    
    This follows Professional CMake's recommended practises
    I missed plenty of these in my first commit. This one should fix
    these remaining occurrences.

diff --git a/CMakeLists.txt b/CMakeLists.txt
index e1ca611a7..07b71d945 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -109,7 +109,7 @@ if (MINGW)
   if(${IS_MSYS2} GREATER_EQUAL 0)
     set(MINGW64 ON)
   endif()
-endif(MINGW)
+endif()
 
 # Find a proper bash executable
 
@@ -183,13 +183,13 @@ if (WIN32)
   #set(LIBXSLT_XSLTPROC_EXECUTABLE ${CMAKE_PREFIX_PATH}/libxslt/bin/xsltproc)
 #Prevent creating a console window on startup.
   set(CMAKE_EXE_LINKER_FLAGS -mwindows)
-endif(WIN32)
+endif()
 
 find_package(PkgConfig REQUIRED)
 
 if (NOT PKG_CONFIG_FOUND)
    message (SEND_ERROR "pkg-config not found, but is required")
- endif (NOT PKG_CONFIG_FOUND)
+ endif()
 
 if (CMAKE_VERSION VERSION_LESS 3.6)
   include(GncPkgConfig)
@@ -213,7 +213,7 @@ if (WITH_GNUCASH)
       _pkg_create_imp_target(WEBKIT)
     endif()
     set(WEBKIT1 1 CACHE INTERNAL "WebKitGtk")
-  else (WIN32 OR APPLE)
+  else()
     If (NOT CMAKE_VERSION VERSION_LESS 3.6)
       pkg_check_modules (WEBKIT IMPORTED_TARGET webkit2gtk-4.0)
     else()
@@ -226,15 +226,15 @@ if (WITH_GNUCASH)
         pkg_check_modules (WEBKIT REQUIRED webkit2gtk-3.0)
       endif()
       set(WEBKIT2_3 1 CACHE INTERNAL "WebKit2Gtk3")
-    else (NOT WEBKIT_FOUND)
+    else()
       if (NOT WEBKIT2_3)
         set(WEBKIT2_4 1 CACHE INTERNAL "WebKit2Gtk4")
-      endif(NOT WEBKIT2_3)
-    endif (NOT WEBKIT_FOUND)
+      endif()
+    endif()
     if (CMAKE_VERSION VERSION_LESS 3.6)
       _pkg_create_imp_target(WEBKIT)
     endif()
-  endif (WIN32 OR APPLE)
+  endif()
 
   if (NOT CMAKE_VERSION VERSION_LESS 3.6)
     pkg_check_modules (GTK3 REQUIRED IMPORTED_TARGET gtk+-3.0>=3.10.0)
@@ -242,7 +242,7 @@ if (WITH_GNUCASH)
     pkg_check_modules (GTK3 REQUIRED gtk+-3.0>=3.10.0)
     _pkg_create_imp_target(GTK3)
   endif()
-endif (WITH_GNUCASH)
+endif()
 
 pkg_check_modules (ZLIB REQUIRED zlib)
 
@@ -252,7 +252,7 @@ if (MSVC)
   # Disable the obnoxious min/max macros in MSVC - we want to use the
   # function versions of them.
   add_definitions ( -DNOMINMAX )
-endif (MSVC)
+endif()
 
 find_path (LTDL_INCLUDE_PATH NAMES ltdl.h PATHS /usr/include)
 if(NOT LTDL_INCLUDE_PATH-NOTFOUND)
@@ -262,7 +262,7 @@ 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)
+endif()
 
 find_path (REGEX_INCLUDE_PATH NAMES regex.h
 		  PATHS /usr/include /opt/gnome/include)
@@ -271,25 +271,25 @@ find_library (REGEX_LIBRARY NAMES regex)
 # I18N
 if (ALLOW_OLD_GETTEXT)
     find_package (Gettext REQUIRED)
-else (ALLOW_OLD_GETTEXT)
+else()
     find_package (Gettext 0.20)
     if (NOT GETTEXT_FOUND)
         message (FATAL_ERROR "Note the build can be configured with an older version of gettext by setting ALLOW_OLD_GETTEXT=ON but then some files will not be translated:
         - gnucash.desktop (requires at least gettext 0.19)
         - gnucash.appdata.xml (requires at least gettext 0.19.6)
         - tag developer_name from gnucash.appdata.xml (requires at least gettext 0.20)")
-    endif (NOT GETTEXT_FOUND)
-endif (ALLOW_OLD_GETTEXT)
+    endif()
+endif()
 
 if (${GETTEXT_VERSION_STRING} VERSION_LESS 0.19)
     message (WARNING "Got gettext version ${GETTEXT_VERSION_STRING}, however you need at least gettext version 0.19 in order to handle translation of the gnucash.desktop file. The build will be configured with an untranslated gnucash.desktop file.")
-endif ()
+endif()
 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 ()
+endif()
 if (${GETTEXT_VERSION_STRING} VERSION_LESS 0.20)
     message (WARNING "Got gettext version ${GETTEXT_VERSION_STRING}, however you need at least gettext version 0.20 in order to handle the translation of 'GnuCash Project' from the gnucash.appdata file. That message will be missing in gnucash.pot.")
-endif ()
+endif()
 
 find_path (LIBINTL_INCLUDE_PATH NAMES libintl.h
 		  PATHS /usr/include /opt/gnome/include)
@@ -300,7 +300,7 @@ if (WIN32)
   message(STATUS "Looking for htmlhelp.h and htmlhelp.a")
   find_path (HTMLHELP_INCLUDE_PATH NAMES htmlhelp.h)
   find_library (HTMLHELP_LIBRARY htmlhelp)
-endif (WIN32)
+endif()
 
 # ############################################################
 
@@ -326,10 +326,10 @@ if (GUILE22_FOUND) # found guile-2.2
   find_program (GUILD_EXECUTABLE NAMES guild2.2 guild)
   if (NOT GUILD_EXECUTABLE)
     message (SEND_ERROR "The guild executable was not found, but is required. Please set GUILD_EXECUTABLE.")
-  endif (NOT GUILD_EXECUTABLE)
+  endif()
   message(STATUS "Using guile-2.2.x")
   find_program (GUILE_EXECUTABLE NAMES guile2.2 guile)
-else(GUILE22_FOUND)
+else()
   pkg_check_modules (GUILE2 guile-2.0>=2.0.9 QUIET)
   if (GUILE2_FOUND) # found guile-2.0
     add_definitions (-DHAVE_GUILE20)
@@ -341,17 +341,17 @@ else(GUILE22_FOUND)
     find_program (GUILD_EXECUTABLE NAMES guild2.0 guild)
     if (NOT GUILD_EXECUTABLE)
       message (SEND_ERROR "The guild executable was not found, but is required. Please set GUILD_EXECUTABLE.")
-    endif (NOT GUILD_EXECUTABLE)
+    endif()
     message(STATUS "Using guile-2.0.x")
     find_program (GUILE_EXECUTABLE NAMES guile2.0 guile)
-  else(GUILE2_FOUND)
+  else()
     message (FATAL_ERROR "Neither guile 2.2 nor guile 2.0 were found GnuCash can't run without one of them. Ensure that one is installed and can be found with pkg-config.")
-  endif(GUILE2_FOUND)
-endif(GUILE22_FOUND)
+  endif()
+endif()
 
 if (NOT GUILE_EXECUTABLE)
   message (SEND_ERROR "The guile executable was not found, but is required. Please set GUILE_EXECUTABLE.")
-endif (NOT GUILE_EXECUTABLE)
+endif()
 
 # Test that guile has SRFI-64. This is required for some unit tests.
 execute_process (COMMAND ${GUILE_EXECUTABLE} -c "(use-modules (srfi srfi-64))"
@@ -362,7 +362,7 @@ execute_process (COMMAND ${GUILE_EXECUTABLE} -c "(use-modules (srfi srfi-64))"
 if (GNC_SRFI64_RESULT EQUAL 0)
   message (STATUS "Using guile SRFI-64")
   set (HAVE_SRFI64 TRUE)
-endif ()
+endif()
 
 # Test that guile has textual-ports. This is required for the stress test.
 execute_process (COMMAND ${GUILE_EXECUTABLE} -c "(use-modules (ice-9 textual-ports))"
@@ -373,7 +373,7 @@ execute_process (COMMAND ${GUILE_EXECUTABLE} -c "(use-modules (ice-9 textual-por
 if (GNC_TEXT_PORTS_RESULT EQUAL 0)
   message (STATUS "Using guile textual-ports")
   set (HAVE_TEXT_PORTS TRUE)
-endif ()
+endif()
 
 # ############################################################
 if (WITH_AQBANKING)
@@ -384,17 +384,17 @@ if (WITH_AQBANKING)
     if(GWEN_GTK3_FOUND AND GWEN_GTK3_VERSION VERSION_GREATER "4.20.0")
       set(HAVE_GWEN_GTK3 1 CACHE BOOL "True if gwen-gtk3.pc exists")
     endif()
-  endif(WITH_GNUCASH)
-endif (WITH_AQBANKING)
+  endif()
+endif()
 
 if (WITH_OFX)
   pkg_check_modules (LIBOFX REQUIRED libofx)
   include(CheckCXXSourceRuns)
   if (WIN32)
       set(CMAKE_REQUIRED_LIBRARIES "-L ${CMAKE_PREFIX_PATH}/libofx/lib -lofx")
-  else (WIN32)
+  else()
       set(CMAKE_REQUIRED_LIBRARIES "-lofx")
-  endif (WIN32)
+  endif()
       CHECK_CXX_SOURCE_RUNS("
 #include <time.h>
 #include <stdlib.h>
@@ -421,7 +421,7 @@ int main(int argc, char** argv)
 " HAVE_OFX_BUG_39)
   set(HAVE_OFX_BUG_39 ${HAVE_OFX_BUG_39})
   set(CMAKE_REQUIRED_LIBRARIES)
-endif(WITH_OFX)
+endif()
 # ############################################################
 
 if(APPLE)
@@ -441,9 +441,9 @@ if(APPLE)
       find_library(CARBON_LIBRARY Carbon)
       set(OSX_EXTRA_COMPILE_FLAGS $<$<COMPILE_LANGUAGE:C>:-xobjective-c> $<$<COMPILE_LANGUAGE:CXX>:-xobjective-c++>)
       set(OSX_EXTRA_LIBRARIES objc ${COCOA_LIBRARY} ${SECURITY_LIBRARY} ${CARBON_LIBRARY})
-    endif(GTK_MAC_FOUND)
+    endif()
   endif()
-endif(APPLE)
+endif()
 
 # find_package(LibXslt) eats PKG_CONFIG_EXECUTABLE, so preserve it.
 set(GNC_PKG_CONFIG_EXE ${PKG_CONFIG_EXECUTABLE})
@@ -454,10 +454,10 @@ find_package(LibXslt)
 
 if (NOT LIBXSLT_FOUND)
    message(FATAL_ERROR "libxslt library not found.")
-endif(NOT LIBXSLT_FOUND)
+endif()
 if (${LIBXSLT_XSLTPROC_EXECUTABLE} STREQUAL "LIBXSLT_XSLTPROC_EXECUTABLE-NOTFOUND")
   message(FATAL_ERROR "xsltproc executable not found")
-endif ()
+endif()
 # ############################################################
 set(PKG_CONFIG_EXECUTABLE ${GNC_PKG_CONFIG_EXE})
 
@@ -473,10 +473,10 @@ find_library (LIBDBI_DRIVERS_DIR
 if (WITH_SQL)
   if (NOT LIBDBI_INCLUDE_PATH)
     message (SEND_ERROR "Include file <dbi/dbi.h> was not found - did you install libdbi0-dev or libdbi-dev?")
-  endif (NOT LIBDBI_INCLUDE_PATH)
+  endif()
   if (NOT LIBDBI_LIBRARY)
     message (SEND_ERROR "Library libdbi was not found")
-  endif (NOT LIBDBI_LIBRARY)
+  endif()
   set(HAVE_DBI_DBI_H 1)
   if (NOT LIBDBI_DRIVERS_DIR)
     message (SEND_ERROR "No libdbi drivers found, SQL tests will fail.")
@@ -484,7 +484,7 @@ if (WITH_SQL)
     get_filename_component(drivers_dir ${LIBDBI_DRIVERS_DIR} DIRECTORY)
     set(LIBDBI_DRIVERS_DIR ${drivers_dir} CACHE FILEPATH "Directory containing the libdbi driver modules." FORCE)
   endif()
-endif (WITH_SQL)
+endif()
 
 # ############################################################
 
@@ -524,7 +524,7 @@ find_package(Perl)
 
 if (NOT PERL_FOUND)
   message(SEND_ERROR "Perl executable not found. Please set PERL_EXECUTABLE.")
-endif(NOT PERL_FOUND)
+endif()
 
 get_filename_component(PERL_DIR ${PERL_EXECUTABLE} DIRECTORY)
 
@@ -551,9 +551,9 @@ find_package (Boost 1.54.0 REQUIRED COMPONENTS date_time regex locale filesystem
 if (Boost_FOUND)
   include_directories(${Boost_INCLUDE_DIRS})
   set(HAVE_BOOST 1)
-else (Boost_FOUND)
+else()
   message (SEND_ERROR "Boost 1.54.0 or later is not installed, and is required. Please install it and ensure that the following libraries are built: chrono, date_time, filesystem, log, program_options, regex, signals, system, and test.")
-endif (Boost_FOUND)
+endif()
 
 
 # Compiler flags
@@ -588,16 +588,16 @@ if (UNIX)
   set( CMAKE_CXX_FLAGS "-Werror -Wall -Wmissing-declarations -Wno-unused -Wno-error=parentheses ${CMAKE_CXX_FLAGS}")
   set( CMAKE_CXX_FLAGS "-Wno-error=deprecated-declarations ${REGISTER_CXXFLAG} ${CMAKE_CXX_FLAGS}")
   set( CMAKE_C_FLAGS_RELEASE "-O3 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 ${CMAKE_C_FLAGS}")
-endif (UNIX)
+endif()
 if (MINGW)
   set( CMAKE_C_FLAGS "-Werror -Wdeclaration-after-statement -Wno-pointer-sign -Wall -Wunused -Wmissing-prototypes -Wmissing-declarations  -Wno-unused -Wno-error=deprecated-declarations -std=gnu11 ${CMAKE_C_FLAGS}")
   set( CMAKE_CXX_FLAGS "-DWINVER=0x0500 -D_EMULATE_GLIBC=0 ${CMAKE_CXX_FLAGS}") # Workaround for bug in gtest on mingw, see https://github.com/google/googletest/issues/893 and https://github.com/google/googletest/issues/920
-endif (MINGW)
+endif()
 
 if (APPLE AND WITH_GNUCASH)
   set(CMAKE_MACOSX_RPATH ON)
   set(CMAKE_INSTALL_NAME_DIR "${CMAKE_INSTALL_FULL_LIBDIR}")
-endif (APPLE AND WITH_GNUCASH)
+endif()
 
 if (UNIX)
   set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_FULL_LIBDIR}:${CMAKE_INSTALL_FULL_LIBDIR}/gnucash")
@@ -675,9 +675,9 @@ if (MINGW)
 set (HAVE_SCANF_LLD 1)
 else ()
 set (HAVE_SCANF_I64D 1)
-endif ()
+endif()
 set (HAVE_HTMLHELPW 1)
-endif (WIN32)
+endif()
 
 check_include_files (dirent.h HAVE_DIRENT_H)
 check_include_files (dlfcn.h HAVE_DLFCN_H)
@@ -702,17 +702,17 @@ check_include_files (wctype.h HAVE_WCTYPE_H)
 test_big_endian(IS_BIGENDIAN)
 if (IS_BIGENDIAN)
   set(WORDS_BIGENDIAN)
-endif (IS_BIGENDIAN)
+endif()
 
 if (NOT DISABLE_NLS)
 set(ENABLE_NLS 1)
-endif(NOT DISABLE_NLS)
+endif()
 
 if (ENABLE_BINRELOC)
 if (UNIX OR MINGW)
 set(BR_PTHREAD 1)
-endif(UNIX OR MINGW)
-endif(ENABLE_BINRELOC)
+endif()
+endif()
 
 if (UNIX OR MINGW)
 set (HAVE_GETTIMEOFDAY 1)
@@ -725,7 +725,7 @@ set (_GNU_SOURCE 1)
 set (_POSIX_PTHREAD_SEMANTICS 1)
 set (_TANDEM_SOURCE 1)
 set (__EXTENSIONS__ 1)
-endif (UNIX OR MINGW)
+endif()
 
 if (UNIX)
 set (HAVE_CHOWN 1)
@@ -751,11 +751,11 @@ set (HAVE_STRUCT_TM_GMTOFF 1)
 set (HAVE_TIMEGM 1)
 set (HAVE_TOWUPPER 1)
 set (GNC_PLATFORM_POSIX 1)
-endif (UNIX)
+endif()
 
 if (WIN32)
 set (GNC_PLATFORM_WINDOWS 1)
-endif (WIN32)
+endif()
 
 if (APPLE)
 # FIXME: HANDLE gtk-mac-integration-gtk2
@@ -763,7 +763,7 @@ set(GNC_PLATFORM_DARWIN 1)
 set(GNC_PLATFORM_OSX 1)
 set(PLATFORM_OSX 1)
 set(HAVE_OSX_KEYCHAIN 1)
-endif(APPLE)
+endif()
 
 if(GLIB2_VERSION VERSION_GREATER 2.46.0 OR GLIB2_VERSION VERSION_EQUAL 2.46.0)
 set(HAVE_GLIB_2_46 1)
@@ -771,17 +771,17 @@ endif()
 
 if(DISABLE_DEPRECATED_GNOME)
 set(GNOME_DISABLE_DEPRECATED 1)
-endif(DISABLE_DEPRECATED_GNOME)
+endif()
 
 if(DISABLE_DEPRECATED_GTK)
 set(GTK_DISABLE_DEPRECATED 1)
 set(GDK_DISABLE_DEPRECATED 1)
 set(GDK_PIXMAP_DISABLE_DEPRECATED 1)
-endif(DISABLE_DEPRECATED_GTK)
+endif()
 
 if(DISABLE_DEPRECATED_GLIB)
 set(G_DISABLE_DEPRECATED 1)
-endif(DISABLE_DEPRECATED_GLIB)
+endif()
 
 add_definitions (-DHAVE_CONFIG_H)
 
@@ -800,7 +800,7 @@ add_subdirectory (common)
 add_subdirectory (libgnucash)
 if (WITH_GNUCASH)
   add_subdirectory (gnucash)
-endif (WITH_GNUCASH)
+endif()
 add_subdirectory (bindings)
 add_subdirectory (test-templates)
 add_subdirectory (util)
@@ -902,11 +902,11 @@ set(_MODULES gnc-core-utils gnc-module gnc-backend-xml-utils)
 
 if (WITH_SQL)
   list(APPEND _MODULES gnc-backend-sql)
-endif(WITH_SQL)
+endif()
 
 if (WITH_GNUCASH)
   list(APPEND _MODULES gnc-gnome)
-endif(WITH_GNUCASH)
+endif()
 
 set_target_properties(${_MODULES} PROPERTIES
   LIBRARY_OUTPUT_DIRECTORY         ${LIBDIR_BUILD}
@@ -960,6 +960,6 @@ endif()
 
 if(UNIX)
   set(CPACK_GENERATOR "TGZ")
-endif(UNIX)
+endif()
 
 include (CPack)
diff --git a/borrowed/CMakeLists.txt b/borrowed/CMakeLists.txt
index b849ca5f2..5360f297c 100644
--- a/borrowed/CMakeLists.txt
+++ b/borrowed/CMakeLists.txt
@@ -3,7 +3,7 @@ add_subdirectory(goffice)
 add_subdirectory(guile-json)
 if (WITH_GNUCASH)
   add_subdirectory(gwengui-gtk3)
-endif (WITH_GNUCASH)
+endif()
 
 set_local_dist(borrowed_DIST_local jenny/jenny.c CMakeLists.txt README)
 set(borrowed_DIST ${borrowed_DIST_local} ${libc_DIST} ${guile-json_DIST} ${goffice_DIST} ${gwengui_gtk3_DIST} PARENT_SCOPE)
diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt
index bb3ddf2bb..453550802 100644
--- a/cmake/CMakeLists.txt
+++ b/cmake/CMakeLists.txt
@@ -5,7 +5,7 @@ if (APPLE)
                 COMMAND /usr/bin/install_name_tool -add_rpath ${CMAKE_INSTALL_LIBDIR}
                                                    -add_rpath ${PKGLIBDIR}
                                                    ${CMAKE_INSTALL_BINDIR}/gnucash)")
-endif(APPLE)
+endif()
 
 
 set_dist_list(cmake_DIST CMakeLists.txt README_CMAKE.txt cmake_uninstall.cmake.in
diff --git a/cmake/cmake_uninstall.cmake.in b/cmake/cmake_uninstall.cmake.in
index f3b1d03c4..0c341762c 100644
--- a/cmake/cmake_uninstall.cmake.in
+++ b/cmake/cmake_uninstall.cmake.in
@@ -2,7 +2,7 @@
 
 if(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
   message(FATAL_ERROR "Cannot find install manifest: @CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
-endif(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
+endif()
 
 file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files)
 string(REGEX REPLACE "\n" ";" files "${files}")
@@ -16,8 +16,8 @@ foreach(file ${files})
       )
     if(NOT "${rm_retval}" STREQUAL 0)
       message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}")
-    endif(NOT "${rm_retval}" STREQUAL 0)
-  else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
+    endif()
+  else()
     message(STATUS "File $ENV{DESTDIR}${file} does not exist.")
-  endif(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
+  endif()
 endforeach(file)
diff --git a/common/cmake_modules/GncAddSchemeTargets.cmake b/common/cmake_modules/GncAddSchemeTargets.cmake
index 977ef1bfd..17336b0a2 100644
--- a/common/cmake_modules/GncAddSchemeTargets.cmake
+++ b/common/cmake_modules/GncAddSchemeTargets.cmake
@@ -34,11 +34,11 @@ function(gnc_add_scheme_targets _TARGET _SOURCE_FILES _OUTPUT_DIR _GUILE_DEPENDS
     message("   SOURCE_FILES: ${_SOURCE_FILES}")
     message("   GUILE_DEPENDS: ${_GUILE_DEPENDS}")
     message("   DIRECTORIES: ${BINDIR_BUILD}, ${LIBDIR_BUILD}, ${DATADIR_BUILD}")
-  endif(__DEBUG)
+  endif()
   set(_CMD "create_symlink")
   if(WIN32)
     set(_CMD "copy")
-  endif(WIN32)
+  endif()
   set(current_srcdir ${CMAKE_CURRENT_SOURCE_DIR})
   set(current_bindir ${CMAKE_CURRENT_BINARY_DIR})
   set(build_bindir ${BINDIR_BUILD})
@@ -75,7 +75,7 @@ function(gnc_add_scheme_targets _TARGET _SOURCE_FILES _OUTPUT_DIR _GUILE_DEPENDS
       endif()
     endforeach(scheme_file)
     add_custom_target(${_TARGET}-links ALL DEPENDS ${_SCHEME_LINKS})
-  endif(MAKE_LINKS)
+  endif()
 
   # Construct the guile source and compiled load paths
   set(_GUILE_LOAD_PATH "${current_srcdir}"
@@ -120,18 +120,18 @@ function(gnc_add_scheme_targets _TARGET _SOURCE_FILES _OUTPUT_DIR _GUILE_DEPENDS
         set(fpath "")
         file(TO_CMAKE_PATH "$ENV{PATH}" fpath)
         set(LIBRARY_PATH "PATH=${BINDIR_BUILD};${fpath}")
-      else (MINGW64)
+      else()
         set (LIBRARY_PATH "LD_LIBRARY_PATH=${LIBDIR_BUILD}:${LIBDIR_BUILD}/gnucash")
-      endif (MINGW64)
+      endif()
       if (APPLE)
         set (LIBRARY_PATH "DYLD_LIBRARY_PATH=${LIBDIR_BUILD}:${LIBDIR_BUILD}/gnucash")
-      endif (APPLE)
+      endif()
       set(_GNC_MODULE_PATH "")
       if(MINGW64)
         set(_GNC_MODULE_PATH "${build_bindir}")
-      else(MINGW64)
+      else()
         set(_GNC_MODULE_PATH "${LIBDIR_BUILD}" "${LIBDIR_BUILD}/gnucash" "${GNC_MODULE_PATH}")
-      endif(MINGW64)
+      endif()
       if(NOT MINGW64 OR ${GUILE_EFFECTIVE_VERSION} VERSION_LESS 2.2)
         make_unix_path_list(_GUILE_LOAD_PATH)
         make_unix_path_list(_GUILE_LOAD_COMPILED_PATH)
@@ -143,7 +143,7 @@ function(gnc_add_scheme_targets _TARGET _SOURCE_FILES _OUTPUT_DIR _GUILE_DEPENDS
         message("   GUILE_LOAD_PATH: ${_GUILE_LOAD_PATH}")
         message("   GUILE_LOAD_COMPILED_PATH: ${_GUILE_LOAD_COMPILED_PATH}")
         message("   GNC_MODULE_PATH: ${_GNC_MODULE_PATH}")
-      endif(__DEBUG)
+      endif()
       #We quote the arguments to stop CMake stripping the path separators.
       add_custom_command(
         OUTPUT ${output_file}
@@ -162,7 +162,7 @@ function(gnc_add_scheme_targets _TARGET _SOURCE_FILES _OUTPUT_DIR _GUILE_DEPENDS
   endforeach(source_file)
   if (__DEBUG)
     message("TARGET_FILES are ${_TARGET_FILES}")
-  endif(__DEBUG)
+  endif()
   add_custom_target(${_TARGET} ALL DEPENDS ${_TARGET_FILES})
   install(FILES ${_TARGET_FILES} DESTINATION ${SCHEME_INSTALLED_CACHE_DIR}/${_OUTPUT_DIR})
   install(FILES ${_SOURCE_FILES} DESTINATION ${SCHEME_INSTALLED_SOURCE_DIR}/${_OUTPUT_DIR})
diff --git a/common/cmake_modules/GncAddTest.cmake b/common/cmake_modules/GncAddTest.cmake
index dbf475b22..31cc76217 100644
--- a/common/cmake_modules/GncAddTest.cmake
+++ b/common/cmake_modules/GncAddTest.cmake
@@ -27,7 +27,7 @@ function(get_guile_env)
     set(compiled_path "${LIBDIR_BUILD}/gnucash/scm/ccache/${GUILE_EFFECTIVE_VERSION}")
     string(REGEX REPLACE "^([A-Za-z]):" "/\\1" compiled_path ${compiled_path})
     list(APPEND env GUILE_LOAD_COMPILED_PATH=${compiled_path})
-  endif(MINGW64)
+  endif()
   list(APPEND env "GNC_MODULE_PATH=${_GNC_MODULE_PATH}")
   list(APPEND env "GUILE=${GUILE_EXECUTABLE}")
 
@@ -49,7 +49,7 @@ function(get_guile_env)
       list(APPEND new_path ${load_item})
     endforeach(load_item)
     set(guile_load_path ${new_path})
-  endif (MINGW64)
+  endif()
   if (WIN32 AND NOT MINGW64)
     string(REPLACE ";" "\\\\;" GUILE_LOAD_PATH "${guile_load_path}")
   else()
diff --git a/common/cmake_modules/MacroAddSourceFileCompileFlags.cmake b/common/cmake_modules/MacroAddSourceFileCompileFlags.cmake
index 660f4e8c9..5440b967b 100644
--- a/common/cmake_modules/MacroAddSourceFileCompileFlags.cmake
+++ b/common/cmake_modules/MacroAddSourceFileCompileFlags.cmake
@@ -11,9 +11,9 @@ macro (macro_add_source_file_compile_flags _sourcefile _additionalflags)
    get_source_file_property (_flags ${_sourcefile} COMPILE_FLAGS)
    if (_flags)
       set(_flags "${_flags} ${_additionalflags}")
-   else (_flags)
+   else()
       set(_flags "${_additionalflags}")
-   endif (_flags)
+   endif()
    set_source_files_properties (${_sourcefile} PROPERTIES COMPILE_FLAGS "${_flags}")
 
 endmacro (macro_add_source_file_compile_flags)
diff --git a/common/cmake_modules/MakeDistCheck.cmake b/common/cmake_modules/MakeDistCheck.cmake
index 6fce2c04e..f7458c07c 100644
--- a/common/cmake_modules/MakeDistCheck.cmake
+++ b/common/cmake_modules/MakeDistCheck.cmake
@@ -20,7 +20,7 @@ function(run_dist_check PACKAGE_PREFIX EXT)
     FIND_PROGRAM(NINJA_COMMAND NAMES ninja ninja-build)
     if (${NINJA_COMMAND} STREQUAL "NINJA_COMMAND-NOTFOUND")
         message(FATAL_ERROR "Can't find the 'ninja' or 'ninja-build' program.")
-    endif ()
+    endif()
 
     execute_process_and_check_result(
             COMMAND ${CMAKE_COMMAND} -E tar ${TAR_OPTION} ${tarball}
diff --git a/gnucash/CMakeLists.txt b/gnucash/CMakeLists.txt
index e2761c7d0..f1ecdafc5 100644
--- a/gnucash/CMakeLists.txt
+++ b/gnucash/CMakeLists.txt
@@ -39,11 +39,11 @@ if (WIN32)
     set (GNUCASH_RESOURCE_FILE ${CMAKE_CURRENT_BINARY_DIR}/gnucash.rc)
     configure_file(gnucash.rc.in gnucash.rc @ONLY NEWLINE_STYLE WIN32)
 
-else (WIN32)
+else()
   # All other platforms use these settings:
   set (PLATFORM_FILES gnucash-valgrind)
 
-endif (WIN32)
+endif()
 
 set (gnucash_SOURCES
   gnucash-bin.c
@@ -62,7 +62,7 @@ target_compile_definitions(gnucash PRIVATE -DG_LOG_DOMAIN=\"gnc.bin\")
 if (BUILDING_FROM_VCS)
   target_compile_definitions(gnucash PRIVATE -DGNC_VCS=\"git\")
   target_compile_definitions(gncmod-gnome-utils PRIVATE -DGNC_VCS=\"git\")
-endif (BUILDING_FROM_VCS)
+endif()
 
 target_link_libraries (gnucash
    gncmod-ledger-core gncmod-report-gnome gnc-gnome gncmod-gnome-utils
@@ -111,7 +111,7 @@ add_custom_command(
 if (MAC_INTEGRATION)
   target_compile_options(gnucash PRIVATE ${OSX_EXTRA_COMPILE_FLAGS})
   target_link_libraries(gnucash ${OSX_EXTRA_LIBRARIES})
-endif(MAC_INTEGRATION)
+endif()
 
 install(TARGETS gnucash DESTINATION ${CMAKE_INSTALL_BINDIR})
 # No headers to install.
@@ -238,7 +238,7 @@ if (WIN32)
       file(TO_NATIVE_PATH ${CMAKE_PREFIX_PATH}/${dir}/bin PATH_ITEM)
       list(APPEND CMD_LINES "set PATH=${PATH_ITEM}\;%PATH%\n")
     endforeach(dir)
-  endif (NOT ${MINGW64})
+  endif()
   set(CMD_FILE ${CMAKE_CURRENT_BINARY_DIR}/gnucash-launcher.cmd)
   file(WRITE ${CMD_FILE} "@echo off\nsetlocal\n\n")
   foreach(line ${CMD_LINES})
@@ -254,7 +254,7 @@ if (WIN32)
   file(APPEND ${BUILD_CMD_FILE} "\nstart gnucash %*\n")
 
   install(PROGRAMS ${CMD_FILE} DESTINATION  ${CMAKE_INSTALL_BINDIR})
-endif(WIN32)
+endif()
 
 # The GResource Files are absolute paths but set_local_dist requires
 # relative paths.
diff --git a/gnucash/gnome-utils/CMakeLists.txt b/gnucash/gnome-utils/CMakeLists.txt
index 3c9c6d195..f444cccbc 100644
--- a/gnucash/gnome-utils/CMakeLists.txt
+++ b/gnucash/gnome-utils/CMakeLists.txt
@@ -29,10 +29,10 @@ add_custom_command(
 if (NOT have_mod_mask)
 if (MAC_INTEGRATION)
   add_definitions(-DGDK_MODIFIER_INTENT_DEFAULT_MOD_MASK=GDK_SHIFT_MASK|GDK_CONTROL_MASK|GDK_MOD1_MASK|GDK_MOD2_MASK|GDK_SUPER_MASK|GDK_HYPER_MASK|GDK_META_MASK)
-else (MAC_INTEGRATION)
+else()
   add_definitions(-DGDK_MODIFIER_INTENT_DEFAULT_MOD_MASK=GDK_SHIFT_MASK|GDK_CONTROL_MASK|GDK_MOD1_MASK|GDK_SUPER_MASK|GDK_HYPER_MASK|GDK_META_MASK)
-endif (MAC_INTEGRATION)
-endif (NOT have_mod_mask)
+endif()
+endif()
 
 set (gnome_utils_SOURCES
   account-quickfill.c
@@ -220,12 +220,12 @@ target_compile_definitions(gncmod-gnome-utils PUBLIC ${GTK_MAC_CFLAGS_OTHER}
 
 if (BUILDING_FROM_VCS)
   target_compile_definitions(gncmod-gnome-utils PRIVATE -DGNC_VCS=\"git\")
-endif (BUILDING_FROM_VCS)
+endif()
 
 if (MAC_INTEGRATION)
   target_compile_options(gncmod-gnome-utils PRIVATE ${OSX_EXTRA_COMPILE_FLAGS})
   target_link_libraries(gncmod-gnome-utils ${OSX_EXTRA_LIBRARIES})
-endif(MAC_INTEGRATION)
+endif()
 
 target_include_directories(gncmod-gnome-utils
     PUBLIC
diff --git a/gnucash/gnome/CMakeLists.txt b/gnucash/gnome/CMakeLists.txt
index 0a0292475..727f91df6 100644
--- a/gnucash/gnome/CMakeLists.txt
+++ b/gnucash/gnome/CMakeLists.txt
@@ -143,7 +143,7 @@ add_dependencies (gnc-gnome swig-runtime-h)
 if (MAC_INTEGRATION)
   target_compile_options(gnc-gnome PRIVATE ${OSX_EXTRA_COMPILE_FLAGS})
   target_link_libraries(gnc-gnome ${OSX_EXTRA_LIBRARIES})
-endif(MAC_INTEGRATION)
+endif()
 
 
 install(TARGETS gnc-gnome
diff --git a/gnucash/gschemas/CMakeLists.txt b/gnucash/gschemas/CMakeLists.txt
index 735e5c11d..8e8e40f21 100644
--- a/gnucash/gschemas/CMakeLists.txt
+++ b/gnucash/gschemas/CMakeLists.txt
@@ -46,7 +46,7 @@ if (COMPILE_GSCHEMAS)
     execute_process(
         COMMAND ${SHELL} -c \"echo Compiling gschema files in \$ENV\{DESTDIR\}${CMAKE_INSTALL_FULL_DATADIR}/glib-2.0/schemas ;
                               ${GLIB_COMPILE_SCHEMAS} \$ENV\{DESTDIR\}${CMAKE_INSTALL_FULL_DATADIR}/glib-2.0/schemas\")")
-endif ()
+endif()
 
 set(gschemas_DIST_local "")
 foreach(file ${gschema_SOURCES})
diff --git a/gnucash/html/CMakeLists.txt b/gnucash/html/CMakeLists.txt
index 834cc8f4a..8abffd616 100644
--- a/gnucash/html/CMakeLists.txt
+++ b/gnucash/html/CMakeLists.txt
@@ -30,7 +30,7 @@ else ()
   list(APPEND html_HEADERS gnc-html-webkit2.h)
   list(APPEND html_SOURCES gnc-html-webkit2.c)
   set(html_EXTRA_DIST gnc-html-webkit1.h gnc-html-webkit1.c)
-endif ()
+endif()
 
 set_dist_list(html_DIST CMakeLists.txt ${html_HEADERS} ${html_SOURCES} gnc-html.i ${html_EXTRA_DIST})
 
diff --git a/gnucash/import-export/aqb/CMakeLists.txt b/gnucash/import-export/aqb/CMakeLists.txt
index 3c37b75d5..bd007d493 100644
--- a/gnucash/import-export/aqb/CMakeLists.txt
+++ b/gnucash/import-export/aqb/CMakeLists.txt
@@ -89,7 +89,7 @@ endif()
     DESTINATION ${DATADIR_BUILD}/gnucash/ui)
   file(COPY ${aqbanking_GLADE}
     DESTINATION ${DATADIR_BUILD}/gnucash/gtkbuilder)
-endif(WITH_AQBANKING)
+endif()
 
 set_local_dist(aqbanking_DIST_local CMakeLists.txt migratable-prefs-aqbanking.xml
         ${aqbanking_SOURCES} ${aqbanking_noinst_HEADERS} ${aqbanking_EXTRA_DIST}
diff --git a/gnucash/import-export/aqb/gschemas/CMakeLists.txt b/gnucash/import-export/aqb/gschemas/CMakeLists.txt
index 7b162c2a7..ba5425e6b 100644
--- a/gnucash/import-export/aqb/gschemas/CMakeLists.txt
+++ b/gnucash/import-export/aqb/gschemas/CMakeLists.txt
@@ -3,6 +3,6 @@ if (WITH_AQBANKING)
   set(aqb_GSCHEMA org.gnucash.dialogs.import.hbci.gschema.xml)
 
   add_gschema_targets("${aqb_GSCHEMA}")
-endif(WITH_AQBANKING)
+endif()
 
 set_dist_list(aqbanking_gschema_DIST CMakeLists.txt org.gnucash.dialogs.import.hbci.gschema.xml.in)
diff --git a/gnucash/import-export/ofx/gschemas/CMakeLists.txt b/gnucash/import-export/ofx/gschemas/CMakeLists.txt
index 762596383..bed4fd6cc 100644
--- a/gnucash/import-export/ofx/gschemas/CMakeLists.txt
+++ b/gnucash/import-export/ofx/gschemas/CMakeLists.txt
@@ -3,6 +3,6 @@ if (WITH_OFX)
   set(ofx_GSCHEMA org.gnucash.dialogs.import.ofx.gschema.xml)
 
   add_gschema_targets("${ofx_GSCHEMA}")
-endif (WITH_OFX)
+endif()
 
 set_dist_list(ofx_gschema_DIST CMakeLists.txt org.gnucash.dialogs.import.ofx.gschema.xml.in)
diff --git a/gnucash/import-export/ofx/test/CMakeLists.txt b/gnucash/import-export/ofx/test/CMakeLists.txt
index 8b1b7b9a3..536e37376 100644
--- a/gnucash/import-export/ofx/test/CMakeLists.txt
+++ b/gnucash/import-export/ofx/test/CMakeLists.txt
@@ -5,6 +5,6 @@ if(WITH_OFX)
   set(OFX_TEST_LIBS)
 
   gnc_add_test(test-link-ofx test-link.c OFX_TEST_INCLUDE_DIRS OFX_TEST_LIBS)
-endif(WITH_OFX)
+endif()
 
 set_dist_list(test_ofx_DIST CMakeLists.txt test-link.c)
\ No newline at end of file
diff --git a/gnucash/import-export/qif-imp/test/CMakeLists.txt b/gnucash/import-export/qif-imp/test/CMakeLists.txt
index b367578e7..18589cb76 100644
--- a/gnucash/import-export/qif-imp/test/CMakeLists.txt
+++ b/gnucash/import-export/qif-imp/test/CMakeLists.txt
@@ -15,7 +15,7 @@ gnc_add_test(test-link-qif-imp test-link.c QIF_IMP_TEST_INCLUDE_DIRS QIF_IMP_TES
 if (HAVE_SRFI64)
   gnc_add_scheme_tests("${scm_qifimp_test_with_srfi64_SOURCES}")
   add_dependencies(check scm-qif-import-2 scm-qif-import)
-endif (HAVE_SRFI64)
+endif()
 
 set_dist_list(test_qif_import_DIST CMakeLists.txt test-link.c
   ${scm_qifimp_test_with_srfi64_SOURCES})
diff --git a/gnucash/python/CMakeLists.txt b/gnucash/python/CMakeLists.txt
index a6690ddf8..77fcdced6 100644
--- a/gnucash/python/CMakeLists.txt
+++ b/gnucash/python/CMakeLists.txt
@@ -33,7 +33,7 @@ endif()
 
   file(COPY ${pycons_DATA} DESTINATION ${CMAKE_BINARY_DIR}/share/gnucash/python/pycons)
   file(COPY init.py DESTINATION ${CMAKE_BINARY_DIR}/share/gnucash/python)
-endif(WITH_PYTHON)
+endif()
 
 set_local_dist(pycons_DIST ${pycons_DATA})
 set_local_dist(python_DIST_local CMakeLists.txt gncmod-python.c init.py)
diff --git a/gnucash/register/register-gnome/CMakeLists.txt b/gnucash/register/register-gnome/CMakeLists.txt
index 5aa82ffa3..110ecb08b 100644
--- a/gnucash/register/register-gnome/CMakeLists.txt
+++ b/gnucash/register/register-gnome/CMakeLists.txt
@@ -6,10 +6,10 @@ check_symbol_exists(GDK_MODIFIER_INTENT_DEFAULT_MOD_MASK gdk/gdktypes.h have_mod
 if (NOT have_mod_mask)
 if (MAC_INTEGRATION)
   add_definitions(-DGDK_MODIFIER_INTENT_DEFAULT_MOD_MASK=GDK_SHIFT_MASK|GDK_CONTROL_MASK|GDK_MOD1_MASK|GDK_MOD2_MASK|GDK_SUPER_MASK|GDK_HYPER_MASK|GDK_META_MASK)
-else (MAC_INTEGRATION)
+else()
   add_definitions(-DGDK_MODIFIER_INTENT_DEFAULT_MOD_MASK=GDK_SHIFT_MASK|GDK_CONTROL_MASK|GDK_MOD1_MASK|GDK_SUPER_MASK|GDK_HYPER_MASK|GDK_META_MASK)
-endif(MAC_INTEGRATION)
-endif(NOT have_mod_mask)
+endif()
+endif()
 
 set (register_gnome_SOURCES
   gncmod-register-gnome.c
diff --git a/gnucash/report/business-reports/test/CMakeLists.txt b/gnucash/report/business-reports/test/CMakeLists.txt
index 2976ec48e..5e502bbc4 100644
--- a/gnucash/report/business-reports/test/CMakeLists.txt
+++ b/gnucash/report/business-reports/test/CMakeLists.txt
@@ -17,7 +17,7 @@ set(GUILE_DEPENDS
 
 if (HAVE_SRFI64)
   gnc_add_scheme_tests("${scm_test_business_reports_with_srfi64_SOURCES}")
-endif (HAVE_SRFI64)
+endif()
 
 gnc_add_scheme_targets(scm-test-business-reports
   "${scm_test_business_reports_SOURCES}"
diff --git a/gnucash/report/report-system/test/CMakeLists.txt b/gnucash/report/report-system/test/CMakeLists.txt
index 51e752e7e..72ce24c1f 100644
--- a/gnucash/report/report-system/test/CMakeLists.txt
+++ b/gnucash/report/report-system/test/CMakeLists.txt
@@ -37,7 +37,7 @@ gnc_add_scheme_tests("${scm_test_report_system_SOURCES}")
 
 if (HAVE_SRFI64)
   gnc_add_scheme_tests ("${scm_test_report_system_with_srfi64_SOURCES}")
-endif (HAVE_SRFI64)
+endif()
 
 gnc_add_scheme_targets(scm-test-report-system
   "test-extras.scm"
diff --git a/gnucash/report/standard-reports/test/CMakeLists.txt b/gnucash/report/standard-reports/test/CMakeLists.txt
index 839fa946a..7c2e6b7fc 100644
--- a/gnucash/report/standard-reports/test/CMakeLists.txt
+++ b/gnucash/report/standard-reports/test/CMakeLists.txt
@@ -40,8 +40,8 @@ if (HAVE_SRFI64)
   gnc_add_scheme_tests("${scm_test_with_srfi64_SOURCES}")
   if (HAVE_TEXT_PORTS)
     gnc_add_scheme_tests("${scm_test_with_textual_ports_SOURCES}")
-  endif (HAVE_TEXT_PORTS)
-endif (HAVE_SRFI64)
+  endif()
+endif()
 
 gnc_add_scheme_tests("${scm_test_standard_reports_SOURCES}")
 
diff --git a/gnucash/report/stylesheets/CMakeLists.txt b/gnucash/report/stylesheets/CMakeLists.txt
index ede0652a0..3743517e7 100644
--- a/gnucash/report/stylesheets/CMakeLists.txt
+++ b/gnucash/report/stylesheets/CMakeLists.txt
@@ -19,7 +19,7 @@ target_compile_definitions(gncmod-stylesheets PRIVATE -DG_LOG_DOMAIN=\"gnc.repor
 set(LIB_DIR ${CMAKE_INSTALL_LIBDIR}/gnucash)
 if (WIN32)
   set(LIB_DIR ${CMAKE_INSTALL_BINDIR})
-endif(WIN32)
+endif()
 
 
 if (APPLE)
diff --git a/po/CMakeLists.txt b/po/CMakeLists.txt
index 4c20e145a..25aa9a6a8 100644
--- a/po/CMakeLists.txt
+++ b/po/CMakeLists.txt
@@ -91,7 +91,7 @@ function(make_gnucash_potfiles)
         AND
         NOT ${path} MATCHES "/[.][^/]*$")
         list (APPEND GOOD_FILES ${path})
-    endif ()
+    endif()
   endforeach (path)
 
   # Remove the paths that we have marked as explicitly skipped
@@ -142,7 +142,7 @@ if(BUILDING_FROM_VCS)
 
   if (${XGETTEXT} STREQUAL "XGETTEXT-NOTFOUND")
     message(FATAL_ERROR "Can't find the 'xgettext' program.")
-  endif ()
+  endif()
 
   add_custom_command(OUTPUT gnucash.pot
         COMMAND ${CMAKE_COMMAND}

commit 7f794bb26b9c336b0489c202a1ee305bf66e68be
Merge: e523d5280 4f624087e
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Thu Feb 6 20:37:43 2020 +0800

    Merge branch 'maint-fix-budget-totals' into maint


commit e523d52802ce85432534b19e451cd5fa02cab15d
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Wed Feb 5 17:07:18 2020 +0800

    [eguile-gnc] show error after stacktrace
    
    ... which makes the error more visible
    and reuse gnc:html-string-sanitize

diff --git a/gnucash/report/report-system/eguile-gnc.scm b/gnucash/report/report-system/eguile-gnc.scm
index 76a48b04c..4a033bc04 100644
--- a/gnucash/report/report-system/eguile-gnc.scm
+++ b/gnucash/report/report-system/eguile-gnc.scm
@@ -87,6 +87,7 @@
 (use-modules (ice-9 rdelim))      ; for read-line
 (use-modules (ice-9 local-eval))  ; for the-environment
 (use-modules (gnucash app-utils)) ; for _
+(use-modules (gnucash utilities)) ; for gnc:html-string-sanitize
 
 (define-public (string-substitute-alist str sub-alist)
   (with-output-to-string
@@ -98,15 +99,6 @@
               c)))
        str))))
 
-;; This is needed for displaying error messages -- note that it assumes that
-;; the output is HTML, which is a pity, because otherwise this module is
-;; non-specific -- it is designed to output a mixture of Guile and any other
-;; sort of text.  Oh well.
-(define-public (escape-html s1)
-  (string-substitute-alist s1 '((#\< . "<")
-                                (#\> . ">")
-                                (#\& . "&"))))
-
 ;; regexps used to find start and end of code segments
 (define startre (and (defined? 'make-regexp) (make-regexp "<\\?scm(:d)?[[:space:]]")))
 (define endre   (and (defined? 'make-regexp) (make-regexp "(^|[[:space:]])\\?>")))
@@ -203,11 +195,12 @@
     (display (_ "An error occurred when processing the template:"))
     (display "<br/><pre>")
     (display
-     (escape-html
+     (gnc:html-string-sanitize
       (with-output-to-string
         (lambda ()
-          (display-error #f (current-output-port) subr message args rest)
-          (display-backtrace error-stack (current-output-port))))))
+          (display-backtrace error-stack (current-output-port))
+          (newline)
+          (display-error #f (current-output-port) subr message args rest)))))
     (display "</pre><br/>"))
 
   (define (pre-unwind-handler key . rest)

commit a0fb7d3bd6584e5fcb7b936c44b215a3356dde0c
Merge: e79e82edc a456c8a33
Author: Geert Janssens <geert at kobaltwit.be>
Date:   Wed Feb 5 16:25:19 2020 +0100

    Merge branch 'patch-1' of https://github.com/pau4o/gnucash into maint


commit 4f624087e1e0c521aca46254633b3ae1ad7d5d78
Author: Geert Janssens <geert at kobaltwit.be>
Date:   Wed Feb 5 16:02:44 2020 +0100

    Budget Treeview - reshuffle totals logic
    
    The rearranged switch statements case on row_type rather than
    account type. This gives better isolation of the account types
    vs row_types in the conditions inside each case.

diff --git a/gnucash/gnome/gnc-budget-view.c b/gnucash/gnome/gnc-budget-view.c
index 76ef3904e..7b44c294a 100644
--- a/gnucash/gnome/gnc-budget-view.c
+++ b/gnucash/gnome/gnc-budget-view.c
@@ -1188,74 +1188,71 @@ totals_col_source (GtkTreeViewColumn *col, GtkCellRenderer *cell,
 
     for (i = 0; i < num_top_accounts; ++i)
     {
+        GNCAccountType acctype;
+
         account  = gnc_account_nth_child (priv->rootAcct, i);
         currency = gnc_account_get_currency_or_parent (account);
+        acctype = xaccAccountGetType (account);
 
         if (gnc_using_unreversed_budgets(gnc_account_get_book(account)))
         {  /* using book with unreversed-budgets feature. This will be
               the default in 4.x after budget scrubbing*/
             neg = gnc_reverse_balance (account);
-            switch (xaccAccountGetType (account))
+
+            switch (row_type)
             {
-            case ACCT_TYPE_ASSET:
-                if (row_type != TOTALS_TYPE_ASSET_LIAB_EQ &&
-                    row_type != TOTALS_TYPE_REMAINDER)
-                    continue;
-                if (row_type == TOTALS_TYPE_REMAINDER)
-                    neg = !neg;
-                break;
-            case ACCT_TYPE_LIABILITY:
-            case ACCT_TYPE_EQUITY:
-                if (row_type != TOTALS_TYPE_ASSET_LIAB_EQ &&
-                    row_type != TOTALS_TYPE_REMAINDER)
-                    continue;
-                if (row_type == TOTALS_TYPE_ASSET_LIAB_EQ)
+                case TOTALS_TYPE_ASSET_LIAB_EQ:
+                    if ((acctype == ACCT_TYPE_LIABILITY) ||
+                        (acctype == ACCT_TYPE_EQUITY))
+                        neg = !neg;
+                    else if (acctype != ACCT_TYPE_ASSET)
+                        continue;
+                    break;
+                case TOTALS_TYPE_EXPENSES:
+                    if (acctype != ACCT_TYPE_EXPENSE)
+                        continue;
+                    break;
+                case TOTALS_TYPE_INCOME:
+                    if (acctype != ACCT_TYPE_INCOME)
+                        continue;
                     neg = !neg;
-                break;
-            case ACCT_TYPE_INCOME:
-                if (row_type != TOTALS_TYPE_INCOME &&
-                    row_type != TOTALS_TYPE_REMAINDER)
-                    continue;
-                neg = !neg;
-                break;
-            case ACCT_TYPE_EXPENSE:
-                if ((row_type != TOTALS_TYPE_EXPENSES) &&
-                    (row_type != TOTALS_TYPE_REMAINDER))
-                    continue;
-                if (row_type == TOTALS_TYPE_REMAINDER)
-                    neg = !neg;
-                break;
-            default:
-                continue;       /* skip other types... */
+                    break;
+                case TOTALS_TYPE_REMAINDER:
+                    if ((acctype == ACCT_TYPE_ASSET) ||
+                        (acctype == ACCT_TYPE_INCOME) ||
+                        (acctype == ACCT_TYPE_EXPENSE))
+                        neg = !neg;
+                    break;
+                default:
+                    continue;       /* don't count if unexpected total row type is passed in... */
             }
         }
         else
         {   /* this section is for backward compatibility, to be
                removed when unreversed-budgets are mandatory */
-            switch (xaccAccountGetType (account))
+            neg = FALSE;
+
+            switch (row_type)
             {
-            case ACCT_TYPE_ASSET:
-            case ACCT_TYPE_LIABILITY:
-            case ACCT_TYPE_EQUITY:
-                if (row_type != TOTALS_TYPE_ASSET_LIAB_EQ &&
-                    row_type != TOTALS_TYPE_REMAINDER)
-                    continue;
-                neg = (row_type != TOTALS_TYPE_ASSET_LIAB_EQ);
-                break;
-            case ACCT_TYPE_INCOME:
-                if (row_type != TOTALS_TYPE_INCOME &&
-                    row_type != TOTALS_TYPE_REMAINDER)
-                    continue;
-                neg = FALSE;
-                break;
-            case ACCT_TYPE_EXPENSE:
-                if ((row_type != TOTALS_TYPE_EXPENSES) &&
-                    (row_type != TOTALS_TYPE_REMAINDER))
-                    continue;
-                neg = (row_type == TOTALS_TYPE_REMAINDER);
-                break;
-            default:
-                continue;       /* skip other types... */
+                case TOTALS_TYPE_ASSET_LIAB_EQ:
+                    if ((acctype != ACCT_TYPE_ASSET) &&
+                        (acctype != ACCT_TYPE_LIABILITY) &&
+                        (acctype != ACCT_TYPE_EQUITY))
+                        continue;
+                    break;
+                case TOTALS_TYPE_EXPENSES:
+                    if (acctype != ACCT_TYPE_EXPENSE)
+                        continue;
+                    break;
+                case TOTALS_TYPE_INCOME:
+                    if (acctype != ACCT_TYPE_INCOME)
+                        continue;
+                    break;
+                case TOTALS_TYPE_REMAINDER:
+                    neg = (acctype != ACCT_TYPE_INCOME);
+                    break;
+                default:
+                    continue;       /* don't count if unexpected total row type is passed in... */
             }
         }
         // find the total for this account

commit e79e82edcfe8db67d17d950b001e9ab196b720f3
Author: Geert Janssens <geert at kobaltwit.be>
Date:   Thu Jan 30 12:20:25 2020 +0100

    CMake - remove parameter repetition in else() and endif() statements
    
    This follows Professional CMake's recommended practises

diff --git a/libgnucash/app-utils/test/CMakeLists.txt b/libgnucash/app-utils/test/CMakeLists.txt
index 435250c60..484820c49 100644
--- a/libgnucash/app-utils/test/CMakeLists.txt
+++ b/libgnucash/app-utils/test/CMakeLists.txt
@@ -68,7 +68,7 @@ gnc_add_scheme_tests("${test_app_utils_scheme_SOURCES}")
 
 if (HAVE_SRFI64)
   gnc_add_scheme_tests("${test_app_utils_scheme_SRFI64_SOURCES}")
-endif ()
+endif()
 
 # Doesn't work yet:
 gnc_add_test_with_guile(test-app-utils "${test_app_utils_SOURCES}" APP_UTILS_TEST_INCLUDE_DIRS APP_UTILS_TEST_LIBS)
diff --git a/libgnucash/backend/dbi/CMakeLists.txt b/libgnucash/backend/dbi/CMakeLists.txt
index ff7d760c7..668e3e096 100644
--- a/libgnucash/backend/dbi/CMakeLists.txt
+++ b/libgnucash/backend/dbi/CMakeLists.txt
@@ -32,7 +32,7 @@ if (WITH_SQL)
   set(WINSOCK_LIB "")
   if(MINGW64)
     set(WINSOCK_LIB "-lws2_32")
-  endif(MINGW64)
+  endif()
   target_link_libraries(gncmod-backend-dbi gnc-backend-sql gncmod-engine ${GTK2_LDFLAGS} ${Boost_REGEX_LIBRARY} ${LIBDBI_LIBRARY} ${WINSOCK_LIB})
 
   target_compile_definitions(gncmod-backend-dbi PRIVATE -DG_LOG_DOMAIN=\"gnc.backend.dbi\")
@@ -48,4 +48,4 @@ if (WITH_SQL)
     ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/gnucash
     RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
 # No headers to install
-endif(WITH_SQL)
+endif()
diff --git a/libgnucash/backend/sql/CMakeLists.txt b/libgnucash/backend/sql/CMakeLists.txt
index ebd2a8324..8949546d2 100644
--- a/libgnucash/backend/sql/CMakeLists.txt
+++ b/libgnucash/backend/sql/CMakeLists.txt
@@ -81,4 +81,4 @@ if(WITH_SQL)
     RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
 
   # No headers to install
-endif(WITH_SQL)
+endif()
diff --git a/libgnucash/backend/sql/test/CMakeLists.txt b/libgnucash/backend/sql/test/CMakeLists.txt
index d0c06ccfc..cb1b6ecb6 100644
--- a/libgnucash/backend/sql/test/CMakeLists.txt
+++ b/libgnucash/backend/sql/test/CMakeLists.txt
@@ -24,4 +24,4 @@ if(WITH_SQL)
     BACKEND_SQL_TEST_INCLUDE_DIRS BACKEND_SQL_TEST_LIBS
   )
   target_compile_definitions(test-sqlbe PRIVATE TESTPROG=test_sqlbe)
-endif(WITH_SQL)
+endif()
diff --git a/libgnucash/backend/xml/CMakeLists.txt b/libgnucash/backend/xml/CMakeLists.txt
index 3c5c96dd3..d7dff2a08 100644
--- a/libgnucash/backend/xml/CMakeLists.txt
+++ b/libgnucash/backend/xml/CMakeLists.txt
@@ -112,7 +112,7 @@ target_compile_definitions (gncmod-backend-xml PRIVATE -DG_LOG_DOMAIN=\"gnc.back
 set(LIB_DIR ${CMAKE_INSTALL_LIBDIR}/gnucash)
 if (WIN32)
   set(LIB_DIR ${CMAKE_INSTALL_BINDIR})
-endif(WIN32)
+endif()
 
 
 if (APPLE)
diff --git a/libgnucash/core-utils/CMakeLists.txt b/libgnucash/core-utils/CMakeLists.txt
index 3960cd7c4..c12fe3dee 100644
--- a/libgnucash/core-utils/CMakeLists.txt
+++ b/libgnucash/core-utils/CMakeLists.txt
@@ -72,9 +72,9 @@ add_custom_target(gnc-vcs-info ALL
                              -D SHELL="${SHELL}"
                              -P ${CMAKE_SOURCE_DIR}/cmake/git2version-info.cmake
 )
-else(BUILDING_FROM_VCS)
+else()
   add_custom_target(gnc-vcs-info DEPENDS ${VCS_INFO_FILE})
-endif(BUILDING_FROM_VCS)
+endif()
 dist_add_generated (${BUILDING_FROM_VCS} gnc-vcs-info.h)
 ### Compile library
 
@@ -124,10 +124,10 @@ target_include_directories(gnc-core-utils PUBLIC ${core_utils_ALL_INCLUDES})
 
 if (MAC_INTEGRATION)
   target_compile_options(gnc-core-utils PRIVATE ${OSX_EXTRA_COMPILE_FLAGS})
-endif(MAC_INTEGRATION)
+endif()
 if (BUILDING_FROM_VCS)
   target_compile_definitions(gnc-core-utils PRIVATE -DGNC_VCS=\"git\")
-endif (BUILDING_FROM_VCS)
+endif()
 
 install(TARGETS gnc-core-utils
   LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
diff --git a/libgnucash/core-utils/test/CMakeLists.txt b/libgnucash/core-utils/test/CMakeLists.txt
index 6da6d16a5..29e629f94 100644
--- a/libgnucash/core-utils/test/CMakeLists.txt
+++ b/libgnucash/core-utils/test/CMakeLists.txt
@@ -25,7 +25,7 @@ endif()
 if (MAC_INTEGRATION)
   target_compile_options(test-userdata-dir PRIVATE ${OSX_EXTRA_COMPILE_FLAGS})
   target_compile_definitions(test-userdata-dir PRIVATE ${GTK_MAC_CFLAGS_OTHER})
-endif(MAC_INTEGRATION)
+endif()
 
 set(gtest_core_utils_INCLUDES
   ${MODULEPATH}
diff --git a/libgnucash/doc/design/CMakeLists.txt b/libgnucash/doc/design/CMakeLists.txt
index 4a35ebe79..17a91748c 100644
--- a/libgnucash/doc/design/CMakeLists.txt
+++ b/libgnucash/doc/design/CMakeLists.txt
@@ -38,7 +38,7 @@ if (NOT ${MAKEINFO} STREQUAL "MAKEINFO-NOTFOUND")
     COMMAND ${MAKEINFO} -I ${TEXI_BINARY_DIR} ${TEXI_SOURCE_FILE}
     DEPENDS ${gnucash_design_TEXINFOS}
   )
-endif (NOT ${MAKEINFO} STREQUAL "MAKEINFO-NOTFOUND")
+endif()
 dist_add_generated (${BUILDING_FROM_VCS} gnucash-design.info)
 
 set_dist_list(doc_design_DIST CMakeLists.txt gnucash-design.texi ${gnucash_design_TEXINFOS})
diff --git a/libgnucash/engine/CMakeLists.txt b/libgnucash/engine/CMakeLists.txt
index 8af499ece..62c760b28 100644
--- a/libgnucash/engine/CMakeLists.txt
+++ b/libgnucash/engine/CMakeLists.txt
@@ -212,7 +212,7 @@ if (WIN32)
   qof-win32.cpp
   ../../borrowed/libc/strptime.c
   )
-endif (WIN32)
+endif()
 
 # Add dependency on config.h
 set_source_files_properties (${engine_SOURCES} PROPERTIES OBJECT_DEPENDS ${CONFIG_H})
@@ -281,7 +281,7 @@ set (engine_SCHEME_1
 set(BACKEND_DEPENDS gncmod-backend-xml)
 if (WITH_SQL)
     list(APPEND BACKEND_DEPENDS gncmod-backend-dbi)
-endif(WITH_SQL)
+endif()
 
 set(GUILE_DEPENDS
   ${BACKEND_DEPENDS}
@@ -321,7 +321,7 @@ set(engine_EXTRA_DIST
 
 if (NOT WIN32)
   list(APPEND engine_EXTRA_DIST qof-win32.cpp)
-endif (NOT WIN32)
+endif()
 set_local_dist(engine_DIST_local CMakeLists.txt ${engine_SOURCES} ${engine_HEADERS}
                      ${engine_noinst_HEADERS} ${engine_SCHEME_0} ${engine_SCHEME_1} ${engine_EXTRA_DIST})
 set(engine_DIST ${engine_DIST_local} ${engine_test_core_DIST} ${test_engine_DIST} PARENT_SCOPE)
diff --git a/libgnucash/engine/test/CMakeLists.txt b/libgnucash/engine/test/CMakeLists.txt
index c04871054..49d4b89f9 100644
--- a/libgnucash/engine/test/CMakeLists.txt
+++ b/libgnucash/engine/test/CMakeLists.txt
@@ -119,7 +119,7 @@ if (WIN32)
     ${MODULEPATH}/qof-win32.cpp
     ../../../borrowed/libc/strptime.c
   )
-endif (WIN32)
+endif()
 
 set(test_gnc_guid_SOURCES
   ${MODULEPATH}/guid.cpp
@@ -244,7 +244,7 @@ if (HAVE_SRFI64)
 
   gnc_add_scheme_tests("${scm_tests_with_srfi64_SOURCES}")
   add_dependencies(check scm-srfi64-extras)
-endif (HAVE_SRFI64)
+endif()
 
 gnc_add_scheme_targets(scm-test-engine
   "${engine_test_SCHEME}"
diff --git a/libgnucash/scm/test/CMakeLists.txt b/libgnucash/scm/test/CMakeLists.txt
index 677d6124a..c9cdbc7c6 100644
--- a/libgnucash/scm/test/CMakeLists.txt
+++ b/libgnucash/scm/test/CMakeLists.txt
@@ -19,7 +19,7 @@ if (HAVE_SRFI64)
 
   gnc_add_scheme_tests("${scm_test_SCHEME}")
 
-endif (HAVE_SRFI64)
+endif()
 
 set_dist_list(test_scm_DIST
   CMakeLists.txt

commit 8365283f1834b341883f71eb20bff6a1cf6cab6d
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Wed Feb 5 16:31:44 2020 +0800

    Bug 797609 - Backtraces for eguile report errors strips wrong part of stack
    
    Previous code used invalid algorithm to capture the desired error
    stack. Use simpler capture code, which does not require capturing the
    good stack.

diff --git a/gnucash/report/report-system/eguile-gnc.scm b/gnucash/report/report-system/eguile-gnc.scm
index f37b95dd3..76a48b04c 100644
--- a/gnucash/report/report-system/eguile-gnc.scm
+++ b/gnucash/report/report-system/eguile-gnc.scm
@@ -183,65 +183,38 @@
 ;;   env  - environment in which to do the evaluation;
 ;;          if #f, (the-environment) will be used
 (define (script->output env)
-  ; Placeholder for the normal stack and error stack in case of an error
-  (define good-stack #f)
+
+  ;; Placeholder for the error stack in case of an error
   (define error-stack #f)
-  ; Actual evaluation function. This is where the work happens.
+  (define local-env (or env (the-environment)))
+
+  ;; Actual evaluation function. This is where the work happens.
   (define (eval-input)
-    (let ((s-expression (read)))
-      (while (not (eof-object? s-expression))
-	     ; Capture the current stack, so we can detect from where we
-	     ; need to display the stack trace
-	     (set! good-stack (make-stack #t))
-             (local-eval s-expression (or env (the-environment)))
-             (set! s-expression (read)))))
+    (let lp ((next (read)))
+      (cond
+       ((eof-object? next) #f)
+       (else
+        (local-eval next local-env)
+        (lp (read))))))
 
-  ; Error handler to display any errors while evaluating the template
+  ;; Error handler to display any errors while evaluating the template
   (define (error-handler key subr message args . rest)
     (display "<p>")
     (display (_ "An error occurred when processing the template:"))
-    (display "<br><pre>")
+    (display "<br/><pre>")
     (display
-      (escape-html
-        (with-output-to-string
-          (lambda ()
-            (display-error #f (current-output-port) subr message args rest)))))
-	    ; Find out how many frames are interesting. From the
-	    ; good-stack, all but the bottom two frames are in
-	    ; error-stack as well, so we can remove the top #good - 2
-	    ; right away. Below that, there is still one frame in error
-	    ; stack, the call to local-eval, which we'll remove as well.
-	    ; So (#good - 2) + 1 == #good - 1 to remove from the top.
-	    ; We remove the bottom three frames as well: the pre-unwind
-	    ; handler, make-trace and one frame inside make-trace.
-	    (let* ((remove-top (- (stack-length good-stack) 1))
-		   (remove-bottom 3)
-		   (error-length (stack-length error-stack)))
-	      ; Show the backtrace. Remove one extra from the "first"
-	      ; argument, since that is an index, not a count.
-	      (display-backtrace error-stack
-                                 (current-output-port)
-                                 (- (- error-length remove-top) 1)
-                                 (- (- error-length remove-top) remove-bottom)))
-    (display "</pre><br>"))
+     (escape-html
+      (with-output-to-string
+        (lambda ()
+          (display-error #f (current-output-port) subr message args rest)
+          (display-backtrace error-stack (current-output-port))))))
+    (display "</pre><br/>"))
 
-  ; This handler will be called by catch before unwinding the
-  ; stack, so we can capture it. The above handler will then be called
-  ; to actually handle the exception. This technique is based on the
-  ; example in the guile manual. See:
-  ; https://www.gnu.org/software/guile/manual/html_node/Debug-on-Error.html
   (define (pre-unwind-handler key . rest)
-    ; Save the current stack. Note that this will include a couple of
-    ; extra entries (this error handler, the call to make-stack and
-    ; another one to gsubr-apply) which we'll cutt off at the display
-    ; above.
-    (set! error-stack (make-stack #t))
-    ; And throw the error again
-    (apply throw key rest))
+    ;; Capture the stack here, cut the last 3 frames which are
+    ;; make-stack, this one, and the throw handler.
+    (set! error-stack (make-stack #t 3)))
 
-  ; Use two nested catches. The inner one is lazy and does not unwind,
-  ; so it can catch th stack. The outer one does the real error
-  ; handling.
   (catch #t eval-input error-handler pre-unwind-handler))
 
 ; end of (script->output)

commit bb986e474cf927335ce730c5709802e127297c4f
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Wed Feb 5 16:31:20 2020 +0800

    [eguile-utilities] compact code, use (ice-9 match)

diff --git a/gnucash/report/report-system/eguile-utilities.scm b/gnucash/report/report-system/eguile-utilities.scm
index 0e536212f..f3e3e4923 100644
--- a/gnucash/report/report-system/eguile-utilities.scm
+++ b/gnucash/report/report-system/eguile-utilities.scm
@@ -23,6 +23,7 @@
 ;; 02111-1307 USA
 
 (define-module (gnucash report eguile-utilities))
+(use-modules (ice-9 match))
 
 ; using all of these seems like overkill -- 
 ; not sure which are really required
@@ -35,13 +36,10 @@
 
 (define-public (fmtnumber n)
   ;; Format a number (integer or real) into something printable
-  (number->string (if (integer? n) 
-                    (inexact->exact n) 
-                    n)))
+  (number->string (if (integer? n) (inexact->exact n) n)))
 
-(define-public (fmtnumeric n)
-  ;; Format gnc-numeric n with as many decimal places as required
-  (fmtnumber (gnc-numeric-to-double n)))
+;; Format gnc-numeric n with as many decimal places as required
+(define-public fmtnumeric fmtnumber)
 
 (define-public (gnc-monetary-neg? monetary)
   ; return true if the monetary value is negative
@@ -49,14 +47,15 @@
 
 ;; 'Safe' versions of cdr and cadr that don't crash
 ;; if the list is empty  (is there a better way?)
-(define-public (safe-cdr l)
-  (if (null? l) '()
-      (cdr l)))
-(define-public (safe-cadr l)
-  (cond
-   ((null? l) '())
-   ((null? (cdr l)) '())
-   (else (cadr l))))
+(define-public safe-cdr
+  (match-lambda
+    ((_ . x) x)
+    (_ '())))
+
+(define-public safe-cadr
+  (match-lambda
+    ((_ x . _) x)
+    (_ '())))
 
 (define-public (find-file fname)
   ;; Find the file 'fname', and return its full path.

commit c94b433187e2e67f56f454bbc7ec58601757fe8a
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Wed Feb 5 15:35:18 2020 +0800

    [commodity-utilities] compact code, use (ice-9 match)

diff --git a/gnucash/report/report-system/commodity-utilities.scm b/gnucash/report/report-system/commodity-utilities.scm
index c6e1f29bb..1463ef081 100644
--- a/gnucash/report/report-system/commodity-utilities.scm
+++ b/gnucash/report/report-system/commodity-utilities.scm
@@ -618,10 +618,9 @@ construct with gnc:make-gnc-monetary and gnc:monetary->string instead.")
   ;; total balances from get-exchange-totals are divided by each
   ;; other.
   (map
-   (lambda (e)
-     (list (car e)
-           (abs (/ ((cdadr e) 'total #f)
-                   ((caadr e) 'total #f)))))
+   (match-lambda
+     ((comm (domestic . foreign))
+      (list comm (abs (/ (foreign 'total #f) (domestic 'total #f))))))
    (gnc:get-exchange-totals report-commodity end-date)))
 
 (define (gnc:make-exchange-cost-alist report-commodity end-date)
@@ -629,12 +628,10 @@ construct with gnc:make-gnc-monetary and gnc:monetary->string instead.")
   ;; total balances from get-exchange-totals are divided by each
   ;; other.
   (map
-   (lambda (e)
-     (list (car e)
-           (if (zero? ((caadr e) 'total #f))
-               0
-               (abs (/ ((cdadr e) 'total #f)
-                       ((caadr e) 'total #f))))))
+   (match-lambda
+     ((comm (domestic . foreign))
+      (let ((denom (domestic 'total #f)))
+        (list comm (if (zero? denom) 0 (abs (/ (foreign 'total #f) denom)))))))
    (gnc:get-exchange-cost-totals report-commodity end-date)))
 
 
@@ -973,7 +970,7 @@ construct with gnc:make-gnc-monetary and gnc:monetary->string instead.")
 (define (gnc:uniform-commodity? amt report-commodity)
   ;; function to see if the commodity-collector amt
   ;; contains any foreign commodities
-  (let ((list-of-commodities (amt 'format (lambda (comm amt) comm) #f)))
-    (or (null? list-of-commodities)
-        (and (null? (cdr list-of-commodities))
-             (gnc-commodity-equiv report-commodity (car list-of-commodities))))))
+  (match (amt 'format (lambda (comm amt) comm) #f)
+    (() #t)
+    ((comm) (gnc-commodity-equiv report-commodity comm))
+    (_ #f)))

commit ad094f4345f590fb9258258f3292e11a05b7f44f
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Wed Feb 5 15:35:01 2020 +0800

    [report-utilities] compact code, use (ice-9 match)

diff --git a/gnucash/report/report-system/report-utilities.scm b/gnucash/report/report-system/report-utilities.scm
index 0383bc969..20cff240c 100644
--- a/gnucash/report/report-system/report-utilities.scm
+++ b/gnucash/report/report-system/report-utilities.scm
@@ -423,11 +423,10 @@ construct gnc:make-gnc-monetary and use gnc:monetary->string instead.")
 ;; usage: (gnc:monetaries-add monetary1 monetary2 ...)
 ;; output: a monetary object
 (define (gnc:monetary+ . monetaries)
-  (let* ((coll (apply gnc:monetaries-add monetaries))
-         (list-of-monetaries (coll 'format gnc:make-gnc-monetary #f)))
-    (if (null? (cdr list-of-monetaries))
-        (car list-of-monetaries)
-        (throw "gnc:monetary+ expects 1 currency " (gnc:strify monetaries)))))
+  (let ((coll (apply gnc:monetaries-add monetaries)))
+    (match (coll 'format gnc:make-gnc-monetary #f)
+      ((mon) mon)
+      (_ (throw "gnc:monetary+ expects 1 currency " (gnc:strify monetaries))))))
 
 ;; get the account balance at the specified date. if include-children?
 ;; is true, the balances of all children (not just direct children)

commit dafff68914b085cc6520fd12dbcbadf849e7bebc
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Sun Feb 2 23:30:11 2020 +0800

    [lot-viewer] show lot guid in headers
    
    * also compact code, use partition
    * also don't need to localise option string for debugging tool

diff --git a/gnucash/report/standard-reports/lot-viewer.scm b/gnucash/report/standard-reports/lot-viewer.scm
index 01a061007..815fe9566 100644
--- a/gnucash/report/standard-reports/lot-viewer.scm
+++ b/gnucash/report/standard-reports/lot-viewer.scm
@@ -22,6 +22,7 @@
 (define-module (gnucash report standard-reports lot-viewer))
 
 (use-modules (srfi srfi-1))
+(use-modules (srfi srfi-11))            ;for let-values
 (use-modules (ice-9 match))
 (use-modules (gnucash utilities))
 (use-modules (gnucash gnc-module))
@@ -35,7 +36,7 @@
 (define optname-from-date (N_ "Start Date"))
 (define optname-to-date (N_ "End Date"))
 (define optname-account (N_ "Account"))
-(define optname-desc-filter (N_ "Desc Filter"))
+(define optname-desc-filter "Description Filter")
 
 (define txn-type-alist
   (list (cons TXN-TYPE-NONE "None")
@@ -133,6 +134,9 @@
       (let ((title (gnc-lot-get-title lot)))
         (if (string-null? title) "None" title)))
 
+    (define (lot->guid lot)
+      (string-take (gncLotReturnGUID lot) 8))
+
     (define (to-cell elt)
       (gnc:make-html-table-cell/markup "number-cell" elt))
 
@@ -158,8 +162,9 @@
 
      (else
       (let ((table (gnc:make-html-table)))
-        (gnc:html-table-set-col-headers!
-         table `("Date" "Desc" "Type" ,@(map lot->title lots) "Non-APAR"))
+        (gnc:html-table-set-multirow-col-headers!
+         table `(("Date" "Desc" "Type" ,@(map lot->title lots) "Other Account")
+                 (#f #f #f ,@(map lot->guid lots) #f)))
 
         (gnc:html-table-append-row!
          table `(#f "Document" #f ,@(map lot->document lots)))
@@ -180,11 +185,8 @@
                  (() (map (compose to-cell list->text) (reverse (cons splits accum))))
                  ((this-lot . rest-lots)
                   (define (in-lot? s) (member s (car lots-splits)))
-                  (let lp1 ((splits splits) (next '()) (this '()))
-                    (match splits
-                      (() (lp rest-lots (cdr lots-splits) next (cons this accum)))
-                      (((? in-lot? head) . tail) (lp1 tail next (cons head this)))
-                      ((head . tail) (lp1 tail (cons head next) this))))))))))
+                  (let-values (((this next) (partition in-lot? splits)))
+                    (lp rest-lots (cdr lots-splits) next (cons this accum)))))))))
          (sort transactions (lambda (a b) (< (xaccTransOrder a b) 0))))
 
         (gnc:html-table-append-row!

commit b0b6f2c6eb65b4521a17fa8c99267989e0b9f0b6
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Wed Feb 5 00:20:17 2020 +0800

    fix budget totals for unreversed budgets books

diff --git a/gnucash/gnome/gnc-budget-view.c b/gnucash/gnome/gnc-budget-view.c
index 0345303f0..76ef3904e 100644
--- a/gnucash/gnome/gnc-budget-view.c
+++ b/gnucash/gnome/gnc-budget-view.c
@@ -1190,33 +1190,73 @@ totals_col_source (GtkTreeViewColumn *col, GtkCellRenderer *cell,
     {
         account  = gnc_account_nth_child (priv->rootAcct, i);
         currency = gnc_account_get_currency_or_parent (account);
-        neg = FALSE;
 
-        switch (xaccAccountGetType (account))
-        {
-        case ACCT_TYPE_ASSET:
-        case ACCT_TYPE_LIABILITY:
-        case ACCT_TYPE_EQUITY:
-            if (row_type != TOTALS_TYPE_ASSET_LIAB_EQ &&
-                row_type != TOTALS_TYPE_REMAINDER)
-                continue;
-            neg = (row_type != TOTALS_TYPE_ASSET_LIAB_EQ);
-            break;
-        case ACCT_TYPE_INCOME:
-            if (row_type != TOTALS_TYPE_INCOME &&
-                row_type != TOTALS_TYPE_REMAINDER)
-                continue;
-            neg = (row_type == TOTALS_TYPE_ASSET_LIAB_EQ);
-            break;
-        case ACCT_TYPE_EXPENSE:
-            if ((row_type != TOTALS_TYPE_EXPENSES) &&
-                (row_type != TOTALS_TYPE_REMAINDER))
-                continue;
-            neg = (row_type == TOTALS_TYPE_REMAINDER ||
-                   row_type == TOTALS_TYPE_ASSET_LIAB_EQ);
-            break;
-        default:
-            continue;
+        if (gnc_using_unreversed_budgets(gnc_account_get_book(account)))
+        {  /* using book with unreversed-budgets feature. This will be
+              the default in 4.x after budget scrubbing*/
+            neg = gnc_reverse_balance (account);
+            switch (xaccAccountGetType (account))
+            {
+            case ACCT_TYPE_ASSET:
+                if (row_type != TOTALS_TYPE_ASSET_LIAB_EQ &&
+                    row_type != TOTALS_TYPE_REMAINDER)
+                    continue;
+                if (row_type == TOTALS_TYPE_REMAINDER)
+                    neg = !neg;
+                break;
+            case ACCT_TYPE_LIABILITY:
+            case ACCT_TYPE_EQUITY:
+                if (row_type != TOTALS_TYPE_ASSET_LIAB_EQ &&
+                    row_type != TOTALS_TYPE_REMAINDER)
+                    continue;
+                if (row_type == TOTALS_TYPE_ASSET_LIAB_EQ)
+                    neg = !neg;
+                break;
+            case ACCT_TYPE_INCOME:
+                if (row_type != TOTALS_TYPE_INCOME &&
+                    row_type != TOTALS_TYPE_REMAINDER)
+                    continue;
+                neg = !neg;
+                break;
+            case ACCT_TYPE_EXPENSE:
+                if ((row_type != TOTALS_TYPE_EXPENSES) &&
+                    (row_type != TOTALS_TYPE_REMAINDER))
+                    continue;
+                if (row_type == TOTALS_TYPE_REMAINDER)
+                    neg = !neg;
+                break;
+            default:
+                continue;       /* skip other types... */
+            }
+        }
+        else
+        {   /* this section is for backward compatibility, to be
+               removed when unreversed-budgets are mandatory */
+            switch (xaccAccountGetType (account))
+            {
+            case ACCT_TYPE_ASSET:
+            case ACCT_TYPE_LIABILITY:
+            case ACCT_TYPE_EQUITY:
+                if (row_type != TOTALS_TYPE_ASSET_LIAB_EQ &&
+                    row_type != TOTALS_TYPE_REMAINDER)
+                    continue;
+                neg = (row_type != TOTALS_TYPE_ASSET_LIAB_EQ);
+                break;
+            case ACCT_TYPE_INCOME:
+                if (row_type != TOTALS_TYPE_INCOME &&
+                    row_type != TOTALS_TYPE_REMAINDER)
+                    continue;
+                neg = FALSE;
+                break;
+            case ACCT_TYPE_EXPENSE:
+                if ((row_type != TOTALS_TYPE_EXPENSES) &&
+                    (row_type != TOTALS_TYPE_REMAINDER))
+                    continue;
+                neg = (row_type == TOTALS_TYPE_REMAINDER);
+                break;
+            default:
+                continue;       /* skip other types... */
+            }
         }
         // find the total for this account
 

commit a456c8a33cc60d4d94210e0c3e6810aa01c6c8e2
Author: Kamen Naydenov <pau4o at users.noreply.github.com>
Date:   Mon Feb 3 18:26:59 2020 +0200

    Fix white text on white background
    
    When dark theme is active in Gnome Shell it sets text colour to white, combined with background colour set in default style to white lead to unreadable reports.

diff --git a/gnucash/report/report-system/html-fonts.scm b/gnucash/report/report-system/html-fonts.scm
index abdd154dd..930419375 100644
--- a/gnucash/report/report-system/html-fonts.scm
+++ b/gnucash/report/report-system/html-fonts.scm
@@ -132,6 +132,7 @@
     (gnc:html-document-set-style-text!
      ssdoc
      (string-append
+      "@media (prefers-color-scheme: dark) {body {color: #000; background-color: #fff;}}\n"
       "h3 { " title-info " }\n"
       "a { " account-link-info " }\n"
       "body, p, table, tr, td { vertical-align: top; " text-cell-info " }\n"

commit f1667e7ba85bd449cd15af1630e16540b1da7e60
Author: Alex Aycinena <alex.aycinena at gmail.com>
Date:   Sun Feb 2 13:58:00 2020 -0800

    Update US Income Tax information for more 2019 changes

diff --git a/libgnucash/tax/us/txf.scm b/libgnucash/tax/us/txf.scm
index 250741788..f577fab12 100644
--- a/libgnucash/tax/us/txf.scm
+++ b/libgnucash/tax/us/txf.scm
@@ -153,7 +153,7 @@
     (cons 'N497 #(not-impl "Sched C-EZ" "Schedule C-EZ" 1 #t ""))
     (cons 'N498 #(not-impl "Sched C-EZ" "Spouse" 0 #t "" ((1992 ""))))
     (cons 'N501 #(not-impl "Sched C-EZ" "Principal business/prof" 2 #t "" ((1992 "A"))))
-    (cons 'N499 #(none "Sched C-EZ" "Gross receipts" 1 #t "" ((2012 "1") (2011 "1b") (1992 "1"))))
+    (cons 'N499 #(none "Sched C-EZ" "Gross receipts" 1 #t "" ((2012 "1") (2011 "1b") (1992 "1")) 2018))
 
     (cons 'N320 #(not-impl "Sched D" "Schedule D" 1 #f ""))
     (cons 'N321 #(not-impl "Form 8949 Copy A" "Short Term gain/loss - security" 5 #f "" ((2013 "Part I, 1") (2011 "1") (1993 "Sched D, line 1") (1991 "Sched D, line 1a") (1986 "Sched D, line 2a") (1985 "Sched D, line 1b") (1980 "Sched D, line 1"))))

commit a44bd34dcfaee61b549571d05780d865abde682f
Author: gnucash-dev <gnucash-dev at LenovoFedora30VM.home>
Date:   Sun Feb 2 13:13:50 2020 -0800

    Correct double-counting of accounts in some cases in US Income Tax Report.

diff --git a/gnucash/report/locale-specific/us/taxtxf.scm b/gnucash/report/locale-specific/us/taxtxf.scm
index e09cdf9a6..86a7aa8e4 100644
--- a/gnucash/report/locale-specific/us/taxtxf.scm
+++ b/gnucash/report/locale-specific/us/taxtxf.scm
@@ -1651,17 +1651,12 @@
   ) ;;end of let*
 )
 
-;; Recursively validate children if parent is not a tax account.
-;; Don't check children if parent is valid.
-;; Returns the Parent if a child or grandchild is valid.
+;; Returns #t if account is tax related.
 (define (validate accounts)
   (filter (lambda (a)
             (if (xaccAccountGetTaxRelated a)
                 #t
-                ;; check children
-                (if (null? (validate (gnc-account-get-descendants a)))
-                    #f
-                    #t)))
+                #f))
           accounts))
 
 (define (generate-tax-schedule report-name
@@ -1829,10 +1824,6 @@
                   )
                   selected-accounts-sorted-by-form-line-acct)
                );; end of if
-               (if (not (null? children))
-                        (make-form-line-acct-list children tax-year)
-                        selected-accounts-sorted-by-form-line-acct
-               )
             );; end let*
           );; end lambda
       accounts)
@@ -2005,7 +1996,7 @@
          (selected-accounts (if (not (null? user-sel-accnts))
                                 valid-user-sel-accnts
                                 (validate (reverse
-                                           (gnc-account-get-children-sorted
+                                           (gnc-account-get-descendants-sorted
                                             (gnc-get-current-root-account))))))
 
          (work-to-do 0)

commit 1e0983d0d8c482896cfce2ca3b5f6618f7f24314
Merge: 0c5bded6f f59e3ca75
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Sun Feb 2 14:40:05 2020 +0800

    Merge branch 'maint-202001-budget-editor-summaries' into maint


commit 0c5bded6fc0cfefc8252e37f747cb4955f3d2370
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Sat Feb 1 01:21:28 2020 +0800

    [report-utilities] streamline (match) use
    
    reduces the indent level

diff --git a/gnucash/report/report-system/report-utilities.scm b/gnucash/report/report-system/report-utilities.scm
index 1c595a673..0383bc969 100644
--- a/gnucash/report/report-system/report-utilities.scm
+++ b/gnucash/report/report-system/report-utilities.scm
@@ -506,28 +506,26 @@ flawed. see report-utilities.scm. please update reports.")
       (() (reverse result))
 
       ((date . rest)
+       (define (before-date? s) (< (split->date s) date))
+       (define (after-date? s) (< date (split->date s)))
        (match splits
 
          ;; end of splits, but still has dates. pad with last-result
          ;; until end of dates.
          (() (lp '() rest (cons last-result result) last-result))
 
-         ((head . tail)
-          (let ((next (and (pair? tail) (car tail))))
-            (cond
-
-             ;; the next split is still before date.
-             ((and next (< (split->date next) date))
-              (lp tail dates result (split->elt head)))
+         ;; the next split is still before date.
+         ((and (_ (? before-date?) . _) (head . tail))
+          (lp tail dates result (split->elt head)))
 
-             ;; head split after date, accumulate previous result
-             ((< date (split->date head))
-              (lp splits rest (cons last-result result) last-result))
+         ;; head split after date, accumulate previous result
+         (((? after-date?) . tail)
+          (lp splits rest (cons last-result result) last-result))
 
-             ;; head split before date, next split after date, or end.
-             (else
-              (let ((head-result (split->elt head)))
-                (lp tail rest (cons head-result result) head-result)))))))))))
+         ;; head split before date, next split after date, or end.
+         ((head . tail)
+          (let ((head-result (split->elt head)))
+            (lp tail rest (cons head-result result) head-result))))))))
 
 ;; This works similar as above but returns a commodity-collector, 
 ;; thus takes care of children accounts with different currencies.

commit 97eb3c7e98a99196b7aa6ad5fc5dab1b1713e396
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Sat Feb 1 00:24:28 2020 +0800

    [new-owner-report] handle LINK txns as normal payments
    
    With this commit, lot-splits which are part of LINK transactions are
    handled similarly to PAYMENT splits -- the non-APAR var is renamed to
    non-document to reflect their new role: collating all splits without
    an attached invoice lot.

diff --git a/gnucash/report/business-reports/new-owner-report.scm b/gnucash/report/business-reports/new-owner-report.scm
index 8ccf3406e..201fb800a 100644
--- a/gnucash/report/business-reports/new-owner-report.scm
+++ b/gnucash/report/business-reports/new-owner-report.scm
@@ -561,39 +561,39 @@
 
             ;; each invoice payment split's peer splits are analysed.
             (let lp1 ((lot-txn-splits (xaccTransGetSplitList lot-txn))
-                      (non-APAR '())
+                      (non-document '())
                       (result result))
               (cond
 
-               ;; finished. loop up, adding single row with non-APAR
+               ;; finished. loop up, adding single row with non-document
                ((null? lot-txn-splits)
                 (lp (cdr lot-splits)
-                    (if (null? non-APAR)
+                    (if (null? non-document)
                         result
                         (cons (make-link-data
                                (qof-print-date (xaccTransGetDate lot-txn))
                                (split->reference lot-split)
                                (split->type-str lot-split)
-                               (splits->desc non-APAR)
+                               (splits->desc non-document)
                                (gnc:make-html-text (split->anchor lot-split #t))
                                (list->cell
-                                (map (lambda (s) (split->anchor s #f)) non-APAR))
+                                (map (lambda (s) (split->anchor s #f)) non-document))
                                (gncTransGetGUID lot-txn))
                               result))))
 
-               ;; this payment peer is non-APAR, accumulate it.
+               ;; this payment peer is non-document, accumulate it.
                ((not (memv (xaccAccountGetType
                             (xaccSplitGetAccount (car lot-txn-splits)))
                            (list ACCT-TYPE-RECEIVABLE ACCT-TYPE-PAYABLE)))
                 (lp1 (cdr lot-txn-splits)
-                     (cons (car lot-txn-splits) non-APAR)
+                     (cons (car lot-txn-splits) non-document)
                      result))
 
                ;; this payment's peer split has same sign as the
                ;; payment split. ignore.
                ((sign-equal? (xaccSplitGetAmount (car lot-txn-splits))
                              (xaccSplitGetAmount lot-split))
-                (lp1 (cdr lot-txn-splits) non-APAR result))
+                (lp1 (cdr lot-txn-splits) non-document result))
 
                ;; this payment's peer APAR split is a document lot
                ;; reducing split.
@@ -604,7 +604,7 @@
                                   (xaccSplitGetParent posting-split)))
                         (posting-txn (xaccSplitGetParent posting-split)))
                     (lp1 (cdr lot-txn-splits)
-                         non-APAR
+                         non-document
                          (cons (make-link-data
                                 (qof-print-date (xaccTransGetDate posting-txn))
                                 (split->reference posting-split)
@@ -621,19 +621,9 @@
                (else
                 (gnc:warn (car lot-txn-splits) " in APAR but can't find "
                           "owner; is likely an old-style link transaction.")
-                (let* ((lot-txn-split (car lot-txn-splits))
-                       (posting-txn (xaccSplitGetParent lot-txn-split)))
-                  (lp1 (cdr lot-txn-splits)
-                       non-APAR
-                       (cons (make-link-data
-                              (qof-print-date (xaccTransGetDate posting-txn))
-                              (split->reference lot-txn-split)
-                              (split->type-str lot-txn-split)
-                              (splits->desc (list lot-txn-split))
-                              (gnc:make-html-text (split->anchor lot-txn-split #t))
-                              (gnc:make-html-text (split->anchor lot-txn-split #t))
-                              (gncTransGetGUID posting-txn))
-                             result))))))))))))
+                (lp1 (cdr lot-txn-splits)
+                     (cons (car lot-txn-splits) non-document)
+                     result))))))))))
 
 
 

commit 77c2bc2b9a77685601e3a733f9cac8368af3fb31
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Tue Jan 21 22:56:15 2020 +0800

    [new-owner-report] simplify build-column-used

diff --git a/gnucash/report/business-reports/new-owner-report.scm b/gnucash/report/business-reports/new-owner-report.scm
index c581d02a3..8ccf3406e 100644
--- a/gnucash/report/business-reports/new-owner-report.scm
+++ b/gnucash/report/business-reports/new-owner-report.scm
@@ -183,34 +183,15 @@
          (cols-list (assq-ref cols-alist section)))
     (count identity cols-list)))
 
-(define columns-used-size 10)
-
 (define (build-column-used options)
-  (define (opt-val section name)
+  (define (opt-val name)
     (gnc:option-value
-     (gnc:lookup-option options section name)))
-  (define (make-set-col col-vector)
-    (let ((col 0))
-      (lambda (used? index)
-        (if used?
-            (begin
-              (vector-set! col-vector index col)
-              (set! col (+ col 1)))
-            (vector-set! col-vector index #f)))))
-
-  (let* ((col-vector (make-vector columns-used-size #f))
-         (set-col (make-set-col col-vector)))
-    (set-col (opt-val "Display Columns" date-header) 0)
-    (set-col (opt-val "Display Columns" due-date-header) 1)
-    (set-col (opt-val "Display Columns" reference-header) 2)
-    (set-col (opt-val "Display Columns" type-header) 3)
-    (set-col (opt-val "Display Columns" desc-header) 4)
-    (set-col (opt-val "Display Columns" sale-header) 5)
-    (set-col (opt-val "Display Columns" tax-header) 6)
-    (set-col (opt-val "Display Columns" debit-header) 7)
-    (set-col (opt-val "Display Columns" credit-header) 8)
-    (set-col (opt-val "Display Columns" balance-header) 9)
-    col-vector))
+     (gnc:lookup-option options "Display Columns" name)))
+  (list->vector
+   (map opt-val
+        (list date-header due-date-header reference-header type-header
+              desc-header sale-header tax-header debit-header credit-header
+              balance-header))))
 
 (define (make-heading-list column-vector link-option acct-type)
   (let ((heading-list '())
@@ -254,8 +235,6 @@
     (reverse heading-list)))
 
 (define num-buckets 6)
-(define (new-bucket-vector)
-  (make-vector num-buckets 0))
 
 (define (sign-equal? a b)
   (or (= 0 a b) (< 0 (* a b))))

commit f59e3ca751ac149177925d7b94e1ffa21fedd5a7
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Sat Jan 4 12:03:46 2020 +0800

    Bug 797551 - Budget totals line missing in 3.8
    
    Reinstate Income/Expense/Transfer/Total, but rename to:
    
    * Inflow from Income
    * Outflow to Expense
    * Outflow to Asset/Equity/Liability
    * Remaining to Budget

diff --git a/gnucash/gnome/gnc-budget-view.c b/gnucash/gnome/gnc-budget-view.c
index 96d596dd1..0345303f0 100644
--- a/gnucash/gnome/gnc-budget-view.c
+++ b/gnucash/gnome/gnc-budget-view.c
@@ -93,11 +93,10 @@ struct _GncBudgetViewClass
 
 enum
 {
-    TOTALS_TYPE_INCOME,    /**< This total is Income type*/
-    TOTALS_TYPE_EXPENSES,  /**< This total is Expenses type*/
-    TOTALS_TYPE_ASSET,     /**< This total is Assets type*/
-    TOTALS_TYPE_LIABILITY, /**< This total is Liabilities type*/
-    TOTALS_TYPE_EQUITY     /**< This total is for Equity type*/
+    TOTALS_TYPE_INCOME,        /**< This total is Income type*/
+    TOTALS_TYPE_EXPENSES,      /**< This total is Expenses type*/
+    TOTALS_TYPE_ASSET_LIAB_EQ, /**< This total is Asset/Liab/Equity type*/
+    TOTALS_TYPE_REMAINDER      /**< This total is Remaining to Budget*/
 };
 /**< \brief ENUM for different budget totals types.
 
@@ -446,17 +445,15 @@ gbv_create_widget (GncBudgetView *budget_view)
                       G_CALLBACK(gbv_totals_scrollbar_value_changed_cb), budget_view);
 
     // Create totals tree view
-    totals_tree_model = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_INT);
-    gtk_list_store_append (totals_tree_model, &iter);
-    gtk_list_store_set (totals_tree_model, &iter, 0, _("Income"), 1, TOTALS_TYPE_INCOME, -1);
-    gtk_list_store_append (totals_tree_model, &iter);
-    gtk_list_store_set (totals_tree_model, &iter, 0, _("Expenses"), 1, TOTALS_TYPE_EXPENSES, -1);
-    gtk_list_store_append (totals_tree_model, &iter);
-    gtk_list_store_set (totals_tree_model, &iter, 0, _("Assets"), 1, TOTALS_TYPE_ASSET, -1);
-    gtk_list_store_append (totals_tree_model, &iter);
-    gtk_list_store_set (totals_tree_model, &iter, 0, _("Liabilities"), 1, TOTALS_TYPE_LIABILITY, -1);
-    gtk_list_store_append (totals_tree_model, &iter);
-    gtk_list_store_set (totals_tree_model, &iter, 0, _("Equity"), 1, TOTALS_TYPE_EQUITY, -1);
+    totals_tree_model = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_INT);
+    gtk_list_store_append(totals_tree_model, &iter);
+    gtk_list_store_set(totals_tree_model, &iter, 0, _("Inflow from Income"), 1, TOTALS_TYPE_INCOME, -1);
+    gtk_list_store_append(totals_tree_model, &iter);
+    gtk_list_store_set(totals_tree_model, &iter, 0, _("Outflow to Expenses"), 1, TOTALS_TYPE_EXPENSES, -1);
+    gtk_list_store_append(totals_tree_model, &iter);
+    gtk_list_store_set(totals_tree_model, &iter, 0, _("Outflow to Asset/Equity/Liability"), 1, TOTALS_TYPE_ASSET_LIAB_EQ, -1);
+    gtk_list_store_append(totals_tree_model, &iter);
+    gtk_list_store_set(totals_tree_model, &iter, 0, _("Remaining to Budget"), 1, TOTALS_TYPE_REMAINDER, -1);
 
     totals_tree_view = GTK_TREE_VIEW(gtk_tree_view_new());
     priv->totals_tree_view = totals_tree_view;
@@ -1168,7 +1165,7 @@ totals_col_source (GtkTreeViewColumn *col, GtkCellRenderer *cell,
     gchar amtbuff[100]; //FIXME: overkill, where's the #define?
     gint i;
     gint num_top_accounts;
-    gboolean red;
+    gboolean red, neg;
     GNCPriceDB *pdb;
     gnc_commodity *total_currency, *currency;
 
@@ -1193,28 +1190,30 @@ totals_col_source (GtkTreeViewColumn *col, GtkCellRenderer *cell,
     {
         account  = gnc_account_nth_child (priv->rootAcct, i);
         currency = gnc_account_get_currency_or_parent (account);
+        neg = FALSE;
 
         switch (xaccAccountGetType (account))
         {
-        case ACCT_TYPE_INCOME:
-            if (row_type != TOTALS_TYPE_INCOME)
-                continue;
-            break;
-        case ACCT_TYPE_EXPENSE:
-            if (row_type != TOTALS_TYPE_EXPENSES)
-                continue;
-            break;
         case ACCT_TYPE_ASSET:
-            if (row_type != TOTALS_TYPE_ASSET)
+        case ACCT_TYPE_LIABILITY:
+        case ACCT_TYPE_EQUITY:
+            if (row_type != TOTALS_TYPE_ASSET_LIAB_EQ &&
+                row_type != TOTALS_TYPE_REMAINDER)
                 continue;
+            neg = (row_type != TOTALS_TYPE_ASSET_LIAB_EQ);
             break;
-        case ACCT_TYPE_LIABILITY:
-            if (row_type != TOTALS_TYPE_LIABILITY)
+        case ACCT_TYPE_INCOME:
+            if (row_type != TOTALS_TYPE_INCOME &&
+                row_type != TOTALS_TYPE_REMAINDER)
                 continue;
+            neg = (row_type == TOTALS_TYPE_ASSET_LIAB_EQ);
             break;
-        case ACCT_TYPE_EQUITY:
-            if (row_type != TOTALS_TYPE_EQUITY)
+        case ACCT_TYPE_EXPENSE:
+            if ((row_type != TOTALS_TYPE_EXPENSES) &&
+                (row_type != TOTALS_TYPE_REMAINDER))
                 continue;
+            neg = (row_type == TOTALS_TYPE_REMAINDER ||
+                   row_type == TOTALS_TYPE_ASSET_LIAB_EQ);
             break;
         default:
             continue;
@@ -1234,6 +1233,9 @@ totals_col_source (GtkTreeViewColumn *col, GtkCellRenderer *cell,
                         gnc_budget_get_period_start_date (budget, period_num));
         }
 
+        if (neg)
+            value = gnc_numeric_neg (value);
+
         total = gnc_numeric_add (total, value, GNC_DENOM_AUTO, GNC_HOW_DENOM_LCD);
     }
 

commit 3460918492c9303accc7786759ddc4b60d95e71c
Merge: 2adaf692b ec7e6c37d
Author: Frank H. Ellenberger <frank.h.ellenberger at gmail.com>
Date:   Sat Feb 1 18:49:23 2020 +0100

    Merge PR #639


commit ec7e6c37d129ca71acdd225d9f3163c06f750740
Author: Frank H. Ellenberger <frank.h.ellenberger at gmail.com>
Date:   Wed Jan 29 05:44:42 2020 +0100

    Add a warning for gettext < 0.20
    
    They do not recognize <developer_name>GnuCash Project</developer_name>
    in gnucash.appdata (https://savannah.gnu.org/bugs/?50408)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 110315aef..e1ca611a7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -272,11 +272,12 @@ find_library (REGEX_LIBRARY NAMES regex)
 if (ALLOW_OLD_GETTEXT)
     find_package (Gettext REQUIRED)
 else (ALLOW_OLD_GETTEXT)
-    find_package (Gettext 0.19.6)
+    find_package (Gettext 0.20)
     if (NOT GETTEXT_FOUND)
         message (FATAL_ERROR "Note the build can be configured with an older version of gettext by setting ALLOW_OLD_GETTEXT=ON but then some files will not be translated:
         - gnucash.desktop (requires at least gettext 0.19)
-        - gnucash.appdata.xml (requires at least gettext 0.19.6)")
+        - gnucash.appdata.xml (requires at least gettext 0.19.6)
+        - tag developer_name from gnucash.appdata.xml (requires at least gettext 0.20)")
     endif (NOT GETTEXT_FOUND)
 endif (ALLOW_OLD_GETTEXT)
 
@@ -286,6 +287,9 @@ endif ()
 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 ()
+if (${GETTEXT_VERSION_STRING} VERSION_LESS 0.20)
+    message (WARNING "Got gettext version ${GETTEXT_VERSION_STRING}, however you need at least gettext version 0.20 in order to handle the translation of 'GnuCash Project' from the gnucash.appdata file. That message will be missing in gnucash.pot.")
+endif ()
 
 find_path (LIBINTL_INCLUDE_PATH NAMES libintl.h
 		  PATHS /usr/include /opt/gnome/include)
diff --git a/README.dependencies b/README.dependencies
index 0322aad6a..d3dce1198 100644
--- a/README.dependencies
+++ b/README.dependencies
@@ -63,7 +63,7 @@ Libraries/Deps
   guile			2.2.0 or 2.0.0		Must be built with regex
                                                 support enabled
   libxml2		2.5.10
-  gettext               0.19.6                  Can use older if you pass
+  gettext               0.20                    Can use older if you pass
                                                 -DALLOW_OLD_GETTEXT to cmake;
                                                 doesn't include all file types
                                                 when building gnucash.pot.



Summary of changes:
 CMakeLists.txt                                     | 114 +++++++++----------
 README.dependencies                                |   2 +-
 bindings/guile/CMakeLists.txt                      |   2 +-
 bindings/guile/test/CMakeLists.txt                 |   4 +-
 borrowed/CMakeLists.txt                            |   2 +-
 cmake/CMakeLists.txt                               |   2 +-
 cmake/cmake_uninstall.cmake.in                     |   8 +-
 common/cmake_modules/GncAddSchemeTargets.cmake     |  20 ++--
 common/cmake_modules/GncAddTest.cmake              |   4 +-
 .../MacroAddSourceFileCompileFlags.cmake           |   4 +-
 common/cmake_modules/MakeDistCheck.cmake           |   2 +-
 gnucash/CMakeLists.txt                             |  12 +-
 gnucash/gnome-utils/CMakeLists.txt                 |   4 +-
 gnucash/gnome/CMakeLists.txt                       |   2 +-
 gnucash/gnome/gnc-budget-view.c                    | 121 ++++++++++++++-------
 gnucash/gschemas/CMakeLists.txt                    |   2 +-
 gnucash/html/CMakeLists.txt                        |   2 +-
 gnucash/import-export/aqb/CMakeLists.txt           |   2 +-
 gnucash/import-export/aqb/gschemas/CMakeLists.txt  |   2 +-
 gnucash/import-export/ofx/gschemas/CMakeLists.txt  |   2 +-
 gnucash/import-export/ofx/test/CMakeLists.txt      |   2 +-
 gnucash/import-export/qif-imp/test/CMakeLists.txt  |   2 +-
 gnucash/python/CMakeLists.txt                      |   2 +-
 gnucash/report/commodity-utilities.scm             |  25 ++---
 gnucash/report/eguile-utilities.scm                |  27 +++--
 gnucash/report/eguile.scm                          |  82 ++++----------
 gnucash/report/html-fonts.scm                      |   1 +
 gnucash/report/report-utilities.scm                |  35 +++---
 .../report/reports/locale-specific/us/taxtxf.scm   |  15 +--
 gnucash/report/reports/standard/lot-viewer.scm     |  26 ++---
 .../report/reports/standard/new-owner-report.scm   |  69 ++++--------
 .../report/reports/standard/test/CMakeLists.txt    |   4 +-
 gnucash/report/test/CMakeLists.txt                 |   2 +-
 libgnucash/app-utils/test/CMakeLists.txt           |   2 +-
 libgnucash/backend/dbi/CMakeLists.txt              |   4 +-
 libgnucash/backend/sql/CMakeLists.txt              |   2 +-
 libgnucash/backend/sql/test/CMakeLists.txt         |   2 +-
 libgnucash/backend/xml/CMakeLists.txt              |   2 +-
 libgnucash/core-utils/CMakeLists.txt               |   4 +-
 libgnucash/core-utils/test/CMakeLists.txt          |   2 +-
 libgnucash/doc/design/CMakeLists.txt               |   2 +-
 libgnucash/engine/CMakeLists.txt                   |   2 +-
 libgnucash/engine/test/CMakeLists.txt              |   2 +-
 libgnucash/tax/us/txf.scm                          |   2 +-
 po/CMakeLists.txt                                  |   4 +-
 45 files changed, 297 insertions(+), 338 deletions(-)



More information about the gnucash-changes mailing list