Commit b985a7b5 authored by Xiaowu Zhang's avatar Xiaowu Zhang

Movement: use start date for source and stop date for destination and rename variable

parent 351b887a
...@@ -47,15 +47,15 @@ from Products.ERP5Type.Cache import transactional_cached ...@@ -47,15 +47,15 @@ from Products.ERP5Type.Cache import transactional_cached
from zLOG import LOG, WARNING from zLOG import LOG, WARNING
@transactional_cached() @transactional_cached()
def getExchangeRate(source_currency_value, section_currency, start_date): def getExchangeRate(currency_value, section_currency, date):
source_currency = source_currency_value.getRelativeUrl() currency = currency_value.getRelativeUrl()
if source_currency != section_currency: if currency != section_currency:
from Products.ERP5Type.Document import newTempAccountingTransactionLine from Products.ERP5Type.Document import newTempAccountingTransactionLine
return source_currency_value.getPrice(context=newTempAccountingTransactionLine( return currency_value.getPrice(context=newTempAccountingTransactionLine(
source_currency_value.getPortalObject(), currency_value.getPortalObject(),
"accounting_line", "accounting_line",
resource=source_currency, resource=currency,
start_date=start_date, start_date=date,
price_currency=section_currency price_currency=section_currency
)) ))
...@@ -501,7 +501,7 @@ class Movement(XMLObject, Amount, CompositionMixin, AmountGeneratorMixin): ...@@ -501,7 +501,7 @@ class Movement(XMLObject, Amount, CompositionMixin, AmountGeneratorMixin):
type_based_script = self._getTypeBasedMethod('getSourceAssetPrice') type_based_script = self._getTypeBasedMethod('getSourceAssetPrice')
if type_based_script: if type_based_script:
return type_based_script() return type_based_script()
return self._getAssetPrice(section = self.getSourceSectionValue()) return self._getAssetPrice(section = self.getSourceSectionValue(), date = self.getStartDate())
security.declareProtected( Permissions.AccessContentsInformation, security.declareProtected( Permissions.AccessContentsInformation,
'getDestinationAssetPrice') 'getDestinationAssetPrice')
...@@ -512,18 +512,18 @@ class Movement(XMLObject, Amount, CompositionMixin, AmountGeneratorMixin): ...@@ -512,18 +512,18 @@ class Movement(XMLObject, Amount, CompositionMixin, AmountGeneratorMixin):
type_based_script = self._getTypeBasedMethod('getDestinationAssetPrice') type_based_script = self._getTypeBasedMethod('getDestinationAssetPrice')
if type_based_script: if type_based_script:
return type_based_script() return type_based_script()
return self._getAssetPrice(section = self.getDestinationSectionValue()) return self._getAssetPrice(section = self.getDestinationSectionValue(), date = self.getStopDate())
def _getAssetPrice(self,section): def _getAssetPrice(self,section,date):
price = self.getPrice() price = self.getPrice()
if section is None or not price: if section is None or not price:
return price return price
source_currency_value = self.getPriceCurrencyValue() currency_value = self.getPriceCurrencyValue()
if source_currency_value: if currency_value:
section_currency = section.getPriceCurrency() section_currency = section.getPriceCurrency()
if section_currency: if section_currency:
exchange_rate = getExchangeRate( exchange_rate = getExchangeRate(
source_currency_value, section_currency, self.getStartDate()) currency_value, section_currency, date)
if exchange_rate: if exchange_rate:
return exchange_rate * price return exchange_rate * price
return price return price
......
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