After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 776396 - Foreign currency reports, amounts are not aligned correctly
Foreign currency reports, amounts are not aligned correctly
Status: RESOLVED FIXED
Product: GnuCash
Classification: Other
Component: Reports
2.6.15
Other Windows
: Normal normal
: ---
Assigned To: gnucash-reports-maint
gnucash-reports-maint
Depends on:
Blocks:
 
 
Reported: 2016-12-22 14:34 UTC by Chris
Modified: 2018-06-29 23:52 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
example screenshot (98.98 KB, image/png)
2016-12-22 14:34 UTC, Chris
Details
Add a separator to the table builder for foreign currency reports. (89.72 KB, image/png)
2017-06-03 13:59 UTC, Chris
Details

Description Chris 2016-12-22 14:34: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.
Comment 1 Chris 2017-03-18 15:32:16 UTC
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)
  )
Comment 2 John Ralls 2017-03-18 23:42:08 UTC
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.
Comment 3 Bert 2017-05-09 16:19:19 UTC
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.
Comment 4 Bert 2017-05-13 06:05:47 UTC
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
Comment 5 Chris 2017-05-13 07:21:39 UTC
@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"))
Comment 6 Chris 2017-06-03 13:59:53 UTC
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.
Comment 7 Chris 2017-06-15 00:19:31 UTC
fixed in gnucash/maint
Comment 8 John Ralls 2018-06-29 23:52:50 UTC
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.