From 7cec0b7527a71e434ec6fb52398827192f47c6db Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C5=81ukasz=20Nowak?= <luke@nexedi.com>
Date: Mon, 19 Nov 2012 14:42:30 +0100
Subject: [PATCH] Rebrand default_payment_rule

---
 .../slapos_payment_simulation_rule.xml}       |  49 +++++++-
 .../destination_payment_tester.xml            |   0
 .../destination_project_tester.xml            |   0
 .../destination_section_tester.xml            |   0
 .../destination_tester.xml                    |   0
 .../payment_mode_tester.xml                   |   0
 .../price_tester.xml                          |   0
 .../quantity_tester.xml                       |   0
 .../resource_tester.xml                       |   0
 .../source_payment_tester.xml                 |   0
 .../source_project_tester.xml                 |   0
 .../source_section_tester.xml                 |   0
 .../source_tester.xml                         |   0
 .../specialise_tester.xml                     |   0
 .../start_date_tester.xml                     |   0
 .../stop_date_tester.xml                      |   0
 ...UpdateHostingSubscriptionOpenSaleOrder.xml |   5 +-
 ...ostingSubscriptionForOpenSaleOrderLine.xml |  75 +++++++++++
 ...ubscription_requestUpdateOpenSaleOrder.xml |   1 -
 ...tionMovement_testPaymentSimulationRule.xml |   0
 ...teHostingSubscriptionOpenSaleOrderAlarm.py | 116 +++++++++++++++++-
 master/bt5/slapos_accounting/bt/revision      |   2 +-
 .../bt/template_keep_workflow_path_list       |   3 +-
 .../slapos_accounting/bt/template_path_list   |   2 +
 master/bt5/vifib_base/bt/revision             |   2 +-
 master/bt5/vifib_data_simulation/bt/revision  |   2 +-
 .../bt/template_keep_workflow_path_list       |   3 +-
 .../bt/template_path_list                     |   2 -
 28 files changed, 243 insertions(+), 19 deletions(-)
 rename master/bt5/{vifib_data_simulation/PathTemplateItem/portal_rules/vifib_payment_simulation_rule.xml => slapos_accounting/PathTemplateItem/portal_rules/slapos_payment_simulation_rule.xml} (94%)
 rename master/bt5/{vifib_data_simulation/PathTemplateItem/portal_rules/vifib_payment_simulation_rule => slapos_accounting/PathTemplateItem/portal_rules/slapos_payment_simulation_rule}/destination_payment_tester.xml (100%)
 rename master/bt5/{vifib_data_simulation/PathTemplateItem/portal_rules/vifib_payment_simulation_rule => slapos_accounting/PathTemplateItem/portal_rules/slapos_payment_simulation_rule}/destination_project_tester.xml (100%)
 rename master/bt5/{vifib_data_simulation/PathTemplateItem/portal_rules/vifib_payment_simulation_rule => slapos_accounting/PathTemplateItem/portal_rules/slapos_payment_simulation_rule}/destination_section_tester.xml (100%)
 rename master/bt5/{vifib_data_simulation/PathTemplateItem/portal_rules/vifib_payment_simulation_rule => slapos_accounting/PathTemplateItem/portal_rules/slapos_payment_simulation_rule}/destination_tester.xml (100%)
 rename master/bt5/{vifib_data_simulation/PathTemplateItem/portal_rules/vifib_payment_simulation_rule => slapos_accounting/PathTemplateItem/portal_rules/slapos_payment_simulation_rule}/payment_mode_tester.xml (100%)
 rename master/bt5/{vifib_data_simulation/PathTemplateItem/portal_rules/vifib_payment_simulation_rule => slapos_accounting/PathTemplateItem/portal_rules/slapos_payment_simulation_rule}/price_tester.xml (100%)
 rename master/bt5/{vifib_data_simulation/PathTemplateItem/portal_rules/vifib_payment_simulation_rule => slapos_accounting/PathTemplateItem/portal_rules/slapos_payment_simulation_rule}/quantity_tester.xml (100%)
 rename master/bt5/{vifib_data_simulation/PathTemplateItem/portal_rules/vifib_payment_simulation_rule => slapos_accounting/PathTemplateItem/portal_rules/slapos_payment_simulation_rule}/resource_tester.xml (100%)
 rename master/bt5/{vifib_data_simulation/PathTemplateItem/portal_rules/vifib_payment_simulation_rule => slapos_accounting/PathTemplateItem/portal_rules/slapos_payment_simulation_rule}/source_payment_tester.xml (100%)
 rename master/bt5/{vifib_data_simulation/PathTemplateItem/portal_rules/vifib_payment_simulation_rule => slapos_accounting/PathTemplateItem/portal_rules/slapos_payment_simulation_rule}/source_project_tester.xml (100%)
 rename master/bt5/{vifib_data_simulation/PathTemplateItem/portal_rules/vifib_payment_simulation_rule => slapos_accounting/PathTemplateItem/portal_rules/slapos_payment_simulation_rule}/source_section_tester.xml (100%)
 rename master/bt5/{vifib_data_simulation/PathTemplateItem/portal_rules/vifib_payment_simulation_rule => slapos_accounting/PathTemplateItem/portal_rules/slapos_payment_simulation_rule}/source_tester.xml (100%)
 rename master/bt5/{vifib_data_simulation/PathTemplateItem/portal_rules/vifib_payment_simulation_rule => slapos_accounting/PathTemplateItem/portal_rules/slapos_payment_simulation_rule}/specialise_tester.xml (100%)
 rename master/bt5/{vifib_data_simulation/PathTemplateItem/portal_rules/vifib_payment_simulation_rule => slapos_accounting/PathTemplateItem/portal_rules/slapos_payment_simulation_rule}/start_date_tester.xml (100%)
 rename master/bt5/{vifib_data_simulation/PathTemplateItem/portal_rules/vifib_payment_simulation_rule => slapos_accounting/PathTemplateItem/portal_rules/slapos_payment_simulation_rule}/stop_date_tester.xml (100%)
 create mode 100644 master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_accounting/Base_getHostingSubscriptionForOpenSaleOrderLine.xml
 rename master/bt5/{vifib_base/SkinTemplateItem/portal_skins/vifib_simulation => slapos_accounting/SkinTemplateItem/portal_skins/slapos_simulation}/SimulationMovement_testPaymentSimulationRule.xml (100%)

