From ee84ceaaad3586d1d592dc2334e81f02337d0239 Mon Sep 17 00:00:00 2001
From: Sebastien Robin <seb@nexedi.com>
Date: Fri, 16 Feb 2007 15:56:24 +0000
Subject: [PATCH] we must use confimed check in check payment. Make sure that a
 check is available when we want to transfer it in usual cash transfer

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@12823 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 .../scripts/validateConsistency.xml           |  2 +-
 ...idateCheckbookVaultTransferConsistency.xml | 24 +++++++++++++++++++
 bt5/erp5_banking_check/bt/revision            |  2 +-
 3 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/bt5/erp5_banking_check/WorkflowTemplateItem/portal_workflow/check_payment_workflow/scripts/validateConsistency.xml b/bt5/erp5_banking_check/WorkflowTemplateItem/portal_workflow/check_payment_workflow/scripts/validateConsistency.xml
index 90d25ad79d..5b9dfb2a01 100644
--- a/bt5/erp5_banking_check/WorkflowTemplateItem/portal_workflow/check_payment_workflow/scripts/validateConsistency.xml
+++ b/bt5/erp5_banking_check/WorkflowTemplateItem/portal_workflow/check_payment_workflow/scripts/validateConsistency.xml
@@ -128,7 +128,7 @@ if not check_number:\n
   msg = Message(domain=\'ui\', message="Check not defined.")\n
   raise ValidationFailed, (msg,)\n
 \n
-result = context.portal_catalog(portal_type = \'Check\', reference = check_number)\n
+result = context.portal_catalog(portal_type = \'Check\', title = check_number,simulation_state=\'confirmed\')\n
 if len(result) == 0:\n
   # Until a certain date, ERP5 allows the user to generate a check automatically.\n
   from DateTime import DateTime\n
diff --git a/bt5/erp5_banking_check/WorkflowTemplateItem/portal_workflow/checkbook_usual_cash_transfer_workflow/scripts/validateCheckbookVaultTransferConsistency.xml b/bt5/erp5_banking_check/WorkflowTemplateItem/portal_workflow/checkbook_usual_cash_transfer_workflow/scripts/validateCheckbookVaultTransferConsistency.xml
index 387dc7119b..5f28aa2bb6 100644
--- a/bt5/erp5_banking_check/WorkflowTemplateItem/portal_workflow/checkbook_usual_cash_transfer_workflow/scripts/validateCheckbookVaultTransferConsistency.xml
+++ b/bt5/erp5_banking_check/WorkflowTemplateItem/portal_workflow/checkbook_usual_cash_transfer_workflow/scripts/validateCheckbookVaultTransferConsistency.xml
@@ -73,8 +73,10 @@ from Products.ERP5Type.Message import Message\n
 \n
 transaction = state_change.object\n
 \n
+\n
 source = transaction.getSource()\n
 destination = transaction.getDestination()\n
+\n
 msg = None\n
 if source == destination:\n
   msg = Message(domain="ui", message="Sorry, the source and the destination must be different")\n
@@ -83,6 +85,17 @@ line_list = transaction.objectValues()\n
 if len(line_list)==0:\n
   msg = Message(domain="ui", message="Sorry, you must select at least one check or checkbook")\n
 \n
+baobab_source = transaction.getBaobabSource()\n
+reference_date = transaction.getStartDate()\n
+current_tracking_list = [x.getObject() for x in getCurrentTrackingList(\n
+                         at_date=reference_date, node=baobab_source,\n
+                         where_expression="item_catalog.portal_type=\'Check\' or item_catalog.portal_type=\'Checkbook\'")]\n
+aggregate_uid_list = [x.uid for x in current_tracking_list]\n
+for line in transaction.getMovementList(portal_type=\'Checkbook Delivery Line\'):\n
+  for aggregate_uid in line.getAggregateUidList():\n
+    if aggregate_uid not in aggregate_uid_list:\n
+      msg = Message(domain="ui", message="Sorry, an item is not available any more")\n
+\n
 if msg is not None:\n
   raise ValidationFailed, (msg,)\n
 </string> </value>
@@ -140,6 +153,17 @@ if msg is not None:\n
                             <string>msg</string>
                             <string>line_list</string>
                             <string>len</string>
+                            <string>baobab_source</string>
+                            <string>reference_date</string>
+                            <string>append</string>
+                            <string>$append0</string>
+                            <string>_getiter_</string>
+                            <string>getCurrentTrackingList</string>
+                            <string>x</string>
+                            <string>current_tracking_list</string>
+                            <string>aggregate_uid_list</string>
+                            <string>line</string>
+                            <string>aggregate_uid</string>
                           </tuple>
                         </value>
                     </item>
diff --git a/bt5/erp5_banking_check/bt/revision b/bt5/erp5_banking_check/bt/revision
index d1cbcfa540..3d9aebb2cc 100644
--- a/bt5/erp5_banking_check/bt/revision
+++ b/bt5/erp5_banking_check/bt/revision
@@ -1 +1 @@
-66
\ No newline at end of file
+68
\ No newline at end of file
-- 
2.30.9