Index: /main/waeup.kofa/trunk/CHANGES.txt
===================================================================
--- /main/waeup.kofa/trunk/CHANGES.txt	(revision 12512)
+++ /main/waeup.kofa/trunk/CHANGES.txt	(revision 12513)
@@ -5,5 +5,6 @@
 =======================
 
-* No changes yet.
+* Check if p_id exists in payments_catalog when importing payment tickets in
+  create mode.
 
 
Index: /main/waeup.kofa/trunk/src/waeup/kofa/students/batching.py
===================================================================
--- /main/waeup.kofa/trunk/src/waeup/kofa/students/batching.py	(revision 12512)
+++ /main/waeup.kofa/trunk/src/waeup/kofa/students/batching.py	(revision 12513)
@@ -793,4 +793,15 @@
                 errs.append(('p_id','invalid format'))
                 return errs, inv_errs, conv_dict
+        # Requirement added on 24/01/2015: p_id must be portal-wide unique.
+        if mode == 'create':
+            cat = getUtility(ICatalog, name='payments_catalog')
+            results = list(cat.searchResults(p_id=(p_id, p_id)))
+            if len(results) > 0:
+                sids = [payment.student.student_id for payment in results]
+                sids_string = ''
+                for id in sids:
+                    sids_string += '%s ' % id
+                errs.append(('p_id','p_id exists in %s' % sids_string))
+                return errs, inv_errs, conv_dict
         return errs, inv_errs, conv_dict
 
Index: /main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_batching.py
===================================================================
--- /main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_batching.py	(revision 12512)
+++ /main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_batching.py	(revision 12513)
@@ -288,4 +288,5 @@
         # XXX: there is no addPayment method to give predictable names
         self.payment = student['payments']['my-payment'] = payment
+        notify(grok.ObjectModifiedEvent(self.payment))
         return payment
 
@@ -1065,4 +1066,11 @@
             dict(p_id=p_id))
         self.assertEqual(len(errs),0)
+        dup_payment = createObject(u'waeup.StudentOnlinePayment')
+        dup_payment.p_id = 'XYZ-99-1234567890'
+        self.student['payments'][dup_payment.p_id] = dup_payment
+        errs, inv_errs, conv_dict = self.processor.checkConversion(
+            dict(p_id='XYZ-99-1234567890'), mode='create')
+        self.assertEqual(len(errs),1)
+        self.assertEqual(errs[0], ('p_id', u'p_id exists in K1000000 '))
 
     def test_import(self):
Index: /main/waeup.kofa/trunk/src/waeup/kofa/utils/batching.py
===================================================================
--- /main/waeup.kofa/trunk/src/waeup/kofa/utils/batching.py	(revision 12512)
+++ /main/waeup.kofa/trunk/src/waeup/kofa/utils/batching.py	(revision 12513)
@@ -183,5 +183,5 @@
 
     def getEntry(self, row, site):
-        """Get the parent object for the entry in ``row``.
+        """Get the object for the entry in ``row``.
         """
         raise NotImplementedError('method not implemented')
