Reports and format float
John Proios <[email protected]> Tue, 11 Aug 2009 10:17:33 +0300
| Newsgroups | gmane.comp.gnu.enterprise.devel |
|---|---|
| Message-ID | <[email protected]> |
Hello all. I found a little problem in gnue-report and i do not know if severely or no. I have my database in MySQL and use report <layout xmlns:out="GNUe:Reports:Char">. I try to print a field (<field name="unit_price" type="number" length="15" precision="5" nullable="False"/> ) with param format="#,##0.00". The gnue-report call the GDataFormatter.py in commons and not check in code if type(value) == FloatType:... because the variable value is decimal.Decimal. Change the code with this attach file and all is nice but i dont know if this is true or false. _______________________________________________ Gnue-dev mailing list [email protected] http://lists.gnu.org/mailman/listinfo/gnue-dev
diff
(text/x-diff, 1.1 KB)
*** GDataFormatter.py 2009-08-11 09:46:29.000000000 +0300
--- GDataFormatter_snigelgr.py 2009-08-07 20:13:01.000000000 +0300
***************
*** 30,39 ****
#
from types import *
from gnue.common.external.fixedpoint import FixedPoint, addHalfAndChop
FixedPoint.round = addHalfAndChop
-
def applyFormatting (value, mask):
# This obviously doesn't do anything with the mask yet
# Just returns a string
--- 30,39 ----
#
from types import *
+ import decimal
from gnue.common.external.fixedpoint import FixedPoint, addHalfAndChop
FixedPoint.round = addHalfAndChop
def applyFormatting (value, mask):
# This obviously doesn't do anything with the mask yet
# Just returns a string
***************
*** 49,55 ****
pass
# TODO: As said above, this is a bad hack w/a lot of assumptions
! if type(value) == FloatType:
v = mask.split('.',1)
try:
dec = len(v[1])
--- 49,55 ----
pass
# TODO: As said above, this is a bad hack w/a lot of assumptions
! if isinstance(value, decimal.Decimal):
v = mask.split('.',1)
try:
dec = len(v[1])