From 01e1ef23e35bc9b68a79d60ba94da8d4ab87a2e2 Mon Sep 17 00:00:00 2001
From: Kazuhiko Shiozaki <kazuhiko@nexedi.com>
Date: Mon, 15 Feb 2010 09:36:31 +0000
Subject: [PATCH] initial implementation of getExpectedQuantity().

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@32538 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5/Document/BusinessPath.py | 14 ++++++++++++++
 product/ERP5/Document/Rule.py         | 10 +++-------
 2 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/product/ERP5/Document/BusinessPath.py b/product/ERP5/Document/BusinessPath.py
index d373ef5d4c..c1c52950fa 100644
--- a/product/ERP5/Document/BusinessPath.py
+++ b/product/ERP5/Document/BusinessPath.py
@@ -406,6 +406,20 @@ class BusinessPath(Path):
           and self._isDeliverySimulationMovementRelated(
             explanation, simulation_movement)]
 
+  def getExpectedQuantity(self, explanation, *args, **kwargs):
+    """
+      Returns the expected stop date for this
+      path based on the explanation.
+
+      XXX predecessor_quantity argument is required?
+    """
+    if self.getQuantity():
+      return self.getQuantity()
+    elif self.getEfficiency():
+      return explanation.getQuantity() * self.getEfficiency()
+    else:
+      return explanation.getQuantity()
+
   def getExpectedStartDate(self, explanation, predecessor_date=None, *args, **kwargs):
     """
       Returns the expected start date for this
diff --git a/product/ERP5/Document/Rule.py b/product/ERP5/Document/Rule.py
index 8ee090a654..a8193562d7 100644
--- a/product/ERP5/Document/Rule.py
+++ b/product/ERP5/Document/Rule.py
@@ -588,15 +588,11 @@ class Rule(Predicate, XMLObject):
         property_dict['%s_list' % base_category] = [category_url]
       else:
         property_dict['%s_list' % base_category] = []
+
     # Amount
-    if business_path.getQuantity():
-      property_dict['quantity'] = business_path.getQuantity()
-    elif business_path.getEfficiency():
-      property_dict['quantity'] = movement.getQuantity() *\
-        business_path.getEfficiency()
-    else:
-      property_dict['quantity'] = movement.getQuantity()
+    property_dict['quantity'] = business_path.getExpectedQuantity()
 
+    # Date
     if movement.getStartDate() == movement.getStopDate():
       property_dict['start_date'] = business_path.getExpectedStartDate(
           movement)
-- 
2.30.9