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
This commit is contained in:
Geert Janssens
2020-02-08 14:13:17 +01:00
9 changed files with 316 additions and 34 deletions

View File

@@ -239,7 +239,19 @@ find_path (REGEX_INCLUDE_PATH NAMES regex.h
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})
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()
find_path (LIBINTL_INCLUDE_PATH NAMES libintl.h
PATHS /usr/include /opt/gnome/include)
find_library (LIBINTL_LIBRARY NAMES intl)

View File

@@ -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
)

View File

@@ -13,4 +13,4 @@
include (${SRC_DIR}/cmake/version-info2env.cmake)
versioninfo2env (${VCS_INFO_FILE})
configure_file(${SRC} ${DST} )
configure_file(${SRC} ${DST})

View File

@@ -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)

View File

@@ -177,25 +177,32 @@ 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)
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)
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)
endif()
# 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}
)
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)
@@ -203,18 +210,25 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/gnucash.appdata.xml DESTINATION ${CMA
#=======
configure_file(gnucash.desktop.in.in gnucash.desktop.in)
set (GNC_DESKTOP_IN ${CMAKE_CURRENT_BINARY_DIR}/gnucash.desktop.in)
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)
add_custom_command (
OUTPUT gnucash.desktop
COMMAND ${CMAKE_COMMAND} -E env
LC_ALL=C
${GETTEXT_MSGFMT_EXECUTABLE}
--desktop --template gnucash.desktop.in
-d ${CMAKE_SOURCE_DIR}/po
-o gnucash.desktop
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/gnucash.desktop.in
)
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)
@@ -250,3 +264,4 @@ gnc_add_scheme_deprecated_module ("gnucash report report-gnome" "gnucash report-
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} ${gnome_SCHEME})
dist_add_generated(${BUILDING_FROM_VCS} gnucash.appdata.xml.in)

View File

@@ -599,6 +599,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
@@ -607,8 +608,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)))))

View File

@@ -18,6 +18,7 @@ set(scm_test_with_srfi64_SOURCES
test-equity-statement.scm
test-average-balance.scm
test-invoice.scm
test-new-owner-report.scm
test-owner-report.scm
test-portfolios.scm
)

View File

@@ -0,0 +1,253 @@
(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 (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")))

View File

@@ -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()