[Erp5-report] r32985 kazuhiko - /erp5/trunk/products/ERP5/Document/PaymentSimulationRule.py

nobody at svn.erp5.org nobody at svn.erp5.org
Tue Feb 23 06:14:19 CET 2010


Author: kazuhiko
Date: Tue Feb 23 06:14:19 2010
New Revision: 32985

URL: http://svn.erp5.org?rev=32985&view=rev
Log:
use payment conditions to calculate start_date, stop_date and quantity.

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

Modified: erp5/trunk/products/ERP5/Document/PaymentSimulationRule.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/PaymentSimulationRule.py?rev=32985&r1=32984&r2=32985&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/PaymentSimulationRule.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Document/PaymentSimulationRule.py [utf8] Tue Feb 23 06:14:19 2010
@@ -52,9 +52,19 @@
     based on its context (parent movement, delivery, configuration ...)
 
     These previsions are returned as dictionaries.
+
+    * source and destination (i.e. account) are provided by rule cells.
+    * start_date, stop_date and quantity are calculated according to
+      payment conditions.
     """
-    input_movement, business_path = self._getInputMovementAndPathTupleList(
-        applied_rule)[0]
+    # Find an input movement and using Payment Conditions.
+    # XXX we also need to support local Payment Conditions, that are not
+    # provided by BPM.
+    movement_and_tuple_list = self._getInputMovementAndPathTupleList(
+        applied_rule)
+    input_movement = movement_and_tuple_list[0][0]
+    payment_condition_list = [x[1] for x in movement_and_tuple_list]
+
     kw = self._getExpandablePropertyDict(applied_rule, input_movement, None)
     prevision_list = []
 
@@ -63,23 +73,26 @@
 
     if cell is not None : # else, we do nothing
       for payment_rule_cell_line in cell.objectValues():
-        prevision_line = kw.copy()
-        prevision_line.update(
-          source=payment_rule_cell_line.getSource() or \
-                 input_movement.getSource(),
-          destination=payment_rule_cell_line.getDestination() or \
-                 input_movement.getDestination(),
-          quantity=input_movement.getQuantity() * \
-                   payment_rule_cell_line.getQuantity()
-          )
-        # Generate Prevision Script is required for Payment Simulation Rule?
-        if payment_rule_cell_line.hasProperty(
-            'generate_prevision_script_id'):
-          generate_prevision_script_id = \
-                payment_rule_cell_line.getGeneratePrevisionScriptId()
-          prevision_line.update(getattr(input_movement,
-                              generate_prevision_script_id)(prevision_line))
-        prevision_list.append(prevision_line)
+        for payment_condition in payment_condition_list:
+          prevision_line = kw.copy()
+          prevision_line.update(
+            source=payment_rule_cell_line.getSource() or \
+                   input_movement.getSource(),
+            destination=payment_rule_cell_line.getDestination() or \
+                   input_movement.getDestination(),
+            start_date=payment_condition.getExpectedStartdate(input_movement),
+            stop_date=payment_condition.getExpectedStopdate(input_movement),
+            quantity=payment_condition.getExpectedQuantity(input_movement) * \
+                     payment_rule_cell_line.getQuantity()
+            )
+          # Generate Prevision Script is required for Payment Simulation Rule?
+          if payment_rule_cell_line.hasProperty(
+              'generate_prevision_script_id'):
+            generate_prevision_script_id = \
+                  payment_rule_cell_line.getGeneratePrevisionScriptId()
+            prevision_line.update(getattr(input_movement,
+                                generate_prevision_script_id)(prevision_line))
+          prevision_list.append(prevision_line)
     return prevision_list
 
   security.declareProtected(Permissions.ModifyPortalContent, 'expand')




More information about the Erp5-report mailing list