gnucash maint: Multiple changes pushed
Christopher Lam
clam at code.gnucash.org
Wed Oct 7 07:25:31 EDT 2020
Updated via https://github.com/Gnucash/gnucash/commit/4905ffc8 (commit)
via https://github.com/Gnucash/gnucash/commit/7b1c9296 (commit)
via https://github.com/Gnucash/gnucash/commit/4ea142c4 (commit)
via https://github.com/Gnucash/gnucash/commit/39a67041 (commit)
via https://github.com/Gnucash/gnucash/commit/0becf8cb (commit)
via https://github.com/Gnucash/gnucash/commit/abf052a2 (commit)
via https://github.com/Gnucash/gnucash/commit/f38a3506 (commit)
from https://github.com/Gnucash/gnucash/commit/c587504c (commit)
commit 4905ffc8898e4359ec5027464de1389ed5654fbc
Merge: 7b1c9296a 39a670416
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Wed Oct 7 19:22:08 2020 +0800
Merge branch 'maint-owner-report-doclinks' into maint #795
commit 7b1c9296adde0cc1a7b45a1cf04b805c563d8132
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Sun Oct 4 15:25:44 2020 +0800
[balsheet-pnl] use vector instead of list for report-dates
because report-dates were accessed via list-ref; vector-ref is O(1).
diff --git a/gnucash/report/reports/standard/balsheet-pnl.scm b/gnucash/report/reports/standard/balsheet-pnl.scm
index 85cf3c5f8..b39268fd3 100644
--- a/gnucash/report/reports/standard/balsheet-pnl.scm
+++ b/gnucash/report/reports/standard/balsheet-pnl.scm
@@ -749,6 +749,9 @@ also show overall period profit & loss."))
((eq? report-type 'pnl) (list startdate enddate))
(else (list enddate))))
+ (report-dates-vec (list->vector report-dates))
+ (num-report-dates (vector-length report-dates-vec))
+
;; an alist of (cons account account-cols-data) whereby
;; account-cols-data is a list of col-datum records
(accounts-cols-data
@@ -810,9 +813,9 @@ also show overall period profit & loss."))
monetary common-currency
(cond
((eq? price-source 'pricedb-latest) (current-time))
- ((eq? col-idx 'overall-period) (last report-dates))
- ((eq? report-type 'balsheet) (list-ref report-dates col-idx))
- ((eq? report-type 'pnl) (list-ref report-dates (1+ col-idx))))))))
+ ((eq? col-idx 'overall-period) enddate)
+ ((eq? report-type 'balsheet) (vector-ref report-dates-vec col-idx))
+ ((eq? report-type 'pnl) (vector-ref report-dates-vec (1+ col-idx))))))))
;; the following function generates an gnc:html-text object
;; to dump exchange rate for a particular column. From the
@@ -894,10 +897,9 @@ also show overall period profit & loss."))
(let ((balances
(fold (lambda (a b) (if (member (car a) accts) (cons (cdr a) b) b))
'() alist)))
- (list->vector
- (if (null? balances)
- (map (const (adder)) report-dates)
- (apply map adder balances)))))
+ (if (null? balances)
+ (make-vector num-report-dates (adder))
+ (list->vector (apply map adder balances)))))
(gnc:html-document-set-title!
doc (with-output-to-string
@@ -992,7 +994,7 @@ also show overall period profit & loss."))
(and-let* (common-currency
(date (case price-source
((pricedb-latest) (current-time))
- (else (list-ref report-dates col-idx))))
+ (else (vector-ref report-dates-vec col-idx))))
(asset-liability-balance
(vector-ref asset-liability-balances col-idx))
(asset-liability-basis
@@ -1009,7 +1011,7 @@ also show overall period profit & loss."))
(lambda (col-idx)
(let* ((date (case price-source
((pricedb-latest) (current-time))
- (else (list-ref report-dates col-idx))))
+ (else (vector-ref report-dates-vec col-idx))))
(income-expense-balance
(vector-ref income-expense-balances-with-closing col-idx)))
(if (and common-currency
@@ -1034,7 +1036,7 @@ also show overall period profit & loss."))
(get-col-header-fn
(lambda (accounts col-idx)
- (let* ((date (list-ref report-dates col-idx))
+ (let* ((date (vector-ref report-dates-vec col-idx))
(header (qof-print-date date))
(cell (gnc:make-html-table-cell/markup
"total-label-cell" header)))
@@ -1054,7 +1056,7 @@ also show overall period profit & loss."))
(add-multicolumn-acct-table
table title accounts
maxindent get-cell-monetary-fn
- (iota (length report-dates))
+ (iota num-report-dates)
#:omit-zb-bals? omit-zb-bals?
#:show-zb-accts? show-zb-accts?
#:disable-account-indent? disable-account-indent?
@@ -1145,12 +1147,12 @@ also show overall period profit & loss."))
(lambda (idx)
(cond
((eq? idx 'overall-period)
- (cons (car report-dates) (last report-dates)))
- ((= idx (- (length report-dates) 2))
- (cons (list-ref report-dates idx) (last report-dates)))
+ (cons startdate enddate))
+ ((= idx (- num-report-dates 2))
+ (cons (vector-ref report-dates-vec idx) enddate))
(else
- (cons (list-ref report-dates idx)
- (decdate (list-ref report-dates (1+ idx)) DayDelta))))))
+ (cons (vector-ref report-dates-vec idx)
+ (decdate (vector-ref report-dates-vec (1+ idx)) DayDelta))))))
(col-idx->monetarypair (lambda (balancelist idx)
(if (eq? idx 'overall-period)
@@ -1224,9 +1226,9 @@ also show overall period profit & loss."))
table title accounts
maxindent get-cell-monetary-fn
(append
- (iota (1- (length report-dates)))
+ (iota (1- num-report-dates))
(if (and include-overall-period?
- (> (length report-dates) 2))
+ (> num-report-dates 2))
'(overall-period)
'()))
#:omit-zb-bals? omit-zb-bals?
commit 4ea142c486dadbe9092f3083957306e03d1ff0e1
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Sun Oct 4 15:26:17 2020 +0800
[html-chart] use vector manipulation
diff --git a/gnucash/report/html-chart.scm b/gnucash/report/html-chart.scm
index 359833112..a65b813a0 100644
--- a/gnucash/report/html-chart.scm
+++ b/gnucash/report/html-chart.scm
@@ -267,12 +267,12 @@
(cons 'backgroundColor (list-to-vec color))
(cons 'borderColor (list-to-vec color)))))
(match rest
- (() (gnc:html-chart-set!
- chart '(data datasets)
- (list->vector
- (append (vector->list
- (or (gnc:html-chart-get chart '(data datasets)) #()))
- (list newseries)))))
+ (() (let* ((old-vec (gnc:html-chart-get chart '(data datasets)))
+ (old-len (vector-length old-vec))
+ (new-vec (make-vector (1+ old-len))))
+ (vector-move-left! old-vec 0 old-len new-vec 0)
+ (vector-set! new-vec old-len newseries)
+ (gnc:html-chart-set! chart '(data datasets) new-vec)))
((key val . rest) (loop rest (assq-set! newseries key (list-to-vec val)))))))
(define-public (gnc:html-chart-clear-data-series! chart)
commit 39a67041697d1385a847e10ba5562f99d9d02bf0
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Tue Oct 6 21:52:27 2020 +0800
[options.scm] rename new-owner-report "Links" to "Transaction Links"
diff --git a/gnucash/report/reports/standard/new-owner-report.scm b/gnucash/report/reports/standard/new-owner-report.scm
index 1e20856b7..e336711a2 100644
--- a/gnucash/report/reports/standard/new-owner-report.scm
+++ b/gnucash/report/reports/standard/new-owner-report.scm
@@ -57,7 +57,7 @@
(define debit-header (N_ "Debits"))
(define balance-header (N_ "Balance"))
(define doclink-header (N_ "Document Links"))
-(define linked-txns-header (N_ "Links"))
+(define linked-txns-header (N_ "Transaction Links"))
(define javascript "
<script>
diff --git a/libgnucash/app-utils/options.scm b/libgnucash/app-utils/options.scm
index 62e530d40..5c008e108 100644
--- a/libgnucash/app-utils/options.scm
+++ b/libgnucash/app-utils/options.scm
@@ -1681,6 +1681,9 @@ the option '~a'."))
("Void Transactions" "Filter" "Void Transactions")
("Account Substring" "Filter" "Account Name Filter")
("Enable links" #f "Enable Links")
+ ;; new-owner-report.scm, renamed Oct 2020 to differentiate with
+ ;; Document Links:
+ ("Links" #f "Transaction Links")
;; invoice.scm, renamed November 2018
("Individual Taxes" #f "Use Detailed Tax Summary")
;; income-gst-statement.scm
commit 0becf8cbc17ce77f5257b388e8c0b68e688cc428
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Mon Oct 5 22:47:17 2020 +0800
[new-owner-report] enable doclink links
diff --git a/gnucash/report/reports/standard/new-owner-report.scm b/gnucash/report/reports/standard/new-owner-report.scm
index b64c4b02b..1e20856b7 100644
--- a/gnucash/report/reports/standard/new-owner-report.scm
+++ b/gnucash/report/reports/standard/new-owner-report.scm
@@ -56,6 +56,7 @@
(define credit-header (N_ "Credits"))
(define debit-header (N_ "Debits"))
(define balance-header (N_ "Balance"))
+(define doclink-header (N_ "Document Links"))
(define linked-txns-header (N_ "Links"))
(define javascript "
@@ -162,6 +163,8 @@
(vector-ref columns-used 8))
(define (bal-col columns-used)
(vector-ref columns-used 9))
+(define (doclink-col columns-used)
+ (vector-ref columns-used 10))
(define (num-cols columns-used section)
(let* ((date? (date-col columns-used))
@@ -174,12 +177,14 @@
(credit? (credit-col columns-used))
(debit? (debit-col columns-used))
(bal? (bal-col columns-used))
+ (doclink? (doclink-col columns-used))
(spacer? (or date? type? ref? desc? debit? credit?))
(amt? (or credit? debit?))
(cols-alist
(list
- (list 'lhs-cols date? due? ref? type? desc? sale? tax? credit? debit? bal?)
- (list 'ptt-span date? due? ref? type? desc?)
+ (list 'lhs-cols date? due? ref? type? desc? sale? tax? credit? debit? bal?
+ doclink?)
+ (list 'ptt-span date? due? ref? type? desc? doclink?)
(list 'mid-spac spacer?)
(list 'rhs-cols date? ref? type? desc? amt? amt?)
(list 'rhs-span date? ref? type? desc?)))
@@ -194,7 +199,7 @@
(map opt-val
(list date-header due-date-header reference-header type-header
desc-header sale-header tax-header debit-header credit-header
- balance-header))))
+ balance-header doclink-header))))
(define (make-heading-list column-vector link-option acct-type)
(let ((heading-list '())
@@ -210,6 +215,8 @@
(addto! heading-list (G_ type-header)))
(if (desc-col column-vector)
(addto! heading-list (G_ desc-header)))
+ (if (doclink-col column-vector)
+ (addto! heading-list (C_ "Column header for 'Document Link'" "L")))
(if (sale-col column-vector)
(addto! heading-list (G_ sale-header)))
(if (tax-col column-vector)
@@ -340,7 +347,7 @@
;; Make a row list based on the visible columns
;;
(define (add-row table odd-row? column-vector date due-date ref type-str
- desc currency amt debit credit sale tax lhs-class
+ desc doclink-invoice currency amt debit credit sale tax lhs-class
link-option link-rows)
(define nrows (if link-rows (length link-rows) 1))
(define (link-data->cols link-data)
@@ -431,7 +438,12 @@
(and due-date (qof-print-date due-date)))
(addif (ref-col column-vector) ref)
(addif (type-col column-vector) type-str)
- (addif (desc-col column-vector) desc)))
+ (addif (desc-col column-vector) desc)
+ (addif (doclink-col column-vector)
+ (and doclink-invoice
+ (gnc:html-invoice-doclink-anchor
+ doclink-invoice
+ (C_ "Column header for 'Document Link'" "L"))))))
(map
(lambda (str)
(let ((cell (gnc:make-html-table-cell/size/markup
@@ -543,7 +555,7 @@
payable? date-type currency)))))
(define (add-balance-row odd-row? total)
- (add-row table odd-row? used-columns start-date #f "" (G_ "Balance") ""
+ (add-row table odd-row? used-columns start-date #f "" (G_ "Balance") "" #f
currency total #f #f #f #f #f
link-option (case link-option
((none) '(()))
@@ -796,6 +808,7 @@
(split->reference split)
(split->type-str split payable?)
(splits->desc (list split))
+ (and (not (string-null? (gncInvoiceGetDocLink invoice))) invoice)
currency (+ total value)
(and (>= orig-value 0) (amount->anchor split orig-value))
(and (< orig-value 0) (amount->anchor split (- orig-value)))
@@ -825,7 +838,7 @@
(split->reference split)
(split->type-str split payable?)
(splits->desc (xaccTransGetAPARAcctSplitList txn #t))
- currency (+ total value)
+ #f currency (+ total value)
(and (>= orig-value 0) (amount->anchor split orig-value))
(and (< orig-value 0) (amount->anchor split (- orig-value)))
#f #f
@@ -929,6 +942,11 @@
(N_ "Invoices show list of payments, payments show list of \
invoices and amounts.")))))
+ (gnc:register-inv-option
+ (gnc:make-simple-boolean-option
+ (N_ "Display Columns") doclink-header
+ "hd" (N_ "Display document link?") #f))
+
(gnc:register-inv-option
(gnc:make-multichoice-option
gnc:pagename-general optname-date-driver "k"
commit abf052a213f416a7f90942f8da71e5ccbd091483
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Mon Oct 5 22:48:22 2020 +0800
[html-utilities][API] add gnc:html-invoice-doclink-anchor
diff --git a/gnucash/report/html-utilities.scm b/gnucash/report/html-utilities.scm
index d5bda78a3..d536201e0 100644
--- a/gnucash/report/html-utilities.scm
+++ b/gnucash/report/html-utilities.scm
@@ -48,6 +48,9 @@
(define (gnc:transaction-doclink-anchor-text trans)
(gnc:register-guid "trans-doclink-guid=" (gncTransGetGUID trans)))
+(define (gnc:invoice-doclink-anchor-text invoice)
+ (gnc:register-guid "invoice-doclink-guid=" (gncInvoiceReturnGUID invoice)))
+
(define (gnc:report-anchor-text report-id)
(gnc-build-url URL-TYPE-REPORT
(string-append "id=" (number->string report-id))
@@ -159,6 +162,11 @@
(gnc:transaction-doclink-anchor-text trans)
text)))
+(define (gnc:html-invoice-doclink-anchor invoice text)
+ (gnc:make-html-text (gnc:html-markup-anchor
+ (gnc:invoice-doclink-anchor-text invoice)
+ text)))
+
(define (gnc:html-price-anchor price value)
(gnc:make-html-text (if price
(gnc:html-markup-anchor
diff --git a/gnucash/report/report.scm b/gnucash/report/report.scm
index 9218e745e..7791d969e 100644
--- a/gnucash/report/report.scm
+++ b/gnucash/report/report.scm
@@ -93,6 +93,7 @@
(export gnc:html-split-anchor)
(export gnc:html-transaction-anchor)
(export gnc:html-transaction-doclink-anchor)
+(export gnc:html-invoice-doclink-anchor)
(export gnc:html-price-anchor)
(export gnc:customer-anchor-text)
(export gnc:job-anchor-text)
commit f38a3506f3dd791c02afd7a0afcb46a3185e00a5
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Mon Oct 5 22:47:53 2020 +0800
[top-level] handle invoice-doclink-guid=InvoiceGUID urls
diff --git a/gnucash/gnome/top-level.c b/gnucash/gnome/top-level.c
index 6f91be1f0..77080180e 100644
--- a/gnucash/gnome/top-level.c
+++ b/gnucash/gnome/top-level.c
@@ -47,6 +47,7 @@
#include "gnc-engine.h"
#include "gnc-file.h"
#include "gnc-hooks.h"
+#include "gncInvoice.h"
#include "gfec.h"
#include "gnc-main-window.h"
#include "gnc-menu-extensions.h"
@@ -120,6 +121,7 @@ gnc_html_register_url_cb (const char *location, const char *label,
Split * split = NULL;
Account * account = NULL;
Transaction * trans;
+ GncInvoice * invoice;
GList * node;
GncGUID guid;
QofInstance * entity = NULL;
@@ -180,6 +182,19 @@ gnc_html_register_url_cb (const char *location, const char *label,
return TRUE;
}
+ else if (strncmp ("invoice-doclink-guid=", location,
+ strlen ("invoice-doclink-guid=")) == 0)
+ {
+ if (!validate_type("invoice-doclink-guid=", location, GNC_ID_INVOICE,
+ result, &guid, &entity))
+ return FALSE;
+
+ invoice = (GncInvoice *) entity;
+ gnc_doclink_open_uri (gnc_ui_get_gtk_window (GTK_WIDGET (result->parent)),
+ gncInvoiceGetDocLink (invoice));
+ return TRUE;
+ }
+
else if (strncmp ("split-guid=", location, strlen ("split-guid=")) == 0)
{
if (!validate_type("split-guid=", location, GNC_ID_SPLIT, result, &guid, &entity))
Summary of changes:
gnucash/gnome/top-level.c | 15 +++++++++
gnucash/report/html-chart.scm | 12 +++----
gnucash/report/html-utilities.scm | 8 +++++
gnucash/report/report.scm | 1 +
gnucash/report/reports/standard/balsheet-pnl.scm | 38 ++++++++++++----------
.../report/reports/standard/new-owner-report.scm | 34 ++++++++++++++-----
libgnucash/app-utils/options.scm | 3 ++
7 files changed, 79 insertions(+), 32 deletions(-)
More information about the gnucash-changes
mailing list