From 5de215049551cc604cc8f19a304d712f8b73538b Mon Sep 17 00:00:00 2001
From: Sebastien Robin <seb@nexedi.com>
Date: Fri, 28 Sep 2007 07:49:00 +0000
Subject: [PATCH] we must have a description on each check deposit line

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

diff --git a/bt5/erp5_banking_check/SkinTemplateItem/portal_skins/erp5_banking_check_operation/CheckbookReceptionLine_checkOrCreateItemList.xml b/bt5/erp5_banking_check/SkinTemplateItem/portal_skins/erp5_banking_check_operation/CheckbookReceptionLine_checkOrCreateItemList.xml
index a3a7cb6bfc..6474eeea59 100644
--- a/bt5/erp5_banking_check/SkinTemplateItem/portal_skins/erp5_banking_check_operation/CheckbookReceptionLine_checkOrCreateItemList.xml
+++ b/bt5/erp5_banking_check/SkinTemplateItem/portal_skins/erp5_banking_check_operation/CheckbookReceptionLine_checkOrCreateItemList.xml
@@ -71,9 +71,6 @@ from Products.DCWorkflow.DCWorkflow import ValidationFailed\n
 from Products.ERP5Type.Message import Message\n
 checkbook_reception = context.getParentValue()\n
 \n
-# Check getBaobabSource and getBaobabDestination\n
-checkbook_reception.Base_checkBaobabSourceAndDestination()\n
-\n
 portal = checkbook_reception.getPortalObject()\n
 portal_activities = portal.portal_activities\n
 if encountered_check_identifiers_dict is None:\n
@@ -130,15 +127,16 @@ def generateTravelerCheckReference(number, original_traveler_check_reference):\n
   prefix = getTravelerCheckReferencePrefix(original_traveler_check_reference)\n
   return \'%s%06d\' % (prefix, number)\n
 \n
-def assertReferenceMatchListEmpty(match_list):\n
+def assertReferenceMatchListEmpty(match_list, destination_payment_uid):\n
   """\n
     Check that the list is empty, otherwise gather all conflicting references and display them in the error message.\n
     TODO: make the error message Localizer-friendly\n
   """\n
   if len(match_list) > 0:\n
+    account = context.portal_catalog(uid=destination_payment_uid)[0].getObject()\n
     matched_reference_list = []\n
     for match in match_list:\n
-      matched_reference_list.append(match.getReference())\n
+      matched_reference_list.append(\'%s (%s)\' % (match.getReference(), account.getInternalBankAccountNumber()))\n
     message = Message(domain=\'ui\', message=\'The following references are already allocated : $reference_list\',\n
                       mapping={\'reference_list\': matched_reference_list})\n
     raise ValidationFailed, (message,)\n
@@ -151,12 +149,13 @@ def checkReferenceListUniqueness(reference_list, model, destination_payment_uid)
     match_list = portal.portal_catalog(portal_type=\'Check\', reference=reference_list, resource_relative_url=model)\n
   else:\n
     match_list = portal.portal_catalog(portal_type=\'Check\', reference=reference_list, destination_payment_uid=destination_payment_uid, resource_relative_url=model)\n
-  assertReferenceMatchListEmpty(match_list)\n
+  assertReferenceMatchListEmpty(match_list, destination_payment_uid)\n
   for reference in reference_list:\n
     tag = \'check_%s_%s_%s\' % (model, destination_payment_uid, reference)\n
     if encountered_check_identifiers_dict.has_key(tag):\n
+      account = context.portal_catalog(uid=destination_payment_uid)[0].getObject()\n
       message = Message(domain=\'ui\', message=\'The following references are already allocated : $reference_list\',\n
-                        mapping={\'reference_list\': [reference, ]})\n
+                        mapping={\'reference_list\': [\'%s (%s)\' % (reference, account.getInternalBankAccountNumber()) ]})\n
       raise ValidationFailed, (message,)\n
     encountered_check_identifiers_dict[tag] = None\n
 \n
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 4135fcf2d0..8ee7900f00 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
@@ -99,6 +99,12 @@ if transaction.getTotalPrice(portal_type = \'Check Operation Line\') != transact
 \n
 # Check each check operation line.\n
 for check_operation_line in transaction.contentValues(filter = {\'portal_type\' : \'Check Operation Line\'}):\n
+\n
+  if check_operation_line.getDescription() in (None, \'\'):\n
+    msg = Message(domain=\'ui\', message=\'The description is not defined on line $line.\'\n
+                  , mapping={"line" : check_operation_line.getId()})\n
+    raise ValidationFailed, (msg,)\n
+\n
   check_number = check_operation_line.getAggregateFreeText()\n
   if not check_number:\n
     msg = Message(domain=\'ui\', message=\'Check is not defined on line $line.\'\n
diff --git a/bt5/erp5_banking_check/bt/revision b/bt5/erp5_banking_check/bt/revision
index 98c1572f67..41a4a819ad 100644
--- a/bt5/erp5_banking_check/bt/revision
+++ b/bt5/erp5_banking_check/bt/revision
@@ -1 +1 @@
-327
\ No newline at end of file
+328
\ No newline at end of file
-- 
2.30.9