gnucash master: Multiple changes pushed

Geert Janssens gjanssens at code.gnucash.org
Mon May 27 05:59:36 EDT 2019


Updated	 via  https://github.com/Gnucash/gnucash/commit/cc7ca438 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/be148484 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/b7479e8f (commit)
	 via  https://github.com/Gnucash/gnucash/commit/ae76a294 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/efe88f13 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/2d4f771b (commit)
	 via  https://github.com/Gnucash/gnucash/commit/311f7d26 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/f6df367f (commit)
	 via  https://github.com/Gnucash/gnucash/commit/51dda770 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/91aceaa7 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/d16a236e (commit)
	 via  https://github.com/Gnucash/gnucash/commit/0319144b (commit)
	 via  https://github.com/Gnucash/gnucash/commit/5bb54d07 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/df1cc590 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/52895eab (commit)
	 via  https://github.com/Gnucash/gnucash/commit/b26276cb (commit)
	 via  https://github.com/Gnucash/gnucash/commit/416b79d3 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/037f5ed5 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/5ad3cd0d (commit)
	 via  https://github.com/Gnucash/gnucash/commit/fade13f8 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/36574f08 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/e3fb593e (commit)
	 via  https://github.com/Gnucash/gnucash/commit/93bf1a0f (commit)
	from  https://github.com/Gnucash/gnucash/commit/29b842ba (commit)



commit cc7ca438c0699921937677fc839530e391c2d755
Merge: 29b842ba9 be1484841
Author: Geert Janssens <geert at kobaltwit.be>
Date:   Mon May 27 11:58:18 2019 +0200

    Merge branch 'maint'

