From 367fdee8c6cd8d9a3bc88975fad4cb6e07dddabd Mon Sep 17 00:00:00 2001
From: Kazuhiko Shiozaki <kazuhiko@nexedi.com>
Date: Tue, 2 Mar 2010 09:44:19 +0000
Subject: [PATCH] rename simulation rules according to the new naming
 convention.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@33255 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 ...yRule.py => DeliveryRootSimulationRule.py} |   6 +-
 .../DeliverySimulationRule.py                 | 113 ++++++++++++++++++
 ...ceRule.py => InvoiceRootSimulationRule.py} |   6 +-
 ...oicingRule.py => InvoiceSimulationRule.py} |   6 +-
 ...py => InvoiceTransactionSimulationRule.py} |   6 +-
 ...rderRule.py => OrderRootSimulationRule.py} |   6 +-
 ...aymentRule.py => PaymentSimulationRule.py} |   6 +-
 ...delRule.py => TradeModelSimulationRule.py} |   6 +-
 bt5/erp5_simulation/bt/revision               |   2 +-
 .../bt/template_document_id_list              |  15 +--
 10 files changed, 143 insertions(+), 29 deletions(-)
 rename bt5/erp5_simulation/DocumentTemplateItem/{DeliveryRule.py => DeliveryRootSimulationRule.py} (97%)
 create mode 100644 bt5/erp5_simulation/DocumentTemplateItem/DeliverySimulationRule.py
 rename bt5/erp5_simulation/DocumentTemplateItem/{InvoiceRule.py => InvoiceRootSimulationRule.py} (97%)
 rename bt5/erp5_simulation/DocumentTemplateItem/{InvoicingRule.py => InvoiceSimulationRule.py} (96%)
 rename bt5/erp5_simulation/DocumentTemplateItem/{InvoiceTransactionRule.py => InvoiceTransactionSimulationRule.py} (97%)
 rename bt5/erp5_simulation/DocumentTemplateItem/{OrderRule.py => OrderRootSimulationRule.py} (96%)
 rename bt5/erp5_simulation/DocumentTemplateItem/{PaymentRule.py => PaymentSimulationRule.py} (96%)
 rename bt5/erp5_simulation/DocumentTemplateItem/{TradeModelRule.py => TradeModelSimulationRule.py} (96%)

diff --git a/bt5/erp5_simulation/DocumentTemplateItem/DeliveryRule.py b/bt5/erp5_simulation/DocumentTemplateItem/DeliveryRootSimulationRule.py
similarity index 97%
rename from bt5/erp5_simulation/DocumentTemplateItem/DeliveryRule.py
rename to bt5/erp5_simulation/DocumentTemplateItem/DeliveryRootSimulationRule.py
index 6148e1fb80..8f8bf052de 100644
--- a/bt5/erp5_simulation/DocumentTemplateItem/DeliveryRule.py
+++ b/bt5/erp5_simulation/DocumentTemplateItem/DeliveryRootSimulationRule.py
@@ -38,7 +38,7 @@ from Products.ERP5.mixin.movement_collection_updater import \
      MovementCollectionUpdaterMixin
 from Products.ERP5.mixin.movement_generator import MovementGeneratorMixin
 
-class DeliveryRule(RuleMixin, MovementCollectionUpdaterMixin, Predicate):
+class DeliveryRootSimulationRule(RuleMixin, MovementCollectionUpdaterMixin, Predicate):
   """
   Delivery Rule object make sure an Delivery in the simulation
   is consistent with the real delivery
@@ -46,8 +46,8 @@ class DeliveryRule(RuleMixin, MovementCollectionUpdaterMixin, Predicate):
   WARNING: what to do with movement split ?
   """
   # CMF Type Definition
-  meta_type = 'ERP5 Delivery Rule'
-  portal_type = 'Delivery Rule'
+  meta_type = 'ERP5 Delivery Root Simulation Rule'
+  portal_type = 'Delivery Root Simulation Rule'
 
   # Declarative security
   security = ClassSecurityInfo()
