Index: main/waeup.kofa/trunk/src/waeup/kofa/applicants/utils.py
===================================================================
--- main/waeup.kofa/trunk/src/waeup/kofa/applicants/utils.py	(revision 8860)
+++ main/waeup.kofa/trunk/src/waeup/kofa/applicants/utils.py	(revision 8884)
@@ -45,5 +45,5 @@
         """Set the payment data of an applicant.
         """
-        timestamp = "%d" % int(time()*1000)
+        timestamp = ("%d" % int(time()*10000))[1:]
         container_fee = container.application_fee
         if container_fee:
Index: main/waeup.kofa/trunk/src/waeup/kofa/students/batching.py
===================================================================
--- main/waeup.kofa/trunk/src/waeup/kofa/students/batching.py	(revision 8860)
+++ main/waeup.kofa/trunk/src/waeup/kofa/students/batching.py	(revision 8884)
@@ -26,4 +26,5 @@
 import grok
 import csv
+from time import time
 from zope.interface import Interface
 from zope.schema import getFields
@@ -291,8 +292,9 @@
     grok.baseclass()
 
-    #: required fields beside 'student_id', 'reg_number' and 'matric_number'
+    # additional available  fields
+    # beside 'student_id', 'reg_number' and 'matric_number'
     additional_fields = []
 
-    #: header fields additional required
+    #: header fields additionally required
     additional_headers = []
 
@@ -558,5 +560,12 @@
     location_fields = []
     additional_fields = ['p_id']
-    additional_headers = ['p_id']
+    additional_headers = []
+
+    def checkHeaders(self, headerfields, mode='ignore'):
+        super(StudentOnlinePaymentProcessor, self).checkHeaders(headerfields)
+        if mode == 'update' and not 'p_id' in headerfields:
+            raise FatalCSVError(
+                "Need p_id for import in update mode!")
+        return True
 
     def parentsExist(self, row, site):
@@ -573,13 +582,15 @@
         if payments is None:
             return None
+        p_id = row.get('p_id', None)
+        if p_id is None:
+            return None
         # We can use the hash symbol at the end of p_id in import files
         # to avoid annoying automatic number transformation
         # by Excel or Calc
-        p_id = row['p_id'].strip('#')
-        if p_id.startswith('p'):
-            entry = payments.get(p_id)
-        else:
-            # For data migration from old SRP
-            entry = payments.get('p' + p_id[6:])
+        p_id = p_id.strip('#')
+        if not p_id.startswith('p'):
+            # For data migration from old SRP only
+            p_id = 'p' + p_id[7:] + '0'
+        entry = payments.get(p_id)
         return entry
 
@@ -600,5 +611,5 @@
         if not p_id.startswith('p'):
             # For data migration from old SRP
-            obj.p_id = 'p' + p_id[6:]
+            obj.p_id = 'p' + p_id[7:] + '0'
             parent[obj.p_id] = obj
         else:
@@ -613,5 +624,12 @@
 
         # We have to check p_id.
-        p_id = row['p_id'].strip('#')
+        p_id = row.get('p_id', None)
+        if p_id is None:
+            timestamp = ("%d" % int(time()*10000))[1:]
+            p_id = "p%s" % timestamp
+            conv_dict['p_id'] = p_id
+            return errs, inv_errs, conv_dict
+        else:
+            p_id = p_id.strip('#')
         if p_id.startswith('p'):
             if not len(p_id) == 14:
Index: main/waeup.kofa/trunk/src/waeup/kofa/students/tests/sample_create_payment_data.csv
===================================================================
--- main/waeup.kofa/trunk/src/waeup/kofa/students/tests/sample_create_payment_data.csv	(revision 8884)
+++ main/waeup.kofa/trunk/src/waeup/kofa/students/tests/sample_create_payment_data.csv	(revision 8884)
@@ -0,0 +1,51 @@
+p_state,p_category,reg_number,session_id,r_amount_approved,p_item,amount_auth,r_card_num,r_code,creation_date,type
+paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online
+paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online
+paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online
+paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online
+paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online
+paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online
+paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online
+paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online
+paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online
+paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online
+paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online
+paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online
+paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online
+paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online
+paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online
+paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online
+paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online
+paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online
+paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online
+paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online
+paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online
+paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online
+paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online
+paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online
+paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online
+paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online
+paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online
+paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online
+paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online
+paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online
+paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online
+paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online
+paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online
+paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online
+paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online
+paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online
+paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online
+paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online
+paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online
+paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online
+paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online
+paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online
+paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online
+paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online
+paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online
+paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online
+paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online
+paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online
+paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online
+paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online
Index: main/waeup.kofa/trunk/src/waeup/kofa/students/tests/sample_payment_data.csv
===================================================================
--- main/waeup.kofa/trunk/src/waeup/kofa/students/tests/sample_payment_data.csv	(revision 8860)
+++ main/waeup.kofa/trunk/src/waeup/kofa/students/tests/sample_payment_data.csv	(revision 8884)
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 8860)
+++ main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_batching.py	(revision 8884)
@@ -124,4 +124,11 @@
 
 PAYMENT_HEADER_FIELDS = PAYMENT_SAMPLE_DATA.split(
+    '\n')[0].split(',')
+
+PAYMENT_CREATE_SAMPLE_DATA = open(
+    os.path.join(os.path.dirname(__file__), 'sample_create_payment_data.csv'),
+    'rb').read()
+
+PAYMENT_CREATE_HEADER_FIELDS = PAYMENT_CREATE_SAMPLE_DATA.split(
     '\n')[0].split(',')
 