diff --cc common/cmake_modules/GncAddTest.cmake
index 7cebe5168,10151eaf0..b673f72f0
--- a/common/cmake_modules/GncAddTest.cmake
+++ b/common/cmake_modules/GncAddTest.cmake
@@@ -97,12 -93,8 +93,8 @@@ endfunction(
  
  
  function(gnc_add_scheme_test _TARGET _SOURCE_FILE)
-   set(CMAKE_COMMAND_TMP "")
-   if (${CMAKE_VERSION} VERSION_GREATER 3.1)
-     set(CMAKE_COMMAND_TMP ${CMAKE_COMMAND} -E env)
-   endif()
-   add_test(${_TARGET} ${CMAKE_COMMAND_TMP}
+   add_test(${_TARGET} ${CMAKE_COMMAND} -E env
 -    ${GUILE_EXECUTABLE} --debug -l ${CMAKE_CURRENT_SOURCE_DIR}/${_SOURCE_FILE} -c "(exit (run-test))"
 +    ${GUILE_EXECUTABLE} --debug -c "(load-from-path \"${_TARGET}\")(exit (run-test))"
    )
    get_guile_env()
    set_tests_properties(${_TARGET} PROPERTIES ENVIRONMENT "${GUILE_ENV};${ARGN}")

commit be1484841c16c064387f9eff7aed4a5ba56a301f
Author: Geert Janssens <geert at kobaltwit.be>
Date:   Sat May 25 12:11:53 2019 +0200

    One more minor cmake cleanup

diff --git a/common/cmake_modules/GncAddTest.cmake b/common/cmake_modules/GncAddTest.cmake
index 466b110e8..10151eaf0 100644
--- a/common/cmake_modules/GncAddTest.cmake
+++ b/common/cmake_modules/GncAddTest.cmake
@@ -73,8 +73,8 @@ function(gnc_add_test _TARGET _SOURCE_FILES TEST_INCLUDE_VAR_NAME TEST_LIBS_VAR_
   target_link_libraries(${_TARGET} ${TEST_LIBS})
   target_include_directories(${_TARGET} PRIVATE ${TEST_INCLUDE_DIRS})
   if (${HAVE_ENV_VARS})
-    set(CMAKE_COMMAND_TMP ${CMAKE_COMMAND} -E env "GNC_UNINSTALLED=YES;GNC_BUILDDIR=${CMAKE_BINARY_DIR};${ARGN}")
-    add_test(${_TARGET} ${CMAKE_COMMAND_TMP} ${CMAKE_BINARY_DIR}/bin/${_TARGET}
+    add_test(${_TARGET} ${CMAKE_COMMAND} -E env "GNC_UNINSTALLED=YES;GNC_BUILDDIR=${CMAKE_BINARY_DIR};${ARGN}"
+      ${CMAKE_BINARY_DIR}/bin/${_TARGET}
     )
     set_tests_properties(${_TARGET} PROPERTIES ENVIRONMENT "GNC_UNINSTALLED=YES;GNC_BUILDDIR=${CMAKE_BINARY_DIR};${ARGN}")
   else()

commit b7479e8fb0091ba4f6f4cc9af60a3b4ecb39d37b
Author: Geert Janssens <geert at kobaltwit.be>
Date:   Sat May 25 11:20:21 2019 +0200

    Bump minimum cmake version to 3.5
    
    This version is available for all supported platforms and distros
    (CentOS can have a version via EPEL, which is required anyway)
    
    Advantages:
    - one cmake version for all platforms
    - we can drop all conditions based on cmake version

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 61cb22010..97440f8d7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,10 +1,6 @@
 # CMakeLists.txt for GnuCash
 
-if (WIN32 OR APPLE)
-  cmake_minimum_required (VERSION 3.3.2)
-else()
-  cmake_minimum_required (VERSION 3.2)
-endif()
+cmake_minimum_required (VERSION 3.5)
 
 project (gnucash)
 
@@ -181,36 +177,31 @@ endif(WIN32)
 
 find_package(PkgConfig REQUIRED)
 
-# The default FindPkgConfig.make code has a bug in how the setting of PKG_CONFIG_PATH is handled.
-# The common/cmake_modules/GncFindPkgConfig.cmake file overrides a couple of macros in FindPkgConfig to fix.
-
-include (GncFindPkgConfig)
-
 if (NOT PKG_CONFIG_FOUND)
    message (SEND_ERROR "pkg-config not found, but is required")
 endif (NOT PKG_CONFIG_FOUND)
 
 # glib et al.
-gnc_pkg_check_modules (GLIB2 REQUIRED glib-2.0>=2.40)
-gnc_pkg_check_modules (GIO REQUIRED gio-2.0)
-gnc_pkg_check_modules (GOBJECT REQUIRED gobject-2.0>=2.20)
-gnc_pkg_check_modules (GMODULE REQUIRED gmodule-2.0>=2.20)
-gnc_pkg_check_modules (GTHREAD REQUIRED gthread-2.0>=2.20)
-
-gnc_pkg_check_modules (LIBXML2 REQUIRED libxml-2.0>=2.7.0)
-gnc_pkg_check_modules (LIBXSLT REQUIRED libxslt)
+pkg_check_modules (GLIB2 REQUIRED glib-2.0>=2.40)
+pkg_check_modules (GIO REQUIRED gio-2.0)
+pkg_check_modules (GOBJECT REQUIRED gobject-2.0>=2.20)
+pkg_check_modules (GMODULE REQUIRED gmodule-2.0>=2.20)
+pkg_check_modules (GTHREAD REQUIRED gthread-2.0>=2.20)
+
+pkg_check_modules (LIBXML2 REQUIRED libxml-2.0>=2.7.0)
+pkg_check_modules (LIBXSLT REQUIRED libxslt)
 if (WITH_GNUCASH)
   if (WIN32 OR APPLE)
-    gnc_pkg_check_modules (WEBKIT1 REQUIRED webkitgtk-3.0)
+    pkg_check_modules (WEBKIT1 REQUIRED webkitgtk-3.0)
     set(WEBKIT1 1)
     set(WEBKIT_CFLAGS ${WEBKIT2_CFLAGS})
     set(WEBKIT_INCLUDE_DIRS ${WEBKIT1_INCLUDE_DIRS})
     set(WEBKIT_LDFLAGS ${WEBKIT1_LDFLAGS})
     set(WEBKIT_LIBRARIES ${WEBKIT1_LIBRARIES})
   else (WIN32 OR APPLE)
-    gnc_pkg_check_modules (WEBKIT2_4 webkit2gtk-4.0)
+    pkg_check_modules (WEBKIT2_4 webkit2gtk-4.0)
     if (NOT WEBKIT2_4_FOUND)
-      gnc_pkg_check_modules (WEBKIT2_3 REQUIRED webkit2gtk-3.0)
+      pkg_check_modules (WEBKIT2_3 REQUIRED webkit2gtk-3.0)
       set(WEBKIT2_3 1)
       set(WEBKIT_CFLAGS ${WEBKIT2_3_CFLAGS})
       set(WEBKIT_INCLUDE_DIRS ${WEBKIT2_3_INCLUDE_DIRS})
@@ -225,10 +216,10 @@ if (WITH_GNUCASH)
     endif (NOT WEBKIT2_4_FOUND)
   endif (WIN32 OR APPLE)
 
-  gnc_pkg_check_modules (GTK3 REQUIRED gtk+-3.0>=3.10.0)
+  pkg_check_modules (GTK3 REQUIRED gtk+-3.0>=3.10.0)
 endif (WITH_GNUCASH)
 
-gnc_pkg_check_modules (ZLIB REQUIRED zlib)
+pkg_check_modules (ZLIB REQUIRED zlib)
 
 if (MSVC)
   message (STATUS "Hint: To create the import libraries for the gnome DLLs (e.g. gconf-2.lib), use the dlltool as follows: pexports bin/libgconf-2-4.dll > lib/libgconf-2.def ; dlltool -d lib/libgconf-2.def -D bin/libgconf-2-4.dll -l lib/gconf-2.lib")
@@ -295,7 +286,7 @@ endif()
 # Look for guile versions in this order: 2.2 > 2.0
 
 # guile library and include dir
-gnc_pkg_check_modules (GUILE22 guile-2.2 QUIET)
+pkg_check_modules (GUILE22 guile-2.2 QUIET)
 if (GUILE22_FOUND) # found guile-2.2
   add_definitions (-DHAVE_GUILE22)
   set(HAVE_GUILE2 TRUE)
@@ -310,7 +301,7 @@ if (GUILE22_FOUND) # found guile-2.2
   message(STATUS "Using guile-2.2.x")
   find_program (GUILE_EXECUTABLE NAMES guile2.2 guile)
 else(GUILE22_FOUND)
-  gnc_pkg_check_modules (GUILE2 guile-2.0>=2.0.9 QUIET)
+  pkg_check_modules (GUILE2 guile-2.0>=2.0.9 QUIET)
   if (GUILE2_FOUND) # found guile-2.0
     add_definitions (-DHAVE_GUILE20)
     set(HAVE_GUILE2 TRUE)
@@ -357,10 +348,10 @@ endif ()
 
 # ############################################################
 if (WITH_AQBANKING)
-  gnc_pkg_check_modules (GWENHYWFAR REQUIRED gwenhywfar>=4.9.99)
-  gnc_pkg_check_modules (AQBANKING REQUIRED aqbanking>=5.3.4)
+  pkg_check_modules (GWENHYWFAR REQUIRED gwenhywfar>=4.9.99)
+  pkg_check_modules (AQBANKING REQUIRED aqbanking>=5.3.4)
   if(WITH_GNUCASH)
-    gnc_pkg_check_modules (GWEN_GTK3 gwengui-gtk3)
+    pkg_check_modules (GWEN_GTK3 gwengui-gtk3)
     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()
@@ -368,7 +359,7 @@ if (WITH_AQBANKING)
 endif (WITH_AQBANKING)
 
 if (WITH_OFX)
-  gnc_pkg_check_modules (LIBOFX REQUIRED libofx)
+  pkg_check_modules (LIBOFX REQUIRED libofx)
   include(CheckCXXSourceRuns)
   if (WIN32)
       set(CMAKE_REQUIRED_LIBRARIES "-L ${CMAKE_PREFIX_PATH}/libofx/lib -lofx")
@@ -413,7 +404,7 @@ if(APPLE)
   if(TARGET_RESULT STREQUAL "quartz")
     set(GNC_PLATFORM_COCOA 1)
     set(GDK_QUARTZ 1)
-    gnc_pkg_check_modules(GTK_MAC gtk-mac-integration-gtk3)
+    pkg_check_modules(GTK_MAC gtk-mac-integration-gtk3)
     if (GTK_MAC_FOUND)
       set(MAC_INTEGRATION 1)
       find_library(COCOA_LIBRARY Cocoa)
@@ -511,10 +502,10 @@ get_filename_component(PERL_DIR ${PERL_EXECUTABLE} DIRECTORY)
 find_program(POD2MAN_EXECUTABLE pod2man HINTS ${PERL_DIR})
 
 #ICU
-gnc_pkg_check_modules (ICU4C REQUIRED icu-uc)
-gnc_pkg_check_modules (ICU4C_I18N REQUIRED icu-i18n)
+pkg_check_modules (ICU4C REQUIRED icu-uc)
+pkg_check_modules (ICU4C_I18N REQUIRED icu-i18n)
 
-GNC_PKG_CHECK_MODULES (LIBSECRET libsecret-1>=0.18)
+pkg_check_modules (LIBSECRET libsecret-1>=0.18)
 IF (LIBSECRET_FOUND)
   SET (HAVE_LIBSECRET ON)
 ENDIF (LIBSECRET_FOUND)
diff --git a/common/cmake_modules/CMakeLists.txt b/common/cmake_modules/CMakeLists.txt
index 1795b15d6..8ca9b740b 100644
--- a/common/cmake_modules/CMakeLists.txt
+++ b/common/cmake_modules/CMakeLists.txt
@@ -1,6 +1,6 @@
 
 set(cmake_FILES GncAddGSchemaTargets.cmake GncAddSchemeTargets.cmake GncAddSwigCommand.cmake GncAddTest.cmake
-        GncFindPkgConfig.cmake MacroAddSourceFileCompileFlags.cmake MacroAppendForeach.cmake
+        MacroAddSourceFileCompileFlags.cmake MacroAppendForeach.cmake
         MakeDist.cmake MakeDistFiles.cmake MakeDistCheck.cmake)
 
 set_dist_list(cmake_modules_DIST CMakeLists.txt COPYING-CMAKE-SCRIPTS.txt ${cmake_FILES})
diff --git a/common/cmake_modules/GncAddGSchemaTargets.cmake b/common/cmake_modules/GncAddGSchemaTargets.cmake
index 7ef412eed..83a26d8a5 100644
--- a/common/cmake_modules/GncAddGSchemaTargets.cmake
+++ b/common/cmake_modules/GncAddGSchemaTargets.cmake
@@ -1,10 +1,6 @@
 macro(add_gschema_targets _gschema_INPUTS)
   set(_gschema_OUTPUTS "")
   set(local_depends ${gschema_depends})
-  set(CMAKE_COMMAND_TMP "")
-  if (${CMAKE_VERSION} VERSION_GREATER 3.1)
-    set(CMAKE_COMMAND_TMP ${CMAKE_COMMAND} -E env)
-  endif()
   foreach(file ${_gschema_INPUTS})
 
     set(_OUTPUT_FILE ${DATADIR_BUILD}/glib-2.0/schemas/${file})
@@ -16,7 +12,7 @@ macro(add_gschema_targets _gschema_INPUTS)
     list(APPEND _gschema_VALIDS ${_VALID_FILE})
     add_custom_command(
         OUTPUT ${_VALID_FILE}
-        COMMAND ${CMAKE_COMMAND_TMP}
+        COMMAND ${CMAKE_COMMAND} -E env
           ${GLIB_COMPILE_SCHEMAS} --strict --dry-run --schema-file=${_OUTPUT_FILE}
         COMMAND ${CMAKE_COMMAND} -E touch ${_VALID_FILE}
         DEPENDS ${_OUTPUT_FILE}
diff --git a/common/cmake_modules/GncAddSchemeTargets.cmake b/common/cmake_modules/GncAddSchemeTargets.cmake
index da0706dfa..740845096 100644
--- a/common/cmake_modules/GncAddSchemeTargets.cmake
+++ b/common/cmake_modules/GncAddSchemeTargets.cmake
@@ -116,10 +116,6 @@ function(gnc_add_scheme_targets _TARGET _SOURCE_FILES _OUTPUT_DIR _GUILE_DEPENDS
       if (__DEBUG)
         message("add_custom_command: output = ${output_file}")
       endif()
-      set(CMAKE_COMMMAND_TMP "")
-      if (${CMAKE_VERSION} VERSION_GREATER 3.1)
-        set(CMAKE_COMMAND_TMP ${CMAKE_COMMAND} -E env)
-      endif()
       if (MINGW64)
         set(fpath "")
         file(TO_CMAKE_PATH "$ENV{PATH}" fpath)
@@ -151,7 +147,7 @@ function(gnc_add_scheme_targets _TARGET _SOURCE_FILES _OUTPUT_DIR _GUILE_DEPENDS
       #We quote the arguments to stop CMake stripping the path separators.
       add_custom_command(
         OUTPUT ${output_file}
-        COMMAND ${CMAKE_COMMAND_TMP}
+        COMMAND ${CMAKE_COMMAND} -E env
             "${LIBRARY_PATH}"
             "GNC_UNINSTALLED=YES"
             "GNC_BUILDDIR=\"${CMAKE_BINARY_DIR}\""
diff --git a/common/cmake_modules/GncAddTest.cmake b/common/cmake_modules/GncAddTest.cmake
index 2d5efbbe6..466b110e8 100644
--- a/common/cmake_modules/GncAddTest.cmake
+++ b/common/cmake_modules/GncAddTest.cmake
@@ -73,12 +73,8 @@ function(gnc_add_test _TARGET _SOURCE_FILES TEST_INCLUDE_VAR_NAME TEST_LIBS_VAR_
   target_link_libraries(${_TARGET} ${TEST_LIBS})
   target_include_directories(${_TARGET} PRIVATE ${TEST_INCLUDE_DIRS})
   if (${HAVE_ENV_VARS})
-    set(CMAKE_COMMAND_TMP "")
-    if (${CMAKE_VERSION} VERSION_GREATER 3.1)
-      set(CMAKE_COMMAND_TMP ${CMAKE_COMMAND} -E env "GNC_UNINSTALLED=YES;GNC_BUILDDIR=${CMAKE_BINARY_DIR};${ARGN}")
-    endif()
-    add_test(${_TARGET} ${CMAKE_COMMAND_TMP}
-      ${CMAKE_BINARY_DIR}/bin/${_TARGET}
+    set(CMAKE_COMMAND_TMP ${CMAKE_COMMAND} -E env "GNC_UNINSTALLED=YES;GNC_BUILDDIR=${CMAKE_BINARY_DIR};${ARGN}")
+    add_test(${_TARGET} ${CMAKE_COMMAND_TMP} ${CMAKE_BINARY_DIR}/bin/${_TARGET}
     )
     set_tests_properties(${_TARGET} PROPERTIES ENVIRONMENT "GNC_UNINSTALLED=YES;GNC_BUILDDIR=${CMAKE_BINARY_DIR};${ARGN}")
   else()
@@ -97,11 +93,7 @@ endfunction()
 
 
 function(gnc_add_scheme_test _TARGET _SOURCE_FILE)
-  set(CMAKE_COMMAND_TMP "")
-  if (${CMAKE_VERSION} VERSION_GREATER 3.1)
-    set(CMAKE_COMMAND_TMP ${CMAKE_COMMAND} -E env)
-  endif()
-  add_test(${_TARGET} ${CMAKE_COMMAND_TMP}
+  add_test(${_TARGET} ${CMAKE_COMMAND} -E env
     ${GUILE_EXECUTABLE} --debug -l ${CMAKE_CURRENT_SOURCE_DIR}/${_SOURCE_FILE} -c "(exit (run-test))"
   )
   get_guile_env()
diff --git a/common/cmake_modules/GncFindPkgConfig.cmake b/common/cmake_modules/GncFindPkgConfig.cmake
deleted file mode 100644
index 96c85c8a3..000000000
--- a/common/cmake_modules/GncFindPkgConfig.cmake
+++ /dev/null
@@ -1,256 +0,0 @@
-if((${CMAKE_VERSION} VERSION_GREATER 3.1) AND (${CMAKE_VERSION} VERSION_LESS 3.5))
-
-function (pkg_get_variable result pkg variable)
-  _pkgconfig_invoke("${pkg}" "prefix" "result" "" "--variable=${variable}")
-  set("${result}"
-          "${prefix_result}"
-          PARENT_SCOPE)
-endfunction ()
-
-
-macro(_gnc_pkg_check_modules_internal _is_required _is_silent _no_cmake_path _no_cmake_environment_path _prefix)
-  _pkgconfig_unset(${_prefix}_FOUND)
-  _pkgconfig_unset(${_prefix}_VERSION)
-  _pkgconfig_unset(${_prefix}_PREFIX)
-  _pkgconfig_unset(${_prefix}_INCLUDEDIR)
-  _pkgconfig_unset(${_prefix}_LIBDIR)
-  _pkgconfig_unset(${_prefix}_LIBS)
-  _pkgconfig_unset(${_prefix}_LIBS_L)
-  _pkgconfig_unset(${_prefix}_LIBS_PATHS)
-  _pkgconfig_unset(${_prefix}_LIBS_OTHER)
-  _pkgconfig_unset(${_prefix}_CFLAGS)
-  _pkgconfig_unset(${_prefix}_CFLAGS_I)
-  _pkgconfig_unset(${_prefix}_CFLAGS_OTHER)
-  _pkgconfig_unset(${_prefix}_STATIC_LIBDIR)
-  _pkgconfig_unset(${_prefix}_STATIC_LIBS)
-  _pkgconfig_unset(${_prefix}_STATIC_LIBS_L)
-  _pkgconfig_unset(${_prefix}_STATIC_LIBS_PATHS)
-  _pkgconfig_unset(${_prefix}_STATIC_LIBS_OTHER)
-  _pkgconfig_unset(${_prefix}_STATIC_CFLAGS)
-  _pkgconfig_unset(${_prefix}_STATIC_CFLAGS_I)
-  _pkgconfig_unset(${_prefix}_STATIC_CFLAGS_OTHER)
-
-  # create a better addressable variable of the modules and calculate its size
-  set(_pkg_check_modules_list ${ARGN})
-  list(LENGTH _pkg_check_modules_list _pkg_check_modules_cnt)
-
-  if(PKG_CONFIG_EXECUTABLE)
-    # give out status message telling checked module
-    if (NOT ${_is_silent})
-      if (_pkg_check_modules_cnt EQUAL 1)
-        message(STATUS "Checking for module '${_pkg_check_modules_list}'")
-      else()
-        message(STATUS "Checking for modules '${_pkg_check_modules_list}'")
-      endif()
-    endif()
-
-    set(_pkg_check_modules_packages)
-    set(_pkg_check_modules_failed)
-
-    set(_extra_paths)
-
-    if(NOT _no_cmake_path)
-      _pkgconfig_add_extra_path(_extra_paths CMAKE_PREFIX_PATH)
-      _pkgconfig_add_extra_path(_extra_paths CMAKE_FRAMEWORK_PATH)
-      _pkgconfig_add_extra_path(_extra_paths CMAKE_APPBUNDLE_PATH)
-    endif()
-
-    if(NOT _no_cmake_environment_path)
-      _pkgconfig_add_extra_path(_extra_paths ENV CMAKE_PREFIX_PATH)
-      _pkgconfig_add_extra_path(_extra_paths ENV CMAKE_FRAMEWORK_PATH)
-      _pkgconfig_add_extra_path(_extra_paths ENV CMAKE_APPBUNDLE_PATH)
-    endif()
-
-    if(NOT "${_extra_paths}" STREQUAL "")
-      # Save the PKG_CONFIG_PATH environment variable, and add paths
-      # from the CMAKE_PREFIX_PATH variables
-      set(_pkgconfig_path_old $ENV{PKG_CONFIG_PATH})
-      set(_pkgconfig_path ${_pkgconfig_path_old})
-      if(NOT "${_pkgconfig_path}" STREQUAL "")
-        file(TO_CMAKE_PATH "${_pkgconfig_path}" _pkgconfig_path)
-      endif()
-
-      # Create a list of the possible pkgconfig subfolder (depending on
-      # the system
-      set(_lib_dirs)
-      if(NOT DEFINED CMAKE_SYSTEM_NAME
-          OR (CMAKE_SYSTEM_NAME MATCHES "^(Linux|kFreeBSD|GNU)$"
-              AND NOT CMAKE_CROSSCOMPILING))
-        if(EXISTS "/etc/debian_version") # is this a debian system ?
-          if(CMAKE_LIBRARY_ARCHITECTURE)
-            list(APPEND _lib_dirs "lib/${CMAKE_LIBRARY_ARCHITECTURE}/pkgconfig")
-          endif()
-        else()
-          # not debian, chech the FIND_LIBRARY_USE_LIB64_PATHS property
-          get_property(uselib64 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS)
-          if(uselib64)
-            list(APPEND _lib_dirs "lib64/pkgconfig")
-          endif()
-        endif()
-      endif()
-      list(APPEND _lib_dirs "lib/pkgconfig")
-
-      # Check if directories exist and eventually append them to the
-      # pkgconfig path list
-      foreach(_prefix_dir ${_extra_paths})
-        foreach(_lib_dir ${_lib_dirs})
-          if(EXISTS "${_prefix_dir}/${_lib_dir}")
-            list(APPEND _pkgconfig_path "${_prefix_dir}/${_lib_dir}")
-            list(REMOVE_DUPLICATES _pkgconfig_path)
-          endif()
-        endforeach()
-      endforeach()
-
-      # Prepare and set the environment variable
-      if(NOT "${_pkgconfig_path}" STREQUAL "")
-        # remove empty values from the list
-        list(REMOVE_ITEM _pkgconfig_path "")
-        file(TO_NATIVE_PATH "${_pkgconfig_path}" _pkgconfig_path)
-        if(UNIX)
-          string(REPLACE ";" ":" _pkgconfig_path "${_pkgconfig_path}")
-          string(REPLACE "\\ " " " _pkgconfig_path "${_pkgconfig_path}")
-        endif()
-        set(ENV{PKG_CONFIG_PATH} "${_pkgconfig_path}")
-      endif()
-
-      # Unset variables
-      unset(_lib_dirs)
-      unset(_pkgconfig_path)
-    endif()
-
-    # iterate through module list and check whether they exist and match the required version
-    foreach (_pkg_check_modules_pkg ${_pkg_check_modules_list})
-      set(_pkg_check_modules_exist_query)
-
-      # check whether version is given
-      if (_pkg_check_modules_pkg MATCHES "(.*[^><])(>=|=|<=)(.*)")
-        set(_pkg_check_modules_pkg_name "${CMAKE_MATCH_1}")
-        set(_pkg_check_modules_pkg_op "${CMAKE_MATCH_2}")
-        set(_pkg_check_modules_pkg_ver "${CMAKE_MATCH_3}")
-      else()
-        set(_pkg_check_modules_pkg_name "${_pkg_check_modules_pkg}")
-        set(_pkg_check_modules_pkg_op)
-        set(_pkg_check_modules_pkg_ver)
-      endif()
-
-      # handle the operands
-      if (_pkg_check_modules_pkg_op STREQUAL ">=")
-        list(APPEND _pkg_check_modules_exist_query --atleast-version)
-      endif()
-
-      if (_pkg_check_modules_pkg_op STREQUAL "=")
-        list(APPEND _pkg_check_modules_exist_query --exact-version)
-      endif()
-
-      if (_pkg_check_modules_pkg_op STREQUAL "<=")
-        list(APPEND _pkg_check_modules_exist_query --max-version)
-      endif()
-
-      # create the final query which is of the format:
-      # * --atleast-version <version> <pkg-name>
-      # * --exact-version <version> <pkg-name>
-      # * --max-version <version> <pkg-name>
-      # * --exists <pkg-name>
-      if (_pkg_check_modules_pkg_op)
-        list(APPEND _pkg_check_modules_exist_query "${_pkg_check_modules_pkg_ver}")
-      else()
-        list(APPEND _pkg_check_modules_exist_query --exists)
-      endif()
-
-      _pkgconfig_unset(${_prefix}_${_pkg_check_modules_pkg_name}_VERSION)
-      _pkgconfig_unset(${_prefix}_${_pkg_check_modules_pkg_name}_PREFIX)
-      _pkgconfig_unset(${_prefix}_${_pkg_check_modules_pkg_name}_INCLUDEDIR)
-      _pkgconfig_unset(${_prefix}_${_pkg_check_modules_pkg_name}_LIBDIR)
-
-      list(APPEND _pkg_check_modules_exist_query "${_pkg_check_modules_pkg_name}")
-      list(APPEND _pkg_check_modules_packages    "${_pkg_check_modules_pkg_name}")
-
-      # execute the query
-      execute_process(
-        COMMAND ${PKG_CONFIG_EXECUTABLE} ${_pkg_check_modules_exist_query}
-        RESULT_VARIABLE _pkgconfig_retval)
-
-      # evaluate result and tell failures
-      if (_pkgconfig_retval)
-        if(NOT ${_is_silent})
-          message(STATUS "  Package '${_pkg_check_modules_pkg}' not found")
-        endif()
-
-        set(_pkg_check_modules_failed 1)
-      endif()
-    endforeach()
-
-    if(_pkg_check_modules_failed)
-      # fail when requested
-      if (${_is_required})
-        message(FATAL_ERROR "A required package was not found")
-      endif ()
-    else()
-      # when we are here, we checked whether requested modules
-      # exist. Now, go through them and set variables
-
-      _pkgconfig_set(${_prefix}_FOUND 1)
-      list(LENGTH _pkg_check_modules_packages pkg_count)
-
-      # iterate through all modules again and set individual variables
-      foreach (_pkg_check_modules_pkg ${_pkg_check_modules_packages})
-        # handle case when there is only one package required
-        if (pkg_count EQUAL 1)
-          set(_pkg_check_prefix "${_prefix}")
-        else()
-          set(_pkg_check_prefix "${_prefix}_${_pkg_check_modules_pkg}")
-        endif()
-
-        _pkgconfig_invoke(${_pkg_check_modules_pkg} "${_pkg_check_prefix}" VERSION    ""   --modversion )
-        pkg_get_variable("${_pkg_check_prefix}_PREFIX" ${_pkg_check_modules_pkg} "prefix")
-        pkg_get_variable("${_pkg_check_prefix}_INCLUDEDIR" ${_pkg_check_modules_pkg} "includedir")
-        pkg_get_variable("${_pkg_check_prefix}_LIBDIR" ${_pkg_check_modules_pkg} "libdir")
-
-        if (NOT ${_is_silent})
-          message(STATUS "  Found ${_pkg_check_modules_pkg}, version ${_pkgconfig_VERSION}")
-        endif ()
-      endforeach()
-
-      # set variables which are combined for multiple modules
-      _pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" LIBRARIES           "(^| )-l" --libs-only-l )
-      _pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" LIBRARY_DIRS        "(^| )-L" --libs-only-L )
-      _pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" LDFLAGS             ""        --libs )
-      _pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" LDFLAGS_OTHER       ""        --libs-only-other )
-
-      _pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" INCLUDE_DIRS        "(^| )-I" --cflags-only-I )
-      _pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" CFLAGS              ""        --cflags )
-      _pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" CFLAGS_OTHER        ""        --cflags-only-other )
-    endif()
-
-    if(NOT "${_extra_paths}" STREQUAL "")
-      # Restore the environment variable
-      set(ENV{PKG_CONFIG_PATH} ${_pkgconfig_path_old})
-    endif()
-
-    unset(_extra_paths)
-    unset(_pkgconfig_path_old)
-  else()
-    if (${_is_required})
-      message(SEND_ERROR "pkg-config tool not found")
-    endif ()
-  endif()
-endmacro()
-
-macro(gnc_pkg_check_modules _prefix _module0)
-  # check cached value
-  if (NOT DEFINED __pkg_config_checked_${_prefix} OR __pkg_config_checked_${_prefix} LESS ${PKG_CONFIG_VERSION} OR NOT ${_prefix}_FOUND)
-    _pkgconfig_parse_options   (_pkg_modules _pkg_is_required _pkg_is_silent _no_cmake_path _no_cmake_environment_path "${_module0}" ${ARGN})
-    _gnc_pkg_check_modules_internal("${_pkg_is_required}" "${_pkg_is_silent}" ${_no_cmake_path} ${_no_cmake_environment_path} "${_prefix}" ${_pkg_modules})
-    _pkgconfig_set(__pkg_config_checked_${_prefix} ${PKG_CONFIG_VERSION})
-  endif()
-endmacro()
-
-else()
-
-include(FindPkgConfig)
-
-macro(gnc_pkg_check_modules _prefix _module0)
-   PKG_CHECK_MODULES(${_prefix} ${_module0} ${ARGN})
-endmacro()
-
-endif()
diff --git a/common/cmake_modules/MakeDist.cmake b/common/cmake_modules/MakeDist.cmake
index 2db3aee2a..da04beddf 100644
--- a/common/cmake_modules/MakeDist.cmake
+++ b/common/cmake_modules/MakeDist.cmake
@@ -15,11 +15,6 @@ include(${CMAKE_MODULE_PATH}/MakeDistFiles.cmake)
 
 function(make_dist PACKAGE_PREFIX GNUCASH_SOURCE_DIR BUILD_SOURCE_DIR BUILDING_FROM_VCS)
 
-    set(CMAKE_COMMAND_TMP "")
-    if (${CMAKE_VERSION} VERSION_GREATER 3.1)
-        set(CMAKE_COMMAND_TMP ${CMAKE_COMMAND} -E env)
-    endif()
-
     # -- Remove any existing packaging directory.
     file(REMOVE_RECURSE ${PACKAGE_PREFIX})
 
@@ -68,7 +63,7 @@ function(make_dist PACKAGE_PREFIX GNUCASH_SOURCE_DIR BUILD_SOURCE_DIR BUILDING_F
         COMMAND ${CMAKE_COMMAND} -E copy ${PACKAGE_PREFIX}.tar ${PACKAGE_PREFIX}.tar.save
     )
     execute_process_and_check_result(
-            COMMAND ${CMAKE_COMMAND_TMP} gzip -f ${PACKAGE_PREFIX}.tar
+            COMMAND ${CMAKE_COMMAND} -E env gzip -f ${PACKAGE_PREFIX}.tar
             WORKING_DIRECTORY .
             ERROR_MSG "gzip command to create ${PACKAGE_PREFIX}.tar.gz failed."
     )
@@ -78,7 +73,7 @@ function(make_dist PACKAGE_PREFIX GNUCASH_SOURCE_DIR BUILD_SOURCE_DIR BUILDING_F
         COMMAND ${CMAKE_COMMAND} -E rename ${PACKAGE_PREFIX}.tar.save ${PACKAGE_PREFIX}.tar
     )
     execute_process_and_check_result(
-            COMMAND ${CMAKE_COMMAND_TMP} bzip2 -f ${PACKAGE_PREFIX}.tar
+            COMMAND ${CMAKE_COMMAND} -E env bzip2 -f ${PACKAGE_PREFIX}.tar
             WORKING_DIRECTORY .
             ERROR_MSG "bzip2 command to create ${PACKAGE_PREFIX}.tar.bz2 failed."
     )
diff --git a/common/cmake_modules/MakeDistCheck.cmake b/common/cmake_modules/MakeDistCheck.cmake
index c9e68ea9b..6fce2c04e 100644
--- a/common/cmake_modules/MakeDistCheck.cmake
+++ b/common/cmake_modules/MakeDistCheck.cmake
@@ -16,11 +16,6 @@ function(run_dist_check PACKAGE_PREFIX EXT)
     if (${EXT} STREQUAL ".bz2")
         set(TAR_OPTION "jxf")
     endif()
-        
-    set(MY_CMAKE_COMMAND "")
-    if (${CMAKE_VERSION} VERSION_GREATER 3.1)
-        set(MY_CMAKE_COMMAND ${CMAKE_COMMAND} -E env)
-    endif()
 
     FIND_PROGRAM(NINJA_COMMAND NAMES ninja ninja-build)
     if (${NINJA_COMMAND} STREQUAL "NINJA_COMMAND-NOTFOUND")
@@ -59,28 +54,28 @@ function(run_dist_check PACKAGE_PREFIX EXT)
 
     # Run ninja in the build directory
     execute_process_and_check_result(
-            COMMAND ${MY_CMAKE_COMMAND} ${NINJA_COMMAND}
+            COMMAND ${CMAKE_COMMAND} -E env ${NINJA_COMMAND}
             WORKING_DIRECTORY ${BUILD_DIR}
             ERROR_MSG "Ninja build failed."
     )
 
     # Run ninja install
     execute_process_and_check_result(
-            COMMAND ${MY_CMAKE_COMMAND} ${NINJA_COMMAND} install
+            COMMAND ${CMAKE_COMMAND} -E env ${NINJA_COMMAND} install
             WORKING_DIRECTORY ${BUILD_DIR}
             ERROR_MSG "Ninja install failed."
     )
 
     # Run ninja check in the build directory
     execute_process_and_check_result(
-            COMMAND ${MY_CMAKE_COMMAND} ${NINJA_COMMAND} check
+            COMMAND ${CMAKE_COMMAND} -E env ${NINJA_COMMAND} check
             WORKING_DIRECTORY ${BUILD_DIR}
             ERROR_MSG "Ninja check failed."
     )
 
     # Run ninja dist
     execute_process_and_check_result(
-            COMMAND ${MY_CMAKE_COMMAND} ${NINJA_COMMAND} dist
+            COMMAND ${CMAKE_COMMAND} -E env ${NINJA_COMMAND} dist
             WORKING_DIRECTORY ${BUILD_DIR}
             ERROR_MSG "Ninja dist failed."
     )
diff --git a/gnucash/gnome/CMakeLists.txt b/gnucash/gnome/CMakeLists.txt
index 083c7ee39..970606c8b 100644
--- a/gnucash/gnome/CMakeLists.txt
+++ b/gnucash/gnome/CMakeLists.txt
@@ -155,12 +155,6 @@ install(TARGETS gnc-gnome
 
 # FIXME: where does LC_ALL=C come from?
 
-set(CMAKE_COMMAND_TMP "")
-if (${CMAKE_VERSION} VERSION_GREATER 3.1)
-  set(CMAKE_COMMAND_TMP ${CMAKE_COMMAND} -E env)
-endif()
-
-
 if (${GETTEXT_VERSION_STRING} VERSION_LESS 0.19.6)
     # Gettext is too old to be able to merge an appdata file.
     # Fall back to providing an unmerged (and hence untranslated) appdata file.
@@ -169,7 +163,7 @@ if (${GETTEXT_VERSION_STRING} VERSION_LESS 0.19.6)
 else()
     add_custom_command (
         OUTPUT gnucash.appdata.xml
-        COMMAND ${CMAKE_COMMAND_TMP}
+        COMMAND ${CMAKE_COMMAND} -E env
             LC_ALL=C
             ${GETTEXT_MSGFMT_EXECUTABLE}
                 --xml --template ${CMAKE_CURRENT_SOURCE_DIR}/gnucash.appdata.xml.in
@@ -195,7 +189,7 @@ if (${GETTEXT_VERSION_STRING} VERSION_LESS 0.19)
 else()
     add_custom_command (
         OUTPUT gnucash.desktop
-        COMMAND ${CMAKE_COMMAND_TMP}
+        COMMAND ${CMAKE_COMMAND} -E env
             LC_ALL=C
             ${GETTEXT_MSGFMT_EXECUTABLE}
                 --desktop --template gnucash.desktop.in
diff --git a/gnucash/gschemas/CMakeLists.txt b/gnucash/gschemas/CMakeLists.txt
index 11b0f3dcc..0b1fcb91b 100644
--- a/gnucash/gschemas/CMakeLists.txt
+++ b/gnucash/gschemas/CMakeLists.txt
@@ -23,14 +23,10 @@ add_gschema_targets("${gschema_SOURCES}")
 
 # Handle gschemas.compiled
 if (COMPILE_GSCHEMAS)
-    set(CMAKE_COMMAND_TMP "")
-    if (${CMAKE_VERSION} VERSION_GREATER 3.1)
-        set(CMAKE_COMMAND_TMP ${CMAKE_COMMAND} -E env)
-    endif()
 
     add_custom_command(
         OUTPUT ${SCHEMADIR_BUILD}/gschemas.compiled
-        COMMAND ${CMAKE_COMMAND_TMP} ${GLIB_COMPILE_SCHEMAS} ${SCHEMADIR_BUILD}
+        COMMAND ${CMAKE_COMMAND} -E env ${GLIB_COMPILE_SCHEMAS} ${SCHEMADIR_BUILD}
         DEPENDS ${gschema_depends}
     )
 
diff --git a/libgnucash/backend/xml/test/CMakeLists.txt b/libgnucash/backend/xml/test/CMakeLists.txt
index 77b126c66..df1e599c2 100644
--- a/libgnucash/backend/xml/test/CMakeLists.txt
+++ b/libgnucash/backend/xml/test/CMakeLists.txt
@@ -90,18 +90,13 @@ add_xml_test(test-xml-transaction "${test_backend_xml_module_SOURCES};test-xml-t
 add_xml_test(test-xml2-is-file "${test_backend_xml_module_SOURCES};test-xml2-is-file.cpp"
    GNC_TEST_FILES=${CMAKE_CURRENT_SOURCE_DIR}/test-files/xml2)
 
-set(CMAKE_COMMAND_TMP "")
-if (${CMAKE_VERSION} VERSION_GREATER 3.1)
-  set(CMAKE_COMMAND_TMP ${CMAKE_COMMAND} -E env)
-endif()
-
 set(test-real-data-env
   SRCDIR=${CMAKE_CURRENT_SOURCE_DIR}
   VERBOSE=yes
   TEST_PATH=${CMAKE_BINARY_DIR}/bin
 )
 add_test(NAME test-real-data
-   COMMAND ${CMAKE_COMMAND_TMP}
+   COMMAND ${CMAKE_COMMAND} -E env
     ${SHELL} ${CMAKE_CURRENT_SOURCE_DIR}/test-real-data.sh
 )
 set_tests_properties(test-real-data PROPERTIES ENVIRONMENT "${test-real-data-env}")
diff --git a/libgnucash/doc/design/CMakeLists.txt b/libgnucash/doc/design/CMakeLists.txt
index 8e5068617..b9dec7e65 100644
--- a/libgnucash/doc/design/CMakeLists.txt
+++ b/libgnucash/doc/design/CMakeLists.txt
@@ -33,20 +33,11 @@ file(TO_NATIVE_PATH "${CMAKE_CURRENT_BINARY_DIR}" TEXI_BINARY_DIR)
 file(TO_NATIVE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/gnucash-design.texi" TEXI_SOURCE_FILE)
 find_program(MAKEINFO makeinfo)
 if (NOT ${MAKEINFO} STREQUAL "MAKEINFO-NOTFOUND")
-
-  if(${CMAKE_VERSION} VERSION_GREATER 3.1)
-    add_custom_command(
-      OUTPUT gnucash-design.info
-      COMMAND ${MAKEINFO} -I ${TEXI_BINARY_DIR} ${TEXI_SOURCE_FILE}
-      DEPENDS ${gnucash_design_TEXINFOS}
-      )
-  else()
-    add_custom_command(
-      OUTPUT gnucash-design.info
-      COMMAND ${MAKEINFO} -I ${TEXI_BINARY_DIR} ${TEXI_SOURCE_FILE}
-      DEPENDS ${gnucash_design_TEXINFOS}
-      )
-  endif()
+  add_custom_command(
+    OUTPUT gnucash-design.info
+    COMMAND ${MAKEINFO} -I ${TEXI_BINARY_DIR} ${TEXI_SOURCE_FILE}
+    DEPENDS ${gnucash_design_TEXINFOS}
+  )
 endif (NOT ${MAKEINFO} STREQUAL "MAKEINFO-NOTFOUND")
 dist_add_generated (${BUILDING_FROM_VCS} gnucash-design.info)
 
diff --git a/libgnucash/quotes/CMakeLists.txt b/libgnucash/quotes/CMakeLists.txt
index 1f98035ba..966b38a69 100644
--- a/libgnucash/quotes/CMakeLists.txt
+++ b/libgnucash/quotes/CMakeLists.txt
@@ -7,11 +7,6 @@ foreach(file gnc-fq-check.in gnc-fq-helper.in gnc-fq-update.in gnc-fq-dump)
   list(APPEND _BIN_FILES ${_ABS_OUTPUT_FILE})
 endforeach(file)
 
-set(CMAKE_COMMAND_TMP "")
-if (${CMAKE_VERSION} VERSION_GREATER 3.1)
-  set(CMAKE_COMMAND_TMP ${CMAKE_COMMAND} -E env)
-endif()
-
 
 set(_MAN_FILES "")
 foreach(file gnc-fq-dump gnc-fq-helper)
@@ -20,8 +15,7 @@ foreach(file gnc-fq-dump gnc-fq-helper)
   list(APPEND _MAN_FILES ${_MAN_OUTPUT})
   add_custom_command(
       OUTPUT ${_MAN_OUTPUT}
-      COMMAND
-        ${CMAKE_COMMAND_TMP} ${PERL_EXECUTABLE} ${POD2MAN_EXECUTABLE} ${_POD_INPUT} ${_MAN_OUTPUT}
+      COMMAND ${CMAKE_COMMAND} -E env ${PERL_EXECUTABLE} ${POD2MAN_EXECUTABLE} ${_POD_INPUT} ${_MAN_OUTPUT}
       DEPENDS ${_POD_INPUT}
   )
 endforeach(file)
diff --git a/po/CMakeLists.txt b/po/CMakeLists.txt
index ccbdf8f2f..202ef7198 100644
--- a/po/CMakeLists.txt
+++ b/po/CMakeLists.txt
@@ -16,11 +16,6 @@ file (WRITE LINGUAS "${ALL_LINGUAS}")
 set (CATALOGS "")
 set (BUILD_CATALOGS "")
 
-set(CMAKE_COMMAND_TMP "")
-if (${CMAKE_VERSION} VERSION_GREATER 3.1)
-  set(CMAKE_COMMAND_TMP ${CMAKE_COMMAND} -E env)
-endif()
-
 set(po_SOURCES "")
 file (WRITE LINGUAS "")
 foreach(lingua ${ALL_LINGUAS})
@@ -37,7 +32,7 @@ foreach(lingua ${ALL_LINGUAS})
   list(APPEND CATALOGS ${_OUTPUT_FILE})
   add_custom_command(
       OUTPUT ${_OUTPUT_FILE}
-      COMMAND ${CMAKE_COMMAND_TMP}
+      COMMAND ${CMAKE_COMMAND} -E env
         ${GETTEXT_MSGFMT_EXECUTABLE}
             -o ${_OUTPUT_FILE} ${CMAKE_CURRENT_SOURCE_DIR}/${lingua}.po
   )

commit ae76a294531de1b310cadf46c8bafb8bc81126ba
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Tue May 21 15:35:42 2019 +0800

    [aging] bugfix avoid report-crash when no APAR account exists
    
    need additional sanity checks.
    
    in a book with no suitable AP/AR account, from 'Customers Overview'
    spreadsheet, clicking 'Customer Listing' may call aging.scm renderer
    with account = #f leading to report crash.

diff --git a/gnucash/report/business-reports/aging.scm b/gnucash/report/business-reports/aging.scm
index 4c2dc4528..55844b2a0 100644
--- a/gnucash/report/business-reports/aging.scm
+++ b/gnucash/report/business-reports/aging.scm
@@ -716,7 +716,7 @@ copying this report to a spreadsheet for use in a mail merge.")
     ;; set default title
     (gnc:html-document-set-title! document report-title)
     ;; maybe redefine better...
-    (if (not (null? account))
+    (if (and account (not (null? account)))
         (begin
           (gnc:html-document-set-title!
            document (string-append report-title ": " (xaccAccountGetName account)))
@@ -731,7 +731,7 @@ copying this report to a spreadsheet for use in a mail merge.")
 
     (gnc:html-table-set-col-headers! table heading-list)
 				     
-    (if (not (null? account))
+    (if (and account (not (null? account)))
 	(begin
 	  (setup-query query account report-date)
 	  ;; get the appropriate splits

commit efe88f13a83f27c896079cbc5d3709ffa721040e
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Mon May 20 11:35:31 2019 +0800

    [balsheet-pnl] link pnl->transaction-report inherits common-currency

diff --git a/gnucash/report/standard-reports/balsheet-pnl.scm b/gnucash/report/standard-reports/balsheet-pnl.scm
index 44795c88d..fd3de167d 100644
--- a/gnucash/report/standard-reports/balsheet-pnl.scm
+++ b/gnucash/report/standard-reports/balsheet-pnl.scm
@@ -1117,6 +1117,7 @@ also show overall period profit & loss."))
                           (cdr monetarypair)
                           (car monetarypair)
                           (closing-adjustment account col-idx)))))))
+
              (get-cell-anchor-fn (lambda (account col-idx)
                                    (define datepair (col-idx->datepair col-idx))
                                    (gnc:make-report-anchor
@@ -1126,9 +1127,16 @@ also show overall period profit & loss."))
                                            (cons 'absolute (car datepair)))
                                      (list "General" "End Date"
                                            (cons 'absolute (cdr datepair)))
+                                     (list "General" "Show original currency amount"
+                                           (and common-currency #t))
+                                     (list "General" "Common Currency"
+                                           common-currency)
+                                     (list "General" "Report's currency"
+                                           (or common-currency book-main-currency))
                                      (list "Display" "Amount" 'double)
                                      (list "Accounts" "Accounts"
                                            (list account))))))
+
              (chart (and include-chart?
                          (gnc:make-report-anchor
                           pnl-barchart-uuid report-obj

commit 2d4f771bedf13ef9a2de4bd45d25d9afc860a8ec
Merge: 311f7d26e f6df367f5
Author: John Ralls <jralls at ceridwen.us>
Date:   Thu May 23 09:50:20 2019 -0700

    Merge Adrién Panella's 'budget' into maint.


commit 311f7d26e64238719523c59fa61a0e2aeacf6885
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Mon May 13 16:27:54 2019 +0800

    [dialog-tax-table] implement renaming of Tax Table name
    
    Adds a new button 'Rename' in dialog-tax-table.

diff --git a/gnucash/gnome-utils/dialog-tax-table.c b/gnucash/gnome-utils/dialog-tax-table.c
index 16971e330..4151d8076 100644
--- a/gnucash/gnome-utils/dialog-tax-table.c
+++ b/gnucash/gnome-utils/dialog-tax-table.c
@@ -60,6 +60,7 @@ enum tax_entry_cols
 };
 
 void tax_table_new_table_cb (GtkButton *button, TaxTableWindow *ttw);
+void tax_table_rename_table_cb (GtkButton *button, TaxTableWindow *ttw);
 void tax_table_delete_table_cb (GtkButton *button, TaxTableWindow *ttw);
 void tax_table_new_entry_cb (GtkButton *button, TaxTableWindow *ttw);
 void tax_table_edit_entry_cb (GtkButton *button, TaxTableWindow *ttw);
@@ -555,6 +556,95 @@ tax_table_new_table_cb (GtkButton *button, TaxTableWindow *ttw)
     new_tax_table_dialog (ttw, TRUE, NULL, NULL);
 }
 
+
+static const char
+*rename_tax_table_dialog (GtkWidget *parent,
+                          const char *title,
+                          const char *msg,
+                          const char *button_name,
+                          const char *text)
+{
+    GtkWidget *vbox;
+    GtkWidget *main_vbox;
+    GtkWidget *label;
+    GtkWidget *textbox;
+    GtkWidget *dialog;
+    GtkWidget *dvbox;
+
+    main_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 3);
+    gtk_box_set_homogeneous (GTK_BOX (main_vbox), FALSE);
+    gtk_container_set_border_width (GTK_CONTAINER(main_vbox), 6);
+    gtk_widget_show (main_vbox);
+
+    label = gtk_label_new (msg);
+    gtk_label_set_justify (GTK_LABEL(label), GTK_JUSTIFY_LEFT);
+    gtk_box_pack_start (GTK_BOX(main_vbox), label, FALSE, FALSE, 0);
+    gtk_widget_show (label);
+
+    vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 3);
+    gtk_box_set_homogeneous (GTK_BOX (vbox), TRUE);
+    gtk_container_set_border_width (GTK_CONTAINER(vbox), 6);
+    gtk_container_add (GTK_CONTAINER(main_vbox), vbox);
+    gtk_widget_show (vbox);
+
+    textbox = gtk_entry_new ();
+    gtk_widget_show (textbox);
+    gtk_entry_set_text (GTK_ENTRY(textbox), text);
+    gtk_box_pack_start (GTK_BOX(vbox), textbox, FALSE, FALSE, 0);
+
+    dialog = gtk_dialog_new_with_buttons (title, GTK_WINDOW(parent),
+                                          GTK_DIALOG_DESTROY_WITH_PARENT,
+                                          _("_Cancel"), GTK_RESPONSE_CANCEL,
+                                          button_name, GTK_RESPONSE_OK,
+                                          NULL);
+    gtk_dialog_set_default_response (GTK_DIALOG(dialog), GTK_RESPONSE_OK);
+
+    dvbox = gtk_dialog_get_content_area (GTK_DIALOG(dialog));
+    gtk_box_pack_start (GTK_BOX(dvbox), main_vbox, TRUE, TRUE, 0);
+
+    if (gtk_dialog_run (GTK_DIALOG(dialog)) != GTK_RESPONSE_OK)
+    {
+        gtk_widget_destroy (dialog);
+        return NULL;
+    }
+
+    text = g_strdup (gtk_entry_get_text (GTK_ENTRY (textbox)));
+    gtk_widget_destroy (dialog);
+    return text;
+}
+
+void
+tax_table_rename_table_cb (GtkButton *button, TaxTableWindow *ttw)
+{
+    const char *oldname;
+    const char *newname;
+    g_return_if_fail (ttw);
+
+    if (!ttw->current_table)
+        return;
+
+    oldname = gncTaxTableGetName (ttw->current_table);
+    newname = rename_tax_table_dialog (ttw->dialog, (_("Rename")),
+                                       (_("Please enter new name")),
+                                       (_("_Rename")), oldname);
+
+    if (newname && *newname != '\0' && (g_strcmp0(oldname, newname) != 0))
+    {
+        if (gncTaxTableLookupByName (ttw->book, newname))
+        {
+            char *message = g_strdup_printf (_("Tax table name \"%s\" already exists."),
+                                             newname);
+            gnc_error_dialog (GTK_WINDOW (ttw->dialog), "%s", message);
+            g_free (message);
+        }
+        else
+        {
+            gncTaxTableSetName (ttw->current_table, newname);
+        }
+    }
+}
+
+
 void
 tax_table_delete_table_cb (GtkButton *button, TaxTableWindow *ttw)
 {
diff --git a/gnucash/gtkbuilder/dialog-tax-table.glade b/gnucash/gtkbuilder/dialog-tax-table.glade
index 7c9445914..9c4a99928 100644
--- a/gnucash/gtkbuilder/dialog-tax-table.glade
+++ b/gnucash/gtkbuilder/dialog-tax-table.glade
@@ -121,7 +121,7 @@
                           <packing>
                             <property name="expand">False</property>
                             <property name="fill">False</property>
-                            <property name="position">0</property>
+                            <property name="position">1</property>
                           </packing>
                         </child>
                         <child>
@@ -136,7 +136,22 @@
                           <packing>
                             <property name="expand">False</property>
                             <property name="fill">False</property>
-                            <property name="position">1</property>
+                            <property name="position">2</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkButton" id="rename_table_button">
+                            <property name="label" translatable="yes">_Rename</property>
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="receives_default">False</property>
+                            <property name="use_underline">True</property>
+                            <signal name="clicked" handler="tax_table_rename_table_cb" swapped="no"/>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">False</property>
+                            <property name="position">0</property>
                           </packing>
                         </child>
                       </object>

commit f6df367f50506aef8ae6f18cffbbbad6db2b945f
Author: Adrian Panella <ianchi74 at outlook.com>
Date:   Sat May 18 14:14:27 2019 -0500

    [budget] Remove unused code
    
    Remove some priv attributes and code that were never used

diff --git a/gnucash/gnome/gnc-budget-view.c b/gnucash/gnome/gnc-budget-view.c
index 697701fce..3710196b3 100644
--- a/gnucash/gnome/gnc-budget-view.c
+++ b/gnucash/gnome/gnc-budget-view.c
@@ -161,10 +161,6 @@ struct GncBudgetViewPrivate
     GtkTreeViewColumn* total_col;
     AccountFilterDialog *fd;
 
-    Account* income;
-    Account* expenses;
-    Account* assets;
-    Account* liabilities;
     Account* rootAcct;
 
     GtkCellRenderer *temp_cr;
@@ -235,29 +231,6 @@ gnc_budget_view_init(GncBudgetView *budget_view)
 
     priv->rootAcct = root;
 
-    for (i = 0; i < num_top_accounts; ++i)
-    {
-        Account* acc = gnc_account_nth_child(root, i);
-        GNCAccountType type = xaccAccountGetType(acc);
-
-        if (type == ACCT_TYPE_ASSET)
-        {
-            priv->assets = acc;
-        }
-        else if (type == ACCT_TYPE_LIABILITY)
-        {
-            priv->liabilities = acc;
-        }
-        else if (type == ACCT_TYPE_INCOME)
-        {
-            priv->income = acc;
-        }
-        else if (type == ACCT_TYPE_EXPENSE)
-        {
-            priv->expenses = acc;
-        }
-    }
-
     LEAVE("");
 }
 

commit 51dda770579efa666ea516a96de7a8f4639e1473
Author: Adrian Panella <ianchi74 at outlook.com>
Date:   Fri May 17 23:10:25 2019 -0500

    Bug 577968 - Values are not stored by pressing <TAB> in budget page
    
    Also fix duplicates: 760194

diff --git a/gnucash/gnome/gnc-budget-view.c b/gnucash/gnome/gnc-budget-view.c
index e6b06aea2..697701fce 100644
--- a/gnucash/gnome/gnc-budget-view.c
+++ b/gnucash/gnome/gnc-budget-view.c
@@ -118,10 +118,8 @@ static void gbv_create_widget(GncBudgetView *view);
 static gboolean gbv_button_press_cb(
     GtkWidget *widget, GdkEventButton *event, GncBudgetView *view);
 #endif
-#if 0
-static gboolean gbv_key_press_cb(
-    GtkWidget *treeview, GdkEventKey *event, gpointer userdata);
-#endif
+static gboolean gbv_key_press_cb(GtkWidget *treeview, GdkEventKey *event,
+                                 gpointer userdata);
 static void gbv_row_activated_cb(
     GtkTreeView *treeview, GtkTreePath *path, GtkTreeViewColumn *col,
     GncBudgetView *view);
@@ -168,6 +166,9 @@ struct GncBudgetViewPrivate
     Account* assets;
     Account* liabilities;
     Account* rootAcct;
+
+    GtkCellRenderer *temp_cr;
+    GtkCellEditable *temp_ce;
 };
 
 G_DEFINE_TYPE_WITH_PRIVATE(GncBudgetView, gnc_budget_view, GTK_TYPE_BOX)
@@ -427,9 +428,6 @@ gbv_create_widget(GncBudgetView *view)
                      G_CALLBACK(gbv_selection_changed_cb), view);
     g_signal_connect(G_OBJECT(tree_view), "button-press-event",
                      G_CALLBACK(gbv_button_press_cb), view);
-    g_signal_connect_after(G_OBJECT(tree_view), "key-press-event",
-                           G_CALLBACK(gbv_key_press_cb), NULL);
-
     gbv_selection_changed_cb(NULL, view);
 #endif
 
@@ -669,39 +667,103 @@ gbv_button_press_cb(GtkWidget *widget, GdkEventButton *event,
 }
 #endif
 
-#if 0
-/** \brief Key press action for gnc budget view.
+/** \brief Key press action for gnc budget view when in editing mode.
+ * Used for navigating with tab while editing.
+ * The handler is for the cell-editable, not for the treeview
 */
 static gboolean
-gbv_key_press_cb(GtkWidget *treeview, GdkEventKey *event, gpointer userdata)
+gbv_key_press_cb(GtkWidget *widget, GdkEventKey *event, gpointer userdata)
 {
-    GtkTreeView *tv = GTK_TREE_VIEW(treeview);
     GtkTreeViewColumn *col;
-    GtkTreePath *path = NULL;
-
-    if (event->type != GDK_KEY_PRESS) return TRUE;
+    GtkTreePath *path          = NULL;
+    GncBudgetViewPrivate *priv = GNC_BUDGET_VIEW_GET_PRIVATE(userdata);
+    GtkTreeView *tv            = priv->tree_view;
+    gboolean shifted;
+    gint period_num, num_periods;
+    gpointer data;
+
+    if (event->type != GDK_KEY_PRESS || !priv->temp_cr)
+        return FALSE;
 
     switch (event->keyval)
     {
     case GDK_KEY_Tab:
     case GDK_KEY_ISO_Left_Tab:
     case GDK_KEY_KP_Tab:
-    case GDK_KEY_Return:
-    case GDK_KEY_KP_Enter:
+        shifted = event->state & GDK_SHIFT_MASK;
         gtk_tree_view_get_cursor(tv, &path, &col);
-        if (!path) return TRUE;
-        //finish_edit(col);
+        if (!path)
+            return TRUE;
+        data        = g_object_get_data(G_OBJECT(col), "period_num");
+        period_num  = GPOINTER_TO_UINT(data);
+        num_periods = gnc_budget_get_num_periods(priv->budget);
+
+        if (period_num >= num_periods)
+            period_num = num_periods - 1;
+
+        if (shifted)
+            period_num--;
+        else
+            period_num++;
+
+        if (period_num >= num_periods)
+        {
+            period_num = 0;
+            if (gtk_tree_view_row_expanded(tv, path))
+            {
+                gtk_tree_path_down(path);
+            }
+            else
+            {
+                gtk_tree_path_next(path);
+                while (!gnc_tree_view_path_is_valid(GNC_TREE_VIEW(tv), path) &&
+                       gtk_tree_path_get_depth(path) > 1)
+                {
+                    gtk_tree_path_up(path);
+                    gtk_tree_path_next(path);
+                }
+            }
+        }
+        else if (period_num < 0)
+        {
+            period_num = num_periods - 1;
+            if (!gtk_tree_path_prev(path))
+                gtk_tree_path_up(path);
+            else
+                while (gtk_tree_view_row_expanded(tv, path))
+                {
+                    gtk_tree_path_down(path);
+                    do
+                    {
+                        gtk_tree_path_next(path);
+                    } while (
+                        gnc_tree_view_path_is_valid(GNC_TREE_VIEW(tv), path));
+                    gtk_tree_path_prev(path);
+                }
+        }
+
+        col = g_list_nth_data(priv->period_col_list, period_num);
+
+        // finish editing
+        if (priv->temp_ce)
+        {
+            gtk_cell_editable_editing_done(priv->temp_ce);
+            gtk_cell_editable_remove_widget(priv->temp_ce);
+
+            while (gtk_events_pending())
+                gtk_main_iteration();
+        }
+
+        if (gnc_tree_view_path_is_valid(GNC_TREE_VIEW(tv), path))
+            gtk_tree_view_set_cursor(tv, path, col, TRUE);
+        gtk_tree_path_free(path);
         break;
     default:
-        return TRUE;
+        return FALSE;
     }
-    gnc_tree_view_keynav(GNC_TREE_VIEW(tv), &col, path, event);
 
-    if (path && gnc_tree_view_path_is_valid(GNC_TREE_VIEW(tv), path))
-        gtk_tree_view_set_cursor(tv, path, col, TRUE);
     return TRUE;
 }
-#endif
 
 /** \brief gnc budget view actions for resize of treeview.
 */
@@ -1270,6 +1332,30 @@ gbv_col_edited_cb(GtkCellRendererText* cell, gchar* path_string, gchar* new_text
     gtk_widget_queue_draw(GTK_WIDGET(priv->totals_tree_view));
 }
 
+/* The main Start Editing Call back for the budget columns, for key navigation
+ */
+static void
+gdv_editing_started_cb(GtkCellRenderer *cr, GtkCellEditable *editable,
+                       const gchar *path_string, gpointer user_data)
+{
+    GncBudgetViewPrivate *priv = GNC_BUDGET_VIEW_GET_PRIVATE(user_data);
+
+    priv->temp_cr = cr;
+    priv->temp_ce = editable;
+
+    g_signal_connect(G_OBJECT(editable), "key-press-event",
+                     G_CALLBACK(gbv_key_press_cb), user_data);
+}
+
+static void
+gdv_editing_canceled_cb(GtkCellRenderer *cr, gpointer user_data)
+{
+    GncBudgetViewPrivate *priv = GNC_BUDGET_VIEW_GET_PRIVATE(user_data);
+
+    priv->temp_cr = NULL;
+    priv->temp_ce = NULL;
+}
+
 /** \brief refreshes the current budget view
 
 The function will step through to only display the columns that are set
@@ -1343,7 +1429,10 @@ gnc_budget_view_refresh(GncBudgetView *view)
         gbv_renderer_add_padding (renderer);
 
         g_signal_connect(G_OBJECT(renderer), "edited", (GCallback)gbv_col_edited_cb, view);
-
+        g_signal_connect(G_OBJECT(renderer), "editing-started",
+                         (GCallback)gdv_editing_started_cb, view);
+        g_signal_connect(G_OBJECT(renderer), "editing-canceled",
+                         (GCallback)gdv_editing_canceled_cb, view);
         col = gbv_create_totals_column(view, num_periods_visible);
         if (col != NULL)
         {

commit 91aceaa71ba4a162d246b60fcdc09b14b6545d62
Author: Adrian Panella <ianchi74 at outlook.com>
Date:   Fri May 17 23:04:35 2019 -0500

    Bug 781345 - Equity disregarded by budget totals

diff --git a/gnucash/gnome/gnc-budget-view.c b/gnucash/gnome/gnc-budget-view.c
index 3c6013ccc..e6b06aea2 100644
--- a/gnucash/gnome/gnc-budget-view.c
+++ b/gnucash/gnome/gnc-budget-view.c
@@ -1125,6 +1125,7 @@ totals_col_source(GtkTreeViewColumn *col, GtkCellRenderer *cell,
                 continue;
             break;
         case ACCT_TYPE_LIABILITY:
+        case ACCT_TYPE_EQUITY:
             if (row_type != TOTALS_TYPE_TRANSFERS &&
                 row_type != TOTALS_TYPE_TOTAL)
                 continue;

commit d16a236eceaaf7dd322996fbbdcafdc42da23789
Author: Adrian Panella <ianchi74 at outlook.com>
Date:   Fri May 17 23:03:14 2019 -0500

    [Budget] Fix negative Numbers Not Colored Red

diff --git a/gnucash/gnome/gnc-budget-view.c b/gnucash/gnome/gnc-budget-view.c
index 92d603177..3c6013ccc 100644
--- a/gnucash/gnome/gnc-budget-view.c
+++ b/gnucash/gnome/gnc-budget-view.c
@@ -869,6 +869,19 @@ gbv_get_accumulated_budget_amount(GncBudget* budget, Account* account, guint per
     return info.total;
 }
 
+static gchar*
+get_negative_color (void)
+{
+    GdkRGBA color;
+    GtkWidget *label = gtk_label_new ("Color");
+    GtkStyleContext *context = gtk_widget_get_style_context (GTK_WIDGET(label));
+    gtk_style_context_add_class (context, "negative-numbers");
+    gtk_style_context_get_color (context, GTK_STATE_FLAG_NORMAL, &color);
+    gtk_widget_destroy(label);
+    
+    return gdk_rgba_to_string(&color);
+}
+
 /** \brief Calculates and displays budget amount for a period in a defined account.
 
    Displays budget amount for a period for an account.  If a budget
@@ -885,6 +898,7 @@ budget_col_source(Account *account, GtkTreeViewColumn *col,
     guint period_num;
     gnc_numeric numeric;
     gchar amtbuff[100]; //FIXME: overkill, where's the #define?
+    gboolean red = gnc_prefs_get_bool(GNC_PREFS_GROUP_GENERAL, GNC_PREF_NEGATIVE_IN_RED);
 
     budget = GNC_BUDGET(g_object_get_data(G_OBJECT(col), "budget"));
     bview = GTK_TREE_VIEW(g_object_get_data(G_OBJECT(col), "budget_view"));
@@ -906,10 +920,18 @@ budget_col_source(Account *account, GtkTreeViewColumn *col,
             numeric = gbv_get_accumulated_budget_amount(budget, account, period_num);
             xaccSPrintAmount(amtbuff, numeric,
                              gnc_account_print_info(account, FALSE));
-            if (gnc_is_dark_theme (&color))
-                g_object_set(cell, "foreground", "darkgray", NULL);
+            if (gnc_is_dark_theme(&color))
+                g_object_set(cell, "foreground",
+                             red && gnc_numeric_negative_p(numeric)
+                                 ? "darkred"
+                                 : "darkgray",
+                             NULL);
             else
-                g_object_set(cell, "foreground", "dimgray", NULL);
+                g_object_set(cell, "foreground",
+                             red && gnc_numeric_negative_p(numeric)
+                                 ? "PaleVioletRed"
+                                 : "dimgray",
+                             NULL);
         }
     }
     else
@@ -924,7 +946,11 @@ budget_col_source(Account *account, GtkTreeViewColumn *col,
         {
             xaccSPrintAmount(amtbuff, numeric,
                              gnc_account_print_info(account, FALSE));
-            g_object_set(cell, "foreground", NULL, NULL);
+            g_object_set(cell, "foreground",
+                         red && gnc_numeric_negative_p(numeric)
+                             ? get_negative_color()
+                             : NULL,
+                         NULL);
         }
     }
     return g_strdup(amtbuff);
@@ -994,11 +1020,14 @@ budget_total_col_source(Account *account, GtkTreeViewColumn *col,
     GncBudget *budget;
     gnc_numeric total;
     gchar amtbuff[100]; //FIXME: overkill, where's the #define?
+    gboolean red = gnc_prefs_get_bool(GNC_PREFS_GROUP_GENERAL, GNC_PREF_NEGATIVE_IN_RED);
 
     budget = GNC_BUDGET(g_object_get_data(G_OBJECT(col), "budget"));
     total = bgv_get_total_for_account(account, budget, NULL);
     xaccSPrintAmount(amtbuff, total,
                      gnc_account_print_info(account, TRUE));
+    g_object_set(cell, "foreground",
+                 red && gnc_numeric_negative_p(total) ? get_negative_color () : NULL, NULL);
     return g_strdup(amtbuff);
 }
 
@@ -1060,14 +1089,16 @@ totals_col_source(GtkTreeViewColumn *col, GtkCellRenderer *cell,
     gchar amtbuff[100]; //FIXME: overkill, where's the #define?
     gint i;
     gint num_top_accounts;
-    gboolean neg;
+    gboolean neg, red;
     GNCPriceDB *pdb;
     gnc_commodity *total_currency, *currency;
 
+
     gnc_numeric total = gnc_numeric_zero();
 
     view = GNC_BUDGET_VIEW(user_data);
     priv = GNC_BUDGET_VIEW_GET_PRIVATE(view);
+    red = gnc_prefs_get_bool(GNC_PREFS_GROUP_GENERAL, GNC_PREF_NEGATIVE_IN_RED);
 
     gtk_tree_model_get(s_model, s_iter, 1, &row_type, -1);
     budget = GNC_BUDGET(g_object_get_data(G_OBJECT(col), "budget"));
@@ -1141,7 +1172,7 @@ totals_col_source(GtkTreeViewColumn *col, GtkCellRenderer *cell,
                      gnc_commodity_print_info(total_currency,
                                               period_num < 0 ? TRUE : FALSE));
     g_object_set(cell, "foreground",
-                 gnc_numeric_negative_p(total) ? "red" : NULL, NULL);
+                 red && gnc_numeric_negative_p(total) ? get_negative_color () : NULL, NULL);
 
     g_object_set(G_OBJECT(cell), "text", amtbuff, "xalign", 1.0, NULL);
 }

commit 0319144ba6d04e94d84bbae190952beccee93f63
Author: Adrian Panella <ianchi74 at outlook.com>
Date:   Mon May 13 22:57:51 2019 -0500

    Bug 788157 - Open Budget Menu Item Doesn't Select Default Budget

diff --git a/gnucash/gnome/gnc-plugin-budget.c b/gnucash/gnome/gnc-plugin-budget.c
index c1afd95f7..358567303 100644
--- a/gnucash/gnome/gnc-plugin-budget.c
+++ b/gnucash/gnome/gnc-plugin-budget.c
@@ -312,6 +312,13 @@ gnc_budget_gui_select_budget(GtkWindow *parent, QofBook *book)
     gtk_container_add(GTK_CONTAINER (gtk_dialog_get_content_area (dlg)), GTK_WIDGET(tv));
     gtk_widget_show_all(GTK_WIDGET(dlg));
 
+    // Preselect the default budget
+    bgt = gnc_budget_get_default(book);
+    if (bgt && gnc_tree_model_budget_get_iter_for_budget(tm, &iter, bgt))
+    {
+        gtk_tree_view_set_cursor(tv, gtk_tree_model_get_path(tm, &iter), NULL,
+                                 FALSE);
+    }
     bgt = NULL;
     response = gtk_dialog_run(dlg);
     switch (response)

commit 5bb54d073c2fc936ff5cc129110844b18096c599
Author: Adrian Panella <ianchi74 at outlook.com>
Date:   Mon May 13 22:56:04 2019 -0500

    [budget] Fix error in qof_book property path
    
    The "Default budget" property had an erroneus path
    and was not returning any value.

diff --git a/libgnucash/engine/qofbook.cpp b/libgnucash/engine/qofbook.cpp
index 3991e96d6..8e7dc93cf 100644
--- a/libgnucash/engine/qofbook.cpp
+++ b/libgnucash/engine/qofbook.cpp
@@ -163,6 +163,8 @@ qof_book_init (QofBook *book)
 
 static const std::string str_KVP_OPTION_PATH(KVP_OPTION_PATH);
 static const std::string str_OPTION_SECTION_ACCOUNTS(OPTION_SECTION_ACCOUNTS);
+static const std::string str_OPTION_SECTION_BUDGETING(OPTION_SECTION_BUDGETING);
+static const std::string str_OPTION_NAME_DEFAULT_BUDGET(OPTION_NAME_DEFAULT_BUDGET);
 static const std::string str_OPTION_NAME_TRADING_ACCOUNTS(OPTION_NAME_TRADING_ACCOUNTS);
 static const std::string str_OPTION_NAME_AUTO_READONLY_DAYS(OPTION_NAME_AUTO_READONLY_DAYS);
 static const std::string str_OPTION_NAME_NUM_FIELD_SOURCE(OPTION_NAME_NUM_FIELD_SOURCE);
@@ -206,7 +208,7 @@ qof_book_get_property (GObject* object,
         break;
     case PROP_OPT_DEFAULT_BUDGET:
         qof_instance_get_path_kvp (QOF_INSTANCE (book), value, {str_KVP_OPTION_PATH,
-                str_OPTION_SECTION_ACCOUNTS, OPTION_NAME_DEFAULT_BUDGET});
+                str_OPTION_SECTION_BUDGETING, str_OPTION_NAME_DEFAULT_BUDGET});
         break;
     case PROP_OPT_FY_END:
         qof_instance_get_path_kvp (QOF_INSTANCE (book), value, {"fy_end"});
@@ -261,7 +263,7 @@ qof_book_set_property (GObject      *object,
         break;
     case PROP_OPT_DEFAULT_BUDGET:
         qof_instance_set_path_kvp (QOF_INSTANCE (book), value, {str_KVP_OPTION_PATH,
-                str_OPTION_SECTION_ACCOUNTS, OPTION_NAME_DEFAULT_BUDGET});
+                str_OPTION_SECTION_BUDGETING, OPTION_NAME_DEFAULT_BUDGET});
         break;
     case PROP_OPT_FY_END:
         qof_instance_set_path_kvp (QOF_INSTANCE (book), value, {"fy_end"});

commit df1cc5902b17916f8da7da9866e9371bfadcb8d0
Author: Adrian Panella <ianchi74 at outlook.com>
Date:   Thu May 9 08:07:34 2019 -0500

    Bug 676810 - Wrong accounting in multi-currency budget report
    
    Adds multicurrency support in budget page
    Convert currencies before summing up to parent and totals.

diff --git a/gnucash/gnome/gnc-budget-view.c b/gnucash/gnome/gnc-budget-view.c
index 6fe4d9eda..92d603177 100644
--- a/gnucash/gnome/gnc-budget-view.c
+++ b/gnucash/gnome/gnc-budget-view.c
@@ -804,6 +804,8 @@ typedef struct
     gnc_numeric total;
     GncBudget* budget;
     guint period_num;
+    GNCPriceDB *pdb;
+    gnc_commodity *total_currency;
 } BudgetAccumulationInfo;
 
 /** \brief Function to assist in the calculation of sub-account totals.
@@ -815,16 +817,29 @@ budget_accum_helper(Account* account, gpointer data)
 {
     BudgetAccumulationInfo* info = (BudgetAccumulationInfo*)data;
     gnc_numeric numeric;
+    gnc_commodity *currency;
+
+    currency = gnc_account_get_currency_or_parent(account);
 
     if (gnc_budget_is_account_period_value_set(info->budget, account, info->period_num))
     {
-        numeric = gnc_budget_get_account_period_value(info->budget, account, info->period_num);
-        info->total = gnc_numeric_add(info->total, numeric, GNC_DENOM_AUTO, GNC_HOW_DENOM_LCD);
+        numeric = gnc_budget_get_account_period_value(info->budget, account,
+                                                      info->period_num);
+        numeric = gnc_pricedb_convert_balance_nearest_price_t64(
+                    info->pdb, numeric, currency, info->total_currency,
+                    gnc_budget_get_period_start_date(info->budget, info->period_num));
+        info->total = gnc_numeric_add(info->total, numeric, GNC_DENOM_AUTO,
+                                      GNC_HOW_DENOM_LCD);
     }
     else if (gnc_account_n_children(account) != 0)
     {
-        numeric = gbv_get_accumulated_budget_amount(info->budget, account, info->period_num);
-        info->total = gnc_numeric_add(info->total, numeric, GNC_DENOM_AUTO, GNC_HOW_DENOM_LCD);
+        numeric = gbv_get_accumulated_budget_amount(info->budget, account,
+                                                    info->period_num);
+        numeric = gnc_pricedb_convert_balance_nearest_price_t64(
+                    info->pdb, numeric, currency, info->total_currency,
+                    gnc_budget_get_period_start_date(info->budget, info->period_num));
+        info->total = gnc_numeric_add(info->total, numeric, GNC_DENOM_AUTO,
+                                      GNC_HOW_DENOM_LCD);
     }
 }
 
@@ -840,6 +855,8 @@ gbv_get_accumulated_budget_amount(GncBudget* budget, Account* account, guint per
     info.total = gnc_numeric_zero();
     info.budget = budget;
     info.period_num = period_num;
+    info.pdb = gnc_pricedb_get_db (gnc_account_get_book (account));
+    info.total_currency = gnc_account_get_currency_or_parent(account);
 
     if (!gnc_budget_is_account_period_value_set(budget, account, period_num))
     {
@@ -917,12 +934,20 @@ budget_col_source(Account *account, GtkTreeViewColumn *col,
  totals column to the right.
 */
 static gnc_numeric
-bgv_get_total_for_account(Account* account, GncBudget* budget)
+bgv_get_total_for_account(Account* account, GncBudget* budget, gnc_commodity *new_currency)
 {
     guint num_periods;
     int period_num;
     gnc_numeric numeric;
     gnc_numeric total = gnc_numeric_zero();
+    GNCPriceDB *pdb;
+    gnc_commodity *currency;
+
+    if (new_currency)
+    {
+        pdb      = gnc_pricedb_get_db(gnc_get_current_book());
+        currency = gnc_account_get_currency_or_parent(account);
+    }
 
     num_periods = gnc_budget_get_num_periods(budget);
     for (period_num = 0; period_num < num_periods; ++period_num)
@@ -932,6 +957,13 @@ bgv_get_total_for_account(Account* account, GncBudget* budget)
             if (gnc_account_n_children(account) != 0)
             {
                 numeric = gbv_get_accumulated_budget_amount(budget, account, period_num);
+
+                if (new_currency)
+                {
+                    numeric = gnc_pricedb_convert_balance_nearest_price_t64(
+                                pdb, numeric, currency, new_currency,
+                                gnc_budget_get_period_start_date(budget, period_num));
+                }
                 total = gnc_numeric_add(total, numeric, GNC_DENOM_AUTO, GNC_HOW_DENOM_LCD);
             }
         }
@@ -940,6 +972,12 @@ bgv_get_total_for_account(Account* account, GncBudget* budget)
             numeric = gnc_budget_get_account_period_value(budget, account, period_num);
             if (!gnc_numeric_check(numeric))
             {
+                if (new_currency)
+                {
+                    numeric = gnc_pricedb_convert_balance_nearest_price_t64(
+                                pdb, numeric, currency, new_currency,
+                                gnc_budget_get_period_start_date(budget, period_num));
+                }
                 total = gnc_numeric_add(total, numeric, GNC_DENOM_AUTO, GNC_HOW_DENOM_LCD);
             }
         }
@@ -958,9 +996,9 @@ budget_total_col_source(Account *account, GtkTreeViewColumn *col,
     gchar amtbuff[100]; //FIXME: overkill, where's the #define?
 
     budget = GNC_BUDGET(g_object_get_data(G_OBJECT(col), "budget"));
-    total = bgv_get_total_for_account(account, budget);
+    total = bgv_get_total_for_account(account, budget, NULL);
     xaccSPrintAmount(amtbuff, total,
-                     gnc_account_print_info(account, FALSE));
+                     gnc_account_print_info(account, TRUE));
     return g_strdup(amtbuff);
 }
 
@@ -1022,11 +1060,11 @@ totals_col_source(GtkTreeViewColumn *col, GtkCellRenderer *cell,
     gchar amtbuff[100]; //FIXME: overkill, where's the #define?
     gint i;
     gint num_top_accounts;
+    gboolean neg;
+    GNCPriceDB *pdb;
+    gnc_commodity *total_currency, *currency;
 
-    gnc_numeric totalincome = gnc_numeric_zero();
-    gnc_numeric totalexpenses = gnc_numeric_zero();
-    gnc_numeric totalassets = gnc_numeric_zero();
-    gnc_numeric totalliabilities = gnc_numeric_zero();
+    gnc_numeric total = gnc_numeric_zero();
 
     view = GNC_BUDGET_VIEW(user_data);
     priv = GNC_BUDGET_VIEW_GET_PRIVATE(view);
@@ -1036,93 +1074,75 @@ totals_col_source(GtkTreeViewColumn *col, GtkCellRenderer *cell,
     period_num = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(col),
                                  "period_num"));
 
+    pdb = gnc_pricedb_get_db (gnc_get_current_book());
+    total_currency = gnc_default_currency();
     num_top_accounts = gnc_account_n_children(priv->rootAcct);
 
     // step through each child account of the root, find the total income, expenses, liabilities, and assets.
 
     for (i = 0; i < num_top_accounts; ++i)
     {
-        account = gnc_account_nth_child(priv->rootAcct, i);
+        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 &&
+                row_type != TOTALS_TYPE_TOTAL)
+                continue;
+            break;
+        case ACCT_TYPE_LIABILITY:
+            if (row_type != TOTALS_TYPE_TRANSFERS &&
+                row_type != TOTALS_TYPE_TOTAL)
+                continue;
+            break;
+        case ACCT_TYPE_EXPENSE:
+            if (row_type == TOTALS_TYPE_TOTAL)
+                neg = TRUE;
+            else if (row_type != TOTALS_TYPE_EXPENSES)
+                continue;
+            break;
+        case ACCT_TYPE_ASSET:
+            if (row_type != TOTALS_TYPE_TRANSFERS &&
+                row_type != TOTALS_TYPE_TOTAL)
+                continue;
+            neg = TRUE;
+            break;
+        default:
+            continue;
+        }
         // find the total for this account
 
         if (period_num < 0)
         {
-            value = bgv_get_total_for_account(account, budget);
+            value = bgv_get_total_for_account(account, budget, total_currency);
         }
         else
         {
-            value = gbv_get_accumulated_budget_amount(budget, account, period_num);
-        }
-
-        // test for what account type, and add 'value' to the appopriate total
+            value =
+                gbv_get_accumulated_budget_amount(budget, account, period_num);
 
-        if (xaccAccountGetType(account) == ACCT_TYPE_INCOME)
-        {
-            totalincome = gnc_numeric_add(totalincome, value, GNC_DENOM_AUTO, GNC_HOW_DENOM_LCD);
-        }
-        else if (xaccAccountGetType(account) == ACCT_TYPE_EXPENSE)
-        {
-            totalexpenses = gnc_numeric_add(totalexpenses, value, GNC_DENOM_AUTO, GNC_HOW_DENOM_LCD);
-        }
-        else if (xaccAccountGetType(account) == ACCT_TYPE_ASSET)
-        {
-            totalassets = gnc_numeric_add(totalassets, value, GNC_DENOM_AUTO, GNC_HOW_DENOM_LCD);
-        }
-        else if (xaccAccountGetType(account) == ACCT_TYPE_LIABILITY)
-        {
-            totalliabilities = gnc_numeric_add(totalliabilities, value, GNC_DENOM_AUTO, GNC_HOW_DENOM_LCD);
+            value = gnc_pricedb_convert_balance_nearest_price_t64(
+                        pdb, value, currency, total_currency,
+                        gnc_budget_get_period_start_date(budget, period_num));
         }
+
+        if (neg)
+            total = gnc_numeric_sub(total, value, GNC_DENOM_AUTO,
+                                    GNC_HOW_DENOM_LCD);
         else
-        {
-            // Do nothing because this account is not of interest
-        }
+            total = gnc_numeric_add(total, value, GNC_DENOM_AUTO,
+                                    GNC_HOW_DENOM_LCD);
     }
 
-    // at this point we should have variables holding the values for assets, liabilities, expenses and incomes.
-
-    // Set the text to display, depending on which of the totals rows we are currently looking at
+    xaccSPrintAmount(amtbuff, total,
+                     gnc_commodity_print_info(total_currency,
+                                              period_num < 0 ? TRUE : FALSE));
+    g_object_set(cell, "foreground",
+                 gnc_numeric_negative_p(total) ? "red" : NULL, NULL);
 
-    if (row_type == TOTALS_TYPE_INCOME)
-    {
-        // FIXME: There must be a better way to get the GncAccountPrintInfo object than this. Would prefer to depreciate the tracking of top level accounts.
-        xaccSPrintAmount(amtbuff, totalincome,
-                         gnc_account_print_info(priv->income, FALSE));
-        g_object_set(cell, "foreground", NULL, NULL);
-    }
-    else if (row_type == TOTALS_TYPE_EXPENSES)
-    {
-        xaccSPrintAmount(amtbuff, totalexpenses,
-                         gnc_account_print_info(priv->expenses, FALSE));
-        g_object_set(cell, "foreground", NULL, NULL);
-    }
-    else if (row_type == TOTALS_TYPE_TRANSFERS)
-    {
-        xaccSPrintAmount(amtbuff, gnc_numeric_sub(totalassets, totalliabilities, GNC_DENOM_AUTO, GNC_HOW_DENOM_LCD),
-                         gnc_account_print_info(priv->assets, FALSE));
-        g_object_set(cell, "foreground", NULL, NULL);
-    }
-    else if (row_type == TOTALS_TYPE_TOTAL)
-    {
-        value = gnc_numeric_sub(totalincome, totalexpenses, GNC_DENOM_AUTO, GNC_HOW_DENOM_LCD);
-        value = gnc_numeric_sub(value, totalassets, GNC_DENOM_AUTO, GNC_HOW_DENOM_LCD);
-        value = gnc_numeric_add(value, totalliabilities, GNC_DENOM_AUTO, GNC_HOW_DENOM_LCD);
-        xaccSPrintAmount(amtbuff, value,
-                         gnc_account_print_info(priv->assets, FALSE));
-        if (gnc_numeric_negative_p(value))
-        {
-            g_object_set(cell, "foreground", "red", NULL);
-        }
-        else
-        {
-            g_object_set(cell, "foreground", NULL, NULL);
-        }
-    }
-    else
-    {
-        // if it reaches here then the row type was not set correctly
-        g_strlcpy(amtbuff, "error", sizeof(amtbuff));
-    }
     g_object_set(G_OBJECT(cell), "text", amtbuff, "xalign", 1.0, NULL);
 }
 

commit 52895eabd1996f9cf3693a813889dcb29a3e0ccd
Author: Adrian Panella <ianchi74 at outlook.com>
Date:   Wed May 15 21:50:36 2019 -0500

    Bug 679800 - Shortcut to allow population of all budgeting periods
    
    Add functionality to change at once the budget for all
    periods of selected accounts.
    It can :
    replace with a new value
    unset the budget
    add a value to current budget
    multiply current budget with value
    
    Solvese issue #679800 and a duplicates (#639404, #760634)

diff --git a/gnucash/gnome/gnc-plugin-page-budget.c b/gnucash/gnome/gnc-plugin-page-budget.c
index 8bb2283f9..d47ae121c 100644
--- a/gnucash/gnome/gnc-plugin-page-budget.c
+++ b/gnucash/gnome/gnc-plugin-page-budget.c
@@ -115,6 +115,8 @@ static void gnc_plugin_page_budget_cmd_view_options(
     GtkAction *action, GncPluginPageBudget *page);
 static void gnc_plugin_page_budget_cmd_estimate_budget(
     GtkAction *action, GncPluginPageBudget *page);
+static void gnc_plugin_page_budget_cmd_allperiods_budget(
+    GtkAction *action, GncPluginPageBudget *page);
 
 static GtkActionEntry gnc_plugin_page_budget_actions [] =
 {
@@ -151,6 +153,12 @@ static GtkActionEntry gnc_plugin_page_budget_actions [] =
         N_("Estimate a budget value for the selected accounts from past transactions"),
         G_CALLBACK (gnc_plugin_page_budget_cmd_estimate_budget)
     },
+    {
+        "AllPeriodsBudgetAction", "system-run", N_("All Periods"),
+        NULL,
+        N_("Edit budget for all periods for the selected accounts"),
+        G_CALLBACK (gnc_plugin_page_budget_cmd_allperiods_budget)
+    },
 
     /* View menu */
     {
@@ -179,9 +187,18 @@ static action_toolbar_labels toolbar_labels[] =
     { "DeleteBudgetAction",         N_("Delete") },
     { "OptionsBudgetAction",        N_("Options") },
     { "EstimateBudgetAction",       N_("Estimate") },
+    { "AllPeriodsBudgetAction",     N_("All Periods") },
     { NULL, NULL },
 };
 
+typedef enum allperiods_action 
+{
+    REPLACE,
+    ADD,
+    MULTIPLY,
+    UNSET
+} allperiods_action; 
+
 typedef struct GncPluginPageBudgetPrivate
 {
     GtkActionGroup *action_group;
@@ -205,6 +222,11 @@ typedef struct GncPluginPageBudgetPrivate
     Recurrence r;
     gint sigFigs;
     gboolean useAvg;
+
+    /* For the allPeriods value dialog */
+    gnc_numeric allValue;
+    allperiods_action action;
+
 } GncPluginPageBudgetPrivate;
 
 G_DEFINE_TYPE_WITH_PRIVATE(GncPluginPageBudget, gnc_plugin_page_budget, GNC_TYPE_PLUGIN_PAGE)
@@ -864,11 +886,13 @@ estimate_budget_helper(GtkTreeModel *model, GtkTreePath *path,
     if (priv->useAvg && num_periods)
     {
         num = xaccAccountGetBalanceChangeForPeriod(acct, 
-            recurrenceGetPeriodTime(&priv->r, 0, FALSE),
-            recurrenceGetPeriodTime(&priv->r, num_periods - 1, TRUE), TRUE);
+                recurrenceGetPeriodTime(&priv->r, 0, FALSE),
+                recurrenceGetPeriodTime(&priv->r, num_periods - 1, TRUE), TRUE);
         num = gnc_numeric_div(num, 
-            gnc_numeric_create(num_periods, 1), GNC_DENOM_AUTO,
-            GNC_HOW_DENOM_SIGFIGS(priv->sigFigs) | GNC_HOW_RND_ROUND_HALF_UP);
+                              gnc_numeric_create(num_periods, 1), 
+                              GNC_DENOM_AUTO,
+                              GNC_HOW_DENOM_SIGFIGS(priv->sigFigs) | 
+                              GNC_HOW_RND_ROUND_HALF_UP);
 
         if (gnc_reverse_balance(acct))
             num = gnc_numeric_neg(num);
@@ -979,6 +1003,133 @@ gnc_plugin_page_budget_cmd_estimate_budget(GtkAction *action,
     g_object_unref(G_OBJECT(builder));
 }
 
+static void
+allperiods_budget_helper(GtkTreeModel *model, GtkTreePath *path,
+                         GtkTreeIter *iter, gpointer data)
+{
+    Account *acct;
+    guint num_periods, i;
+    gnc_numeric num;
+    GncPluginPageBudgetPrivate *priv;
+    GncPluginPageBudget *page = data;
+
+    g_return_if_fail(GNC_IS_PLUGIN_PAGE_BUDGET(page));
+    priv = GNC_PLUGIN_PAGE_BUDGET_GET_PRIVATE(page);
+    acct = gnc_budget_view_get_account_from_path(priv->budget_view, path);
+    num_periods = gnc_budget_get_num_periods(priv->budget);
+    num = priv->allValue;
+
+    for (i = 0; i < num_periods; i++)
+    {
+        switch (priv->action)
+        {
+        case ADD:
+            num = gnc_budget_get_account_period_value(priv->budget, acct, i);
+            num = gnc_numeric_add(num, priv->allValue, GNC_DENOM_AUTO,
+                                  GNC_HOW_DENOM_SIGFIGS(priv->sigFigs) |
+                                  GNC_HOW_RND_ROUND_HALF_UP);
+            gnc_budget_set_account_period_value(priv->budget, acct, i, num);
+            break;
+        case MULTIPLY:
+            num = gnc_budget_get_account_period_value(priv->budget, acct, i);
+            num = gnc_numeric_mul(num, priv->allValue, GNC_DENOM_AUTO,
+                                  GNC_HOW_DENOM_SIGFIGS(priv->sigFigs) |
+                                  GNC_HOW_RND_ROUND_HALF_UP);
+            gnc_budget_set_account_period_value(priv->budget, acct, i, num);
+            break;
+        case UNSET:
+            gnc_budget_unset_account_period_value(priv->budget, acct, i);
+            break;
+        default:
+            gnc_budget_set_account_period_value(priv->budget, acct, i,
+                                                priv->allValue);
+            break;
+        }
+    }
+}
+
+/*******************************/
+/*  All Periods Value Dialog   */
+/*******************************/
+static void
+gnc_plugin_page_budget_cmd_allperiods_budget(GtkAction *action,
+                                             GncPluginPageBudget *page)
+{
+    GncPluginPageBudgetPrivate *priv;
+    GtkTreeSelection *sel;
+    GtkWidget *dialog, *gde, *val, *dtr, *add, *mult;
+    gint result;
+    GtkBuilder *builder;
+    const gchar *txt;
+
+    g_return_if_fail(GNC_IS_PLUGIN_PAGE_BUDGET(page));
+    priv = GNC_PLUGIN_PAGE_BUDGET_GET_PRIVATE(page);
+    sel = gnc_budget_view_get_selection(priv->budget_view);
+
+    if (gtk_tree_selection_count_selected_rows(sel) <= 0)
+    {
+        dialog = gtk_message_dialog_new(
+                    GTK_WINDOW(gnc_plugin_page_get_window(GNC_PLUGIN_PAGE(page))),
+                    GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_MODAL,
+                    GTK_MESSAGE_INFO, GTK_BUTTONS_CLOSE, "%s",
+                    _("You must select at least one account to edit."));
+        gtk_dialog_run(GTK_DIALOG(dialog));
+        gtk_widget_destroy(dialog);
+        return;
+    }
+
+    builder = gtk_builder_new();
+    gnc_builder_add_from_file(builder, "gnc-plugin-page-budget.glade",
+                              "DigitsToRound_Adj");
+    gnc_builder_add_from_file(builder, "gnc-plugin-page-budget.glade",
+                              "budget_allperiods_dialog");
+
+    dialog = GTK_WIDGET(
+        gtk_builder_get_object(builder, "budget_allperiods_dialog"));
+
+    gtk_window_set_transient_for(
+        GTK_WINDOW(dialog),
+        GTK_WINDOW(gnc_plugin_page_get_window(GNC_PLUGIN_PAGE(page))));
+
+    val = GTK_WIDGET(gtk_builder_get_object(builder, "Value"));
+    gtk_entry_set_text(GTK_ENTRY(val), "");
+
+    dtr = GTK_WIDGET(gtk_builder_get_object(builder, "DigitsToRound1"));
+    gtk_spin_button_set_value(GTK_SPIN_BUTTON(dtr), (gdouble)priv->sigFigs);
+
+    add  = GTK_WIDGET(gtk_builder_get_object(builder, "RB_Add"));
+    mult = GTK_WIDGET(gtk_builder_get_object(builder, "RB_Multiply"));
+
+    gtk_widget_show_all(dialog);
+    result = gtk_dialog_run(GTK_DIALOG(dialog));
+    switch (result)
+    {
+    case GTK_RESPONSE_OK:
+
+        priv->sigFigs = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(dtr));
+        priv->action = REPLACE;
+        txt = gtk_entry_get_text(GTK_ENTRY(val));
+
+        if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(add)))
+            priv->action = ADD;
+        else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(mult)))
+            priv->action = MULTIPLY;
+
+        if (priv->action == REPLACE &&
+            !gtk_entry_get_text_length(GTK_ENTRY(val)))
+            priv->action = UNSET;
+
+        if (xaccParseAmount(txt, TRUE, &priv->allValue, NULL) ||
+            priv->action == UNSET)
+            gtk_tree_selection_selected_foreach(sel, allperiods_budget_helper,
+                                                page);
+        break;
+    default:
+        break;
+    }
+    gtk_widget_destroy(dialog);
+    g_object_unref(G_OBJECT(builder));
+}
 
 static void
 gnc_plugin_page_budget_cmd_view_filter_by (GtkAction *action,
diff --git a/gnucash/gtkbuilder/gnc-plugin-page-budget.glade b/gnucash/gtkbuilder/gnc-plugin-page-budget.glade
index 088d8b504..7f102b3dd 100644
--- a/gnucash/gtkbuilder/gnc-plugin-page-budget.glade
+++ b/gnucash/gtkbuilder/gnc-plugin-page-budget.glade
@@ -9,6 +9,244 @@
     <property name="step_increment">1</property>
     <property name="page_increment">1</property>
   </object>
+  <object class="GtkDialog" id="budget_allperiods_dialog">
+    <property name="can_focus">False</property>
+    <property name="border_width">5</property>
+    <property name="title" translatable="yes">Edit budget for all periods</property>
+    <property name="modal">True</property>
+    <property name="type_hint">dialog</property>
+    <child>
+      <placeholder/>
+    </child>
+    <child internal-child="vbox">
+      <object class="GtkBox">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="orientation">vertical</property>
+        <child internal-child="action_area">
+          <object class="GtkButtonBox">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="layout_style">end</property>
+            <child>
+              <object class="GtkButton" id="cancelbutton3">
+                <property name="label" translatable="yes">_Cancel</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="can_default">True</property>
+                <property name="receives_default">False</property>
+                <property name="use_underline">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkButton" id="okbutton3">
+                <property name="label" translatable="yes">_OK</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="can_default">True</property>
+                <property name="receives_default">False</property>
+                <property name="use_underline">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="pack_type">end</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkBox" id="vbox1">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="orientation">vertical</property>
+            <child>
+              <object class="GtkLabel" id="label1">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="halign">start</property>
+                <property name="valign">start</property>
+                <property name="label" translatable="yes">
+                  Use a fixed value or apply transformation for all periods.
+                </property>
+                <property name="wrap">True</property>
+                <property name="width_chars">40</property>
+                <property name="max_width_chars">40</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
+            <property name="position">2</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkGrid" id="table1">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <child>
+              <object class="GtkLabel" id="label3">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="halign">start</property>
+                <property name="label" translatable="yes">Value:</property>
+              </object>
+              <packing>
+                <property name="left_attach">0</property>
+                <property name="top_attach">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkEntry" id="Value">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="input_purpose">number</property>
+              </object>
+              <packing>
+                <property name="left_attach">1</property>
+                <property name="top_attach">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLabel">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="label" translatable="yes">Action</property>
+              </object>
+              <packing>
+                <property name="left_attach">0</property>
+                <property name="top_attach">2</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkBox">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="orientation">vertical</property>
+                <child>
+                  <object class="GtkRadioButton" id="RB_Replace">
+                    <property name="label" translatable="yes">Replace</property>
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">False</property>
+                    <property name="tooltip_text" translatable="yes">
+                      Replace the budget for all periods with new 'value'. Use empty value to unset budget for the accounts.
+                    </property>
+                    <property name="active">True</property>
+                    <property name="draw_indicator">True</property>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">True</property>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkRadioButton" id="RB_Add">
+                    <property name="label" translatable="yes">Add</property>
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">False</property>
+                    <property name="tooltip_text" translatable="yes">
+                      Add 'value' to current budget for each period
+                    </property>
+                    <property name="active">True</property>
+                    <property name="draw_indicator">True</property>
+                    <property name="group">RB_Replace</property>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">True</property>
+                    <property name="position">1</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkRadioButton" id="RB_Multiply">
+                    <property name="label" translatable="yes">Multiply</property>
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">False</property>
+                    <property name="tooltip_text" translatable="yes">
+                      Multiply current budget for each period by 'value'
+                    </property>
+                    <property name="active">True</property>
+                    <property name="draw_indicator">True</property>
+                    <property name="group">RB_Replace</property>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">True</property>
+                    <property name="position">2</property>
+                  </packing>
+                </child>
+              </object>
+              <packing>
+                <property name="left_attach">1</property>
+                <property name="top_attach">2</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkSpinButton" id="DigitsToRound1">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="tooltip_text" translatable="yes">The number of leading digits to keep when rounding</property>
+                <property name="hexpand">True</property>
+                <property name="text" translatable="yes">1</property>
+                <property name="primary_icon_activatable">False</property>
+                <property name="secondary_icon_activatable">False</property>
+                <property name="adjustment">DigitsToRound_Adj</property>
+                <property name="climb_rate">1</property>
+                <property name="numeric">True</property>
+                <property name="value">1</property>
+              </object>
+              <packing>
+                <property name="left_attach">1</property>
+                <property name="top_attach">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLabel" id="label2">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="halign">start</property>
+                <property name="label" translatable="yes">Significant Digits:</property>
+              </object>
+              <packing>
+                <property name="left_attach">0</property>
+                <property name="top_attach">1</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
+            <property name="position">3</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+    <action-widgets>
+      <action-widget response="-6">cancelbutton3</action-widget>
+      <action-widget response="-5">okbutton3</action-widget>
+    </action-widgets>
+  </object>
   <object class="GtkDialog" id="budget_estimate_dialog">
     <property name="can_focus">False</property>
     <property name="border_width">5</property>
diff --git a/gnucash/ui/gnc-plugin-page-budget-ui.xml b/gnucash/ui/gnc-plugin-page-budget-ui.xml
index 87fcceb11..9f45fe45a 100644
--- a/gnucash/ui/gnc-plugin-page-budget-ui.xml
+++ b/gnucash/ui/gnc-plugin-page-budget-ui.xml
@@ -3,6 +3,7 @@
     <menu name="Edit" action="EditAction">
       <placeholder name="EditSelectedPlaceholder">
         <menuitem name="Estimate" action="EstimateBudgetAction"/>
+        <menuitem name="AllPeriods" action="AllPeriodsBudgetAction"/>
         <menuitem name="Delete" action="DeleteBudgetAction"/>
       </placeholder>
       <menuitem name="Options" action="OptionsBudgetAction"/>
@@ -22,6 +23,7 @@
       <toolitem name="Options" action="OptionsBudgetAction"/>
       <separator name="ToolbarSep4"/>
       <toolitem name="Estimate" action="EstimateBudgetAction"/>
+      <toolitem name="AllPeriods" action="AllPeriodsBudgetAction"/>
       <toolitem name="Delete" action="DeleteBudgetAction"/>
     </placeholder>
   </toolbar>

commit b26276cba4229c399a38158bb877c6be1e66584f
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Fri May 17 23:05:56 2019 +0800

    Bug 797241 - Some reports skip transactions of the last day of the selected period
    
    portfolio.scm and advanced-portfolio.scm were not taking into account
    transactions dated on the report-date. expand query so that end-date
    is 23:59:59 rather than somewhere mid-day.

diff --git a/gnucash/report/standard-reports/advanced-portfolio.scm b/gnucash/report/standard-reports/advanced-portfolio.scm
index 44bd6293b..8e7bfc01e 100644
--- a/gnucash/report/standard-reports/advanced-portfolio.scm
+++ b/gnucash/report/standard-reports/advanced-portfolio.scm
@@ -997,8 +997,9 @@ by preventing negative stock balances.<br/>")
   ;; The first thing we do is make local variables for all the specific
   ;; options in the set of options given to the function. This set will
   ;; be generated by the options generator above.
-  (let ((to-date     (gnc:date-option-absolute-time
-                      (get-option gnc:pagename-general "Date")))
+  (let ((to-date     (gnc:time64-end-day-time
+                      (gnc:date-option-absolute-time
+                       (get-option gnc:pagename-general "Date"))))
         (accounts    (get-option gnc:pagename-accounts "Accounts"))
         (currency    (get-option gnc:pagename-general "Report's currency"))
         (price-source (get-option gnc:pagename-general
diff --git a/gnucash/report/standard-reports/portfolio.scm b/gnucash/report/standard-reports/portfolio.scm
index c4faa6872..95f1df272 100644
--- a/gnucash/report/standard-reports/portfolio.scm
+++ b/gnucash/report/standard-reports/portfolio.scm
@@ -170,8 +170,9 @@
   ;; The first thing we do is make local variables for all the specific
   ;; options in the set of options given to the function. This set will
   ;; be generated by the options generator above.
-  (let ((to-date     (gnc:date-option-absolute-time
-                      (get-option gnc:pagename-general "Date")))
+  (let ((to-date     (gnc:time64-end-day-time
+                      (gnc:date-option-absolute-time
+                       (get-option gnc:pagename-general "Date"))))
         (accounts    (get-option gnc:pagename-accounts "Accounts"))
         (currency    (get-option gnc:pagename-general "Report's currency"))
         (report-title (get-option gnc:pagename-general

commit 416b79d304f5efc8fdbffa393205e9a5eaccc461
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Fri May 17 10:56:56 2019 +0100

    Reformat source files gnc-accounting-period.*
    
    Change tabs to white space and some other white space changes.

diff --git a/libgnucash/app-utils/gnc-accounting-period.c b/libgnucash/app-utils/gnc-accounting-period.c
index 2c50aebbf..bdeb06610 100644
--- a/libgnucash/app-utils/gnc-accounting-period.c
+++ b/libgnucash/app-utils/gnc-accounting-period.c
@@ -50,14 +50,14 @@
 #include "gnc-ui-util.h"
 
 static time64 gnc_accounting_period_start_time64 (GncAccountingPeriod which,
-						   const GDate *fy_end,
-						   const GDate *contains);
+                                                  const GDate *fy_end,
+                                                  const GDate *contains);
 static time64 gnc_accounting_period_end_time64 (GncAccountingPeriod which,
-						 const GDate *fy_end,
-						 const GDate *contains);
+                                                const GDate *fy_end,
+                                                const GDate *contains);
 
 static time64
-lookup_start_date_option(GDate *fy_end)
+lookup_start_date_option (GDate *fy_end)
 {
     time64 time;
     int which;
@@ -67,8 +67,8 @@ lookup_start_date_option(GDate *fy_end)
                                         (GNC_PREFS_GROUP_ACCT_SUMMARY, GNC_PREF_START_DATE));
     else
     {
-        which = gnc_prefs_get_int(GNC_PREFS_GROUP_ACCT_SUMMARY, GNC_PREF_START_PERIOD);
-        time = gnc_accounting_period_start_time64(which, fy_end, NULL);
+        which = gnc_prefs_get_int (GNC_PREFS_GROUP_ACCT_SUMMARY, GNC_PREF_START_PERIOD);
+        time = gnc_accounting_period_start_time64 (which, fy_end, NULL);
     }
     /* we will need the balance of the last transaction before the start
        date, so subtract 1 from start date */
@@ -78,7 +78,7 @@ lookup_start_date_option(GDate *fy_end)
 }
 
 static time64
-lookup_end_date_option(GDate *fy_end)
+lookup_end_date_option (GDate *fy_end)
 {
     time64 time;
     int which;
@@ -88,8 +88,8 @@ lookup_end_date_option(GDate *fy_end)
                                       (GNC_PREFS_GROUP_ACCT_SUMMARY, GNC_PREF_END_DATE));
     else
     {
-        which = gnc_prefs_get_int(GNC_PREFS_GROUP_ACCT_SUMMARY, GNC_PREF_END_PERIOD);
-        time = gnc_accounting_period_end_time64(which, fy_end, NULL);
+        which = gnc_prefs_get_int (GNC_PREFS_GROUP_ACCT_SUMMARY, GNC_PREF_END_PERIOD);
+        time = gnc_accounting_period_end_time64 (which, fy_end, NULL);
     }
     if (time == 0)
         time = -1;
@@ -97,38 +97,36 @@ lookup_end_date_option(GDate *fy_end)
 }
 
 static GDate *
-get_fy_end(void)
+get_fy_end (void)
 {
     QofBook *book;
     GDate *date = NULL;
 
     book = gnc_get_current_book();
-    qof_instance_get (QOF_INSTANCE (book),
-		      "fy-end", &date,
-		      NULL);
+    qof_instance_get (QOF_INSTANCE (book), "fy-end", &date, NULL);
     return date;
 }
 
 time64
-gnc_accounting_period_fiscal_start(void)
+gnc_accounting_period_fiscal_start (void)
 {
     time64 t;
     GDate *fy_end = get_fy_end();
-    t = lookup_start_date_option(fy_end);
+    t = lookup_start_date_option (fy_end);
     if (fy_end)
-        g_date_free(fy_end);
+        g_date_free (fy_end);
     return t;
 }
 
 time64
-gnc_accounting_period_fiscal_end(void)
+gnc_accounting_period_fiscal_end (void)
 {
     time64 t;
     GDate *fy_end = get_fy_end();
 
-    t = lookup_end_date_option(fy_end);
+    t = lookup_end_date_option (fy_end);
     if (fy_end)
-        g_date_free(fy_end);
+        g_date_free (fy_end);
     return t;
 }
 
@@ -141,9 +139,9 @@ gnc_accounting_period_start_gdate (GncAccountingPeriod which,
 
     if (contains)
     {
-        date = g_date_new_dmy(g_date_get_day(contains),
-                              g_date_get_month(contains),
-                              g_date_get_year(contains));
+        date = g_date_new_dmy (g_date_get_day (contains),
+                               g_date_get_month (contains),
+                               g_date_get_year (contains));
     }
     else
     {
@@ -154,8 +152,8 @@ gnc_accounting_period_start_gdate (GncAccountingPeriod which,
     switch (which)
     {
     default:
-        g_message("Undefined relative time constant %d", which);
-        g_date_free(date);
+        g_message ("Undefined relative time constant %d", which);
+        g_date_free (date);
         return NULL;
 
     case GNC_ACCOUNTING_PERIOD_TODAY:
@@ -163,47 +161,47 @@ gnc_accounting_period_start_gdate (GncAccountingPeriod which,
         break;
 
     case GNC_ACCOUNTING_PERIOD_MONTH:
-        gnc_gdate_set_month_start(date);
+        gnc_gdate_set_month_start (date);
         break;
 
     case GNC_ACCOUNTING_PERIOD_MONTH_PREV:
-        gnc_gdate_set_prev_month_start(date);
+        gnc_gdate_set_prev_month_start (date);
         break;
 
     case GNC_ACCOUNTING_PERIOD_QUARTER:
-        gnc_gdate_set_quarter_start(date);
+        gnc_gdate_set_quarter_start (date);
         break;
 
     case GNC_ACCOUNTING_PERIOD_QUARTER_PREV:
-        gnc_gdate_set_prev_quarter_start(date);
+        gnc_gdate_set_prev_quarter_start (date);
         break;
 
     case GNC_ACCOUNTING_PERIOD_CYEAR:
-        gnc_gdate_set_year_start(date);
+        gnc_gdate_set_year_start (date);
         break;
 
     case GNC_ACCOUNTING_PERIOD_CYEAR_PREV:
-        gnc_gdate_set_prev_year_start(date);
+        gnc_gdate_set_prev_year_start (date);
         break;
 
     case GNC_ACCOUNTING_PERIOD_FYEAR:
         if (fy_end == NULL)
         {
-            g_message("Request for fisal year value but no fiscal year end value provided.");
-            g_date_free(date);
+            g_message ("Request for fisal year value but no fiscal year end value provided.");
+            g_date_free (date);
             return NULL;
         }
-        gnc_gdate_set_fiscal_year_start(date, fy_end);
+        gnc_gdate_set_fiscal_year_start (date, fy_end);
         break;
 
     case GNC_ACCOUNTING_PERIOD_FYEAR_PREV:
         if (fy_end == NULL)
         {
-            g_message("Request for fisal year value but no fiscal year end value provided.");
-            g_date_free(date);
+            g_message ("Request for fisal year value but no fiscal year end value provided.");
+            g_date_free (date);
             return NULL;
         }
-        gnc_gdate_set_prev_fiscal_year_start(date, fy_end);
+        gnc_gdate_set_prev_fiscal_year_start (date, fy_end);
         break;
     }
     return date;
@@ -211,18 +209,18 @@ gnc_accounting_period_start_gdate (GncAccountingPeriod which,
 
 static time64
 gnc_accounting_period_start_time64 (GncAccountingPeriod which,
-                                   const GDate *fy_end,
-                                   const GDate *contains)
+                                    const GDate *fy_end,
+                                    const GDate *contains)
 {
     GDate *date;
     time64 secs;
 
-    date = gnc_accounting_period_start_gdate(which, fy_end, contains);
+    date = gnc_accounting_period_start_gdate (which, fy_end, contains);
     if (!date)
         return 0;
 
-    secs = gnc_time64_get_day_start_gdate(date);
-    g_date_free(date);
+    secs = gnc_time64_get_day_start_gdate (date);
+    g_date_free (date);
     return secs;
 }
 
@@ -235,9 +233,9 @@ gnc_accounting_period_end_gdate (GncAccountingPeriod which,
 
     if (contains)
     {
-        date = g_date_new_dmy(g_date_get_day(contains),
-                              g_date_get_month(contains),
-                              g_date_get_year(contains));
+        date = g_date_new_dmy (g_date_get_day (contains),
+                               g_date_get_month (contains),
+                               g_date_get_year (contains));
     }
     else
     {
@@ -248,8 +246,8 @@ gnc_accounting_period_end_gdate (GncAccountingPeriod which,
     switch (which)
     {
     default:
-        g_message("Undefined relative time constant %d", which);
-        g_date_free(date);
+        g_message ("Undefined relative time constant %d", which);
+        g_date_free (date);
         return 0;
 
     case GNC_ACCOUNTING_PERIOD_TODAY:
@@ -257,47 +255,47 @@ gnc_accounting_period_end_gdate (GncAccountingPeriod which,
         break;
 
     case GNC_ACCOUNTING_PERIOD_MONTH:
-        gnc_gdate_set_month_end(date);
+        gnc_gdate_set_month_end (date);
         break;
 
     case GNC_ACCOUNTING_PERIOD_MONTH_PREV:
-        gnc_gdate_set_prev_month_end(date);
+        gnc_gdate_set_prev_month_end (date);
         break;
 
     case GNC_ACCOUNTING_PERIOD_QUARTER:
-        gnc_gdate_set_quarter_end(date);
+        gnc_gdate_set_quarter_end (date);
         break;
 
     case GNC_ACCOUNTING_PERIOD_QUARTER_PREV:
-        gnc_gdate_set_prev_quarter_end(date);
+        gnc_gdate_set_prev_quarter_end (date);
         break;
 
     case GNC_ACCOUNTING_PERIOD_CYEAR:
-        gnc_gdate_set_year_end(date);
+        gnc_gdate_set_year_end (date);
         break;
 
     case GNC_ACCOUNTING_PERIOD_CYEAR_PREV:
-        gnc_gdate_set_prev_year_end(date);
+        gnc_gdate_set_prev_year_end (date);
         break;
 
     case GNC_ACCOUNTING_PERIOD_FYEAR:
         if (fy_end == NULL)
         {
-            g_message("Request for fisal year value but no fiscal year end value provided.");
-            g_date_free(date);
+            g_message ("Request for fisal year value but no fiscal year end value provided.");
+            g_date_free (date);
             return 0;
         }
-        gnc_gdate_set_fiscal_year_end(date, fy_end);
+        gnc_gdate_set_fiscal_year_end (date, fy_end);
         break;
 
     case GNC_ACCOUNTING_PERIOD_FYEAR_PREV:
         if (fy_end == NULL)
         {
-            g_message("Request for fisal year value but no fiscal year end value provided.");
-            g_date_free(date);
+            g_message ("Request for fisal year value but no fiscal year end value provided.");
+            g_date_free (date);
             return 0;
         }
-        gnc_gdate_set_prev_fiscal_year_end(date, fy_end);
+        gnc_gdate_set_prev_fiscal_year_end (date, fy_end);
         break;
     }
 
@@ -306,18 +304,18 @@ gnc_accounting_period_end_gdate (GncAccountingPeriod which,
 
 static time64
 gnc_accounting_period_end_time64 (GncAccountingPeriod which,
-                                 const GDate *fy_end,
-                                 const GDate *contains)
+                                  const GDate *fy_end,
+                                  const GDate *contains)
 {
     GDate *date;
     time64 secs;
 
-    date = gnc_accounting_period_end_gdate(which, fy_end, contains);
+    date = gnc_accounting_period_end_gdate (which, fy_end, contains);
     if (!date)
         return 0;
 
-    secs = gnc_time64_get_day_end_gdate(date);
-    g_date_free(date);
+    secs = gnc_time64_get_day_end_gdate (date);
+    g_date_free (date);
     return secs ;
 }
 
diff --git a/libgnucash/app-utils/gnc-accounting-period.h b/libgnucash/app-utils/gnc-accounting-period.h
index 7c7649ef8..835d03b9c 100644
--- a/libgnucash/app-utils/gnc-accounting-period.h
+++ b/libgnucash/app-utils/gnc-accounting-period.h
@@ -92,8 +92,9 @@ typedef enum
  *  @return The starting day of the specified time interval, as a
  *  GDate. */
 GDate *gnc_accounting_period_start_gdate (GncAccountingPeriod which,
-        const GDate *fy_end,
-        const GDate *contains);
+                                          const GDate *fy_end,
+                                          const GDate *contains);
+
 /** This function returns the ending date for an accounting period.
  *  The date will be computed based upon the type of accounting
  *  interval requested, an optional fiscal year end value, and an
@@ -119,8 +120,8 @@ GDate *gnc_accounting_period_end_gdate (GncAccountingPeriod which,
 
 /* Get the fiscal accounting period from the preferences and return
    the start and end times. */
-time64 gnc_accounting_period_fiscal_start(void);
-time64 gnc_accounting_period_fiscal_end(void);
+time64 gnc_accounting_period_fiscal_start (void);
+time64 gnc_accounting_period_fiscal_end (void);
 
 /** @} */
 

commit 037f5ed5be12549330e71ffd9a61b90a5cf7f759
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Fri May 17 10:39:53 2019 +0100

    Bug 797089 - Wrong time for accounting period end date
    
    In the Preferences/Accounting Period, there is an option to specify
    absolute dates but the end date was being set to start of day instead
    of end of day, changed this.

diff --git a/libgnucash/app-utils/gnc-accounting-period.c b/libgnucash/app-utils/gnc-accounting-period.c
index eb6d2d915..2c50aebbf 100644
--- a/libgnucash/app-utils/gnc-accounting-period.c
+++ b/libgnucash/app-utils/gnc-accounting-period.c
@@ -63,7 +63,8 @@ lookup_start_date_option(GDate *fy_end)
     int which;
 
     if (gnc_prefs_get_bool (GNC_PREFS_GROUP_ACCT_SUMMARY, GNC_PREF_START_CHOICE_ABS))
-        time = gnc_prefs_get_int64 (GNC_PREFS_GROUP_ACCT_SUMMARY, GNC_PREF_START_DATE);
+        time = gnc_time64_get_day_start (gnc_prefs_get_int64
+                                        (GNC_PREFS_GROUP_ACCT_SUMMARY, GNC_PREF_START_DATE));
     else
     {
         which = gnc_prefs_get_int(GNC_PREFS_GROUP_ACCT_SUMMARY, GNC_PREF_START_PERIOD);
@@ -83,7 +84,8 @@ lookup_end_date_option(GDate *fy_end)
     int which;
 
     if (gnc_prefs_get_bool (GNC_PREFS_GROUP_ACCT_SUMMARY, GNC_PREF_END_CHOICE_ABS))
-        time = gnc_prefs_get_int64 (GNC_PREFS_GROUP_ACCT_SUMMARY, GNC_PREF_END_DATE);
+        time = gnc_time64_get_day_end (gnc_prefs_get_int64
+                                      (GNC_PREFS_GROUP_ACCT_SUMMARY, GNC_PREF_END_DATE));
     else
     {
         which = gnc_prefs_get_int(GNC_PREFS_GROUP_ACCT_SUMMARY, GNC_PREF_END_PERIOD);

commit 5ad3cd0d607f20d3e5d2c8d85d20120018eb67cc
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Wed May 15 17:55:09 2019 +0100

    Deleting TaxTable entries can crash application
    
    Change the switch statement to include GNC_AMT_TYPE_VALUE to return a
    value for row_text[1] and change default to set it to NULL

diff --git a/gnucash/gnome-utils/dialog-tax-table.c b/gnucash/gnome-utils/dialog-tax-table.c
index 7e9d204d9..16971e330 100644
--- a/gnucash/gnome-utils/dialog-tax-table.c
+++ b/gnucash/gnome-utils/dialog-tax-table.c
@@ -377,12 +377,15 @@ tax_table_entries_refresh (TaxTableWindow *ttw)
                                  xaccPrintAmount (amount,
                                                   gnc_default_print_info (FALSE)));
             break;
-        default:
+        case GNC_AMT_TYPE_VALUE:
             row_text[1] =
                 g_strdup_printf ("%s",
                                  xaccPrintAmount (amount,
                                                   gnc_default_print_info (TRUE)));
             break;
+         default:
+             row_text[1] = NULL;
+             break;
         }
 
         gtk_list_store_prepend(store, &iter);

commit fade13f81368e56d3484676450c09f30ee60fa7a
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Wed May 15 16:09:27 2019 +0100

    Setup some default sorting for the TaxTable entries

diff --git a/gnucash/gnome-utils/dialog-tax-table.c b/gnucash/gnome-utils/dialog-tax-table.c
index 833c26846..7e9d204d9 100644
--- a/gnucash/gnome-utils/dialog-tax-table.c
+++ b/gnucash/gnome-utils/dialog-tax-table.c
@@ -730,11 +730,18 @@ gnc_ui_tax_table_window_new (GtkWindow *parent, QofBook *book)
     gtk_tree_view_set_model(view, GTK_TREE_MODEL(store));
     g_object_unref(store);
 
+    /* default sort order */
+    gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE(store),
+                                          TAX_TABLE_COL_NAME,
+                                          GTK_SORT_ASCENDING);
+
     renderer = gtk_cell_renderer_text_new();
     column = gtk_tree_view_column_new_with_attributes("", renderer,
              "text", TAX_TABLE_COL_NAME,
              NULL);
+    g_object_set (G_OBJECT(column), "reorderable", TRUE, NULL);
     gtk_tree_view_append_column(view, column);
+    gtk_tree_view_column_set_sort_column_id (column, TAX_TABLE_COL_NAME);
 
     selection = gtk_tree_view_get_selection(view);
     g_signal_connect(selection, "changed",
@@ -747,11 +754,18 @@ gnc_ui_tax_table_window_new (GtkWindow *parent, QofBook *book)
     gtk_tree_view_set_model(view, GTK_TREE_MODEL(store));
     g_object_unref(store);
 
+    /* default sort order */
+    gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE(store),
+                                          TAX_ENTRY_COL_NAME,
+                                          GTK_SORT_ASCENDING);
+
     renderer = gtk_cell_renderer_text_new();
     column = gtk_tree_view_column_new_with_attributes("", renderer,
              "text", TAX_ENTRY_COL_NAME,
              NULL);
+    g_object_set (G_OBJECT(column), "reorderable", TRUE, NULL);
     gtk_tree_view_append_column(view, column);
+    gtk_tree_view_column_set_sort_column_id (column, TAX_ENTRY_COL_NAME);
 
     selection = gtk_tree_view_get_selection(view);
     g_signal_connect(selection, "changed",

commit 36574f08fb1ed9543de84cb481e0799b0ad7515c
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Wed May 15 16:08:53 2019 +0100

    After editing the TaxTables the selection has moved

diff --git a/gnucash/gnome-utils/dialog-tax-table.c b/gnucash/gnome-utils/dialog-tax-table.c
index 67e607535..833c26846 100644
--- a/gnucash/gnome-utils/dialog-tax-table.c
+++ b/gnucash/gnome-utils/dialog-tax-table.c
@@ -426,6 +426,7 @@ tax_table_window_refresh (TaxTableWindow *ttw)
     GtkTreePath *path;
     GtkTreeSelection *selection;
     GtkTreeRowReference *reference = NULL;
+    GncTaxTable *saved_current_table = ttw->current_table;
 
     g_return_if_fail (ttw);
     view = GTK_TREE_VIEW (ttw->names_view);
@@ -454,7 +455,8 @@ tax_table_window_refresh (TaxTableWindow *ttw)
                            TAX_TABLE_COL_NAME, gncTaxTableGetName (table),
                            TAX_TABLE_COL_POINTER, table,
                            -1);
-        if (table == ttw->current_table)
+
+        if (table == saved_current_table)
         {
             path = gtk_tree_model_get_path(GTK_TREE_MODEL(store), &iter);
             reference = gtk_tree_row_reference_new(GTK_TREE_MODEL(store), path);

commit e3fb593edc9e86ac9ed60803694ddf682e5264fb
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Fri May 17 11:11:30 2019 +0800

    Bug 797240 - Multicolumn report not showing each report name
    
    reportname was not correctly applied as the chart-title

diff --git a/gnucash/report/standard-reports/balance-forecast.scm b/gnucash/report/standard-reports/balance-forecast.scm
index 581c0ee98..2462c751a 100644
--- a/gnucash/report/standard-reports/balance-forecast.scm
+++ b/gnucash/report/standard-reports/balance-forecast.scm
@@ -32,7 +32,7 @@
 (gnc:module-load "gnucash/report/report-system" 0)
 
 ; Name definitions
-(define report-title         (N_ "Balance Forecast"))
+(define reportname           (N_ "Balance Forecast"))
 
 (define optname-accounts     (N_ "Accounts"))
 (define opthelp-accounts     (_ "Report on these accounts."))
@@ -133,6 +133,8 @@ date point, a projected minimum balance including scheduled transactions."))
   (define (get-option pagename optname)
     (gnc:option-value
       (gnc:lookup-option (gnc:report-options report-obj) pagename optname)))
+  (define report-title
+    (get-option gnc:pagename-general gnc:optname-reportname))
 
   (gnc:report-starting report-title)
 
@@ -282,7 +284,7 @@ date point, a projected minimum balance including scheduled transactions."))
 
 (gnc:define-report
   'version 1
-  'name report-title
+  'name reportname
   'report-guid "321d940d487d4ccbb4bd0467ffbadbf2"
   'menu-path (list gnc:menuname-asset-liability)
   'options-generator options-generator

commit 93bf1a0f23913fb9c88e29470c782e3aac4de92b
Author: Adrian Panella <ianchi74 at outlook.com>
Date:   Sat May 4 20:47:52 2019 -0500

    Bug 646361 - Estimate budget option to have same amount in each budget period
    
    If set, all periods get the same budget, from the average
    of the reference period.

diff --git a/gnucash/gnome/gnc-plugin-page-budget.c b/gnucash/gnome/gnc-plugin-page-budget.c
index ccddfd306..8bb2283f9 100644
--- a/gnucash/gnome/gnc-plugin-page-budget.c
+++ b/gnucash/gnome/gnc-plugin-page-budget.c
@@ -204,6 +204,7 @@ typedef struct GncPluginPageBudgetPrivate
     /* For the estimation dialog */
     Recurrence r;
     gint sigFigs;
+    gboolean useAvg;
 } GncPluginPageBudgetPrivate;
 
 G_DEFINE_TYPE_WITH_PRIVATE(GncPluginPageBudget, gnc_plugin_page_budget, GNC_TYPE_PLUGIN_PAGE)
@@ -309,6 +310,7 @@ gnc_plugin_page_budget_init (GncPluginPageBudget *plugin_page)
     priv->fd.filter_override = g_hash_table_new (g_direct_hash, g_direct_equal);
 
     priv->sigFigs = 1;
+    priv->useAvg = FALSE;
     recurrenceSet(&priv->r, 1, PERIOD_MONTH, NULL, WEEKEND_ADJ_NONE);
 
     LEAVE("page %p, priv %p, action group %p",
@@ -859,19 +861,38 @@ estimate_budget_helper(GtkTreeModel *model, GtkTreePath *path,
 
     num_periods = gnc_budget_get_num_periods(priv->budget);
 
-    for (i = 0; i < num_periods; i++)
+    if (priv->useAvg && num_periods)
     {
-        num = recurrenceGetAccountPeriodValue(&priv->r, acct, i);
-        if (!gnc_numeric_check(num))
-        {
-            if (gnc_reverse_balance (acct))
-                num = gnc_numeric_neg (num);
+        num = xaccAccountGetBalanceChangeForPeriod(acct, 
+            recurrenceGetPeriodTime(&priv->r, 0, FALSE),
+            recurrenceGetPeriodTime(&priv->r, num_periods - 1, TRUE), TRUE);
+        num = gnc_numeric_div(num, 
+            gnc_numeric_create(num_periods, 1), GNC_DENOM_AUTO,
+            GNC_HOW_DENOM_SIGFIGS(priv->sigFigs) | GNC_HOW_RND_ROUND_HALF_UP);
 
+        if (gnc_reverse_balance(acct))
+            num = gnc_numeric_neg(num);
 
-            num = gnc_numeric_convert(num, GNC_DENOM_AUTO,
-                                      GNC_HOW_DENOM_SIGFIGS(priv->sigFigs) | GNC_HOW_RND_ROUND_HALF_UP);
-            gnc_budget_set_account_period_value(
-                priv->budget, acct, i, num);
+        for (i = 0; i < num_periods; i++)
+        {
+            gnc_budget_set_account_period_value(priv->budget, acct, i, num);
+        }
+    }
+    else
+    {
+        for (i = 0; i < num_periods; i++)
+        {
+            num = recurrenceGetAccountPeriodValue(&priv->r, acct, i);
+            if (!gnc_numeric_check(num))
+            {
+                if (gnc_reverse_balance(acct))
+                    num = gnc_numeric_neg(num);
+
+                num = gnc_numeric_convert(num, GNC_DENOM_AUTO,
+                                          GNC_HOW_DENOM_SIGFIGS(priv->sigFigs) |
+                                          GNC_HOW_RND_ROUND_HALF_UP);
+                gnc_budget_set_account_period_value(priv->budget, acct, i, num);
+            }
         }
     }
 }
@@ -886,7 +907,7 @@ gnc_plugin_page_budget_cmd_estimate_budget(GtkAction *action,
 {
     GncPluginPageBudgetPrivate *priv;
     GtkTreeSelection *sel;
-    GtkWidget *dialog, *gde, *dtr, *hb;
+    GtkWidget *dialog, *gde, *dtr, *hb, *avg;
     gint result;
     GDate date;
     const Recurrence *r;
@@ -930,6 +951,9 @@ gnc_plugin_page_budget_cmd_estimate_budget(GtkAction *action,
     gtk_spin_button_set_value(GTK_SPIN_BUTTON(dtr),
                               (gdouble)priv->sigFigs);
 
+    avg = GTK_WIDGET(gtk_builder_get_object(builder, "UseAverage"));
+    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(avg), priv->useAvg);
+
     gtk_widget_show_all (dialog);
     result = gtk_dialog_run(GTK_DIALOG(dialog));
     switch (result)
@@ -944,6 +968,8 @@ gnc_plugin_page_budget_cmd_estimate_budget(GtkAction *action,
         priv->sigFigs =
             gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(dtr));
 
+        priv->useAvg = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(avg));
+        
         gtk_tree_selection_selected_foreach(sel, estimate_budget_helper, page);
         break;
     default:
diff --git a/gnucash/gtkbuilder/gnc-plugin-page-budget.glade b/gnucash/gtkbuilder/gnc-plugin-page-budget.glade
index da3c11e75..088d8b504 100644
--- a/gnucash/gtkbuilder/gnc-plugin-page-budget.glade
+++ b/gnucash/gtkbuilder/gnc-plugin-page-budget.glade
@@ -151,6 +151,22 @@
                 <property name="top_attach">0</property>
               </packing>
             </child>
+            <child>
+              <object class="GtkCheckButton" id="UseAverage">
+                <property name="label" translatable="yes">Use Average</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">False</property>
+                <property name="tooltip_text" translatable="yes">
+                  Use the average value over all actual periods for all projected periods
+                </property>
+                <property name="draw_indicator">True</property>
+              </object>
+              <packing>
+                <property name="left_attach">1</property>
+                <property name="top_attach">2</property>
+              </packing>
+            </child>
           </object>
           <packing>
             <property name="expand">False</property>



Summary of changes:
 CMakeLists.txt                                     |  57 ++--
 common/cmake_modules/CMakeLists.txt                |   2 +-
 common/cmake_modules/GncAddGSchemaTargets.cmake    |   6 +-
 common/cmake_modules/GncAddSchemeTargets.cmake     |   6 +-
 common/cmake_modules/GncAddTest.cmake              |  12 +-
 common/cmake_modules/GncFindPkgConfig.cmake        | 256 --------------
 common/cmake_modules/MakeDist.cmake                |   9 +-
 common/cmake_modules/MakeDistCheck.cmake           |  13 +-
 gnucash/gnome-utils/dialog-tax-table.c             | 113 +++++-
 gnucash/gnome/CMakeLists.txt                       |  10 +-
 gnucash/gnome/gnc-budget-view.c                    | 380 +++++++++++++--------
 gnucash/gnome/gnc-plugin-budget.c                  |   7 +
 gnucash/gnome/gnc-plugin-page-budget.c             | 199 ++++++++++-
 gnucash/gschemas/CMakeLists.txt                    |   6 +-
 gnucash/gtkbuilder/dialog-tax-table.glade          |  19 +-
 gnucash/gtkbuilder/gnc-plugin-page-budget.glade    | 254 ++++++++++++++
 gnucash/report/reports/aging.scm                   |   4 +-
 .../report/reports/standard/advanced-portfolio.scm |   5 +-
 .../report/reports/standard/balance-forecast.scm   |   6 +-
 gnucash/report/reports/standard/balsheet-pnl.scm   |   8 +
 gnucash/report/reports/standard/portfolio.scm      |   5 +-
 gnucash/ui/gnc-plugin-page-budget-ui.xml           |   2 +
 libgnucash/app-utils/gnc-accounting-period.c       | 132 +++----
 libgnucash/app-utils/gnc-accounting-period.h       |   9 +-
 libgnucash/backend/xml/test/CMakeLists.txt         |   7 +-
 libgnucash/doc/design/CMakeLists.txt               |  19 +-
 libgnucash/engine/qofbook.cpp                      |   6 +-
 libgnucash/quotes/CMakeLists.txt                   |   8 +-
 po/CMakeLists.txt                                  |   7 +-
 29 files changed, 967 insertions(+), 600 deletions(-)
 delete mode 100644 common/cmake_modules/GncFindPkgConfig.cmake



More information about the gnucash-changes mailing list