Project

General

Profile

Defect #820

rounding issue

Added by Harjo Kompagnie over 9 years ago. Updated over 9 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Start date:
09/05/2014
Due date:
% Done:

0%

Estimated time:
Browser (if web client):

Description

We came across a situation, that a SUM in jasper is using the wrong Rounding (format on the field is: #,##0.00)

Servoy shows the sum of: 128,865 to 128,87
doing the sum in jasper it shows: 128,86

We worked around it now, by passing the sums (rounded by servoy) as parameters from Servoy
But I want to know, how you can do this in jasper!

History

#1

Updated by Andrei Costache over 9 years ago

Hi,

I am not very sure here. There is something called the rounding mode to use for the sum, that you can configure in the report template (for instance, RoundingMode.HALF_DOWN).
More here:
- with an example http://stackoverflow.com/questions/16899298/how-to-specify-roundingmode-for-decimal-numbers-in-jasper-reports
- documentation: http://docs.oracle.com/javase/6/docs/api/java/text/DecimalFormat.html#setRoundingMode(java.math.RoundingMode).
This maybe you can probably use in the expression element (if using Java as the scripting language), but I am not sure entirely about the setup. I have not used rounding modes for Jasper myself.

Or you can use jasper report scriptlets (http://jasperreports.sourceforge.net/sample.reference/scriptlet/, http://jasperreports.sourceforge.net/api/net/sf/jasperreports/engine/util/Java15BigDecimalHandler.html), but I guess that's a bit complex.

Also, I do not exclude the possibility that there is an easier solution :-).

Hope this helps,
Andrei

Also available in: Atom PDF