diff --git a/master/bt5/vifib_data_simulation/PathTemplateItem/portal_rules/vifib_payment_simulation_rule.xml b/master/bt5/slapos_accounting/PathTemplateItem/portal_rules/slapos_payment_simulation_rule.xml
similarity index 94%
rename from master/bt5/vifib_data_simulation/PathTemplateItem/portal_rules/vifib_payment_simulation_rule.xml
rename to master/bt5/slapos_accounting/PathTemplateItem/portal_rules/slapos_payment_simulation_rule.xml
index 0b0627d5c..c644eb432 100644
--- a/master/bt5/vifib_data_simulation/PathTemplateItem/portal_rules/vifib_payment_simulation_rule.xml
+++ b/master/bt5/slapos_accounting/PathTemplateItem/portal_rules/slapos_payment_simulation_rule.xml
@@ -134,7 +134,7 @@
         </item>
         <item>
             <key> <string>id</string> </key>
-            <value> <string>vifib_payment_simulation_rule</string> </value>
+            <value> <string>slapos_payment_simulation_rule</string> </value>
         </item>
         <item>
             <key> <string>index</string> </key>
@@ -211,7 +211,7 @@
         </item>
         <item>
             <key> <string>title</string> </key>
-            <value> <string>Vifib Payment Simulation Rule</string> </value>
+            <value> <string>SlapOS Payment Simulation Rule</string> </value>
         </item>
         <item>
             <key> <string>version</string> </key>
@@ -818,6 +818,51 @@
                 </value>
             </item>
           </dictionary>
+          <dictionary>
+            <item>
+                <key> <string>action</string> </key>
+                <value> <string>edit</string> </value>
+            </item>
+            <item>
+                <key> <string>actor</string> </key>
+                <value> <string>zope</string> </value>
+            </item>
+            <item>
+                <key> <string>comment</string> </key>
+                <value>
+                  <none/>
+                </value>
+            </item>
+            <item>
+                <key> <string>error_message</string> </key>
+                <value> <string></string> </value>
+            </item>
+            <item>
+                <key> <string>serial</string> </key>
+                <value> <string>922.45108.39363.35447</string> </value>
+            </item>
+            <item>
+                <key> <string>state</string> </key>
+                <value> <string>current</string> </value>
+            </item>
+            <item>
+                <key> <string>time</string> </key>
+                <value>
+                  <object>
+                    <klass> <reference id="10.1"/> </klass>
+                    <tuple>
+                      <none/>
+                    </tuple>
+                    <state>
+                      <tuple>
+                        <float>1353332454.35</float>
+                        <string>GMT+1</string>
+                      </tuple>
+                    </state>
+                  </object>
+                </value>
+            </item>
+          </dictionary>
         </list>
       </tuple>
     </pickle>
