Commit cee096d8 authored by Yoshinori Okuji's avatar Yoshinori Okuji

Add getQuantityPrecision.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@5546 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent fac77c40
...@@ -622,3 +622,14 @@ class Resource(XMLMatrix, CoreResource, Variated): ...@@ -622,3 +622,14 @@ class Resource(XMLMatrix, CoreResource, Variated):
unit_base_price = unit_base_price / priced_quantity unit_base_price = unit_base_price / priced_quantity
# Return result # Return result
return unit_base_price return unit_base_price
security.declareProtected(Permissions.AccessContentsInformation,
'getQuantityPrecision')
def getQuantityPrecision(self):
"""Return the floating point precision of a quantity.
"""
quantity = str(self.getBaseUnitQuantity())
i = quantity.find('.')
if i < 0:
return 0
return len(quantity[i+1:].rstrip('0'))
\ No newline at end of file
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