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

nobody at svn.erp5.org nobody at svn.erp5.org
Tue Oct 28 14:03:04 CET 2008


Author: mame
Date: Tue Oct 28 14:03:03 2008
New Revision: 24358

URL: http://svn.erp5.org?rev=24358&view=rev
Log:
modification on expand method to so that the asset_price won't be copied on the invoice lines

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=24358&r1=24357&r2=24358&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/InvoiceTransactionRule.py (original)
+++ erp5/trunk/products/ERP5/Document/InvoiceTransactionRule.py Tue Oct 28 14:03:03 2008
@@ -197,50 +197,38 @@
       #set asset_price on movement when resource is different from price
       #currency of the source/destination section
       currency = new_mvmt.getResourceValue()
-      if new_mvmt.AccountingTransaction_isDestinationCurrencyConvertible():
-        precision = \
-         new_mvmt.getDestinationSectionValue().getPriceCurrencyValue().\
+      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/currency_module/%s' %
-               new_mvmt.getDestinationSectionValue().getPriceCurrencyId(),
+	  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()))
-	if dest_exchange_ratio is None:
-	  raise AssertionError
-        new_mvmt.edit(destination_total_asset_price=round(
+	  if dest_exchange_ratio is not None:
+            new_mvmt.edit(destination_total_asset_price=round(
              (dest_exchange_ratio*
-           applied_rule.getParentValue().getTotalPrice()),precision))
-        relative_parent_movement = applied_rule.getParentValue()
-	relative_parent_movement.edit(destination_total_asset_price=\
-                 (new_mvmt.getDestinationTotalAssetPrice()))
-	relative_applied_rule = relative_parent_movement.getParentValue()
-	parent_movement = relative_applied_rule.getParentValue()
-	parent_movement.edit(destination_total_asset_price=\
-	               new_mvmt.getDestinationTotalAssetPrice())  
-      if new_mvmt.AccountingTransaction_isSourceCurrencyConvertible():
-	precision = \
-         new_mvmt.getSourceSectionValue().getPriceCurrencyValue().\
+              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/currency_module/%s' %
-        new_mvmt.getSourceSectionValue().getPriceCurrencyId(),
+	  source_exchange_ratio = \
+             currency.getPrice(context=new_mvmt.asContext(
+               categories=['price_currency/%s'
+             %new_mvmt.getSourceSectionValue().getPriceCurrency(),
 	    'resource/%s'%
             new_mvmt.getResourceRelativeUrl()],
             start_date=new_mvmt.getStartDate()))
-	if source_exchange_ratio is None:
-	  raise AssertionError
-        new_mvmt.setSourceTotalAssetPrice(round(
-    (source_exchange_ratio*applied_rule.getParentValue().getTotalPrice()),
+          if source_exchange_ratio is not None:
+            new_mvmt.setSourceTotalAssetPrice(round(
+       (source_exchange_ratio*applied_rule.getParentValue().getTotalPrice()),
             precision))
-	relative_parent_movement = applied_rule.getParentValue()
-	relative_parent_movement.setSourceTotalAssetPrice\
-                     (new_mvmt.getSourceTotalAssetPrice())
-	relative_applied_rule = relative_parent_movement.getParentValue()
-	parent_movement = relative_applied_rule.getParentValue()
-	parent_movement.setSourceTotalAssetPrice\
-	               (new_mvmt.getSourceTotalAssetPrice())
+	
     # Pass to base class
     Rule.expand(self, applied_rule, force=force, **kw)
   




More information about the Erp5-report mailing list