diff --git a/bt5/erp5_simulation/DocumentTemplateItem/DeliverySimulationRule.py b/bt5/erp5_simulation/DocumentTemplateItem/DeliverySimulationRule.py
new file mode 100644
index 0000000000..830a42ec8c
--- /dev/null
+++ b/bt5/erp5_simulation/DocumentTemplateItem/DeliverySimulationRule.py
@@ -0,0 +1,113 @@
+##############################################################################
+#
+# Copyright (c) 2010 Nexedi SA and Contributors. All Rights Reserved.
+#
+# WARNING: This program as such is intended to be used by professional
+# programmers who take the whole responsibility of assessing all potential
+# consequences resulting from its eventual inadequacies and bugs
+# End users who are looking for a ready-to-use solution with commercial
+# guarantees and support are strongly adviced to contract a Free Software
+# Service Company
+#
+# This program is Free Software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+##############################################################################
+"""
+XXX This file is experimental for new simulation implementation, and
+will replace DeliveryRule.
+"""
+
+import zope.interface
+from AccessControl import ClassSecurityInfo
+from Products.ERP5Type import Permissions, PropertySheet, interfaces
+from Products.ERP5.Document.Predicate import Predicate
+from Products.ERP5.mixin.rule import RuleMixin
+from Products.ERP5.mixin.movement_collection_updater import \
+     MovementCollectionUpdaterMixin
+from Products.ERP5.mixin.movement_generator import MovementGeneratorMixin
+
+class DeliverySimulationRule(RuleMixin, MovementCollectionUpdaterMixin, Predicate):
+  """
+  Delivery Rule object make sure an Delivery in the simulation
+  is consistent with the real delivery
+
+  WARNING: what to do with movement split ?
+  """
+  # CMF Type Definition
+  meta_type = 'ERP5 Delivery Simulation Rule'
+  portal_type = 'Delivery Simulation Rule'
+
+  # Declarative security
+  security = ClassSecurityInfo()
+  security.declareObjectProtected(Permissions.AccessContentsInformation)
+
+  # Declarative interfaces
+  zope.interface.implements(interfaces.IRule,
+                            interfaces.IDivergenceController,
+                            interfaces.IMovementCollectionUpdater,)
+
+  # Default Properties
+  property_sheets = (
+    PropertySheet.Base,
+    PropertySheet.XMLObject,
+    PropertySheet.CategoryCore,
+    PropertySheet.DublinCore,
+    PropertySheet.Task,
+    PropertySheet.Predicate,
+    PropertySheet.Reference,
+    PropertySheet.Version,
+    PropertySheet.Rule
+    )
+
+  def _getMovementGenerator(self):
+    """
+    Return the movement generator to use in the expand process
+    """
+    return DeliveryRuleMovementGenerator()
+
+  def _getMovementGeneratorContext(self, context):
+    """
+    Return the movement generator context to use for expand
+    """
+    return context
+
+  def _getMovementGeneratorMovementList(self):
+    """
+    Return the movement lists to provide to the movement generator
+    """
+    return []
+
+  def _isProfitAndLossMovement(self, movement):
+    # For a kind of trade rule, a profit and loss movement lacks source
+    # or destination.
+    return (movement.getSource() is None or movement.getDestination() is None)
+
+class DeliveryRuleMovementGenerator(MovementGeneratorMixin):
+  def getGeneratedMovementList(self, context, movement_list=None,
+                                rounding=False):
+    """
+    Input movement list comes from the parent
+    """
+    ret = []
+    for input_movement, business_path in self \
+            ._getInputMovementAndPathTupleList(context):
+      kw = self._getPropertyAndCategoryList(input_movement, business_path)
+      kw.update({'order':None,'delivery':None})
+      simulation_movement = context.newContent(
+        portal_type=RuleMixin.movement_type,
+        temp_object=True,
+        **kw)
+      ret.append(simulation_movement)
+    return ret
diff --git a/bt5/erp5_simulation/DocumentTemplateItem/InvoiceRule.py b/bt5/erp5_simulation/DocumentTemplateItem/InvoiceRootSimulationRule.py
similarity index 97%
rename from bt5/erp5_simulation/DocumentTemplateItem/InvoiceRule.py
rename to bt5/erp5_simulation/DocumentTemplateItem/InvoiceRootSimulationRule.py
index 0fed6ec4a9..a79267eff0 100644
--- a/bt5/erp5_simulation/DocumentTemplateItem/InvoiceRule.py
+++ b/bt5/erp5_simulation/DocumentTemplateItem/InvoiceRootSimulationRule.py
@@ -38,14 +38,14 @@ from Products.ERP5.mixin.movement_collection_updater import \
      MovementCollectionUpdaterMixin
 from Products.ERP5.mixin.movement_generator import MovementGeneratorMixin
 
-class InvoiceRule(RuleMixin, MovementCollectionUpdaterMixin, Predicate):
+class InvoiceRootSimulationRule(RuleMixin, MovementCollectionUpdaterMixin, Predicate):
   """
   InvoiceRule and DeliveryRule seems to be identical. Keep it for
   compatibility only.
   """
   # CMF Type Definition
-  meta_type = 'ERP5 Invoice Rule'
-  portal_type = 'Invoice Rule'
+  meta_type = 'ERP5 Invoice Root Simulation Rule'
+  portal_type = 'Invoice Root Simulation Rule'
 
   # Declarative security
   security = ClassSecurityInfo()
