From 69f3652f502728d0a698783692798aac1637c956 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Aur=C3=A9lien=20Calonne?= <aurel@nexedi.com>
Date: Tue, 16 Oct 2007 08:31:58 +0000
Subject: [PATCH] check resource is the same between document and lines

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@17017 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 .../scripts/validateVaultBalance.xml          | 19 +++++++++++++------
 .../scripts/checkDestination.xml              |  3 ++-
 bt5/erp5_banking_cash/bt/revision             |  2 +-
 3 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/bt5/erp5_banking_cash/WorkflowTemplateItem/portal_workflow/cash_to_currency_purchase_workflow/scripts/validateVaultBalance.xml b/bt5/erp5_banking_cash/WorkflowTemplateItem/portal_workflow/cash_to_currency_purchase_workflow/scripts/validateVaultBalance.xml
index 0d3361c55e..e8b8393444 100644
--- a/bt5/erp5_banking_cash/WorkflowTemplateItem/portal_workflow/cash_to_currency_purchase_workflow/scripts/validateVaultBalance.xml
+++ b/bt5/erp5_banking_cash/WorkflowTemplateItem/portal_workflow/cash_to_currency_purchase_workflow/scripts/validateVaultBalance.xml
@@ -75,9 +75,9 @@ currency = transaction.getResourceTitle()\n
 encaisse_billets_et_monnaies = "/encaisse_des_billets_et_monnaies/sortante"\n
 \n
 \n
-var_ressource_title = transaction.getResourceTitle().lower()\n
-var_ressource_title = var_ressource_title.replace(" ", "_")\n
-encaisse_devise = "/encaisse_des_devises/%s/entrante" %(var_ressource_title)\n
+ressource_title = transaction.getResourceTitle().lower()\n
+ressource_title = ressource_title.replace(" ", "_")\n
+encaisse_devise = "/encaisse_des_devises/%s/entrante" %(ressource_title)\n
 \n
 #encaisse_devise = "/encaisse_des_devises/%s/entrante" %(transaction.getResourceTitle().lower())\n
 \n
@@ -106,8 +106,12 @@ if base_price is None or base_price <= 0:\n
 fix_montant = transaction.getDiscount()\n
 pourcentage = transaction.getDiscountRatio()\n
 \n
-\n
-\n
+# check resource on incoming line\n
+doc_resource = transaction.getResource()\n
+for line in transaction.contentValues(portal_type="Incoming Cash To Currency Purchase Line"):\n
+  if line.getResource() != doc_resource:\n
+    msg = Message(domain="ui", message="Resource defined on document is different from input cash.")\n
+    raise ValidationFailed, (msg,)\n
 \n
 resource_two = transaction.CashDelivery_checkCounterInventory(outgoing_source,portal_type=\'Outgoing Cash To Currency Purchase Line\')\n
 \n
@@ -190,7 +194,7 @@ elif resource_two!= 0 :\n
                             <string>_getattr_</string>
                             <string>currency</string>
                             <string>encaisse_billets_et_monnaies</string>
-                            <string>var_ressource_title</string>
+                            <string>ressource_title</string>
                             <string>encaisse_devise</string>
                             <string>counter_site</string>
                             <string>incoming_destination</string>
@@ -201,6 +205,9 @@ elif resource_two!= 0 :\n
                             <string>msg</string>
                             <string>fix_montant</string>
                             <string>pourcentage</string>
+                            <string>doc_resource</string>
+                            <string>_getiter_</string>
+                            <string>line</string>
                             <string>resource_two</string>
                             <string>billetage_entre</string>
                             <string>billetage_sorti</string>
diff --git a/bt5/erp5_banking_cash/WorkflowTemplateItem/portal_workflow/monetary_reception_workflow/scripts/checkDestination.xml b/bt5/erp5_banking_cash/WorkflowTemplateItem/portal_workflow/monetary_reception_workflow/scripts/checkDestination.xml
index eb7d082f7a..438bbaadf0 100644
--- a/bt5/erp5_banking_cash/WorkflowTemplateItem/portal_workflow/monetary_reception_workflow/scripts/checkDestination.xml
+++ b/bt5/erp5_banking_cash/WorkflowTemplateItem/portal_workflow/monetary_reception_workflow/scripts/checkDestination.xml
@@ -83,7 +83,7 @@ if len(object.objectValues(portal_type=\'Cash Delivery Line\')) == 0:\n
   raise ValidationFailed, (msg,)\n
        \n
 dest = object.getDestinationValue()\n
-if \'encaisse_des_billets_retires_de_la_circulation\' in dest.getRelativeUrl():\n
+if dest is None or \'encaisse_des_billets_retires_de_la_circulation\' in dest.getRelativeUrl():\n
   msg = Message(domain="ui", message="Wrong Destination Selected.")\n
   raise ValidationFailed, (msg,)\n
 \n
@@ -154,6 +154,7 @@ if \'transit\' not in dest.getRelativeUrl():\n
                             <string>len</string>
                             <string>msg</string>
                             <string>dest</string>
+                            <string>None</string>
                             <string>first_movement</string>
                             <string>line_letter</string>
                           </tuple>
diff --git a/bt5/erp5_banking_cash/bt/revision b/bt5/erp5_banking_cash/bt/revision
index 7c2b018235..8db1e5f188 100644
--- a/bt5/erp5_banking_cash/bt/revision
+++ b/bt5/erp5_banking_cash/bt/revision
@@ -1 +1 @@
-521
\ No newline at end of file
+522
\ No newline at end of file
-- 
2.30.9