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.
# Jean-Paul Smets-Solanes <jp@nexedi.com>
# Copyright (c) 2002-2006 Nexedi SARL and Contributors. All Rights Reserved.
# Jean-Paul Smets-Solanes <jp@nexedi.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
......@@ -34,42 +34,52 @@ from Products.ERP5.Document.Resource import Resource
from zLOG import LOG
class Currency(Resource):
"""
Currency
"""
"""
Currency
"""
meta_type = 'ERP5 Currency'
portal_type = 'Currency'
add_permission = Permissions.AddPortalContent
isPortalContent = 1
isRADContent = 1
meta_type = 'ERP5 Currency'
portal_type = 'Currency'
add_permission = Permissions.AddPortalContent
isPortalContent = 1
isRADContent = 1
# Declarative security
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
# Declarative security
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
# Declarative interfaces
__implements__ = ( Interface.Variated, )
# Declarative interfaces
__implements__ = ( Interface.Variated, )
# Declarative properties
property_sheets = ( PropertySheet.Base
, PropertySheet.XMLObject
, PropertySheet.CategoryCore
, PropertySheet.DublinCore
, PropertySheet.Price
, PropertySheet.Resource
, PropertySheet.Reference
)
# Declarative properties
property_sheets = ( PropertySheet.Base
, PropertySheet.XMLObject
, PropertySheet.CategoryCore
, PropertySheet.DublinCore
, PropertySheet.Price
, PropertySheet.Resource
, PropertySheet.Reference
)
# Unit conversion
security.declareProtected(Permissions.AccessContentsInformation, 'convertQuantity')
def convertQuantity(self, quantity, from_unit, to_unit):
return quantity
# Unit conversion
security.declareProtected(Permissions.AccessContentsInformation, 'convertQuantity')
def convertQuantity(self, quantity, from_unit, to_unit):
return quantity
security.declareProtected(Permissions.AccessContentsInformation, 'convertCurrency')
def convertCurrency(self, quantity, to_currency):
if to_currency is self:
return quantity
security.declareProtected(Permissions.AccessContentsInformation, 'convertCurrency')
def convertCurrency(self, quantity, to_currency):
if to_currency is self:
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