diff --git a/master/bt5/vifib_data_simulation/PathTemplateItem/portal_rules/vifib_payment_simulation_rule/destination_payment_tester.xml b/master/bt5/slapos_accounting/PathTemplateItem/portal_rules/slapos_payment_simulation_rule/destination_payment_tester.xml
similarity index 100%
rename from master/bt5/vifib_data_simulation/PathTemplateItem/portal_rules/vifib_payment_simulation_rule/destination_payment_tester.xml
rename to master/bt5/slapos_accounting/PathTemplateItem/portal_rules/slapos_payment_simulation_rule/destination_payment_tester.xml
diff --git a/master/bt5/vifib_data_simulation/PathTemplateItem/portal_rules/vifib_payment_simulation_rule/destination_project_tester.xml b/master/bt5/slapos_accounting/PathTemplateItem/portal_rules/slapos_payment_simulation_rule/destination_project_tester.xml
similarity index 100%
rename from master/bt5/vifib_data_simulation/PathTemplateItem/portal_rules/vifib_payment_simulation_rule/destination_project_tester.xml
rename to master/bt5/slapos_accounting/PathTemplateItem/portal_rules/slapos_payment_simulation_rule/destination_project_tester.xml
diff --git a/master/bt5/vifib_data_simulation/PathTemplateItem/portal_rules/vifib_payment_simulation_rule/destination_section_tester.xml b/master/bt5/slapos_accounting/PathTemplateItem/portal_rules/slapos_payment_simulation_rule/destination_section_tester.xml
similarity index 100%
rename from master/bt5/vifib_data_simulation/PathTemplateItem/portal_rules/vifib_payment_simulation_rule/destination_section_tester.xml
rename to master/bt5/slapos_accounting/PathTemplateItem/portal_rules/slapos_payment_simulation_rule/destination_section_tester.xml
diff --git a/master/bt5/vifib_data_simulation/PathTemplateItem/portal_rules/vifib_payment_simulation_rule/destination_tester.xml b/master/bt5/slapos_accounting/PathTemplateItem/portal_rules/slapos_payment_simulation_rule/destination_tester.xml
similarity index 100%
rename from master/bt5/vifib_data_simulation/PathTemplateItem/portal_rules/vifib_payment_simulation_rule/destination_tester.xml
rename to master/bt5/slapos_accounting/PathTemplateItem/portal_rules/slapos_payment_simulation_rule/destination_tester.xml
diff --git a/master/bt5/vifib_data_simulation/PathTemplateItem/portal_rules/vifib_payment_simulation_rule/payment_mode_tester.xml b/master/bt5/slapos_accounting/PathTemplateItem/portal_rules/slapos_payment_simulation_rule/payment_mode_tester.xml
similarity index 100%
rename from master/bt5/vifib_data_simulation/PathTemplateItem/portal_rules/vifib_payment_simulation_rule/payment_mode_tester.xml
rename to master/bt5/slapos_accounting/PathTemplateItem/portal_rules/slapos_payment_simulation_rule/payment_mode_tester.xml
diff --git a/master/bt5/vifib_data_simulation/PathTemplateItem/portal_rules/vifib_payment_simulation_rule/price_tester.xml b/master/bt5/slapos_accounting/PathTemplateItem/portal_rules/slapos_payment_simulation_rule/price_tester.xml
similarity index 100%
rename from master/bt5/vifib_data_simulation/PathTemplateItem/portal_rules/vifib_payment_simulation_rule/price_tester.xml
rename to master/bt5/slapos_accounting/PathTemplateItem/portal_rules/slapos_payment_simulation_rule/price_tester.xml
diff --git a/master/bt5/vifib_data_simulation/PathTemplateItem/portal_rules/vifib_payment_simulation_rule/quantity_tester.xml b/master/bt5/slapos_accounting/PathTemplateItem/portal_rules/slapos_payment_simulation_rule/quantity_tester.xml
similarity index 100%
rename from master/bt5/vifib_data_simulation/PathTemplateItem/portal_rules/vifib_payment_simulation_rule/quantity_tester.xml
rename to master/bt5/slapos_accounting/PathTemplateItem/portal_rules/slapos_payment_simulation_rule/quantity_tester.xml
diff --git a/master/bt5/vifib_data_simulation/PathTemplateItem/portal_rules/vifib_payment_simulation_rule/resource_tester.xml b/master/bt5/slapos_accounting/PathTemplateItem/portal_rules/slapos_payment_simulation_rule/resource_tester.xml
similarity index 100%
rename from master/bt5/vifib_data_simulation/PathTemplateItem/portal_rules/vifib_payment_simulation_rule/resource_tester.xml
rename to master/bt5/slapos_accounting/PathTemplateItem/portal_rules/slapos_payment_simulation_rule/resource_tester.xml
diff --git a/master/bt5/vifib_data_simulation/PathTemplateItem/portal_rules/vifib_payment_simulation_rule/source_payment_tester.xml b/master/bt5/slapos_accounting/PathTemplateItem/portal_rules/slapos_payment_simulation_rule/source_payment_tester.xml
similarity index 100%
rename from master/bt5/vifib_data_simulation/PathTemplateItem/portal_rules/vifib_payment_simulation_rule/source_payment_tester.xml
rename to master/bt5/slapos_accounting/PathTemplateItem/portal_rules/slapos_payment_simulation_rule/source_payment_tester.xml
diff --git a/master/bt5/vifib_data_simulation/PathTemplateItem/portal_rules/vifib_payment_simulation_rule/source_project_tester.xml b/master/bt5/slapos_accounting/PathTemplateItem/portal_rules/slapos_payment_simulation_rule/source_project_tester.xml
similarity index 100%
rename from master/bt5/vifib_data_simulation/PathTemplateItem/portal_rules/vifib_payment_simulation_rule/source_project_tester.xml
rename to master/bt5/slapos_accounting/PathTemplateItem/portal_rules/slapos_payment_simulation_rule/source_project_tester.xml
diff --git a/master/bt5/vifib_data_simulation/PathTemplateItem/portal_rules/vifib_payment_simulation_rule/source_section_tester.xml b/master/bt5/slapos_accounting/PathTemplateItem/portal_rules/slapos_payment_simulation_rule/source_section_tester.xml
similarity index 100%
rename from master/bt5/vifib_data_simulation/PathTemplateItem/portal_rules/vifib_payment_simulation_rule/source_section_tester.xml
rename to master/bt5/slapos_accounting/PathTemplateItem/portal_rules/slapos_payment_simulation_rule/source_section_tester.xml
diff --git a/master/bt5/vifib_data_simulation/PathTemplateItem/portal_rules/vifib_payment_simulation_rule/source_tester.xml b/master/bt5/slapos_accounting/PathTemplateItem/portal_rules/slapos_payment_simulation_rule/source_tester.xml
similarity index 100%
rename from master/bt5/vifib_data_simulation/PathTemplateItem/portal_rules/vifib_payment_simulation_rule/source_tester.xml
rename to master/bt5/slapos_accounting/PathTemplateItem/portal_rules/slapos_payment_simulation_rule/source_tester.xml
diff --git a/master/bt5/vifib_data_simulation/PathTemplateItem/portal_rules/vifib_payment_simulation_rule/specialise_tester.xml b/master/bt5/slapos_accounting/PathTemplateItem/portal_rules/slapos_payment_simulation_rule/specialise_tester.xml
similarity index 100%
rename from master/bt5/vifib_data_simulation/PathTemplateItem/portal_rules/vifib_payment_simulation_rule/specialise_tester.xml
rename to master/bt5/slapos_accounting/PathTemplateItem/portal_rules/slapos_payment_simulation_rule/specialise_tester.xml
diff --git a/master/bt5/vifib_data_simulation/PathTemplateItem/portal_rules/vifib_payment_simulation_rule/start_date_tester.xml b/master/bt5/slapos_accounting/PathTemplateItem/portal_rules/slapos_payment_simulation_rule/start_date_tester.xml
similarity index 100%
rename from master/bt5/vifib_data_simulation/PathTemplateItem/portal_rules/vifib_payment_simulation_rule/start_date_tester.xml
rename to master/bt5/slapos_accounting/PathTemplateItem/portal_rules/slapos_payment_simulation_rule/start_date_tester.xml
diff --git a/master/bt5/vifib_data_simulation/PathTemplateItem/portal_rules/vifib_payment_simulation_rule/stop_date_tester.xml b/master/bt5/slapos_accounting/PathTemplateItem/portal_rules/slapos_payment_simulation_rule/stop_date_tester.xml
similarity index 100%
rename from master/bt5/vifib_data_simulation/PathTemplateItem/portal_rules/vifib_payment_simulation_rule/stop_date_tester.xml
rename to master/bt5/slapos_accounting/PathTemplateItem/portal_rules/slapos_payment_simulation_rule/stop_date_tester.xml
diff --git a/master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_accounting/Alarm_requestUpdateHostingSubscriptionOpenSaleOrder.xml b/master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_accounting/Alarm_requestUpdateHostingSubscriptionOpenSaleOrder.xml
index 0f5b7a693..a8ad83843 100644
--- a/master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_accounting/Alarm_requestUpdateHostingSubscriptionOpenSaleOrder.xml
+++ b/master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_accounting/Alarm_requestUpdateHostingSubscriptionOpenSaleOrder.xml
@@ -51,11 +51,12 @@
         <item>
             <key> <string>_body</string> </key>
             <value> <string>portal = context.getPortalObject()\n
