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.
This commit is contained in:
Robert Fewell 2020-05-18 16:59:32 +01:00
parent ac02966426
commit 6b3f9bd80e
4 changed files with 39 additions and 0 deletions

View File

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

View File

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

View File

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

View File

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