[Erp5-report] r24562 - /erp5/trunk/products/ERP5/Document/InvoiceTransactionRule.py

nobody at svn.erp5.org nobody at svn.erp5.org
Wed Nov 12 16:45:48 CET 2008


Author: kazuhiko
Date: Wed Nov 12 16:45:44 2008
New Revision: 24562

URL: http://svn.erp5.org?rev=24562&view=rev
Log:
instead of using AccountingTransaction_isDestinationCurrencyConvertible
for Simulation Movement, implement the same logic here.

Modified:
    erp5/trunk/products/ERP5/Document/InvoiceTransactionRule.py

Modified: erp5/trunk/products/ERP5/Document/InvoiceTransactionRule.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/InvoiceTransactionRule.py?rev=24562&r1=24561&r2=24562&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/InvoiceTransactionRule.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Document/InvoiceTransactionRule.py [utf8] Wed Nov 12 16:45:44 2008
@@ -198,31 +198,33 @@
       #currency of the source/destination section
       currency = new_mvmt.getResourceValue()
       if currency is not None:
-        if new_mvmt.AccountingTransaction_isDestinationCurrencyConvertible():
-          precision = \
-           new_mvmt.getDestinationSectionValue().getPriceCurrencyValue().\
-                      getQuantityPrecision()
-	  dest_exchange_ratio = \
-            currency.getPrice(context=new_mvmt.asContext(
-                      categories=['price_currency/%s'
-                 %new_mvmt.getDestinationSectionValue().getPriceCurrency(),
-	      'resource/%s'% new_mvmt.getResourceRelativeUrl()],
-              start_date=new_mvmt.getStopDate()))
+        currency_url = currency.getRelativeUrl()
+        dest_section = new_mvmt.getDestinationSectionValue()
+        if dest_section is not None:
+          dest_currency = dest_section.getPriceCurrencyValue()
+        else:
+          dest_currency = None
+        if dest_currency is not None and currency != dest_currency:
+          precision = dest_currency.getQuantityPrecision()
+	  dest_exchange_ratio = currency.getPrice(context=new_mvmt.asContext(
+            categories=['price_currency/%s' % dest_currency.getRelativeUrl(),
+                        'resource/%s' % currency_url],
+            start_date=new_mvmt.getStartDate()))
 	  if dest_exchange_ratio is not None:
             new_mvmt.edit(destination_total_asset_price=round(
              (dest_exchange_ratio*
               applied_rule.getParentValue().getTotalPrice()),precision))
-	     
-        if new_mvmt.AccountingTransaction_isSourceCurrencyConvertible():
-	  precision = \
-           new_mvmt.getSourceSectionValue().getPriceCurrencyValue().\
-                      getQuantityPrecision()
-	  source_exchange_ratio = \
-             currency.getPrice(context=new_mvmt.asContext(
-               categories=['price_currency/%s'
-             %new_mvmt.getSourceSectionValue().getPriceCurrency(),
-	    'resource/%s'%
-            new_mvmt.getResourceRelativeUrl()],
+
+        source_section = new_mvmt.getSourceSectionValue()
+        if source_section is not None:
+          source_currency = source_section.getPriceCurrencyValue()
+        else:
+          source_currency = None
+        if source_currency is not None and currency != source_currency:
+	  precision = source_currency.getQuantityPrecision()
+	  source_exchange_ratio = currency.getPrice(context=new_mvmt.asContext(
+            categories=['price_currency/%s' % source_currency.getRelativeUrl(),
+                        'resource/%s' % currency_url],
             start_date=new_mvmt.getStartDate()))
           if source_exchange_ratio is not None:
             new_mvmt.setSourceTotalAssetPrice(round(




More information about the Erp5-report mailing list