diff --git a/bt5/erp5_simulation/DocumentTemplateItem/InvoicingRule.py b/bt5/erp5_simulation/DocumentTemplateItem/InvoiceSimulationRule.py
similarity index 96%
rename from bt5/erp5_simulation/DocumentTemplateItem/InvoicingRule.py
rename to bt5/erp5_simulation/DocumentTemplateItem/InvoiceSimulationRule.py
index 109940f190..78f5b55a4d 100644
--- a/bt5/erp5_simulation/DocumentTemplateItem/InvoicingRule.py
+++ b/bt5/erp5_simulation/DocumentTemplateItem/InvoiceSimulationRule.py
@@ -38,13 +38,13 @@ from Products.ERP5.mixin.movement_collection_updater import \
      MovementCollectionUpdaterMixin
 from Products.ERP5.mixin.movement_generator import MovementGeneratorMixin
 
-class InvoicingRule(RuleMixin, MovementCollectionUpdaterMixin, Predicate):
+class InvoiceSimulationRule(RuleMixin, MovementCollectionUpdaterMixin, Predicate):
   """
   Invoicing Rule expand simulation created by a order or delivery rule.
   """
   # CMF Type Definition
-  meta_type = 'ERP5 Invoicing Rule'
-  portal_type = 'Invoicing Rule'
+  meta_type = 'ERP5 Invoice Simulation Rule'
+  portal_type = 'Invoice Simulation Rule'
 
   # Declarative security
   security = ClassSecurityInfo()
diff --git a/bt5/erp5_simulation/DocumentTemplateItem/InvoiceTransactionRule.py b/bt5/erp5_simulation/DocumentTemplateItem/InvoiceTransactionSimulationRule.py
similarity index 97%
rename from bt5/erp5_simulation/DocumentTemplateItem/InvoiceTransactionRule.py
rename to bt5/erp5_simulation/DocumentTemplateItem/InvoiceTransactionSimulationRule.py
index 8e4d51ae2c..93851c40f0 100644
--- a/bt5/erp5_simulation/DocumentTemplateItem/InvoiceTransactionRule.py
+++ b/bt5/erp5_simulation/DocumentTemplateItem/InvoiceTransactionSimulationRule.py
@@ -39,7 +39,7 @@ from Products.ERP5.mixin.movement_collection_updater import \
 from Products.ERP5.Document.PredicateMatrix import PredicateMatrix
 from Products.ERP5.mixin.movement_generator import MovementGeneratorMixin
 
-class InvoiceTransactionRule(RuleMixin, MovementCollectionUpdaterMixin, Predicate, PredicateMatrix):
+class InvoiceTransactionSimulationRule(RuleMixin, MovementCollectionUpdaterMixin, Predicate, PredicateMatrix):
   """
   Invoice Transaction Rule object generates accounting movements for
   each invoice movement based on category membership and other
@@ -47,8 +47,8 @@ class InvoiceTransactionRule(RuleMixin, MovementCollectionUpdaterMixin, Predicat
   an instance of the InvoiceTransactionRule.
   """
   # CMF Type Definition
-  meta_type = 'ERP5 Invoice Transaction Rule'
-  portal_type = 'Invoice Transaction Rule'
+  meta_type = 'ERP5 Invoice Transaction Simulation Rule'
+  portal_type = 'Invoice Transaction Simulation Rule'
 
   # Declarative security
   security = ClassSecurityInfo()
diff --git a/bt5/erp5_simulation/DocumentTemplateItem/OrderRule.py b/bt5/erp5_simulation/DocumentTemplateItem/OrderRootSimulationRule.py
similarity index 96%
rename from bt5/erp5_simulation/DocumentTemplateItem/OrderRule.py
rename to bt5/erp5_simulation/DocumentTemplateItem/OrderRootSimulationRule.py
index 04c7160694..b278e2e365 100644
--- a/bt5/erp5_simulation/DocumentTemplateItem/OrderRule.py
+++ b/bt5/erp5_simulation/DocumentTemplateItem/OrderRootSimulationRule.py
@@ -38,7 +38,7 @@ from Products.ERP5.mixin.movement_collection_updater import \
      MovementCollectionUpdaterMixin
 from Products.ERP5.mixin.movement_generator import MovementGeneratorMixin
 
-class OrderRule(RuleMixin, MovementCollectionUpdaterMixin, Predicate):
+class OrderRootSimulationRule(RuleMixin, MovementCollectionUpdaterMixin, Predicate):
   """
   Order Rule object make sure an Order in the simulation
   is consistent with the real order
@@ -46,8 +46,8 @@ class OrderRule(RuleMixin, MovementCollectionUpdaterMixin, Predicate):
   WARNING: what to do with movement split ?
   """
   # CMF Type Definition
