From d82704e17e7c7b52629112ef65c6c4d52e74fbcc Mon Sep 17 00:00:00 2001 From: helmutm Date: Tue, 31 Mar 2009 09:13:59 +0000 Subject: [PATCH] provide default currency for FloatValue git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@3315 fd906abe-77d9-0310-91a1-e0d9ade77398 --- commerce/common.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/commerce/common.py b/commerce/common.py index 26e2913..17e5536 100644 --- a/commerce/common.py +++ b/commerce/common.py @@ -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