+path_list = [q.PATH for q in portal.Base_getHostingSubscriptionForOpenSaleOrderLine(hosting_subscription_validation_state=\'validated\', open_sale_order_line_validation_state=\'validated\')]\n
+path_list.extend([q.PATH for q in portal.Base_getHostingSubscriptionForOpenSaleOrderLine(hosting_subscription_validation_state=\'archived\', open_sale_order_line_validation_state=\'invalidated\')])\n
 \n
 portal.portal_catalog.searchAndActivate(\n
   method_id=\'HostingSubscription_requestUpdateOpenSaleOrder\',\n
-  portal_type="Hosting Subscription",\n
-  causality_state="diverged",\n
+  path=path_list,\n
   activate_kw={\'tag\': tag},\n
   packet_size=1, # HostingSubscription_trigger_Person_storeOpenSaleOrderJournal\n
 )\n
diff --git a/master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_accounting/Base_getHostingSubscriptionForOpenSaleOrderLine.xml b/master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_accounting/Base_getHostingSubscriptionForOpenSaleOrderLine.xml
new file mode 100644
index 000000000..faaa243d0
--- /dev/null
+++ b/master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_accounting/Base_getHostingSubscriptionForOpenSaleOrderLine.xml
@@ -0,0 +1,75 @@
+<?xml version="1.0"?>
+<ZopeData>
+  <record id="1" aka="AAAAAAAAAAE=">
+    <pickle>
+      <global name="SQL" module="Products.ZSQLMethods.SQL"/>
+    </pickle>
+    <pickle>
+      <dictionary>
+        <item>
+            <key> <string>allow_simple_one_argument_traversal</string> </key>
+            <value>
+              <none/>
+            </value>
+        </item>
+        <item>
+            <key> <string>arguments_src</string> </key>
+            <value> <string>hosting_subscription_validation_state\r\n
+open_sale_order_line_validation_state</string> </value>
+        </item>
+        <item>
+            <key> <string>cache_time_</string> </key>
+            <value> <int>0</int> </value>
+        </item>
+        <item>
+            <key> <string>class_file_</string> </key>
+            <value> <string>ZSQLCatalog.zsqlbrain</string> </value>
+        </item>
+        <item>
+            <key> <string>class_name_</string> </key>
+            <value> <string>ZSQLBrain</string> </value>
+        </item>
+        <item>
+            <key> <string>connection_hook</string> </key>
+            <value> <string></string> </value>
+        </item>
+        <item>
+            <key> <string>connection_id</string> </key>
+            <value> <string>erp5_sql_connection</string> </value>
+        </item>
+        <item>
+            <key> <string>id</string> </key>
+            <value> <string>Base_getHostingSubscriptionForOpenSaleOrderLine</string> </value>
+        </item>
+        <item>
+            <key> <string>max_cache_</string> </key>
+            <value> <int>100</int> </value>
+        </item>
+        <item>
+            <key> <string>max_rows_</string> </key>
+            <value> <int>1000</int> </value>
+        </item>
+        <item>
+            <key> <string>src</string> </key>
+            <value> <string encoding="cdata"><![CDATA[
+
+SELECT\n
+  catalog.uid, catalog.path\n
+FROM catalog\n
+  LEFT JOIN category ON category.category_uid=catalog.uid AND category.base_category_uid=<dtml-var "portal_categories.aggregate.getUid()">\n
+  LEFT JOIN catalog AS order_catalog ON order_catalog.uid=category.uid AND order_catalog.portal_type=\'Open Sale Order Line\' AND order_catalog.validation_state=<dtml-sqlvar open_sale_order_line_validation_state type="string">\n
+WHERE catalog.portal_type=\'Hosting Subscription\' and catalog.validation_state=<dtml-sqlvar hosting_subscription_validation_state type="string">\n
+GROUP BY catalog.uid\n
+HAVING count(order_catalog.uid) = 0\n
+
+
+]]></string> </value>
+        </item>
+        <item>
+            <key> <string>title</string> </key>
+            <value> <string></string> </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+</ZopeData>
diff --git a/master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_accounting/HostingSubscription_requestUpdateOpenSaleOrder.xml b/master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_accounting/HostingSubscription_requestUpdateOpenSaleOrder.xml
index c89d4d4e4..5c9ad6698 100644
--- a/master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_accounting/HostingSubscription_requestUpdateOpenSaleOrder.xml
+++ b/master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_accounting/HostingSubscription_requestUpdateOpenSaleOrder.xml
@@ -53,7 +53,6 @@
             <value> <string>person = context.getDestinationSectionValue()\n
 if person is not None:\n
   person.Person_storeOpenSaleOrderJournal()\n
-context.converge()\n
 </string> </value>
         </item>
         <item>
diff --git a/master/bt5/vifib_base/SkinTemplateItem/portal_skins/vifib_simulation/SimulationMovement_testPaymentSimulationRule.xml b/master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_simulation/SimulationMovement_testPaymentSimulationRule.xml
similarity index 100%
rename from master/bt5/vifib_base/SkinTemplateItem/portal_skins/vifib_simulation/SimulationMovement_testPaymentSimulationRule.xml
rename to master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_simulation/SimulationMovement_testPaymentSimulationRule.xml
diff --git a/master/bt5/slapos_accounting/TestTemplateItem/testSlapOSAccountingSlapOSRequestUpdateHostingSubscriptionOpenSaleOrderAlarm.py b/master/bt5/slapos_accounting/TestTemplateItem/testSlapOSAccountingSlapOSRequestUpdateHostingSubscriptionOpenSaleOrderAlarm.py
index c6adc0881..bf5c8bc4a 100644
--- a/master/bt5/slapos_accounting/TestTemplateItem/testSlapOSAccountingSlapOSRequestUpdateHostingSubscriptionOpenSaleOrderAlarm.py
+++ b/master/bt5/slapos_accounting/TestTemplateItem/testSlapOSAccountingSlapOSRequestUpdateHostingSubscriptionOpenSaleOrderAlarm.py
@@ -83,10 +83,11 @@ class TestOpenSaleOrderAlarm(testSlapOSMixin):
         for q in open_sale_order_template.getCategoryList()]))
 
   @simulateHostingSubscription_requestUpdateOpenSaleOrder
-  def test_alarm_HS_diverged(self):
+  def test_alarm_HS_validated(self):
     subscription = self.portal.hosting_subscription_module\
         .template_hosting_subscription.Base_createCloneDocument(batch_mode=1)
     subscription.edit(reference='TESTHS-%s' % self.generateNewId())
+    self.portal.portal_workflow._jumpToStateFor(subscription, 'validated')
     self.tic()
 
     self.portal.portal_alarms\
@@ -97,6 +98,114 @@ class TestOpenSaleOrderAlarm(testSlapOSMixin):
         'Visited by HostingSubscription_requestUpdateOpenSaleOrder',
         subscription.workflow_history['edit_workflow'][-1]['comment'])
 
+  @simulateHostingSubscription_requestUpdateOpenSaleOrder
+  def test_alarm_HS_validated_OSO_invalidated(self):
+    subscription = self.portal.hosting_subscription_module\
+        .template_hosting_subscription.Base_createCloneDocument(batch_mode=1)
+    subscription.edit(reference='TESTHS-%s' % self.generateNewId())
+    self.portal.portal_workflow._jumpToStateFor(subscription, 'validated')
+
+    open_sale_order = self.portal.open_sale_order_module\
+        .template_open_sale_order.Base_createCloneDocument(batch_mode=1)
+    open_sale_order.edit(reference='TESTOSO-%s' % self.generateNewId())
+    open_sale_order.newContent(portal_type='Open Sale Order Line',
+        aggregate=subscription.getRelativeUrl())
+    self.portal.portal_workflow._jumpToStateFor(open_sale_order, 'invalidated')
+    self.tic()
+
+    self.portal.portal_alarms\
+        .slapos_request_update_hosting_subscription_open_sale_order\
+        .activeSense()
+    self.tic()
+    self.assertEqual(
+        'Visited by HostingSubscription_requestUpdateOpenSaleOrder',
+        subscription.workflow_history['edit_workflow'][-1]['comment'])
+
+  @simulateHostingSubscription_requestUpdateOpenSaleOrder
+  def test_alarm_HS_archived(self):
+    subscription = self.portal.hosting_subscription_module\
+        .template_hosting_subscription.Base_createCloneDocument(batch_mode=1)
+    subscription.edit(reference='TESTHS-%s' % self.generateNewId())
+    self.portal.portal_workflow._jumpToStateFor(subscription, 'archived')
+    self.tic()
+
+    self.portal.portal_alarms\
+        .slapos_request_update_hosting_subscription_open_sale_order\
+        .activeSense()
+    self.tic()
+    self.assertEqual(
+        'Visited by HostingSubscription_requestUpdateOpenSaleOrder',
+        subscription.workflow_history['edit_workflow'][-1]['comment'])
+
+  @simulateHostingSubscription_requestUpdateOpenSaleOrder
+  def test_alarm_HS_archived_OSO_validated(self):
+    subscription = self.portal.hosting_subscription_module\
+        .template_hosting_subscription.Base_createCloneDocument(batch_mode=1)
+    subscription.edit(reference='TESTHS-%s' % self.generateNewId())
+    self.portal.portal_workflow._jumpToStateFor(subscription, 'archived')
+
+    open_sale_order = self.portal.open_sale_order_module\
+        .template_open_sale_order.Base_createCloneDocument(batch_mode=1)
+    open_sale_order.edit(reference='TESTOSO-%s' % self.generateNewId())
+    open_sale_order.newContent(portal_type='Open Sale Order Line',
+        aggregate=subscription.getRelativeUrl())
+    self.portal.portal_workflow._jumpToStateFor(open_sale_order, 'validated')
+    self.tic()
+
+    self.portal.portal_alarms\
+        .slapos_request_update_hosting_subscription_open_sale_order\
+        .activeSense()
+    self.tic()
+    self.assertEqual(
+        'Visited by HostingSubscription_requestUpdateOpenSaleOrder',
+        subscription.workflow_history['edit_workflow'][-1]['comment'])
+
+  @simulateHostingSubscription_requestUpdateOpenSaleOrder
+  def test_alarm_HS_validated_OSO_validated(self):
+    subscription = self.portal.hosting_subscription_module\
+        .template_hosting_subscription.Base_createCloneDocument(batch_mode=1)
+    subscription.edit(reference='TESTHS-%s' % self.generateNewId())
+    self.portal.portal_workflow._jumpToStateFor(subscription, 'validated')
+
+    open_sale_order = self.portal.open_sale_order_module\
+        .template_open_sale_order.Base_createCloneDocument(batch_mode=1)
+    open_sale_order.edit(reference='TESTOSO-%s' % self.generateNewId())
+    open_sale_order.newContent(portal_type='Open Sale Order Line',
+        aggregate=subscription.getRelativeUrl())
+    self.portal.portal_workflow._jumpToStateFor(open_sale_order, 'validated')
+    self.tic()
+
+    self.portal.portal_alarms\
+        .slapos_request_update_hosting_subscription_open_sale_order\
+        .activeSense()
+    self.tic()
+    self.assertNotEqual(
+        'Visited by HostingSubscription_requestUpdateOpenSaleOrder',
+        subscription.workflow_history['edit_workflow'][-1]['comment'])
+
+  @simulateHostingSubscription_requestUpdateOpenSaleOrder
+  def test_alarm_HS_archived_OSO_invalidated(self):
+    subscription = self.portal.hosting_subscription_module\
+        .template_hosting_subscription.Base_createCloneDocument(batch_mode=1)
+    subscription.edit(reference='TESTHS-%s' % self.generateNewId())
+    self.portal.portal_workflow._jumpToStateFor(subscription, 'archived')
+
+    open_sale_order = self.portal.open_sale_order_module\
+        .template_open_sale_order.Base_createCloneDocument(batch_mode=1)
+    open_sale_order.edit(reference='TESTOSO-%s' % self.generateNewId())
+    open_sale_order.newContent(portal_type='Open Sale Order Line',
+        aggregate=subscription.getRelativeUrl())
+    self.portal.portal_workflow._jumpToStateFor(open_sale_order, 'invalidated')
+    self.tic()
+
+    self.portal.portal_alarms\
+        .slapos_request_update_hosting_subscription_open_sale_order\
+        .activeSense()
+    self.tic()
+    self.assertNotEqual(
+        'Visited by HostingSubscription_requestUpdateOpenSaleOrder',
+        subscription.workflow_history['edit_workflow'][-1]['comment'])
+
 class TestHostingSubscription_requestUpdateOpenSaleOrder(testSlapOSMixin):
   def test_empty_HostingSubscription(self):
     person = self.portal.person_module.template_member\
@@ -111,7 +220,6 @@ class TestHostingSubscription_requestUpdateOpenSaleOrder(testSlapOSMixin):
 
     subscription.HostingSubscription_requestUpdateOpenSaleOrder()
     self.tic()
-    self.assertEqual(subscription.getCausalityState(), 'solved')
 
     open_sale_order_list = self.portal.portal_catalog(
         portal_type='Open Sale Order',
@@ -165,7 +273,6 @@ class TestHostingSubscription_requestUpdateOpenSaleOrder(testSlapOSMixin):
 
     subscription.HostingSubscription_requestUpdateOpenSaleOrder()
     self.tic()
-    self.assertEqual(subscription.getCausalityState(), 'solved')
 
     open_sale_order_list = self.portal.portal_catalog(
         portal_type='Open Sale Order',
@@ -213,7 +320,6 @@ class TestHostingSubscription_requestUpdateOpenSaleOrder(testSlapOSMixin):
         'time': destroy_time,
         'action': 'request_destroy'
     })
-    subscription.diverge()
     self.tic()
 
     subscription.HostingSubscription_requestUpdateOpenSaleOrder()
@@ -295,7 +401,6 @@ class TestHostingSubscription_requestUpdateOpenSaleOrder(testSlapOSMixin):
 
     subscription.HostingSubscription_requestUpdateOpenSaleOrder()
     self.tic()
-    self.assertEqual(subscription.getCausalityState(), 'solved')
 
     open_sale_order_list = self.portal.portal_catalog(
         portal_type='Open Sale Order',
@@ -355,7 +460,6 @@ class TestHostingSubscription_requestUpdateOpenSaleOrder(testSlapOSMixin):
 
     subscription.HostingSubscription_requestUpdateOpenSaleOrder()
     self.tic()
-    self.assertEqual(subscription.getCausalityState(), 'solved')
 
     open_sale_order_list = self.portal.portal_catalog(
         portal_type='Open Sale Order',
diff --git a/master/bt5/slapos_accounting/bt/revision b/master/bt5/slapos_accounting/bt/revision
index e77a96349..0aeb54854 100644
--- a/master/bt5/slapos_accounting/bt/revision
+++ b/master/bt5/slapos_accounting/bt/revision
@@ -1 +1 @@
-73
\ No newline at end of file
+74
\ No newline at end of file
diff --git a/master/bt5/slapos_accounting/bt/template_keep_workflow_path_list b/master/bt5/slapos_accounting/bt/template_keep_workflow_path_list
index af78ad0ab..9820101dd 100644
--- a/master/bt5/slapos_accounting/bt/template_keep_workflow_path_list
+++ b/master/bt5/slapos_accounting/bt/template_keep_workflow_path_list
@@ -16,4 +16,5 @@ service_module/slapos_discount
 portal_rules/slapos_subscription_item_rule
 portal_rules/slapos_invoice_simulation_rule
 portal_rules/slapos_invoice_transaction_simulation_rule
-portal_rules/slapos_trade_model_simulation_rule
\ No newline at end of file
+portal_rules/slapos_trade_model_simulation_rule
+portal_rules/slapos_payment_simulation_rule
\ No newline at end of file
diff --git a/master/bt5/slapos_accounting/bt/template_path_list b/master/bt5/slapos_accounting/bt/template_path_list
index 25a115332..fcf6a69a2 100644
--- a/master/bt5/slapos_accounting/bt/template_path_list
+++ b/master/bt5/slapos_accounting/bt/template_path_list
@@ -32,6 +32,8 @@ portal_rules/slapos_invoice_simulation_rule
 portal_rules/slapos_invoice_simulation_rule/**
 portal_rules/slapos_invoice_transaction_simulation_rule
 portal_rules/slapos_invoice_transaction_simulation_rule/**
+portal_rules/slapos_payment_simulation_rule
+portal_rules/slapos_payment_simulation_rule/**
 portal_rules/slapos_subscription_item_rule
 portal_rules/slapos_subscription_item_rule/**
 portal_rules/slapos_trade_model_simulation_rule
diff --git a/master/bt5/vifib_base/bt/revision b/master/bt5/vifib_base/bt/revision
index 8db1e5f18..a9d3bc092 100644
--- a/master/bt5/vifib_base/bt/revision
+++ b/master/bt5/vifib_base/bt/revision
@@ -1 +1 @@
-522
\ No newline at end of file
+523
\ No newline at end of file
diff --git a/master/bt5/vifib_data_simulation/bt/revision b/master/bt5/vifib_data_simulation/bt/revision
index 50f0bcd37..d55f9f745 100644
--- a/master/bt5/vifib_data_simulation/bt/revision
+++ b/master/bt5/vifib_data_simulation/bt/revision
@@ -1 +1 @@
-135
\ No newline at end of file
+136
\ No newline at end of file
diff --git a/master/bt5/vifib_data_simulation/bt/template_keep_workflow_path_list b/master/bt5/vifib_data_simulation/bt/template_keep_workflow_path_list
index 4ed4f9fec..e7c1fb7bf 100644
--- a/master/bt5/vifib_data_simulation/bt/template_keep_workflow_path_list
+++ b/master/bt5/vifib_data_simulation/bt/template_keep_workflow_path_list
@@ -1,5 +1,4 @@
 portal_rules/vifib_delivery_simulation_rule
 portal_rules/vifib_delivery_root_simulation_rule
 portal_rules/vifib_invoice_root_simulation_rule
-portal_rules/vifib_order_root_simulation_rule
-portal_rules/vifib_payment_simulation_rule
\ No newline at end of file
+portal_rules/vifib_order_root_simulation_rule
\ No newline at end of file
diff --git a/master/bt5/vifib_data_simulation/bt/template_path_list b/master/bt5/vifib_data_simulation/bt/template_path_list
index e15e81cb9..b79528b99 100644
--- a/master/bt5/vifib_data_simulation/bt/template_path_list
+++ b/master/bt5/vifib_data_simulation/bt/template_path_list
@@ -21,8 +21,6 @@ portal_rules/vifib_invoice_root_simulation_rule
 portal_rules/vifib_invoice_root_simulation_rule/**
 portal_rules/vifib_order_root_simulation_rule
 portal_rules/vifib_order_root_simulation_rule/**
-portal_rules/vifib_payment_simulation_rule
-portal_rules/vifib_payment_simulation_rule/**
 portal_solvers/Accept Solver
 portal_solvers/Accept Solver/*
 portal_solvers/Adopt Solver
-- 
2.30.9