Commit b71cc88b authored by Kevin Deldycke's avatar Kevin Deldycke

Make getTotalPrice working on Delivery Cells


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@4011 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent d6d633e4
...@@ -29,16 +29,18 @@ ...@@ -29,16 +29,18 @@
from Globals import InitializeClass from Globals import InitializeClass
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from Products.ERP5.Variated import Variated
from Products.ERP5.VariationValue import VariationValue
from Products.ERP5Type import Permissions, PropertySheet, Constraint, Interface from Products.ERP5Type import Permissions, PropertySheet, Constraint, Interface
from Products.ERP5Type.Base import Base from Products.ERP5Type.Base import Base
from Products.ERP5.VariationValue import VariationValue
from Products.ERP5.Variated import Variated
from Products.ERP5Type.Base import TempBase from Products.ERP5Type.Base import TempBase
from Products.CMFCategory.Renderer import Renderer from Products.CMFCategory.Renderer import Renderer
from zLOG import LOG from zLOG import LOG
class Amount(Base, Variated): class Amount(Base, Variated):
""" """
A mix-in class which provides some utilities A mix-in class which provides some utilities
...@@ -313,7 +315,6 @@ class Amount(Base, Variated): ...@@ -313,7 +315,6 @@ class Amount(Base, Variated):
unit_base_price = resource.getPrice(context=self) unit_base_price = resource.getPrice(context=self)
return unit_base_price return unit_base_price
security.declareProtected(Permissions.AccessContentsInformation, 'getDuration') security.declareProtected(Permissions.AccessContentsInformation, 'getDuration')
def getDuration(self): def getDuration(self):
""" """
...@@ -323,14 +324,11 @@ class Amount(Base, Variated): ...@@ -323,14 +324,11 @@ class Amount(Base, Variated):
quantity_unit = self.getQuantityUnit() quantity_unit = self.getQuantityUnit()
if quantity_unit is None: if quantity_unit is None:
return None return None
common_time_category = 'time' common_time_category = 'time'
if common_time_category in quantity_unit[:len(common_time_category)]: if common_time_category in quantity_unit[:len(common_time_category)]:
duration = quantity duration = quantity
else: else:
duration = None duration = None
return duration return duration
security.declareProtected(Permissions.AccessContentsInformation, 'getTotalBasePrice') security.declareProtected(Permissions.AccessContentsInformation, 'getTotalBasePrice')
...@@ -342,13 +340,14 @@ class Amount(Base, Variated): ...@@ -342,13 +340,14 @@ class Amount(Base, Variated):
efficiency = self.getEfficiency() efficiency = self.getEfficiency()
if efficiency != 0: if efficiency != 0:
resource_price = self.getResourcePrice() resource_price = self.getResourcePrice()
if resource_price is None: if resource_price is not None:
return None return resource_price * self.getConvertedQuantity() / efficiency
result = resource_price * self.getConvertedQuantity() / efficiency price = self.getPrice()
quantity = self.getQuantity()
if type(price) in (type(1.0), type(1)) and type(quantity) in (type(1.0), type(1)):
result = quantity * price
return result return result
# Conversion to standard unit # Conversion to standard unit
security.declareProtected(Permissions.AccessContentsInformation, 'getConvertedQuantity') security.declareProtected(Permissions.AccessContentsInformation, 'getConvertedQuantity')
def getConvertedQuantity(self): def getConvertedQuantity(self):
...@@ -586,4 +585,3 @@ class Amount(Base, Variated): ...@@ -586,4 +585,3 @@ class Amount(Base, Variated):
def _setLostQuantity(self, value): def _setLostQuantity(self, value):
return self._setProfitQuantity(- value) return self._setProfitQuantity(- value)
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