provide default currency for FloatValue
git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@3315 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
parent
ee26ab3ff4
commit
d82704e17e
1 changed files with 7 additions and 2 deletions
|
@ -1,3 +1,4 @@
|
|||
#-*- coding: UTF-8 -*-
|
||||
#
|
||||
# Copyright (c) 2009 Helmut Merz helmutm@cy55.de
|
||||
#
|
||||
|
@ -118,12 +119,16 @@ class BaseObject(object):
|
|||
|
||||
class FloatValue(float):
|
||||
|
||||
def __init__(self, value, decimals=2):
|
||||
def __init__(self, value, decimals=2, currency=u'€'):
|
||||
self.decimals = decimals
|
||||
self.currency = currency
|
||||
|
||||
def __str__(self):
|
||||
format = '%%.%if' % self.decimals
|
||||
return (format % self).replace('.', ',')
|
||||
value = (format % self).replace('.', ',')
|
||||
if self.currency:
|
||||
value = value + ' ' + self.currency
|
||||
return value
|
||||
|
||||
|
||||
# utility functions
|
||||
|
|
Loading…
Add table
Reference in a new issue