Commit 164a1570 authored by Jean-Paul Smets's avatar Jean-Paul Smets

Completed asset price API for accounting


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@4916 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 24b0f7a5
...@@ -161,22 +161,22 @@ class AccountingTransactionLine(DeliveryLine): ...@@ -161,22 +161,22 @@ class AccountingTransactionLine(DeliveryLine):
Get the stop date. Get the stop date.
""" """
return self.getStopDate() return self.getStopDate()
# Pricing in standard currency # Pricing in standard currency
security.declareProtected(Permissions.AccessContentsInformation, 'getPrice') security.declareProtected(Permissions.AccessContentsInformation, 'getPrice')
def getPrice(self, context=None): def getPrice(self, context=None):
""" """
The inventoriated quantity converted in a default unit The inventoriated quantity converted in a default unit
For assortments, returns the inventoriated quantity in terms of For assortments, returns the inventoriated quantity in terms of
number of items in the assortemnt. number of items in the assortemnt.
For accounting, returns the quantity converted in a default unit For accounting, returns the quantity converted in a default unit
""" """
result = self.getInventoriatedQuantity() result = self.getInventoriatedQuantity()
resource = self.getResourceValue() resource = self.getResourceValue()
source = self.getSourceValue() source = self.getSourceValue()
if source is not None and resource is not None: if source is not None and resource is not None:
# XXX convertCurrency is not defined # XXX convertCurrency is not defined
# ... so for now, we return 1 # ... so for now, we return 1
...@@ -185,4 +185,22 @@ class AccountingTransactionLine(DeliveryLine): ...@@ -185,4 +185,22 @@ class AccountingTransactionLine(DeliveryLine):
source.getPriceCurrencyValue()) source.getPriceCurrencyValue())
return None return None
security.declareProtected(Permissions.AccessContentsInformation, 'getSourceAssetPrice')
def getSourceAssetPrice(self):
"""
The price is set to 1.0 because we do not want to implement automatic currency
conversion in accounting. Users must define the conversion manually in accounting.
This is required by accounting law. One can not account USD (in a EUR based company)
without defining the equivalent in EUR.
"""
return 1.0
security.declareProtected(Permissions.AccessContentsInformation, 'getDestinationAssetPrice')
def getDestinationAssetPrice(self):
"""
The price is set to 1.0 because we do not want to implement automatic currency
conversion in accounting. Users must define the conversion manually in accounting.
This is required by accounting law. One can not account USD (in a EUR based company)
without defining the equivalent in EUR.
"""
return 1.0
\ No newline at end of file
...@@ -287,7 +287,7 @@ class Movement(XMLObject, Amount): ...@@ -287,7 +287,7 @@ class Movement(XMLObject, Amount):
if quantity > 0.0: if quantity > 0.0:
return None # Outgoing quantity return None # Outgoing quantity
elif quantity < 0.0: elif quantity < 0.0:
return self.getPrice() * quantity # XXX: price should be converted to the source currency return self.getSourceAssetPrice() * quantity # XXX: price should be converted to the source currency
return None return None
security.declareProtected(Permissions.AccessContentsInformation, 'getDestinationInventoriatedTotalAssetPrice') security.declareProtected(Permissions.AccessContentsInformation, 'getDestinationInventoriatedTotalAssetPrice')
...@@ -304,9 +304,25 @@ class Movement(XMLObject, Amount): ...@@ -304,9 +304,25 @@ class Movement(XMLObject, Amount):
if quantity < 0.0: if quantity < 0.0:
return None # Outgoing quantity return None # Outgoing quantity
elif quantity > 0.0: elif quantity > 0.0:
return self.getPrice() * quantity # XXX: price should be converted to the dest. currency return self.getDestinationAssetPrice() * quantity # XXX: price should be converted to the dest. currency
return None return None
security.declareProtected(Permissions.AccessContentsInformation, 'getSourceAssetPrice')
def getSourceAssetPrice(self):
"""
Returns the price converted to the currency of the source section
This will be implemted by calling currency conversion on currency resources
"""
return self.getPrice() # XXX Not implemented yet
security.declareProtected(Permissions.AccessContentsInformation, 'getDestinationAssetPrice')
def getDestinationAssetPrice(self):
"""
Returns the price converted to the currency of the destination section
"""
return self.getPrice() # XXX Not implemented yet
# Causality computation # Causality computation
security.declareProtected(Permissions.View, 'isConvergent') security.declareProtected(Permissions.View, 'isConvergent')
def isConvergent(self): def isConvergent(self):
......
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