@@ -784,5 +791,5 @@
         self.student = self.app['students'][student.student_id]
         payment = createObject(u'waeup.StudentOnlinePayment')
-        payment.p_id = 'p123'
+        payment.p_id = 'p120'
         self.student['payments'][payment.p_id] = payment
 
@@ -798,4 +805,7 @@
             self.workdir, 'sample_payment_data.csv')
         open(self.csv_file, 'wb').write(PAYMENT_SAMPLE_DATA)
+        self.csv_file2 = os.path.join(
+            self.workdir, 'sample_create_payment_data.csv')
+        open(self.csv_file2, 'wb').write(PAYMENT_CREATE_SAMPLE_DATA)
 
     def test_interface(self):
@@ -809,9 +819,9 @@
             dict(student_id='ID_NONE', p_id='nonsense'), self.app) is None
         assert self.processor.getEntry(
-            dict(student_id=self.student.student_id, p_id='p123'),
-            self.app) is self.student['payments']['p123']
+            dict(student_id=self.student.student_id, p_id='p120'),
+            self.app) is self.student['payments']['p120']
         assert self.processor.getEntry(
-            dict(student_id=self.student.student_id, p_id='XXXXXX123'),
-            self.app) is self.student['payments']['p123']
+            dict(student_id=self.student.student_id, p_id='XXXXXX112'),
+            self.app) is self.student['payments']['p120']
 
     def test_addEntry(self):
@@ -831,20 +841,20 @@
             self.app)
         self.assertEqual(len(self.student['payments'].keys()),3)
-        self.assertEqual(self.student['payments']['p456'].p_id, 'p456')
+        self.assertEqual(self.student['payments']['p560'].p_id, 'p560')
 
     def test_checkConversion(self):
         errs, inv_errs, conv_dict = self.processor.checkConversion(
-            dict(reg_number='1', p_id='3816951266236341955'))
+            dict(p_id='3816951266236341955'))
         self.assertEqual(len(errs),0)
         errs, inv_errs, conv_dict = self.processor.checkConversion(
-            dict(reg_number='1', p_id='p1266236341955'))
+            dict(p_id='p1266236341955'))
         self.assertEqual(len(errs),0)
         errs, inv_errs, conv_dict = self.processor.checkConversion(
-            dict(reg_number='1', p_id='nonsense'))
+            dict(p_id='nonsense'))
         self.assertEqual(len(errs),1)
-        timestamp = "%d" % int(time()*1000)
+        timestamp = ("%d" % int(time()*10000))[1:]
         p_id = "p%s" % timestamp
         errs, inv_errs, conv_dict = self.processor.checkConversion(
-            dict(reg_number='1', p_id=p_id))
+            dict(p_id=p_id))
         self.assertEqual(len(errs),0)
 
@@ -854,6 +864,6 @@
         self.assertEqual(num_warns,0)
         payment = self.processor.getEntry(dict(reg_number='1',
-            p_id='p1290797973744'), self.app)
-        self.assertEqual(payment.p_id, 'p1290797973744')
+            p_id='p2907979737440'), self.app)
+        self.assertEqual(payment.p_id, 'p2907979737440')
         cdate = payment.creation_date.strftime("%Y-%m-%d %H:%M:%S")
         self.assertEqual(cdate, "2010-11-26 18:59:33")
@@ -881,4 +891,12 @@
         self.assertEqual(num_warns,0)
         shutil.rmtree(os.path.dirname(fin_file))
+
+    def test_import_wo_pid(self):
+        num, num_warns, fin_file, fail_file = self.processor.doImport(
+            self.csv_file2, PAYMENT_CREATE_HEADER_FIELDS,'create')
+        self.assertEqual(num_warns,0)
+        shutil.rmtree(os.path.dirname(fin_file))
+        self.assertEqual(len(self.app['students']['X666666']['payments']), 50)
+
 
 def test_suite():
