Commit f6f70c4f authored by Kevin Deldycke's avatar Kevin Deldycke

Add getPrecisionAsInteger() method.

Update Copyright year.
Unify the indention to 2 space characters.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@5819 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent f9d4960f
############################################################################## ##############################################################################
# #
# Copyright (c) 2002 Nexedi SARL and Contributors. All Rights Reserved. # Copyright (c) 2002-2006 Nexedi SARL and Contributors. All Rights Reserved.
# Jean-Paul Smets-Solanes <jp@nexedi.com> # Jean-Paul Smets-Solanes <jp@nexedi.com>
# #
# WARNING: This program as such is intended to be used by professional # WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential # programmers who take the whole responsability of assessing all potential
...@@ -34,42 +34,52 @@ from Products.ERP5.Document.Resource import Resource ...@@ -34,42 +34,52 @@ from Products.ERP5.Document.Resource import Resource
from zLOG import LOG from zLOG import LOG
class Currency(Resource): class Currency(Resource):
""" """
Currency Currency
""" """
meta_type = 'ERP5 Currency' meta_type = 'ERP5 Currency'
portal_type = 'Currency' portal_type = 'Currency'
add_permission = Permissions.AddPortalContent add_permission = Permissions.AddPortalContent
isPortalContent = 1 isPortalContent = 1
isRADContent = 1 isRADContent = 1
# Declarative security # Declarative security
security = ClassSecurityInfo() security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation) security.declareObjectProtected(Permissions.AccessContentsInformation)
# Declarative interfaces # Declarative interfaces
__implements__ = ( Interface.Variated, ) __implements__ = ( Interface.Variated, )
# Declarative properties # Declarative properties
property_sheets = ( PropertySheet.Base property_sheets = ( PropertySheet.Base
, PropertySheet.XMLObject , PropertySheet.XMLObject
, PropertySheet.CategoryCore , PropertySheet.CategoryCore
, PropertySheet.DublinCore , PropertySheet.DublinCore
, PropertySheet.Price , PropertySheet.Price
, PropertySheet.Resource , PropertySheet.Resource
, PropertySheet.Reference , PropertySheet.Reference
) )
# Unit conversion # Unit conversion
security.declareProtected(Permissions.AccessContentsInformation, 'convertQuantity') security.declareProtected(Permissions.AccessContentsInformation, 'convertQuantity')
def convertQuantity(self, quantity, from_unit, to_unit): def convertQuantity(self, quantity, from_unit, to_unit):
return quantity return quantity
security.declareProtected(Permissions.AccessContentsInformation, 'convertCurrency') security.declareProtected(Permissions.AccessContentsInformation, 'convertCurrency')
def convertCurrency(self, quantity, to_currency): def convertCurrency(self, quantity, to_currency):
if to_currency is self: if to_currency is self:
return quantity
return quantity return quantity
return quantity
# Unit precision
security.declareProtected(Permissions.AccessContentsInformation, 'getPrecisionAsInteger')
def getPrecisionAsInteger(self):
float_precision = str(self.getBaseUnitQuantity())
decimal_split = float_precision.split('.')
integer_part = decimal_split[0]
floating_part = decimal_split[1]
if floating_part[-1] == '0':
return 0
else:
return len(floating_part)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment