GNOME Bugzilla – Bug 776396
Foreign currency reports, amounts are not aligned correctly
Last modified: 2018-06-29 23:52:50 UTC
Created attachment 342389 [details] example screenshot See screenshot. Usually amounts are aligned correctly. However when a currency conversion takes place it goes haywire.
Dear Devs I think I can fix this is html but don't know how to fix in scheme. The offending function is in html-acct-table.scm (line 1140 on gnucash 2.6.15, see <table> code at [1]). Changing the generated html from <table border="0" cellspacing="0" cellpadding="4"> to <table border="0" cellspacing="0" cellpadding="0" style="width:100%; max-width: 20em"> How to change scheme? (define (gnc-commodity-table amount report-commodity exchange-fn) ;; this creates a small two-column table listing each commodity ;; balance and its respective report balance. note that this ;; shows report-commodity amounts twice: first as a commodity ;; and second in the report commodity. though this may arguably ;; be a bit redundant, i beleive that it makes the report more ;; readable. (let* ((table (gnc:make-html-table)) ;; [1] ) (gnc-commodity-collector-map amount (lambda (curr val) (let ((bal (gnc:make-gnc-monetary curr val))) (gnc:html-table-append-row! table (list ;; add the account balance in the respective commodity (gnc:make-html-table-cell/markup "number-cell" bal) ;; add the account balance in the report commodity (gnc:make-html-table-cell/markup "number-cell" (exchange-fn bal report-commodity)) ) ) ))) table) )
It's accomplished by gnc:html-.*-set-style. See https://github.com/Gnucash/gnucash/blob/master/src/report/report-system/doc/report-html.txt and search for that function for an explanation. The border, cellspacing, and cellpadding attributes are set in each of the stylesheets from the stylesheet definitions, which are editable via the "Tables" tab for each stylesheet via Edit>Stylesheets. The html code is so old it doesn't have any CSS in it. I'd try adding your style attribute either by adding 'attribute(list "style" "width:100; max-width:20em") to the (gnc:html-document-set-style! ssdoc "table" ...) or the (gnc:html-table-set-style! t "table" ...) calls; note that you'll have to add one to stylesheet-plain.scm.
From investigating a bit, the root cause seems to be that numbers in the report's currency are entered as a simple number in the HTML. However, for a foreign currency, a table with columns is used, causing the aligment issues. I'll have a look at trying to fix this in the html, rather than CSS on top of a non-working html structure.
I have submitted a pull request with the changes Chris proposed above (using John's suggestion, thanks!) In the end, this is a simpler fix than adding even more tables to the html. https://github.com/Gnucash/gnucash/pull/147
@Bert I love you! A further change to cellpadding will fix alignment completely (to my satisfaction!) (gnc:html-table-set-style! table "table" 'attribute(list "style" "width:100%; max-width:20em") 'attribute(list "cellpadding" "0"))
Created attachment 353112 [details] Add a separator to the table builder for foreign currency reports. Just wish to add another suggestion here. Side effect of this change: we have eliminated the cell margin. We can restore a margin by adding equal sign to this routine. I can submit a PR if this will help.
fixed in gnucash/maint
GnuCash bug tracking has moved to a new Bugzilla host. This bug has been copied to https://bugs.gnucash.org/show_bug.cgi?id=776396. Please update any external references or bookmarks.