Commit 4d9d69db authored by Jérome Perrin's avatar Jérome Perrin

implements getSource/DestinationInventoriatedTotalAssetPrice to use asset...

implements getSource/DestinationInventoriatedTotalAssetPrice to use asset price if total asset price is not set.

change permissions of isConvergent, isDivergent, isSimulated from View to AccessContentsInformation


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@5280 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent c136cb02
...@@ -273,7 +273,7 @@ class Movement(XMLObject, Amount): ...@@ -273,7 +273,7 @@ class Movement(XMLObject, Amount):
return None return None
# Asset price calculation # Asset price calculation
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected( Permissions.AccessContentsInformation,
'getSourceInventoriatedTotalAssetPrice') 'getSourceInventoriatedTotalAssetPrice')
def getSourceInventoriatedTotalAssetPrice(self): def getSourceInventoriatedTotalAssetPrice(self):
""" """
...@@ -291,16 +291,19 @@ class Movement(XMLObject, Amount): ...@@ -291,16 +291,19 @@ class Movement(XMLObject, Amount):
to calculate asset prices based on calculation rules (FIFO, to calculate asset prices based on calculation rules (FIFO,
FILO, AVERAGE, etc.). FILO, AVERAGE, etc.).
""" """
result = self.getSourceTotalAssetPrice() # This is what we use for accounting # This is what we use for accounting
if result is not None: return result result = self.getSourceTotalAssetPrice()
if result is not None:
return result
quantity = self.getQuantity() quantity = self.getQuantity()
if quantity > 0.0: if quantity :
return None # Outgoing quantity source_asset_price = self.getSourceAssetPrice()
elif quantity < 0.0: if source_asset_price :
return self.getSourceAssetPrice() * quantity # XXX: price should be converted to the source currency return source_asset_price * quantity
return None return None
security.declareProtected(Permissions.AccessContentsInformation, 'getDestinationInventoriatedTotalAssetPrice') security.declareProtected( Permissions.AccessContentsInformation,
'getDestinationInventoriatedTotalAssetPrice')
def getDestinationInventoriatedTotalAssetPrice(self): def getDestinationInventoriatedTotalAssetPrice(self):
""" """
Returns a price which can be used to calculate stock value (asset) Returns a price which can be used to calculate stock value (asset)
...@@ -308,13 +311,15 @@ class Movement(XMLObject, Amount): ...@@ -308,13 +311,15 @@ class Movement(XMLObject, Amount):
Asset price is used for calculation of inventory asset value Asset price is used for calculation of inventory asset value
and for accounting and for accounting
""" """
result = self.getDestinationTotalAssetPrice() # This is what we use for accounting # This is what we use for accounting
if result is not None: return result result = self.getDestinationTotalAssetPrice()
if result is not None:
return result
quantity = self.getQuantity() quantity = self.getQuantity()
if quantity < 0.0: if quantity :
return None # Outgoing quantity destination_asset_price = self.getDestinationAssetPrice()
elif quantity > 0.0: if destination_asset_price :
return self.getDestinationAssetPrice() * quantity # XXX: price should be converted to the dest. currency return destination_asset_price * quantity
return None return None
security.declareProtected( Permissions.AccessContentsInformation, security.declareProtected( Permissions.AccessContentsInformation,
...@@ -336,14 +341,16 @@ class Movement(XMLObject, Amount): ...@@ -336,14 +341,16 @@ class Movement(XMLObject, Amount):
return self.getPrice() # XXX Not implemented yet TODO return self.getPrice() # XXX Not implemented yet TODO
# Causality computation # Causality computation
security.declareProtected(Permissions.View, 'isConvergent') security.declareProtected( Permissions.AccessContentsInformation,
'isConvergent')
def isConvergent(self): def isConvergent(self):
""" """
Returns 0 if the target is not met Returns 0 if the target is not met
""" """
return int(not self.isDivergent()) return int(not self.isDivergent())
security.declareProtected(Permissions.View, 'isDivergent') security.declareProtected( Permissions.AccessContentsInformation,
'isDivergent')
def isDivergent(self): def isDivergent(self):
""" """
XXX documentation out of sync with actual use XXX documentation out of sync with actual use
...@@ -383,7 +390,8 @@ class Movement(XMLObject, Amount): ...@@ -383,7 +390,8 @@ class Movement(XMLObject, Amount):
return self.getDeliveryValue() return self.getDeliveryValue()
# Simulation # Simulation
security.declareProtected(Permissions.View, 'isSimulated') security.declareProtected( Permissions.AccessContentsInformation,
'isSimulated')
def isSimulated(self): def isSimulated(self):
return (len(self.getDeliveryRelatedValueList()) > 0) or\ return (len(self.getDeliveryRelatedValueList()) > 0) or\
(len(self.getOrderRelatedValueList()) > 0) (len(self.getOrderRelatedValueList()) > 0)
......
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