gnucash master: Multiple changes pushed
Geert Janssens
gjanssens at code.gnucash.org
Sat Feb 8 08:32:55 EST 2020
Updated via https://github.com/Gnucash/gnucash/commit/69df81e7 (commit)
via https://github.com/Gnucash/gnucash/commit/1ccea05b (commit)
via https://github.com/Gnucash/gnucash/commit/cce69e37 (commit)
via https://github.com/Gnucash/gnucash/commit/8243496e (commit)
via https://github.com/Gnucash/gnucash/commit/f27cbd4a (commit)
via https://github.com/Gnucash/gnucash/commit/e90e9cbd (commit)
via https://github.com/Gnucash/gnucash/commit/9a90e970 (commit)
from https://github.com/Gnucash/gnucash/commit/2d907ff4 (commit)
commit 69df81e7efe11dfde121b9f362cbfff345ca12de
Merge: 2d907ff49 1ccea05b6
Author: Geert Janssens <geert at kobaltwit.be>
Date: Sat Feb 8 14:13:17 2020 +0100
Merge branch 'maint'
- gettext minimum required version on master becomes 0.19.6
- simplify gettext detection code and appdata/desktop file creation
based on this new minimum
- fix merge conflict for new test-new-owner-report
- update deprecated scheme modules for test-new-owner-report
diff --cc CMakeLists.txt
index e4103965c,fe7a38b8b..54c41aac1
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@@ -239,7 -268,29 +239,19 @@@ find_path (REGEX_INCLUDE_PATH NAMES reg
find_library (REGEX_LIBRARY NAMES regex)
# I18N
+ # Potfile generation will only be enabled if building from a git worktree
+ set (BUILD_GNUCASH_POT ${BUILDING_FROM_VCS})
-set (TRANSLATE_GNUCASH_APPDATA ON)
-set (TRANSLATE_GNUCASH_DESKTOP ON)
+
-find_package (Gettext 0.18.1 REQUIRED)
+find_package (Gettext 0.19.6 REQUIRED)
+ if (${GETTEXT_VERSION_STRING} VERSION_LESS 0.20)
+ message (WARNING "Gettext version 0.20 or more recent is required to translate the 'developer_name' tag in gnucash.appdata.xml. All but that tag will be translated in the generated file.")
+ if(BUILD_GNUCASH_POT)
+ # Only emit warning if potfile generation was enabled otherwise
+ message (WARNING "Gettext version 0.20 or more recent is required to extract all translatable strings. Potfile generation will be disabled.")
+ endif()
+ set (BUILD_GNUCASH_POT OFF)
+ endif()
-if (${GETTEXT_VERSION_STRING} VERSION_LESS 0.19.6)
- set (TRANSLATE_GNUCASH_APPDATA OFF)
- message (WARNING "Gettext version 0.19.6 or more recent is required to translate gnucash.appdata.xml. The build will be configured to generate an untranslated gnucash.appdata.xml.")
-endif()
-if (${GETTEXT_VERSION_STRING} VERSION_LESS 0.19)
- set (TRANSLATE_GNUCASH_DESKTOP OFF)
- message (WARNING "Gettext version 0.19 or more recent is required to translate gnucash.desktop. The build will be configured to generate an untranslated gnucash.desktop.")
-endif()
+
find_path (LIBINTL_INCLUDE_PATH NAMES libintl.h
PATHS /usr/include /opt/gnome/include)
find_library (LIBINTL_LIBRARY NAMES intl)
diff --cc gnucash/gnome/CMakeLists.txt
index 8997ce11a,9fd607d2e..62a66637f
--- a/gnucash/gnome/CMakeLists.txt
+++ b/gnucash/gnome/CMakeLists.txt
@@@ -177,25 -153,43 +177,32 @@@ install(TARGETS gnc-gnom
# No headers to install
- add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/gnucash.appdata.xml.in
- DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/gnucash.appdata.xml.in.in ${VCS_INFO_FILE}
- COMMAND ${CMAKE_COMMAND} -D SRC=${CMAKE_CURRENT_SOURCE_DIR}/gnucash.appdata.xml.in.in
- -D DST=${CMAKE_CURRENT_BINARY_DIR}/gnucash.appdata.xml.in
+ set (GNC_APPDATA_IN ${CMAKE_CURRENT_BINARY_DIR}/gnucash.appdata.xml.in)
+ if (NOT BUILDING_FROM_VCS)
+ # We're building from a dist tarball.
+ # As a convenience to packagers we have included a pretranslated
+ # intermediate appdata file in the dist tarball.
+ set (GNC_APPDATA_IN ${CMAKE_CURRENT_SOURCE_DIR}/gnucash.appdata.xml.in)
-elseif (TRANSLATE_GNUCASH_APPDATA)
++else()
+ add_custom_command (
+ OUTPUT ${GNC_APPDATA_IN}
+ COMMAND ${CMAKE_COMMAND} -E env
+ ${GETTEXT_MSGFMT_EXECUTABLE}
+ --xml --template ${CMAKE_CURRENT_SOURCE_DIR}/gnucash.appdata.xml.in.in
+ -d ${CMAKE_SOURCE_DIR}/po
+ -o ${GNC_APPDATA_IN}
+ DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/gnucash.appdata.xml.in.in)
-else()
- # Gettext is too old to be able to merge a desktop file
- # and we're building from git.
- # Fall back to providing an unmerged (and hence untranslated) appdata file.
- # Note the build system won't allow generating a dist tarball in this scenario.
- add_custom_command (
- OUTPUT ${GNC_APPDATA_IN}
- COMMAND ${CMAKE_COMMAND} -E copy_if_different
- ${CMAKE_CURRENT_SOURCE_DIR}/gnucash.appdata.xml.in.in
- ${GNC_APPDATA_IN}
- DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/gnucash.appdata.xml.in.in)
+ endif()
+
+ add_custom_command(
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/gnucash.appdata.xml
+ DEPENDS ${GNC_APPDATA_IN} ${VCS_INFO_FILE}
+ COMMAND ${CMAKE_COMMAND} -D SRC=${GNC_APPDATA_IN}
+ -D DST=${CMAKE_CURRENT_BINARY_DIR}/gnucash.appdata.xml
-D VCS_INFO_FILE=${VCS_INFO_FILE}
+ -D PROJECT_VERSION=${PROJECT_VERSION}
-D SRC_DIR=${CMAKE_SOURCE_DIR}
- -P ${CMAKE_SOURCE_DIR}/cmake/configure-appdata.cmake)
-
- # FIXME: where does LC_ALL=C come from?
- add_custom_command (
- OUTPUT gnucash.appdata.xml
- COMMAND ${CMAKE_COMMAND} -E env
- LC_ALL=C
- ${GETTEXT_MSGFMT_EXECUTABLE}
- --xml --template ${CMAKE_CURRENT_BINARY_DIR}/gnucash.appdata.xml.in
- -d ${CMAKE_SOURCE_DIR}/po
- -o gnucash.appdata.xml
- DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/gnucash.appdata.xml.in ${VCS_INFO_FILE}
- )
+ -P ${CMAKE_SOURCE_DIR}/cmake/insert-vcs-data.cmake)
add_custom_target(gnucash-appdata ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/gnucash.appdata.xml)
@@@ -203,50 -197,49 +210,58 @@@ install(FILES ${CMAKE_CURRENT_BINARY_DI
#=======
- configure_file(gnucash.desktop.in.in gnucash.desktop.in)
-
+ set (GNC_DESKTOP_IN ${CMAKE_CURRENT_BINARY_DIR}/gnucash.desktop.in)
-if (NOT BUILDING_FROM_VCS)
- # We're building from a dist tarball.
- # As a convenience to packagers we have included a pretranslated
- # intermediate desktop file in the dist tarball.
- set (GNC_DESKTOP_IN ${CMAKE_CURRENT_SOURCE_DIR}/gnucash.desktop.in)
-elseif (TRANSLATE_GNUCASH_DESKTOP)
- add_custom_command (
- OUTPUT ${GNC_DESKTOP_IN}
- COMMAND ${CMAKE_COMMAND} -E env
- ${GETTEXT_MSGFMT_EXECUTABLE}
- --desktop --template ${CMAKE_CURRENT_SOURCE_DIR}/gnucash.desktop.in.in
- -d ${CMAKE_SOURCE_DIR}/po
- -o ${GNC_DESKTOP_IN}
- DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/gnucash.desktop.in.in)
-else()
- # Gettext is too old to be able to merge a desktop file
- # and we're building from git.
- # Fall back to providing an unmerged (and hence untranslated) desktop file.
- # Note the build system won't allow generating a dist tarball in this scenario.
- add_custom_command (
- OUTPUT ${GNC_DESKTOP_IN}
- COMMAND ${CMAKE_COMMAND} -E copy_if_different
- ${CMAKE_CURRENT_SOURCE_DIR}/gnucash.desktop.in.in
- ${GNC_DESKTOP_IN}
- DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/gnucash.desktop.in.in)
-endif()
+add_custom_command (
- OUTPUT gnucash.desktop
++ OUTPUT ${GNC_DESKTOP_IN}
+ COMMAND ${CMAKE_COMMAND} -E env
- LC_ALL=C
+ ${GETTEXT_MSGFMT_EXECUTABLE}
- --desktop --template gnucash.desktop.in
++ --desktop --template ${CMAKE_CURRENT_SOURCE_DIR}/gnucash.desktop.in.in
+ -d ${CMAKE_SOURCE_DIR}/po
- -o gnucash.desktop
- DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/gnucash.desktop.in
- )
++ -o ${GNC_DESKTOP_IN}
++ DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/gnucash.desktop.in.in)
+
+ add_custom_command (
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/gnucash.desktop
+ DEPENDS ${GNC_DESKTOP_IN} ${VCS_INFO_FILE}
+ COMMAND ${CMAKE_COMMAND} -D SRC=${GNC_DESKTOP_IN}
+ -D DST=${CMAKE_CURRENT_BINARY_DIR}/gnucash.desktop
+ -D VCS_INFO_FILE=${VCS_INFO_FILE}
+ -D PROJECT_VERSION=${PROJECT_VERSION}
+ -D SRC_DIR=${CMAKE_SOURCE_DIR}
+ -P ${CMAKE_SOURCE_DIR}/cmake/insert-vcs-data.cmake)
add_custom_target(gnucash-desktop ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/gnucash.desktop)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/gnucash.desktop DESTINATION ${CMAKE_INSTALL_DATADIR}/applications)
+# Scheme
+
+set(gnome_SCHEME
+ report-menus.scm
+)
+
+set(GUILE_OUTPUT_DIR gnucash)
+set(GUILE_DEPENDS
+ gncmod-gnome-utils
+ scm-engine
+ scm-core-utils
+ scm-gnome-utils
+ scm-gnc-module
+ scm-report
+ scm-reports
+)
+
+gnc_add_scheme_targets(scm-gnome
+"${gnome_SCHEME}"
+${GUILE_OUTPUT_DIR}
+"${GUILE_DEPENDS}"
+FALSE
+)
+
+# Module interfaces deprecated in 4.x, will be removed for 5.x
+gnc_add_scheme_deprecated_module ("gnucash report report-gnome" "gnucash report-menus" "scm-gnome" "")
+
set_dist_list(gnome_DIST
CMakeLists.txt gnome.i gnucash.appdata.xml.in.in gnucash.desktop.in.in
- ${gnc_gnome_noinst_HEADERS} ${gnc_gnome_SOURCES})
-dist_add_generated(${BUILDING_FROM_VCS} gnucash.appdata.xml.in gnucash.desktop.in)
+ ${gnc_gnome_noinst_HEADERS} ${gnc_gnome_SOURCES} ${gnome_SCHEME})
++dist_add_generated(${BUILDING_FROM_VCS} gnucash.appdata.xml.in)
diff --cc gnucash/report/reports/standard/test/CMakeLists.txt
index 3fa778120,7c2e6b7fc..2ac1394fd
--- a/gnucash/report/reports/standard/test/CMakeLists.txt
+++ b/gnucash/report/reports/standard/test/CMakeLists.txt
@@@ -17,8 -17,6 +17,9 @@@ set(scm_test_with_srfi64_SOURCE
test-trial-balance.scm
test-equity-statement.scm
test-average-balance.scm
+ test-invoice.scm
++ test-new-owner-report.scm
+ test-owner-report.scm
test-portfolios.scm
)
diff --cc gnucash/report/reports/standard/test/test-new-owner-report.scm
index 000000000,bbb15543b..2847272dc
mode 000000,100644..100644
--- a/gnucash/report/reports/standard/test/test-new-owner-report.scm
+++ b/gnucash/report/reports/standard/test/test-new-owner-report.scm
@@@ -1,0 -1,252 +1,253 @@@
-(use-modules (gnucash gnc-module))
-(gnc:module-begin-syntax (gnc:module-load "gnucash/app-utils" 0))
-(use-modules (gnucash engine test test-extras))
-(use-modules (gnucash report invoice))
-(use-modules (gnucash report stylesheets))
-(use-modules (gnucash report report-system))
-(use-modules (gnucash report report-system test test-extras))
++(use-modules (gnucash core-utils))
++(use-modules (gnucash app-utils))
++(use-modules (gnucash engine))
++(use-modules (tests test-engine-extras))
++(use-modules (gnucash reports standard invoice))
++(use-modules (gnucash report stylesheets plain)) ; For the default stylesheet, required for rendering
++(use-modules (gnucash report))
++(use-modules (tests test-report-extras))
+ (use-modules (srfi srfi-1))
+ (use-modules (srfi srfi-64))
-(use-modules (gnucash engine test srfi64-extras))
++(use-modules (tests srfi64-extras))
+ (use-modules (sxml simple))
+ (use-modules (sxml xpath))
+ (use-modules (system vm coverage))
+ (use-modules (system vm vm))
+
+ (define uuid "c146317be32e4948a561ec7fc89d15c1-new")
+
+ (setlocale LC_ALL "C")
+
+ (define (run-test)
+ (if #f
+ (coverage-test run-test-proper)
+ (run-test-proper)))
+
+ (define (coverage-test tester)
+ (let* ((currfile (dirname (current-filename)))
+ (path (string-take currfile (string-rindex currfile #\/))))
+ (add-to-load-path path))
+ (call-with-values
+ (lambda()
+ (with-code-coverage tester))
+ (lambda (data result)
+ (let ((port (open-output-file "/tmp/lcov.info")))
+ (coverage-data->lcov data port)
+ (close port)))))
+
+ (define (run-test-proper)
+ (let ((saved-format (qof-date-format-get)))
+ (qof-date-format-set QOF-DATE-FORMAT-ISO)
+ (test-runner-factory gnc:test-runner)
+ (test-begin "test-new-owner-report")
+ (owner-tests)
+ (qof-date-format-set saved-format)
+ (test-end "test-new-owner-report")))
+
+ (define (sxml-get-row-col sxml row col)
+ (sxml->table-row-col sxml 3 row col))
+
+ (define (set-option! options section name value)
+ (let ((option (gnc:lookup-option options section name)))
+ (if option
+ (gnc:option-set-value option value)
+ (test-assert (format #f "wrong-option ~a ~a" section name) #f))))
+
+ (define (get-currency sym)
+ (gnc-commodity-table-lookup
+ (gnc-commodity-table-get-table (gnc-get-current-book))
+ (gnc-commodity-get-namespace (gnc-default-report-currency))
+ sym))
+
+ (define structure
+ (list "Root" (list (cons 'type ACCT-TYPE-ASSET)
+ (cons 'commodity (get-currency "USD")))
+ (list "Asset"
+ (list "Bank-USD"))
+ (list "VAT"
+ (list "VAT-on-Purchases")
+ (list "VAT-on-Sales" (list (cons 'type ACCT-TYPE-LIABILITY))))
+ (list "Income" (list (cons 'type ACCT-TYPE-INCOME))
+ (list "Income-USD"))
+ (list "A/Receivable" (list (cons 'type ACCT-TYPE-RECEIVABLE))
+ (list "AR-USD"))
+ (list "A/Payable" (list (cons 'type ACCT-TYPE-PAYABLE))
+ (list "AP-USD"))))
+
+ (define (options->sxml options test-title)
+ (gnc:options->sxml uuid options "test-new-owner-report" test-title))
+
+ (define (owner-tests)
+ (let* ((env (create-test-env))
+ (account-alist (env-create-account-structure-alist env structure))
+ (get-acct (lambda (name)
+ (or (assoc-ref account-alist name)
+ (error "invalid account name" name))))
+ (AR (get-acct "AR-USD"))
+ (Bank (get-acct "Bank-USD"))
+ (YEAR (gnc:time64-get-year (gnc:get-today))))
+
+ (define owner-1
+ (let* ((cust-1 (gncCustomerCreate (gnc-get-current-book)))
+ (owner-1 (gncOwnerNew)))
+ (gncCustomerSetID cust-1 "cust-1-id")
+ (gncCustomerSetName cust-1 "cust-1-name")
+ (gncCustomerSetNotes cust-1 "cust-1-notes")
+ (gncCustomerSetCurrency cust-1 (get-currency "USD"))
+ (gncCustomerSetTaxIncluded cust-1 1)
+ (gncOwnerInitCustomer owner-1 cust-1)
+ owner-1))
+
+ ;; inv-1 is generated for a customer
+ (define inv-1
+ (let ((inv-1 (gncInvoiceCreate (gnc-get-current-book))))
+ (gncInvoiceSetOwner inv-1 owner-1)
+ (gncInvoiceSetNotes inv-1 "inv-1-notes")
+ (gncInvoiceSetBillingID inv-1 "inv-1-billing-id")
+ (gncInvoiceSetCurrency inv-1 (get-currency "USD"))
+ inv-1))
+
+ (define (make-entry amt)
+ (let ((entry (gncEntryCreate (gnc-get-current-book))))
+ (gncEntrySetDateGDate entry (time64-to-gdate (current-time)))
+ (gncEntrySetDescription entry "entry-desc")
+ (gncEntrySetAction entry "entry-action")
+ (gncEntrySetNotes entry "entry-notes")
+ (gncEntrySetInvAccount entry (get-acct "Income-USD"))
+ (gncEntrySetDocQuantity entry 1 #f)
+ (gncEntrySetInvPrice entry amt)
+ entry))
+
+ (define (add-invoice date amount desc)
+ (let ((inv (gncInvoiceCopy inv-1)))
+ (gncInvoiceAddEntry inv (make-entry amount))
+ (gncInvoicePostToAccount inv
+ (get-acct "AR-USD") ;post-to acc
+ date ;posted-date
+ date ;due-date
+ desc ;desc
+ #t ;acc-splits?
+ #f) ;autopay
+ inv))
+
+ (define (create-split-for-lot account amount lot)
+ (let ((split (xaccMallocSplit (gnc-get-current-book))))
+ (xaccSplitSetAccount split account)
+ (xaccSplitSetAmount split amount)
+ (xaccSplitSetValue split amount)
+ (xaccSplitSetAction split "")
+ (when lot
+ (gnc-lot-set-title lot "")
+ (gnc-lot-add-split lot split))
+ split))
+
+ (define (create-multisplit DD MM YY desc type splits)
+ (let* ((book (gnc-get-current-book))
+ (txn (xaccMallocTransaction book)))
+ (xaccTransBeginEdit txn)
+ (xaccTransSetDescription txn desc)
+ (xaccTransSetCurrency txn (xaccAccountGetCommodity
+ (xaccSplitGetAccount (car splits))))
+ (xaccTransSetDate txn DD MM YY)
+ (xaccTransSetTxnType txn type)
+ (for-each (lambda (s) (xaccSplitSetParent s txn)) splits)
+ (xaccTransCommitEdit txn)
+ txn))
+
+ (define (default-testing-options owner account)
+ ;; owner-report will run from 1.1.1980 to 1.7.1980
+ (let ((options (gnc:make-report-options uuid)))
+ (set-option! options "General" "Customer" owner)
+ (set-option! options "General" "From"
+ (cons 'absolute (gnc-dmy2time64 1 1 1980)))
+ (set-option! options "General" "To"
+ (cons 'absolute (gnc-dmy2time64 1 7 1980)))
+ (set-option! options "Display Columns" "Links" 'detailed)
+ options))
+
+ ;; inv $6.75
+ (add-invoice (gnc-dmy2time64 13 05 1980) 27/4 "$6.75")
+
+ ;; inv $11.50, 2 payments
+ (let ((inv (add-invoice (gnc-dmy2time64 13 01 1980) 23/2 "$11.50")))
+ (gncInvoiceApplyPayment inv '() Bank 3/2 1
+ (gnc-dmy2time64 18 03 1980)
+ "inv >90 payment" "pay only $1.50")
+
+ (gncInvoiceApplyPayment inv '() Bank 2 1
+ (gnc-dmy2time64 20 03 1980)
+ "inv >90 payment" "pay only $2.00"))
+
+ ;; CN $3.00
+ (let ((new-cn (add-invoice (gnc-dmy2time64 22 06 1980) -3 "CN")))
+ (gncInvoiceSetIsCreditNote new-cn #t))
+
+ ;; inv $11.50, 2 payments
+ (let* ((inv (add-invoice (gnc-dmy2time64 24 06 1980) 28 "$28.00"))
+ (CN (add-invoice (gnc-dmy2time64 25 06 1980) -27 "$27.00"))
+ (inv-lot (gncInvoiceGetPostedLot inv))
+ (CN-lot (gncInvoiceGetPostedLot CN)))
+ (gncInvoiceSetIsCreditNote CN #t)
+
+ (create-multisplit
+ 26 06 1980 "payment" TXN-TYPE-PAYMENT
+ (list (create-split-for-lot AR -1 inv-lot)
+ (create-split-for-lot Bank 1 #f)))
+
+ (create-multisplit
+ 26 06 1980 "payment" TXN-TYPE-LINK
+ (list (create-split-for-lot AR -27 inv-lot)
+ (create-split-for-lot AR 27 CN-lot))))
+
+ (display "new-owner-report tests:\n")
+ (test-begin "new-customer-report")
+ (let* ((options (default-testing-options owner-1 (get-acct "AR-USD")))
+ (sxml (options->sxml options "new-customer-report basic")))
+ (test-equal "line 1"
+ '("Customer History" "Linked Details" "1980-01-13" "1980-01-13"
+ "Invoice" "$11.50" "$11.50" "1980-03-18" "Payment" "inv >90 payment"
+ "$11.50" "pay only $1.50" "$1.50" "$1.50" "Pre-Payment" "Current"
+ "0-30 days" "31-60 days" "61-90 days" "91+ days" "Total" "$0.00"
+ "$0.00" "-$3.00" "$6.75" "$0.00" "$8.00" "$11.75")
+ ((sxpath `(// (table 3) // (tr 1) // *text*)) sxml))
+ (test-equal "line 2"
+ '("Date" "Due Date" "Reference" "Type" "Description" "Invoice"
+ "Payment" "Balance" "Date" "Reference" "Type" "Description"
+ "Partial Amount" "Amount" "1980-03-20" "Payment" "inv >90 payment"
+ "pay only $2.00" "$2.00" "$2.00")
+ ((sxpath `(// (table 3) // (tr 2) // *text*)) sxml))
+ (test-equal "line 3"
+ '("UNPAID" "$8.00")
+ ((sxpath `(// (table 3) // (tr 3) // *text*)) sxml))
+ (test-equal "line 4"
+ '("1980-03-18" "Payment" "inv >90 payment" "$10.00" "1980-01-13"
+ "Invoice" "inv >90 payment" "pay only $1.50" "$1.50" "$1.50" "$11.50")
+ ((sxpath `(// (table 3) // (tr 4) // *text*)) sxml))
+ (test-equal "line 5"
+ '("1980-03-20" "Payment" "inv >90 payment" "$8.00" "1980-01-13"
+ "Invoice" "inv >90 payment" "pay only $2.00" "$2.00" "$2.00" "$11.50")
+ ((sxpath `(// (table 3) // (tr 5) // *text*)) sxml))
+ (test-equal "line 6"
+ '("1980-05-13" "1980-05-13" "Invoice" "$6.75" "$14.75" "UNPAID"
+ "$6.75" "$6.75")
+ ((sxpath `(// (table 3) // (tr 6) // *text*)) sxml))
+ (test-equal "line 7"
+ '("1980-06-22" "1980-06-22" "Credit Note" "CN" "$11.75" "UNPAID"
+ "-$3.00" "$3.00")
+ ((sxpath `(// (table 3) // (tr 7) // *text*)) sxml))
+ (test-equal "line 8"
+ '("1980-06-24" "1980-06-24" "Invoice" "$28.00" "$39.75" "1980-06-26"
+ "Payment" "$28.00" "$1.00" "$1.00")
+ ((sxpath `(// (table 3) // (tr 8) // *text*)) sxml))
+ (test-equal "line 9"
+ ' ("1980-06-25" "Credit Note" "$27.00" "$27.00" "$27.00")
+ ((sxpath `(// (table 3) // (tr 9) // *text*)) sxml))
+ (test-equal "line 10"
+ '("1980-06-25" "1980-06-25" "Credit Note" "$27.00" "$12.75"
+ "1980-06-24" "Invoice" "$28.00" "$27.00" "$27.00" "$28.00")
+ ((sxpath `(// (table 3) // (tr 10) // *text*)) sxml))
+ (test-equal "line 11"
+ '("1980-06-26" "Payment" "$11.75" "1980-06-24" "Invoice" "$1.00"
+ "$1.00" "$28.00")
+ ((sxpath `(// (table 3) // (tr 11) // *text*)) sxml)))
+ (test-end "new-customer-report")))
commit 1ccea05b6e3bc8019af493c041318ae8bceef920
Author: Geert Janssens <geert at kobaltwit.be>
Date: Sat Feb 8 13:54:28 2020 +0100
CMake - drop LC_ALL=C for generation of appdata and desktop files
It doesn't seem to have any noticable effect.
diff --git a/gnucash/gnome/CMakeLists.txt b/gnucash/gnome/CMakeLists.txt
index 3a96d9169..9fd607d2e 100644
--- a/gnucash/gnome/CMakeLists.txt
+++ b/gnucash/gnome/CMakeLists.txt
@@ -160,11 +160,9 @@ if (NOT BUILDING_FROM_VCS)
# intermediate appdata file in the dist tarball.
set (GNC_APPDATA_IN ${CMAKE_CURRENT_SOURCE_DIR}/gnucash.appdata.xml.in)
elseif (TRANSLATE_GNUCASH_APPDATA)
- # FIXME: where does LC_ALL=C come from?
add_custom_command (
OUTPUT ${GNC_APPDATA_IN}
COMMAND ${CMAKE_COMMAND} -E env
- LC_ALL=C
${GETTEXT_MSGFMT_EXECUTABLE}
--xml --template ${CMAKE_CURRENT_SOURCE_DIR}/gnucash.appdata.xml.in.in
-d ${CMAKE_SOURCE_DIR}/po
@@ -209,7 +207,6 @@ elseif (TRANSLATE_GNUCASH_DESKTOP)
add_custom_command (
OUTPUT ${GNC_DESKTOP_IN}
COMMAND ${CMAKE_COMMAND} -E env
- LC_ALL=C
${GETTEXT_MSGFMT_EXECUTABLE}
--desktop --template ${CMAKE_CURRENT_SOURCE_DIR}/gnucash.desktop.in.in
-d ${CMAKE_SOURCE_DIR}/po
commit cce69e37d27d2a48e1bd4f2b9e0ed2d4ebaaeaf5
Author: Geert Janssens <geert at kobaltwit.be>
Date: Sat Feb 8 11:44:40 2020 +0100
Rework appdata and desktop file generation
- attempt to merge in translations before merging in version data
- add the intermediate file (with translations) to the dist tarball
- dist builds no longer have to run the translation merge, but can instead
use the included intermediate file. This accomodates distros with
older gettext versions.
diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt
index 453550802..a72d38f80 100644
--- a/cmake/CMakeLists.txt
+++ b/cmake/CMakeLists.txt
@@ -9,6 +9,6 @@ endif()
set_dist_list(cmake_DIST CMakeLists.txt README_CMAKE.txt cmake_uninstall.cmake.in
- configure-appdata.cmake configure-manpage.cmake git2version-info.cmake
+ insert-vcs-data.cmake configure-manpage.cmake git2version-info.cmake
version-info2env.cmake
)
diff --git a/cmake/configure-appdata.cmake b/cmake/insert-vcs-data.cmake
similarity index 96%
rename from cmake/configure-appdata.cmake
rename to cmake/insert-vcs-data.cmake
index 11cc7b765..2e0ce92ca 100644
--- a/cmake/configure-appdata.cmake
+++ b/cmake/insert-vcs-data.cmake
@@ -13,4 +13,4 @@
include (${SRC_DIR}/cmake/version-info2env.cmake)
versioninfo2env (${VCS_INFO_FILE})
-configure_file(${SRC} ${DST} )
+configure_file(${SRC} ${DST})
diff --git a/gnucash/gnome/CMakeLists.txt b/gnucash/gnome/CMakeLists.txt
index 7a05b38b0..3a96d9169 100644
--- a/gnucash/gnome/CMakeLists.txt
+++ b/gnucash/gnome/CMakeLists.txt
@@ -153,62 +153,91 @@ install(TARGETS gnc-gnome
# No headers to install
-add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/gnucash.appdata.xml.in
-DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/gnucash.appdata.xml.in.in ${VCS_INFO_FILE}
- COMMAND ${CMAKE_COMMAND} -D SRC=${CMAKE_CURRENT_SOURCE_DIR}/gnucash.appdata.xml.in.in
- -D DST=${CMAKE_CURRENT_BINARY_DIR}/gnucash.appdata.xml.in
- -D VCS_INFO_FILE=${VCS_INFO_FILE}
- -D SRC_DIR=${CMAKE_SOURCE_DIR}
- -P ${CMAKE_SOURCE_DIR}/cmake/configure-appdata.cmake)
-
-if (TRANSLATE_GNUCASH_APPDATA)
+set (GNC_APPDATA_IN ${CMAKE_CURRENT_BINARY_DIR}/gnucash.appdata.xml.in)
+if (NOT BUILDING_FROM_VCS)
+ # We're building from a dist tarball.
+ # As a convenience to packagers we have included a pretranslated
+ # intermediate appdata file in the dist tarball.
+ set (GNC_APPDATA_IN ${CMAKE_CURRENT_SOURCE_DIR}/gnucash.appdata.xml.in)
+elseif (TRANSLATE_GNUCASH_APPDATA)
# FIXME: where does LC_ALL=C come from?
add_custom_command (
- OUTPUT gnucash.appdata.xml
+ OUTPUT ${GNC_APPDATA_IN}
COMMAND ${CMAKE_COMMAND} -E env
LC_ALL=C
${GETTEXT_MSGFMT_EXECUTABLE}
- --xml --template ${CMAKE_CURRENT_BINARY_DIR}/gnucash.appdata.xml.in
+ --xml --template ${CMAKE_CURRENT_SOURCE_DIR}/gnucash.appdata.xml.in.in
-d ${CMAKE_SOURCE_DIR}/po
- -o gnucash.appdata.xml
- DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/gnucash.appdata.xml.in ${VCS_INFO_FILE})
+ -o ${GNC_APPDATA_IN}
+ DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/gnucash.appdata.xml.in.in)
else()
- # Gettext is too old to be able to merge an appdata file.
+ # Gettext is too old to be able to merge a desktop file
+ # and we're building from git.
# Fall back to providing an unmerged (and hence untranslated) appdata file.
+ # Note the build system won't allow generating a dist tarball in this scenario.
add_custom_command (
- OUTPUT gnucash.appdata.xml
+ OUTPUT ${GNC_APPDATA_IN}
COMMAND ${CMAKE_COMMAND} -E copy_if_different
- ${CMAKE_CURRENT_BINARY_DIR}/gnucash.appdata.xml.in
- ${CMAKE_CURRENT_BINARY_DIR}/gnucash.appdata.xml
-
- DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/gnucash.appdata.xml.in ${VCS_INFO_FILE})
+ ${CMAKE_CURRENT_SOURCE_DIR}/gnucash.appdata.xml.in.in
+ ${GNC_APPDATA_IN}
+ DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/gnucash.appdata.xml.in.in)
endif()
+add_custom_command(
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/gnucash.appdata.xml
+ DEPENDS ${GNC_APPDATA_IN} ${VCS_INFO_FILE}
+ COMMAND ${CMAKE_COMMAND} -D SRC=${GNC_APPDATA_IN}
+ -D DST=${CMAKE_CURRENT_BINARY_DIR}/gnucash.appdata.xml
+ -D VCS_INFO_FILE=${VCS_INFO_FILE}
+ -D PROJECT_VERSION=${PROJECT_VERSION}
+ -D SRC_DIR=${CMAKE_SOURCE_DIR}
+ -P ${CMAKE_SOURCE_DIR}/cmake/insert-vcs-data.cmake)
+
add_custom_target(gnucash-appdata ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/gnucash.appdata.xml)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/gnucash.appdata.xml DESTINATION ${CMAKE_INSTALL_DATADIR}/metainfo)
#=======
-configure_file(gnucash.desktop.in.in gnucash.desktop.in)
-
-if (TRANSLATE_GNUCASH_DESKTOP)
+set (GNC_DESKTOP_IN ${CMAKE_CURRENT_BINARY_DIR}/gnucash.desktop.in)
+if (NOT BUILDING_FROM_VCS)
+ # We're building from a dist tarball.
+ # As a convenience to packagers we have included a pretranslated
+ # intermediate desktop file in the dist tarball.
+ set (GNC_DESKTOP_IN ${CMAKE_CURRENT_SOURCE_DIR}/gnucash.desktop.in)
+elseif (TRANSLATE_GNUCASH_DESKTOP)
add_custom_command (
- OUTPUT gnucash.desktop
+ OUTPUT ${GNC_DESKTOP_IN}
COMMAND ${CMAKE_COMMAND} -E env
LC_ALL=C
${GETTEXT_MSGFMT_EXECUTABLE}
- --desktop --template gnucash.desktop.in
+ --desktop --template ${CMAKE_CURRENT_SOURCE_DIR}/gnucash.desktop.in.in
-d ${CMAKE_SOURCE_DIR}/po
- -o gnucash.desktop
- DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/gnucash.desktop.in)
+ -o ${GNC_DESKTOP_IN}
+ DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/gnucash.desktop.in.in)
else()
- # Gettext is too old to be able to merge a desktop file.
+ # Gettext is too old to be able to merge a desktop file
+ # and we're building from git.
# Fall back to providing an unmerged (and hence untranslated) desktop file.
- configure_file (${CMAKE_CURRENT_BINARY_DIR}/gnucash.desktop.in
- ${CMAKE_CURRENT_BINARY_DIR}/gnucash.desktop COPYONLY)
+ # Note the build system won't allow generating a dist tarball in this scenario.
+ add_custom_command (
+ OUTPUT ${GNC_DESKTOP_IN}
+ COMMAND ${CMAKE_COMMAND} -E copy_if_different
+ ${CMAKE_CURRENT_SOURCE_DIR}/gnucash.desktop.in.in
+ ${GNC_DESKTOP_IN}
+ DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/gnucash.desktop.in.in)
endif()
+add_custom_command (
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/gnucash.desktop
+ DEPENDS ${GNC_DESKTOP_IN} ${VCS_INFO_FILE}
+ COMMAND ${CMAKE_COMMAND} -D SRC=${GNC_DESKTOP_IN}
+ -D DST=${CMAKE_CURRENT_BINARY_DIR}/gnucash.desktop
+ -D VCS_INFO_FILE=${VCS_INFO_FILE}
+ -D PROJECT_VERSION=${PROJECT_VERSION}
+ -D SRC_DIR=${CMAKE_SOURCE_DIR}
+ -P ${CMAKE_SOURCE_DIR}/cmake/insert-vcs-data.cmake)
+
add_custom_target(gnucash-desktop ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/gnucash.desktop)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/gnucash.desktop DESTINATION ${CMAKE_INSTALL_DATADIR}/applications)
@@ -216,3 +245,4 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/gnucash.desktop DESTINATION ${CMAKE_I
set_dist_list(gnome_DIST
CMakeLists.txt gnome.i gnucash.appdata.xml.in.in gnucash.desktop.in.in
${gnc_gnome_noinst_HEADERS} ${gnc_gnome_SOURCES})
+dist_add_generated(${BUILDING_FROM_VCS} gnucash.appdata.xml.in gnucash.desktop.in)
commit 8243496ed0b3ea50d399422f0cc7ced713d2ea64
Author: Geert Janssens <geert at kobaltwit.be>
Date: Fri Feb 7 21:56:21 2020 +0100
Rework our gettext tests
- only abort configuration if gettext is older than 0.18.1 (required for string extraction from scheme files)
- otherwise always continue but disable a few other build steps depending on the gettext version
- use feature variables to more clearly convey what is enabled or disabled
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 07b71d945..fe7a38b8b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -55,7 +55,6 @@ option (DISABLE_NLS "do not use Native Language Support" OFF)
option (DISABLE_DEPRECATED_GLIB "don't use deprecated glib functions" OFF)
option (DISABLE_DEPRECATED_GTK "don't use deprecated gtk, gdk or gdk-pixbuf functions" OFF)
option (DISABLE_DEPRECATED_GNOME "don't use deprecated gnome functions" OFF)
-option (ALLOW_OLD_GETTEXT "allow to configure build with a gettext version older than 0.19.6. Some files will not be translated!" OFF)
# ############################################################
# These are also settable from the command line in a similar way.
@@ -269,26 +268,27 @@ find_path (REGEX_INCLUDE_PATH NAMES regex.h
find_library (REGEX_LIBRARY NAMES regex)
# I18N
-if (ALLOW_OLD_GETTEXT)
- find_package (Gettext REQUIRED)
-else()
- find_package (Gettext 0.20)
- if (NOT GETTEXT_FOUND)
- message (FATAL_ERROR "Note the build can be configured with an older version of gettext by setting ALLOW_OLD_GETTEXT=ON but then some files will not be translated:
- - gnucash.desktop (requires at least gettext 0.19)
- - gnucash.appdata.xml (requires at least gettext 0.19.6)
- - tag developer_name from gnucash.appdata.xml (requires at least gettext 0.20)")
- endif()
-endif()
+# Potfile generation will only be enabled if building from a git worktree
+set (BUILD_GNUCASH_POT ${BUILDING_FROM_VCS})
+set (TRANSLATE_GNUCASH_APPDATA ON)
+set (TRANSLATE_GNUCASH_DESKTOP ON)
-if (${GETTEXT_VERSION_STRING} VERSION_LESS 0.19)
- message (WARNING "Got gettext version ${GETTEXT_VERSION_STRING}, however you need at least gettext version 0.19 in order to handle translation of the gnucash.desktop file. The build will be configured with an untranslated gnucash.desktop file.")
+find_package (Gettext 0.18.1 REQUIRED)
+if (${GETTEXT_VERSION_STRING} VERSION_LESS 0.20)
+ message (WARNING "Gettext version 0.20 or more recent is required to translate the 'developer_name' tag in gnucash.appdata.xml. All but that tag will be translated in the generated file.")
+ if(BUILD_GNUCASH_POT)
+ # Only emit warning if potfile generation was enabled otherwise
+ message (WARNING "Gettext version 0.20 or more recent is required to extract all translatable strings. Potfile generation will be disabled.")
+ endif()
+ set (BUILD_GNUCASH_POT OFF)
endif()
if (${GETTEXT_VERSION_STRING} VERSION_LESS 0.19.6)
- message (WARNING "Got gettext version ${GETTEXT_VERSION_STRING}, however you need at least gettext version 0.19.6 in order to handle translation of the gnucash.appdata file. The build will be configured with an untranslated gnucash.appdata file.")
+ set (TRANSLATE_GNUCASH_APPDATA OFF)
+ message (WARNING "Gettext version 0.19.6 or more recent is required to translate gnucash.appdata.xml. The build will be configured to generate an untranslated gnucash.appdata.xml.")
endif()
-if (${GETTEXT_VERSION_STRING} VERSION_LESS 0.20)
- message (WARNING "Got gettext version ${GETTEXT_VERSION_STRING}, however you need at least gettext version 0.20 in order to handle the translation of 'GnuCash Project' from the gnucash.appdata file. That message will be missing in gnucash.pot.")
+if (${GETTEXT_VERSION_STRING} VERSION_LESS 0.19)
+ set (TRANSLATE_GNUCASH_DESKTOP OFF)
+ message (WARNING "Gettext version 0.19 or more recent is required to translate gnucash.desktop. The build will be configured to generate an untranslated gnucash.desktop.")
endif()
find_path (LIBINTL_INCLUDE_PATH NAMES libintl.h
diff --git a/gnucash/gnome/CMakeLists.txt b/gnucash/gnome/CMakeLists.txt
index 727f91df6..7a05b38b0 100644
--- a/gnucash/gnome/CMakeLists.txt
+++ b/gnucash/gnome/CMakeLists.txt
@@ -161,18 +161,7 @@ DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/gnucash.appdata.xml.in.in ${VCS_INFO_FILE}
-D SRC_DIR=${CMAKE_SOURCE_DIR}
-P ${CMAKE_SOURCE_DIR}/cmake/configure-appdata.cmake)
-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.
- add_custom_command (
- OUTPUT gnucash.appdata.xml
- COMMAND ${CMAKE_COMMAND} -E copy_if_different
- ${CMAKE_CURRENT_BINARY_DIR}/gnucash.appdata.xml.in
- ${CMAKE_CURRENT_BINARY_DIR}/gnucash.appdata.xml
-
- DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/gnucash.appdata.xml.in ${VCS_INFO_FILE}
- )
-else()
+if (TRANSLATE_GNUCASH_APPDATA)
# FIXME: where does LC_ALL=C come from?
add_custom_command (
OUTPUT gnucash.appdata.xml
@@ -182,8 +171,17 @@ else()
--xml --template ${CMAKE_CURRENT_BINARY_DIR}/gnucash.appdata.xml.in
-d ${CMAKE_SOURCE_DIR}/po
-o gnucash.appdata.xml
- DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/gnucash.appdata.xml.in ${VCS_INFO_FILE}
- )
+ DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/gnucash.appdata.xml.in ${VCS_INFO_FILE})
+else()
+ # Gettext is too old to be able to merge an appdata file.
+ # Fall back to providing an unmerged (and hence untranslated) appdata file.
+ add_custom_command (
+ OUTPUT gnucash.appdata.xml
+ COMMAND ${CMAKE_COMMAND} -E copy_if_different
+ ${CMAKE_CURRENT_BINARY_DIR}/gnucash.appdata.xml.in
+ ${CMAKE_CURRENT_BINARY_DIR}/gnucash.appdata.xml
+
+ DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/gnucash.appdata.xml.in ${VCS_INFO_FILE})
endif()
add_custom_target(gnucash-appdata ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/gnucash.appdata.xml)
@@ -194,12 +192,7 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/gnucash.appdata.xml DESTINATION ${CMA
configure_file(gnucash.desktop.in.in gnucash.desktop.in)
-if (${GETTEXT_VERSION_STRING} VERSION_LESS 0.19)
- # Gettext is too old to be able to merge a desktop file.
- # Fall back to providing an unmerged (and hence untranslated) desktop file.
- configure_file (${CMAKE_CURRENT_BINARY_DIR}/gnucash.desktop.in
- ${CMAKE_CURRENT_BINARY_DIR}/gnucash.desktop COPYONLY)
-else()
+if (TRANSLATE_GNUCASH_DESKTOP)
add_custom_command (
OUTPUT gnucash.desktop
COMMAND ${CMAKE_COMMAND} -E env
@@ -208,8 +201,12 @@ else()
--desktop --template gnucash.desktop.in
-d ${CMAKE_SOURCE_DIR}/po
-o gnucash.desktop
- DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/gnucash.desktop.in
- )
+ DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/gnucash.desktop.in)
+else()
+ # Gettext is too old to be able to merge a desktop file.
+ # Fall back to providing an unmerged (and hence untranslated) desktop file.
+ configure_file (${CMAKE_CURRENT_BINARY_DIR}/gnucash.desktop.in
+ ${CMAKE_CURRENT_BINARY_DIR}/gnucash.desktop COPYONLY)
endif()
add_custom_target(gnucash-desktop ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/gnucash.desktop)
diff --git a/po/CMakeLists.txt b/po/CMakeLists.txt
index 25aa9a6a8..47092ce07 100644
--- a/po/CMakeLists.txt
+++ b/po/CMakeLists.txt
@@ -132,7 +132,7 @@ function(make_gnucash_potfiles)
set(gnucash_pot_depends ${POTFILE_DEPS} CACHE INTERNAL "List of files with translatable strings. If any of these change, gnucash.pot should be regenerated")
endfunction()
-if(BUILDING_FROM_VCS)
+if(BUILD_GNUCASH_POT)
make_gnucash_potfiles()
commit f27cbd4a11ec00b3929ec63dd03243eb308440fe
Author: Geert Janssens <geert at kobaltwit.be>
Date: Sat Feb 8 11:54:53 2020 +0100
Fix dist after renaming account directory hu_HU to hu
diff --git a/data/accounts/hu/CMakeLists.txt b/data/accounts/hu/CMakeLists.txt
index 6b2b3dc3b..0f9adf6d2 100644
--- a/data/accounts/hu/CMakeLists.txt
+++ b/data/accounts/hu/CMakeLists.txt
@@ -17,7 +17,7 @@ set(account_DATA
acctchrt_spouseretire.gnucash-xea)
-set_dist_list(HU_HU_DIST ${account_DATA} CMakeLists.txt)
+set_dist_list(HU_DIST ${account_DATA} CMakeLists.txt)
install(FILES ${account_DATA} DESTINATION ${ACCOUNTS_INSTALL_DIR}/hu)
file(COPY ${account_DATA} DESTINATION ${ACCOUNTS_BUILD_DIR}/hu)
commit e90e9cbd8c6ad5075ac6cd9b48a37c7af98d665f
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Fri Feb 7 22:08:11 2020 +0800
[test-new-owner-report] initial commit
Tests some basic business transactions
* 1 invoice for $6.75
* 1 invoice for $11.50
2 partial payments $1.50 and $2.00
* 1 credit-note for $3.00
* 1 invoice for $28
1 credit note for $27
1 payment linking both including $1 bank transfer
diff --git a/gnucash/report/business-reports/test/CMakeLists.txt b/gnucash/report/business-reports/test/CMakeLists.txt
index 5e502bbc4..49d591c99 100644
--- a/gnucash/report/business-reports/test/CMakeLists.txt
+++ b/gnucash/report/business-reports/test/CMakeLists.txt
@@ -1,6 +1,7 @@
set(scm_test_business_reports_with_srfi64_SOURCES
test-invoice.scm
+ test-new-owner-report.scm
test-owner-report.scm
)
diff --git a/gnucash/report/business-reports/test/test-new-owner-report.scm b/gnucash/report/business-reports/test/test-new-owner-report.scm
new file mode 100644
index 000000000..bbb15543b
--- /dev/null
+++ b/gnucash/report/business-reports/test/test-new-owner-report.scm
@@ -0,0 +1,252 @@
+(use-modules (gnucash gnc-module))
+(gnc:module-begin-syntax (gnc:module-load "gnucash/app-utils" 0))
+(use-modules (gnucash engine test test-extras))
+(use-modules (gnucash report invoice))
+(use-modules (gnucash report stylesheets))
+(use-modules (gnucash report report-system))
+(use-modules (gnucash report report-system test test-extras))
+(use-modules (srfi srfi-1))
+(use-modules (srfi srfi-64))
+(use-modules (gnucash engine test srfi64-extras))
+(use-modules (sxml simple))
+(use-modules (sxml xpath))
+(use-modules (system vm coverage))
+(use-modules (system vm vm))
+
+(define uuid "c146317be32e4948a561ec7fc89d15c1-new")
+
+(setlocale LC_ALL "C")
+
+(define (run-test)
+ (if #f
+ (coverage-test run-test-proper)
+ (run-test-proper)))
+
+(define (coverage-test tester)
+ (let* ((currfile (dirname (current-filename)))
+ (path (string-take currfile (string-rindex currfile #\/))))
+ (add-to-load-path path))
+ (call-with-values
+ (lambda()
+ (with-code-coverage tester))
+ (lambda (data result)
+ (let ((port (open-output-file "/tmp/lcov.info")))
+ (coverage-data->lcov data port)
+ (close port)))))
+
+(define (run-test-proper)
+ (let ((saved-format (qof-date-format-get)))
+ (qof-date-format-set QOF-DATE-FORMAT-ISO)
+ (test-runner-factory gnc:test-runner)
+ (test-begin "test-new-owner-report")
+ (owner-tests)
+ (qof-date-format-set saved-format)
+ (test-end "test-new-owner-report")))
+
+(define (sxml-get-row-col sxml row col)
+ (sxml->table-row-col sxml 3 row col))
+
+(define (set-option! options section name value)
+ (let ((option (gnc:lookup-option options section name)))
+ (if option
+ (gnc:option-set-value option value)
+ (test-assert (format #f "wrong-option ~a ~a" section name) #f))))
+
+(define (get-currency sym)
+ (gnc-commodity-table-lookup
+ (gnc-commodity-table-get-table (gnc-get-current-book))
+ (gnc-commodity-get-namespace (gnc-default-report-currency))
+ sym))
+
+(define structure
+ (list "Root" (list (cons 'type ACCT-TYPE-ASSET)
+ (cons 'commodity (get-currency "USD")))
+ (list "Asset"
+ (list "Bank-USD"))
+ (list "VAT"
+ (list "VAT-on-Purchases")
+ (list "VAT-on-Sales" (list (cons 'type ACCT-TYPE-LIABILITY))))
+ (list "Income" (list (cons 'type ACCT-TYPE-INCOME))
+ (list "Income-USD"))
+ (list "A/Receivable" (list (cons 'type ACCT-TYPE-RECEIVABLE))
+ (list "AR-USD"))
+ (list "A/Payable" (list (cons 'type ACCT-TYPE-PAYABLE))
+ (list "AP-USD"))))
+
+(define (options->sxml options test-title)
+ (gnc:options->sxml uuid options "test-new-owner-report" test-title))
+
+(define (owner-tests)
+ (let* ((env (create-test-env))
+ (account-alist (env-create-account-structure-alist env structure))
+ (get-acct (lambda (name)
+ (or (assoc-ref account-alist name)
+ (error "invalid account name" name))))
+ (AR (get-acct "AR-USD"))
+ (Bank (get-acct "Bank-USD"))
+ (YEAR (gnc:time64-get-year (gnc:get-today))))
+
+ (define owner-1
+ (let* ((cust-1 (gncCustomerCreate (gnc-get-current-book)))
+ (owner-1 (gncOwnerNew)))
+ (gncCustomerSetID cust-1 "cust-1-id")
+ (gncCustomerSetName cust-1 "cust-1-name")
+ (gncCustomerSetNotes cust-1 "cust-1-notes")
+ (gncCustomerSetCurrency cust-1 (get-currency "USD"))
+ (gncCustomerSetTaxIncluded cust-1 1)
+ (gncOwnerInitCustomer owner-1 cust-1)
+ owner-1))
+
+ ;; inv-1 is generated for a customer
+ (define inv-1
+ (let ((inv-1 (gncInvoiceCreate (gnc-get-current-book))))
+ (gncInvoiceSetOwner inv-1 owner-1)
+ (gncInvoiceSetNotes inv-1 "inv-1-notes")
+ (gncInvoiceSetBillingID inv-1 "inv-1-billing-id")
+ (gncInvoiceSetCurrency inv-1 (get-currency "USD"))
+ inv-1))
+
+ (define (make-entry amt)
+ (let ((entry (gncEntryCreate (gnc-get-current-book))))
+ (gncEntrySetDateGDate entry (time64-to-gdate (current-time)))
+ (gncEntrySetDescription entry "entry-desc")
+ (gncEntrySetAction entry "entry-action")
+ (gncEntrySetNotes entry "entry-notes")
+ (gncEntrySetInvAccount entry (get-acct "Income-USD"))
+ (gncEntrySetDocQuantity entry 1 #f)
+ (gncEntrySetInvPrice entry amt)
+ entry))
+
+ (define (add-invoice date amount desc)
+ (let ((inv (gncInvoiceCopy inv-1)))
+ (gncInvoiceAddEntry inv (make-entry amount))
+ (gncInvoicePostToAccount inv
+ (get-acct "AR-USD") ;post-to acc
+ date ;posted-date
+ date ;due-date
+ desc ;desc
+ #t ;acc-splits?
+ #f) ;autopay
+ inv))
+
+ (define (create-split-for-lot account amount lot)
+ (let ((split (xaccMallocSplit (gnc-get-current-book))))
+ (xaccSplitSetAccount split account)
+ (xaccSplitSetAmount split amount)
+ (xaccSplitSetValue split amount)
+ (xaccSplitSetAction split "")
+ (when lot
+ (gnc-lot-set-title lot "")
+ (gnc-lot-add-split lot split))
+ split))
+
+ (define (create-multisplit DD MM YY desc type splits)
+ (let* ((book (gnc-get-current-book))
+ (txn (xaccMallocTransaction book)))
+ (xaccTransBeginEdit txn)
+ (xaccTransSetDescription txn desc)
+ (xaccTransSetCurrency txn (xaccAccountGetCommodity
+ (xaccSplitGetAccount (car splits))))
+ (xaccTransSetDate txn DD MM YY)
+ (xaccTransSetTxnType txn type)
+ (for-each (lambda (s) (xaccSplitSetParent s txn)) splits)
+ (xaccTransCommitEdit txn)
+ txn))
+
+ (define (default-testing-options owner account)
+ ;; owner-report will run from 1.1.1980 to 1.7.1980
+ (let ((options (gnc:make-report-options uuid)))
+ (set-option! options "General" "Customer" owner)
+ (set-option! options "General" "From"
+ (cons 'absolute (gnc-dmy2time64 1 1 1980)))
+ (set-option! options "General" "To"
+ (cons 'absolute (gnc-dmy2time64 1 7 1980)))
+ (set-option! options "Display Columns" "Links" 'detailed)
+ options))
+
+ ;; inv $6.75
+ (add-invoice (gnc-dmy2time64 13 05 1980) 27/4 "$6.75")
+
+ ;; inv $11.50, 2 payments
+ (let ((inv (add-invoice (gnc-dmy2time64 13 01 1980) 23/2 "$11.50")))
+ (gncInvoiceApplyPayment inv '() Bank 3/2 1
+ (gnc-dmy2time64 18 03 1980)
+ "inv >90 payment" "pay only $1.50")
+
+ (gncInvoiceApplyPayment inv '() Bank 2 1
+ (gnc-dmy2time64 20 03 1980)
+ "inv >90 payment" "pay only $2.00"))
+
+ ;; CN $3.00
+ (let ((new-cn (add-invoice (gnc-dmy2time64 22 06 1980) -3 "CN")))
+ (gncInvoiceSetIsCreditNote new-cn #t))
+
+ ;; inv $11.50, 2 payments
+ (let* ((inv (add-invoice (gnc-dmy2time64 24 06 1980) 28 "$28.00"))
+ (CN (add-invoice (gnc-dmy2time64 25 06 1980) -27 "$27.00"))
+ (inv-lot (gncInvoiceGetPostedLot inv))
+ (CN-lot (gncInvoiceGetPostedLot CN)))
+ (gncInvoiceSetIsCreditNote CN #t)
+
+ (create-multisplit
+ 26 06 1980 "payment" TXN-TYPE-PAYMENT
+ (list (create-split-for-lot AR -1 inv-lot)
+ (create-split-for-lot Bank 1 #f)))
+
+ (create-multisplit
+ 26 06 1980 "payment" TXN-TYPE-LINK
+ (list (create-split-for-lot AR -27 inv-lot)
+ (create-split-for-lot AR 27 CN-lot))))
+
+ (display "new-owner-report tests:\n")
+ (test-begin "new-customer-report")
+ (let* ((options (default-testing-options owner-1 (get-acct "AR-USD")))
+ (sxml (options->sxml options "new-customer-report basic")))
+ (test-equal "line 1"
+ '("Customer History" "Linked Details" "1980-01-13" "1980-01-13"
+ "Invoice" "$11.50" "$11.50" "1980-03-18" "Payment" "inv >90 payment"
+ "$11.50" "pay only $1.50" "$1.50" "$1.50" "Pre-Payment" "Current"
+ "0-30 days" "31-60 days" "61-90 days" "91+ days" "Total" "$0.00"
+ "$0.00" "-$3.00" "$6.75" "$0.00" "$8.00" "$11.75")
+ ((sxpath `(// (table 3) // (tr 1) // *text*)) sxml))
+ (test-equal "line 2"
+ '("Date" "Due Date" "Reference" "Type" "Description" "Invoice"
+ "Payment" "Balance" "Date" "Reference" "Type" "Description"
+ "Partial Amount" "Amount" "1980-03-20" "Payment" "inv >90 payment"
+ "pay only $2.00" "$2.00" "$2.00")
+ ((sxpath `(// (table 3) // (tr 2) // *text*)) sxml))
+ (test-equal "line 3"
+ '("UNPAID" "$8.00")
+ ((sxpath `(// (table 3) // (tr 3) // *text*)) sxml))
+ (test-equal "line 4"
+ '("1980-03-18" "Payment" "inv >90 payment" "$10.00" "1980-01-13"
+ "Invoice" "inv >90 payment" "pay only $1.50" "$1.50" "$1.50" "$11.50")
+ ((sxpath `(// (table 3) // (tr 4) // *text*)) sxml))
+ (test-equal "line 5"
+ '("1980-03-20" "Payment" "inv >90 payment" "$8.00" "1980-01-13"
+ "Invoice" "inv >90 payment" "pay only $2.00" "$2.00" "$2.00" "$11.50")
+ ((sxpath `(// (table 3) // (tr 5) // *text*)) sxml))
+ (test-equal "line 6"
+ '("1980-05-13" "1980-05-13" "Invoice" "$6.75" "$14.75" "UNPAID"
+ "$6.75" "$6.75")
+ ((sxpath `(// (table 3) // (tr 6) // *text*)) sxml))
+ (test-equal "line 7"
+ '("1980-06-22" "1980-06-22" "Credit Note" "CN" "$11.75" "UNPAID"
+ "-$3.00" "$3.00")
+ ((sxpath `(// (table 3) // (tr 7) // *text*)) sxml))
+ (test-equal "line 8"
+ '("1980-06-24" "1980-06-24" "Invoice" "$28.00" "$39.75" "1980-06-26"
+ "Payment" "$28.00" "$1.00" "$1.00")
+ ((sxpath `(// (table 3) // (tr 8) // *text*)) sxml))
+ (test-equal "line 9"
+ ' ("1980-06-25" "Credit Note" "$27.00" "$27.00" "$27.00")
+ ((sxpath `(// (table 3) // (tr 9) // *text*)) sxml))
+ (test-equal "line 10"
+ '("1980-06-25" "1980-06-25" "Credit Note" "$27.00" "$12.75"
+ "1980-06-24" "Invoice" "$28.00" "$27.00" "$27.00" "$28.00")
+ ((sxpath `(// (table 3) // (tr 10) // *text*)) sxml))
+ (test-equal "line 11"
+ '("1980-06-26" "Payment" "$11.75" "1980-06-24" "Invoice" "$1.00"
+ "$1.00" "$28.00")
+ ((sxpath `(// (table 3) // (tr 11) // *text*)) sxml)))
+ (test-end "new-customer-report")))
commit 9a90e97009860e92238bab9fd90d226135537311
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Sat Feb 8 08:46:38 2020 +0800
[new-owner-report] negate RHS inv amounts if credit-note.
diff --git a/gnucash/report/business-reports/new-owner-report.scm b/gnucash/report/business-reports/new-owner-report.scm
index 201fb800a..49ce284bf 100644
--- a/gnucash/report/business-reports/new-owner-report.scm
+++ b/gnucash/report/business-reports/new-owner-report.scm
@@ -602,6 +602,7 @@
(let ((lot-txn-split (car lot-txn-splits))
(invoice (gncInvoiceGetInvoiceFromTxn
(xaccSplitGetParent posting-split)))
+ (neg (not (gncInvoiceGetIsCreditNote invoice)))
(posting-txn (xaccSplitGetParent posting-split)))
(lp1 (cdr lot-txn-splits)
non-document
@@ -610,8 +611,8 @@
(split->reference posting-split)
(split->type-str posting-split)
(splits->desc (list posting-split))
- (gnc:make-html-text (split->anchor lot-txn-split #t))
- (gnc:make-html-text (split->anchor posting-split #f))
+ (gnc:make-html-text (split->anchor lot-split neg))
+ (gnc:make-html-text (split->anchor posting-split neg))
(gncInvoiceReturnGUID invoice))
result)))))
Summary of changes:
CMakeLists.txt | 12 +
cmake/CMakeLists.txt | 2 +-
...nfigure-appdata.cmake => insert-vcs-data.cmake} | 2 +-
data/accounts/hu/CMakeLists.txt | 2 +-
gnucash/gnome/CMakeLists.txt | 65 ++++--
.../report/reports/standard/new-owner-report.scm | 5 +-
.../report/reports/standard/test/CMakeLists.txt | 1 +
.../standard/test/test-new-owner-report.scm | 253 +++++++++++++++++++++
po/CMakeLists.txt | 2 +-
9 files changed, 313 insertions(+), 31 deletions(-)
rename cmake/{configure-appdata.cmake => insert-vcs-data.cmake} (96%)
create mode 100644 gnucash/report/reports/standard/test/test-new-owner-report.scm
More information about the gnucash-changes
mailing list