-  meta_type = 'ERP5 Order Rule'
-  portal_type = 'Order Rule'
+  meta_type = 'ERP5 Order Root Simulation Rule'
+  portal_type = 'Order Root Simulation Rule'
 
   # Declarative security
   security = ClassSecurityInfo()
diff --git a/bt5/erp5_simulation/DocumentTemplateItem/PaymentRule.py b/bt5/erp5_simulation/DocumentTemplateItem/PaymentSimulationRule.py
similarity index 96%
rename from bt5/erp5_simulation/DocumentTemplateItem/PaymentRule.py
rename to bt5/erp5_simulation/DocumentTemplateItem/PaymentSimulationRule.py
index 72c44b3805..c991a18ddf 100644
--- a/bt5/erp5_simulation/DocumentTemplateItem/PaymentRule.py
+++ b/bt5/erp5_simulation/DocumentTemplateItem/PaymentSimulationRule.py
@@ -38,14 +38,14 @@ from Products.ERP5.mixin.movement_collection_updater import \
      MovementCollectionUpdaterMixin
 from Products.ERP5.mixin.movement_generator import MovementGeneratorMixin
 
-class PaymentRule(RuleMixin, MovementCollectionUpdaterMixin, Predicate):
+class PaymentSimulationRule(RuleMixin, MovementCollectionUpdaterMixin, Predicate):
   """
   Payment Rule generates payment simulation movement from invoice
   transaction simulation movements.
   """
   # CMF Type Definition
-  meta_type = 'ERP5 Payment Rule'
-  portal_type = 'Payment Rule'
+  meta_type = 'ERP5 Payment Simulation Rule'
+  portal_type = 'Payment Simulation Rule'
 
   # Declarative security
   security = ClassSecurityInfo()
diff --git a/bt5/erp5_simulation/DocumentTemplateItem/TradeModelRule.py b/bt5/erp5_simulation/DocumentTemplateItem/TradeModelSimulationRule.py
similarity index 96%
rename from bt5/erp5_simulation/DocumentTemplateItem/TradeModelRule.py
rename to bt5/erp5_simulation/DocumentTemplateItem/TradeModelSimulationRule.py
index 4e15aeb3b2..5bf7dc8a61 100644
--- a/bt5/erp5_simulation/DocumentTemplateItem/TradeModelRule.py
+++ b/bt5/erp5_simulation/DocumentTemplateItem/TradeModelSimulationRule.py
@@ -38,13 +38,13 @@ from Products.ERP5.mixin.movement_collection_updater import \
      MovementCollectionUpdaterMixin
 from Products.ERP5.mixin.movement_generator import MovementGeneratorMixin
 
-class TradeModelRule(RuleMixin, MovementCollectionUpdaterMixin, Predicate):
+class TradeModelSimulationRule(RuleMixin, MovementCollectionUpdaterMixin, Predicate):
   """
     Rule for Trade Model
   """
   # CMF Type Definition
-  meta_type = 'ERP5 Trade Model Rule'
-  portal_type = 'Trade Model Rule'
+  meta_type = 'ERP5 Trade Model Simulation Rule'
+  portal_type = 'Trade Model Simulation Rule'
 
   # Declarative security
   security = ClassSecurityInfo()
diff --git a/bt5/erp5_simulation/bt/revision b/bt5/erp5_simulation/bt/revision
index 801f180102..31ff414b74 100644
--- a/bt5/erp5_simulation/bt/revision
+++ b/bt5/erp5_simulation/bt/revision
@@ -1 +1 @@
-47
\ No newline at end of file
+48
\ No newline at end of file
diff --git a/bt5/erp5_simulation/bt/template_document_id_list b/bt5/erp5_simulation/bt/template_document_id_list
index b782aceb29..56f1b71906 100644
--- a/bt5/erp5_simulation/bt/template_document_id_list
+++ b/bt5/erp5_simulation/bt/template_document_id_list
@@ -1,7 +1,8 @@
-DeliveryRule
-InvoiceRule
-InvoiceTransactionRule
-InvoicingRule
-OrderRule
-PaymentRule
-TradeModelRule
\ No newline at end of file
+DeliveryRootSimulationRule
+DeliverySimulationRule
+InvoiceRootSimulationRule
+InvoiceSimulationRule
+InvoiceTransactionSimulationRule
+OrderRootSimulationRule
+PaymentSimulationRule
+TradeModelSimulationRule
-- 
2.30.9