From 6b3f9bd80e4017afba23a664a1b0cfe93ee9addd Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Mon, 18 May 2020 16:59:32 +0100 Subject: [PATCH] Bug 796531 - Display the Transaction Association link Displays the Transaction Association link in the Transaction Report and when selected will open the association outside of Gnucash as it currently does when opened from the register. --- gnucash/gnome/top-level.c | 12 ++++++++++++ gnucash/report/html-utilities.scm | 8 ++++++++ gnucash/report/report.scm | 2 ++ gnucash/report/trep-engine.scm | 17 +++++++++++++++++ 4 files changed, 39 insertions(+) diff --git a/gnucash/gnome/top-level.c b/gnucash/gnome/top-level.c index 2d3023c867..f7fdf34fa2 100644 --- a/gnucash/gnome/top-level.c +++ b/gnucash/gnome/top-level.c @@ -33,6 +33,7 @@ #include "business-urls.h" #include "combocell.h" #include "dialog-account.h" +#include "dialog-assoc.h" #include "dialog-commodity.h" #include "dialog-invoice.h" #include "dialog-preferences.h" @@ -166,6 +167,16 @@ gnc_html_register_url_cb (const char *location, const char *label, } } + else if (strncmp ("trans-association-guid=", location, strlen ("trans-association-guid=")) == 0) + { + if (!validate_type("trans-association-guid=", location, GNC_ID_TRANS, result, &guid, &entity)) + return FALSE; + + trans = (Transaction *) entity; + gnc_assoc_open_uri (gnc_ui_get_gtk_window (GTK_WIDGET(result->parent)), xaccTransGetAssociation (trans)); + return TRUE; + } + else if (strncmp ("split-guid=", location, strlen ("split-guid=")) == 0) { if (!validate_type("split-guid=", location, GNC_ID_SPLIT, result, &guid, &entity)) @@ -174,6 +185,7 @@ gnc_html_register_url_cb (const char *location, const char *label, split = (Split *) entity; account = xaccSplitGetAccount(split); } + else { result->error_message = diff --git a/gnucash/report/html-utilities.scm b/gnucash/report/html-utilities.scm index de6bf81a80..1822c3598d 100644 --- a/gnucash/report/html-utilities.scm +++ b/gnucash/report/html-utilities.scm @@ -44,6 +44,9 @@ (define (gnc:transaction-anchor-text trans) (gnc:register-guid "trans-guid=" (gncTransGetGUID trans))) +(define (gnc:transaction-association-anchor-text trans) + (gnc:register-guid "trans-association-guid=" (gncTransGetGUID trans))) + (define (gnc:report-anchor-text report-id) (gnc-build-url URL-TYPE-REPORT (string-append "id=" (number->string report-id)) @@ -149,6 +152,11 @@ (gnc:transaction-anchor-text trans) text))) +(define (gnc:html-transaction-association-anchor trans text) + (gnc:make-html-text (gnc:html-markup-anchor + (gnc:transaction-association-anchor-text trans) + 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 174ba9d6a6..b48b3d7d51 100644 --- a/gnucash/report/report.scm +++ b/gnucash/report/report.scm @@ -86,11 +86,13 @@ (export gnc:account-anchor-text) (export gnc:split-anchor-text) (export gnc:transaction-anchor-text) +(export gnc:transaction-association-anchor-text) (export gnc:report-anchor-text) (export gnc:make-report-anchor) (export gnc:html-account-anchor) (export gnc:html-split-anchor) (export gnc:html-transaction-anchor) +(export gnc:html-transaction-association-anchor) (export gnc:html-price-anchor) (export gnc:customer-anchor-text) (export gnc:job-anchor-text) diff --git a/gnucash/report/trep-engine.scm b/gnucash/report/trep-engine.scm index 5d4e30dac5..06089707f5 100644 --- a/gnucash/report/trep-engine.scm +++ b/gnucash/report/trep-engine.scm @@ -945,6 +945,7 @@ be excluded from periodic reporting.") (list (N_ "Use Full Other Account Name") "i" (_ "Display the full account name?") #f) (list (N_ "Other Account Code") "j" (_ "Display the other account code?") #f) (list (N_ "Shares") "k" (_ "Display the number of shares?") #f) + (list (N_ "Association") "l5" (_ "Display the transaction association") #f) (list (N_ "Price") "l" (_ "Display the shares price?") #f) ;; note the "Amount" multichoice option in between here (list optname-grid "m5" (_ "Display a subtotal summary table.") #f) @@ -1070,6 +1071,7 @@ be excluded from periodic reporting.") (opt-val gnc:pagename-display (N_ "Other Account Name")))) (cons 'shares (opt-val gnc:pagename-display (N_ "Shares"))) (cons 'price (opt-val gnc:pagename-display (N_ "Price"))) + (cons 'association (opt-val gnc:pagename-display "Association")) (cons 'amount-single (eq? amount-setting 'single)) (cons 'amount-double (eq? amount-setting 'double)) (cons 'common-currency (opt-val gnc:pagename-general optname-common-currency)) @@ -1235,6 +1237,21 @@ be excluded from periodic reporting.") "number-cell" (xaccSplitGetAmount split))))) + (add-if (column-uses? 'association) + (vector "" + (lambda (split transaction-row?) + (let ((url (xaccTransGetAssociation + (xaccSplitGetParent split)))) + (and (not (string-null? url)) + (gnc:make-html-table-cell/markup + "text-cell" + (if opt-use-links? + (gnc:html-transaction-association-anchor + (xaccSplitGetParent split) + ;; Translators: 'A' is short for Association + (_ "A")) + (_ "A")))))))) + (add-if (column-uses? 'price) (vector (_ "Price") (lambda (split transaction-row?)