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
...@@ -72,4 +72,14 @@ class Currency(Resource): ...@@ -72,4 +72,14 @@ class Currency(Resource):
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