gnucash maint: Multiple changes pushed
Christopher Lam
clam at code.gnucash.org
Sun Mar 1 00:53:16 EST 2020
Updated via https://github.com/Gnucash/gnucash/commit/2c1ce30d (commit)
via https://github.com/Gnucash/gnucash/commit/742b9722 (commit)
via https://github.com/Gnucash/gnucash/commit/1d9c51d8 (commit)
via https://github.com/Gnucash/gnucash/commit/ec99c007 (commit)
via https://github.com/Gnucash/gnucash/commit/11689e2a (commit)
via https://github.com/Gnucash/gnucash/commit/890c96ce (commit)
from https://github.com/Gnucash/gnucash/commit/453919b3 (commit)
commit 2c1ce30d7de02e1791689f53ed5a13b61cce54e2
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Sun Mar 1 13:40:12 2020 +0800
[qif-to-gnc] centralize arithmetic functions
diff --git a/gnucash/import-export/qif-imp/qif-to-gnc.scm b/gnucash/import-export/qif-imp/qif-to-gnc.scm
index 75c21ceea..08bc0b31e 100644
--- a/gnucash/import-export/qif-imp/qif-to-gnc.scm
+++ b/gnucash/import-export/qif-imp/qif-to-gnc.scm
@@ -29,6 +29,12 @@
(use-modules (ice-9 match))
(use-modules (gnucash import-export string))
+(define (n- n) (gnc-numeric-neg n))
+(define (nsub a b) (gnc-numeric-sub a b 0 GNC-DENOM-LCD))
+(define (n+ a b) (gnc-numeric-add a b 0 GNC-DENOM-LCD))
+(define (n* a b) (gnc-numeric-mul a b 0 GNC-DENOM-REDUCE))
+(define (n/ a b) (gnc-numeric-div a b 0 GNC-DENOM-REDUCE))
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; qif-import:find-or-make-acct
;;
@@ -465,12 +471,7 @@
(qif-memo #f)
(qif-date (qif-xtn:date qif-xtn))
(qif-from-acct (qif-xtn:from-acct qif-xtn))
- (qif-cleared (qif-xtn:cleared qif-xtn))
- (n- (lambda (n) (gnc-numeric-neg n)))
- (nsub (lambda (a b) (gnc-numeric-sub a b 0 GNC-DENOM-LCD)))
- (n+ (lambda (a b) (gnc-numeric-add a b 0 GNC-DENOM-LCD)))
- (n* (lambda (a b) (gnc-numeric-mul a b 0 GNC-DENOM-REDUCE)))
- (n/ (lambda (a b) (gnc-numeric-div a b 0 GNC-DENOM-REDUCE))))
+ (qif-cleared (qif-xtn:cleared qif-xtn)))
;; Set properties of the whole transaction.
@@ -834,12 +835,7 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define (qif-import:mark-some-splits splits xtn candidate-xtns errorproc)
- (let* ((n- (lambda (n) (gnc-numeric-neg n)))
- (nsub (lambda (a b) (gnc-numeric-sub a b 0 GNC-DENOM-LCD)))
- (n+ (lambda (a b) (gnc-numeric-add a b 0 GNC-DENOM-LCD)))
- (n* (lambda (a b) (gnc-numeric-mul a b 0 GNC-DENOM-REDUCE)))
- (n/ (lambda (a b) (gnc-numeric-div a b 0 GNC-DENOM-REDUCE)))
- (split (car splits))
+ (let* ((split (car splits))
(near-acct-name #f)
(far-acct-name #f)
(date (qif-xtn:date xtn))
@@ -951,12 +947,7 @@
(date-matches
(match (cons date (qif-xtn:date xtn))
(((a b c) . (a b c)) #t)
- (_ #f)))
- (n- (lambda (n) (gnc-numeric-neg n)))
- (nsub (lambda (a b) (gnc-numeric-sub a b 0 GNC-DENOM-LCD)))
- (n+ (lambda (a b) (gnc-numeric-add a b 0 GNC-DENOM-LCD)))
- (n* (lambda (a b) (gnc-numeric-mul a b 0 GNC-DENOM-REDUCE)))
- (n/ (lambda (a b) (gnc-numeric-div a b 0 GNC-DENOM-REDUCE))))
+ (_ #f))))
(if date-matches
(begin
commit 742b97229c0afd588730d11dac537626fb7b17e2
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Sun Mar 1 10:36:25 2020 +0800
[trep-engine] when Running Balance is shown, print "Balance b/f"
diff --git a/gnucash/report/report-system/trep-engine.scm b/gnucash/report/report-system/trep-engine.scm
index 0a10504de..8e12fca7c 100644
--- a/gnucash/report/report-system/trep-engine.scm
+++ b/gnucash/report/report-system/trep-engine.scm
@@ -1401,6 +1401,11 @@ be excluded from periodic reporting.")
(case level
((primary) optname-prime-sortkey)
((secondary) optname-sec-sortkey))))
+ (data (if (and (any (lambda (c) (eq? 'bal-bf (vector-ref c 5)))
+ calculated-cells)
+ (memq sortkey ACCOUNT-SORTING-TYPES))
+ (string-append data ": " (_ "Balance b/f"))
+ data))
(renderer-fn (keylist-get-info
(sortkey-list BOOK-SPLIT-ACTION)
sortkey 'renderer-fn))
commit 1d9c51d8e46f487d976b3f637016ee15a3283899
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Sat Feb 29 22:32:14 2020 +0800
[qif-to-gnc] Bug 796579 - Cannot go forward with empty duplicates screen
better fix for bug 796579.
far-acct-info is a record with acct-info
far-acct-name is a string
far-acct is a gnucash account object
(default-unspec-acct) always returns a string "Unspecified".
983c7ce0b was trying to find, from qif-memo-map the mapping for
"Unspecified" which isn't typically part of qif-memo-map. Therefore
far-acct-info would remain #f and fail the qif-map-entry:gnc-name.
Better fix: if far-acct-info cannot be derived, use unspecified account.
diff --git a/gnucash/import-export/qif-imp/qif-to-gnc.scm b/gnucash/import-export/qif-imp/qif-to-gnc.scm
index 4ab978dcb..75c21ceea 100644
--- a/gnucash/import-export/qif-imp/qif-to-gnc.scm
+++ b/gnucash/import-export/qif-imp/qif-to-gnc.scm
@@ -584,13 +584,11 @@
(hash-ref qif-memo-map qif-memo)))
(and (string? memo)
(not (string=? memo ""))
- (hash-ref qif-memo-map memo))))
- (if (not far-acct-info)
- (set! far-acct-info
- (hash-ref qif-memo-map
- (default-unspec-acct))))))
+ (hash-ref qif-memo-map memo))))))
- (set! far-acct-name (qif-map-entry:gnc-name far-acct-info))
+ (set! far-acct-name (if far-acct-info
+ (qif-map-entry:gnc-name far-acct-info)
+ (default-unspec-acct)))
(set! far-acct (hash-ref gnc-acct-hash far-acct-name))
;; set the reconcile status.
commit ec99c007149d050c4e69cb2f819f79bbf64fb534
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Sat Feb 29 21:29:08 2020 +0800
[qif-to-gnc] use (ice-9 match), and compact functions
diff --git a/gnucash/import-export/qif-imp/qif-to-gnc.scm b/gnucash/import-export/qif-imp/qif-to-gnc.scm
index 10ac1780b..4ab978dcb 100644
--- a/gnucash/import-export/qif-imp/qif-to-gnc.scm
+++ b/gnucash/import-export/qif-imp/qif-to-gnc.scm
@@ -26,6 +26,7 @@
(use-modules (srfi srfi-13))
+(use-modules (ice-9 match))
(use-modules (gnucash import-export string))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -513,12 +514,10 @@
;; Look for the transaction status (QIF "C" line). When it exists, apply
;; the cleared (c) or reconciled (y) status to the split. Otherwise, apply
;; user preference.
- (if (eq? qif-cleared 'cleared)
- (xaccSplitSetReconcile gnc-near-split #\c)
- (if (eq? qif-cleared 'reconciled)
- (xaccSplitSetReconcile gnc-near-split #\y)
- ;; Apply user preference by default.
- (xaccSplitSetReconcile gnc-near-split transaction-status-pref)))
+ (case qif-cleared
+ ((cleared) (xaccSplitSetReconcile gnc-near-split #\c))
+ ((reconciled) (xaccSplitSetReconcile gnc-near-split #\y))
+ (else (xaccSplitSetReconcile gnc-near-split transaction-status-pref)))
(if (not qif-security)
(begin
@@ -595,11 +594,9 @@
(set! far-acct (hash-ref gnc-acct-hash far-acct-name))
;; set the reconcile status.
- (let ((cleared (qif-split:matching-cleared qif-split)))
- (if (eq? 'cleared cleared)
- (xaccSplitSetReconcile gnc-far-split #\c))
- (if (eq? 'reconciled cleared)
- (xaccSplitSetReconcile gnc-far-split #\y)))
+ (case (qif-split:matching-cleared qif-split)
+ ((cleared) (xaccSplitSetReconcile gnc-far-split #\c))
+ ((reconciled) (xaccSplitSetReconcile gnc-far-split #\y)))
;; finally, plug the split into the account
(xaccSplitSetAccount gnc-far-split far-acct)
@@ -762,12 +759,9 @@
(xaccSplitSetValue gnc-near-split (n- split-amt))
(xaccSplitSetValue gnc-far-split split-amt))))
- (let ((cleared (qif-split:matching-cleared
- (car (qif-xtn:splits qif-xtn)))))
- (if (eq? 'cleared cleared)
- (xaccSplitSetReconcile gnc-far-split #\c))
- (if (eq? 'reconciled cleared)
- (xaccSplitSetReconcile gnc-far-split #\y)))
+ (case (qif-split:matching-cleared (car (qif-xtn:splits qif-xtn)))
+ ((cleared) (xaccSplitSetReconcile gnc-far-split #\c))
+ ((reconciled) (xaccSplitSetReconcile gnc-far-split #\y)))
(if qif-commission-acct
(let* ((commission-acct-info
@@ -957,14 +951,9 @@
(this-group-amt (gnc-numeric-zero))
(how #f)
(date-matches
- (let ((self-date (qif-xtn:date xtn)))
- (and (pair? self-date)
- (pair? date)
- (eq? (length self-date) 3)
- (eq? (length date) 3)
- (= (car self-date) (car date))
- (= (cadr self-date) (cadr date))
- (= (caddr self-date) (caddr date)))))
+ (match (cons date (qif-xtn:date xtn))
+ (((a b c) . (a b c)) #t)
+ (_ #f)))
(n- (lambda (n) (gnc-numeric-neg n)))
(nsub (lambda (a b) (gnc-numeric-sub a b 0 GNC-DENOM-LCD)))
(n+ (lambda (a b) (gnc-numeric-add a b 0 GNC-DENOM-LCD)))
commit 11689e2a4daaf70c3f6ba9b8345db01090603237
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Sat Feb 29 21:22:11 2020 +0800
[qif-guess-map] use (ice-9 match), and compact functions
diff --git a/gnucash/import-export/qif-imp/qif-guess-map.scm b/gnucash/import-export/qif-imp/qif-guess-map.scm
index 067013dee..da8ff87df 100644
--- a/gnucash/import-export/qif-imp/qif-guess-map.scm
+++ b/gnucash/import-export/qif-imp/qif-guess-map.scm
@@ -25,6 +25,7 @@
(use-modules (srfi srfi-13))
+(use-modules (ice-9 match))
(define GNC-BANK-TYPE 0)
(define GNC-CASH-TYPE 1)
@@ -227,24 +228,21 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define (qif-import:read-securities security-list)
- (let ((table (make-hash-table 20)))
+ (let ((table (make-hash-table))
+ (comm-table (gnc-commodity-table-get-table (gnc-get-current-book))))
(for-each
- (lambda (entry)
- (if (and (list? entry)
- (= 3 (length entry)))
- ;; The saved information about each security mapping is a
- ;; list of three items: the QIF name, and the GnuCash
- ;; namespace and mnemonic (symbol) to which it maps.
- ;; Example: ("McDonald's" "NYSE" "MCD")
- (let ((commodity (gnc-commodity-table-lookup
- (gnc-commodity-table-get-table
- (gnc-get-current-book))
- (cadr entry)
- (caddr entry))))
- (if (and commodity (not (null? commodity)))
- ;; There is an existing GnuCash commodity for this
- ;; combination of namespace and symbol.
- (hash-set! table (car entry) commodity)))))
+ (match-lambda
+ ((name ns mnemonic)
+ ;; The saved information about each security mapping is a
+ ;; list of three items: the QIF name, and the GnuCash
+ ;; namespace and mnemonic (symbol) to which it maps.
+ ;; Example: ("McDonald's" "NYSE" "MCD")
+ (let ((commodity (gnc-commodity-table-lookup comm-table ns mnemonic)))
+ (if (and commodity (not (null? commodity)))
+ ;; There is an existing GnuCash commodity for this
+ ;; combination of namespace and symbol.
+ (hash-set! table name commodity))))
+ (_ #f))
security-list)
table))
@@ -462,18 +460,11 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define (qif-import:find-new-acct qif-acct allowed-types gnc-acct-info)
- (cond ((and (string? qif-acct)
- (string=? qif-acct (default-equity-account)))
- (let ((existing-equity
- (qif-import:find-similar-acct (default-equity-account)
- (list GNC-EQUITY-TYPE)
- gnc-acct-info)))
- (if existing-equity
- existing-equity
- (list (default-equity-account) (list GNC-EQUITY-TYPE)))))
- ((and (string? qif-acct)
- (not (string=? qif-acct "")))
- (list qif-acct allowed-types))
- (#t
- (list (default-unspec-acct) allowed-types))))
+ (cond
+ ((equal? qif-acct (default-equity-account))
+ (or (qif-import:find-similar-acct
+ (default-equity-account) (list GNC-EQUITY-TYPE) gnc-acct-info)
+ (list (default-equity-account) (list GNC-EQUITY-TYPE))))
+ ((equal? qif-acct "") (list (default-unspec-acct) allowed-types))
+ (else (list qif-acct allowed-types))))
commit 890c96ce239f5a8c8e41517f134872df3e976021
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Sat Feb 29 21:28:33 2020 +0800
[qif-merge-groups] Move gnc:account-tree-get-transactions to qif-to-gnc.scm
This function is only used by qif-to-gnc.scm
diff --git a/gnucash/import-export/qif-imp/qif-merge-groups.scm b/gnucash/import-export/qif-imp/qif-merge-groups.scm
index e576f48a9..c8bdd1215 100644
--- a/gnucash/import-export/qif-imp/qif-merge-groups.scm
+++ b/gnucash/import-export/qif-imp/qif-merge-groups.scm
@@ -24,21 +24,6 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; gnc:account-tree-get-transactions
-;;
-;; Given an account tree, this procedure returns a list of all
-;; transactions whose splits only use accounts in the tree.
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-(define (gnc:account-tree-get-transactions root)
- (let ((accounts (gnc-account-get-descendants-sorted root)))
- (let ((q (qof-query-create-for-splits)))
- (qof-query-set-book q (gnc-account-get-book root))
- (xaccQueryAddAccountMatch q accounts QOF-GUID-MATCH-ANY QOF-QUERY-AND)
- (let ((xtns (xaccQueryGetTransactions q QUERY-TXN-MATCH-ALL)))
- (qof-query-destroy q)
- xtns))))
-
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; gnc:account-tree-find-duplicates
;;
diff --git a/gnucash/import-export/qif-imp/qif-to-gnc.scm b/gnucash/import-export/qif-imp/qif-to-gnc.scm
index df74b48dc..10ac1780b 100644
--- a/gnucash/import-export/qif-imp/qif-to-gnc.scm
+++ b/gnucash/import-export/qif-imp/qif-to-gnc.scm
@@ -1230,6 +1230,20 @@
(if all-marked
(qif-xtn:set-mark! xtn #t))))
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; gnc:account-tree-get-transactions
+;;
+;; Given an account tree, this procedure returns a list of all
+;; transactions whose splits only use accounts in the tree.
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+(define (gnc:account-tree-get-transactions root)
+ (let ((accounts (gnc-account-get-descendants-sorted root)))
+ (let ((q (qof-query-create-for-splits)))
+ (qof-query-set-book q (gnc-account-get-book root))
+ (xaccQueryAddAccountMatch q accounts QOF-GUID-MATCH-ANY QOF-QUERY-AND)
+ (let ((xtns (xaccQueryGetTransactions q QUERY-TXN-MATCH-ALL)))
+ (qof-query-destroy q)
+ xtns))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; qif-import:qif-to-gnc-undo
Summary of changes:
gnucash/import-export/qif-imp/qif-guess-map.scm | 53 ++++++-------
gnucash/import-export/qif-imp/qif-merge-groups.scm | 15 ----
gnucash/import-export/qif-imp/qif-to-gnc.scm | 88 ++++++++++------------
gnucash/report/report-system/trep-engine.scm | 5 ++
4 files changed, 67 insertions(+), 94 deletions(-)
More information about the gnucash-changes
mailing list