From 5b337f585e8e038ec63c7dc2b629914699e28321 Mon Sep 17 00:00:00 2001
From: Sebastien Robin <seb@nexedi.com>
Date: Tue, 9 Oct 2007 11:38:58 +0000
Subject: [PATCH] check the life time of items

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@16901 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 .../scripts/validateConsistency.xml           | 35 +++++++++++--------
 .../portal_workflow/stop_payment_workflow.xml |  1 +
 .../scripts/validatePositionAccounting.xml    | 14 +++++++-
 .../states/cancelled.xml                      | 15 ++++----
 .../states/delivered.xml                      |  6 ++++
 .../stop_payment_workflow/states/draft.xml    | 10 ++++++
 .../stop_payment_workflow/states/started.xml  |  8 +++++
 .../stop_payment_workflow/states/stopped.xml  |  6 ++++
 bt5/erp5_banking_check/bt/revision            |  2 +-
 9 files changed, 74 insertions(+), 23 deletions(-)

diff --git a/bt5/erp5_banking_check/WorkflowTemplateItem/portal_workflow/check_deposit_workflow/scripts/validateConsistency.xml b/bt5/erp5_banking_check/WorkflowTemplateItem/portal_workflow/check_deposit_workflow/scripts/validateConsistency.xml
index 8ee7900f00..34d96ec78d 100644
--- a/bt5/erp5_banking_check/WorkflowTemplateItem/portal_workflow/check_deposit_workflow/scripts/validateConsistency.xml
+++ b/bt5/erp5_banking_check/WorkflowTemplateItem/portal_workflow/check_deposit_workflow/scripts/validateConsistency.xml
@@ -125,20 +125,26 @@ for check_operation_line in transaction.contentValues(filter = {\'portal_type\'
     raise ValidationFailed, (msg,)\n
 \n
   # Test check is valid based on date\n
-  if \'compte\' in check_operation_line.getAggregateResourceTitle():\n
-    interval = getIntervalBetweenDates(check_operation_line.getStartDate(), check_operation_line.getStopDate())\n
-    if interval[\'year\'] >= 3:\n
-      if interval[\'month\'] > 0 or interval["day"] > 0:\n
-        msg = Message(domain=\'ui\', message="Check $check is more than 3 years old.",\n
-                      mapping={"check" : check_operation_line.getAggregateFreeText()})\n
-        raise ValidationFailed, (msg,)\n
-  elif \'virement\' in check_operation_line.getAggregateResourceTitle():\n
-    interval = getIntervalBetweenDates(check_operation_line.getStartDate(), check_operation_line.getStopDate())\n
-    if interval[\'month\'] >= 3:\n
-      if interval["day"] > 0:\n
-        msg = Message(domain=\'ui\', message="Check $check is more than 3 month old.",\n
-                      mapping={"check" : check_operation_line.getAggregateFreeText()})\n
-        raise ValidationFailed, (msg,)\n
+  transaction.Check_checkIntervalBetweenDate(resource=check_operation_line.getAggregateResourceValue(),\n
+                                             start_date=check_operation_line.getStartDate(),\n
+                                             stop_date=check_operation_line.getStopDate(),\n
+                                             check_nb=check_operation_line.getAggregateFreeText())\n
+\n
+#   \n
+#   if \'compte\' in check_operation_line.getAggregateResourceTitle():\n
+#     interval = getIntervalBetweenDates(check_operation_line.getStartDate(), check_operation_line.getStopDate())\n
+#     if interval[\'year\'] >= 3:\n
+#       if interval[\'month\'] > 0 or interval["day"] > 0:\n
+#         msg = Message(domain=\'ui\', message="Check $check is more than 3 years old.",\n
+#                       mapping={"check" : check_operation_line.getAggregateFreeText()})\n
+#         raise ValidationFailed, (msg,)\n
+#   elif \'virement\' in check_operation_line.getAggregateResourceTitle():\n
+#     interval = getIntervalBetweenDates(check_operation_line.getStartDate(), check_operation_line.getStopDate())\n
+#     if interval[\'month\'] >= 3:\n
+#       if interval["day"] > 0:\n
+#         msg = Message(domain=\'ui\', message="Check $check is more than 3 month old.",\n
+#                       mapping={"check" : check_operation_line.getAggregateFreeText()})\n
+#         raise ValidationFailed, (msg,)\n
     \n
   \n
   # Test if the account balance is sufficient.\n
@@ -241,7 +247,6 @@ if transaction.getSimulationState() == "draft":\n
                             <string>check_number</string>
                             <string>check_type</string>
                             <string>source_bank_account</string>
-                            <string>interval</string>
                             <string>context</string>
                             <string>error</string>
                             <string>check</string>
diff --git a/bt5/erp5_banking_check/WorkflowTemplateItem/portal_workflow/stop_payment_workflow.xml b/bt5/erp5_banking_check/WorkflowTemplateItem/portal_workflow/stop_payment_workflow.xml
index 1d87346348..ce29d42e64 100644
--- a/bt5/erp5_banking_check/WorkflowTemplateItem/portal_workflow/stop_payment_workflow.xml
+++ b/bt5/erp5_banking_check/WorkflowTemplateItem/portal_workflow/stop_payment_workflow.xml
@@ -62,6 +62,7 @@
                 <string>View</string>
                 <string>Access contents information</string>
                 <string>Modify portal content</string>
+                <string>Delete objects</string>
               </tuple>
             </value>
         </item>
diff --git a/bt5/erp5_banking_check/WorkflowTemplateItem/portal_workflow/stop_payment_workflow/scripts/validatePositionAccounting.xml b/bt5/erp5_banking_check/WorkflowTemplateItem/portal_workflow/stop_payment_workflow/scripts/validatePositionAccounting.xml
index bbe212bf3c..70d631e8ff 100644
--- a/bt5/erp5_banking_check/WorkflowTemplateItem/portal_workflow/stop_payment_workflow/scripts/validatePositionAccounting.xml
+++ b/bt5/erp5_banking_check/WorkflowTemplateItem/portal_workflow/stop_payment_workflow/scripts/validatePositionAccounting.xml
@@ -73,6 +73,9 @@ from Products.ERP5Type.Message import Message\n
 transaction = state_change[\'object\']\n
 \n
 date = transaction.getStartDate()\n
+from DateTime import DateTime\n
+now = DateTime()\n
+\n
 source = transaction.getSource(None)\n
 if source is None:\n
   msg = Message(domain=\'ui\', message=\'No counter defined.\')\n
@@ -96,7 +99,7 @@ if ref_min is not None or ref_max is not None:\n
                           resource=aggregate_resource)\n
 if len(check_list)>0:\n
   # First make sure there is no delivery line\n
-  line_list = transaction.objectValues(portal_type=\'Cash Delivery Line\')\n
+  line_list = transaction.objectValues(portal_type=\'Checkbook Delivery Line\')\n
   if len(line_list)>0:\n
     id_list = [x.getId() for x in line_list]\n
     transaction.manage_delObjects(ids=id_list)\n
@@ -134,6 +137,13 @@ for movement in movement_list:\n
     if item.getSimulationState()!=\'confirmed\':\n
       msg = Message(domain = "ui", message="Sorry, this check is not issued")\n
       raise ValidationFailed, (msg,)\n
+    # Test check is valid based on date\n
+    transaction.Check_checkIntervalBetweenDate(resource=item.getResourceValue(),\n
+                                             start_date=date,\n
+                                             stop_date=now,\n
+                                             check_nb=item.getTitle())\n
+\n
+\n
 debit_required = transaction.isDebitRequired()\n
 if total_debit in (None,0.0) and debit_required:\n
   msg = Message(domain = "ui", message="Sorry, you forgot to give the amount")\n
@@ -236,6 +246,8 @@ if debit_required:\n
                             <string>transaction</string>
                             <string>_getattr_</string>
                             <string>date</string>
+                            <string>DateTime</string>
+                            <string>now</string>
                             <string>None</string>
                             <string>source</string>
                             <string>msg</string>
diff --git a/bt5/erp5_banking_check/WorkflowTemplateItem/portal_workflow/stop_payment_workflow/states/cancelled.xml b/bt5/erp5_banking_check/WorkflowTemplateItem/portal_workflow/stop_payment_workflow/states/cancelled.xml
index ddade5d0a9..2432739f19 100644
--- a/bt5/erp5_banking_check/WorkflowTemplateItem/portal_workflow/stop_payment_workflow/states/cancelled.xml
+++ b/bt5/erp5_banking_check/WorkflowTemplateItem/portal_workflow/stop_payment_workflow/states/cancelled.xml
@@ -54,17 +54,14 @@
   <record id="2" aka="AAAAAAAAAAI=">
     <pickle>
       <tuple>
-        <tuple>
-          <string>Persistence</string>
-          <string>PersistentMapping</string>
-        </tuple>
-        <none/>
+        <global name="PersistentMapping" module="Persistence.mapping"/>
+        <tuple/>
       </tuple>
     </pickle>
     <pickle>
       <dictionary>
         <item>
-            <key> <string>_container</string> </key>
+            <key> <string>data</string> </key>
             <value>
               <dictionary>
                 <item>
@@ -77,6 +74,12 @@
                       </tuple>
                     </value>
                 </item>
+                <item>
+                    <key> <string>Delete objects</string> </key>
+                    <value>
+                      <tuple/>
+                    </value>
+                </item>
                 <item>
                     <key> <string>Modify portal content</string> </key>
                     <value>
diff --git a/bt5/erp5_banking_check/WorkflowTemplateItem/portal_workflow/stop_payment_workflow/states/delivered.xml b/bt5/erp5_banking_check/WorkflowTemplateItem/portal_workflow/stop_payment_workflow/states/delivered.xml
index b1053c9b7d..33ceb542f0 100644
--- a/bt5/erp5_banking_check/WorkflowTemplateItem/portal_workflow/stop_payment_workflow/states/delivered.xml
+++ b/bt5/erp5_banking_check/WorkflowTemplateItem/portal_workflow/stop_payment_workflow/states/delivered.xml
@@ -73,6 +73,12 @@
                       </tuple>
                     </value>
                 </item>
+                <item>
+                    <key> <string>Delete objects</string> </key>
+                    <value>
+                      <tuple/>
+                    </value>
+                </item>
                 <item>
                     <key> <string>Modify portal content</string> </key>
                     <value>
diff --git a/bt5/erp5_banking_check/WorkflowTemplateItem/portal_workflow/stop_payment_workflow/states/draft.xml b/bt5/erp5_banking_check/WorkflowTemplateItem/portal_workflow/stop_payment_workflow/states/draft.xml
index c67d2f86f9..77b4f696c4 100644
--- a/bt5/erp5_banking_check/WorkflowTemplateItem/portal_workflow/stop_payment_workflow/states/draft.xml
+++ b/bt5/erp5_banking_check/WorkflowTemplateItem/portal_workflow/stop_payment_workflow/states/draft.xml
@@ -80,6 +80,16 @@
                       </tuple>
                     </value>
                 </item>
+                <item>
+                    <key> <string>Delete objects</string> </key>
+                    <value>
+                      <tuple>
+                        <string>Assignee</string>
+                        <string>Assignor</string>
+                        <string>Manager</string>
+                      </tuple>
+                    </value>
+                </item>
                 <item>
                     <key> <string>Modify portal content</string> </key>
                     <value>
diff --git a/bt5/erp5_banking_check/WorkflowTemplateItem/portal_workflow/stop_payment_workflow/states/started.xml b/bt5/erp5_banking_check/WorkflowTemplateItem/portal_workflow/stop_payment_workflow/states/started.xml
index abb2752f04..20471bdd2a 100644
--- a/bt5/erp5_banking_check/WorkflowTemplateItem/portal_workflow/stop_payment_workflow/states/started.xml
+++ b/bt5/erp5_banking_check/WorkflowTemplateItem/portal_workflow/stop_payment_workflow/states/started.xml
@@ -76,6 +76,14 @@
                       </tuple>
                     </value>
                 </item>
+                <item>
+                    <key> <string>Delete objects</string> </key>
+                    <value>
+                      <tuple>
+                        <string>Manager</string>
+                      </tuple>
+                    </value>
+                </item>
                 <item>
                     <key> <string>Modify portal content</string> </key>
                     <value>
diff --git a/bt5/erp5_banking_check/WorkflowTemplateItem/portal_workflow/stop_payment_workflow/states/stopped.xml b/bt5/erp5_banking_check/WorkflowTemplateItem/portal_workflow/stop_payment_workflow/states/stopped.xml
index 1f4011481d..10d627321e 100644
--- a/bt5/erp5_banking_check/WorkflowTemplateItem/portal_workflow/stop_payment_workflow/states/stopped.xml
+++ b/bt5/erp5_banking_check/WorkflowTemplateItem/portal_workflow/stop_payment_workflow/states/stopped.xml
@@ -76,6 +76,12 @@
                       </tuple>
                     </value>
                 </item>
+                <item>
+                    <key> <string>Delete objects</string> </key>
+                    <value>
+                      <tuple/>
+                    </value>
+                </item>
                 <item>
                     <key> <string>Modify portal content</string> </key>
                     <value>
diff --git a/bt5/erp5_banking_check/bt/revision b/bt5/erp5_banking_check/bt/revision
index 41a4a819ad..e8a4e6b71b 100644
--- a/bt5/erp5_banking_check/bt/revision
+++ b/bt5/erp5_banking_check/bt/revision
@@ -1 +1 @@
-328
\ No newline at end of file
+329
\ No newline at end of file
-- 
2.30.9