Index: /WAeUP_SRP/trunk/Upload.py
===================================================================
--- /WAeUP_SRP/trunk/Upload.py	(revision 3987)
+++ /WAeUP_SRP/trunk/Upload.py	(revision 3988)
@@ -12,5 +12,5 @@
 from Products.WAeUP_SRP.WAeUPTables import AccommodationTable,NOT_OCCUPIED
 from WAeUPImport import ApplicationImport,CertificateImport,CertificateCourseImport
-from WAeUPImport import CourseImport,CourseResultImport
+from WAeUPImport import CourseImport,CourseResultImport,PaymentImport
 from WAeUPImport import DepartmentImport,FacultyImport,StudentImport,VerdictImport,StudentStudyLevelImport
 from WAeUPImport import NO_KEY,IGNORE
Index: /WAeUP_SRP/trunk/WAeUPImport.py
===================================================================
--- /WAeUP_SRP/trunk/WAeUPImport.py	(revision 3987)
+++ /WAeUP_SRP/trunk/WAeUPImport.py	(revision 3988)
@@ -989,8 +989,8 @@
                 line_for_reimport.append(format_for_reimport % d)
                 open(reimport_file,"a").write('\n'.join(line_for_reimport) +'\n')                
-                self.course_results.getExportRemoveAllCourses(student_id = student_id, export = True, remove = True)
-#                self.course_results.getExportRemoveAllCourses(student_id = student_id, export = True, remove = False)
-                self.payments_catalog.getExportRemoveAllPayments(student_id = student_id, export = True, remove = True)
-#                self.payments_catalog.getExportRemoveAllPayments(student_id = student_id, export = True, remove = False)
+                self.course_results.exportRemoveAllCourses(student_id = student_id, export = True, remove = True)
+#                self.course_results.exportRemoveAllCourses(student_id = student_id, export = True, remove = False)
+                self.payments_catalog.exportRemoveAllPayments(student_id = student_id, export = True, remove = True)
+#                self.payments_catalog.exportRemoveAllPayments(student_id = student_id, export = True, remove = False)
                 self.waeup_tool.exportAllStudyLevels(student_id = student_id)
                 # end export
@@ -1134,5 +1134,5 @@
         "edit student levels and create StudentStudyLevel object if not existent"
         wftool = self.portal_workflow
-        logger = logging.getLogger('WAeUPTool.mass_create_level')
+        logger = logging.getLogger('WAeUPImport.StudentStudyLevelImport.create')
         students_folder = self.portal_url.getPortalObject().campus.students
         student_id = mapping.get('id',None)
@@ -1177,5 +1177,5 @@
         "edit student levels"
         wftool = self.portal_workflow
-        logger = logging.getLogger('WAeUPTool.mass_edit_level')
+        logger = logging.getLogger('WAeUPImport.StudentStudyLevelImport.edit')
         students_folder = self.portal_url.getPortalObject().campus.students
         student_id = mapping.get('id',None)
@@ -1221,5 +1221,5 @@
         "edit student verdicts and create StudentStudyLevel object if not existent"
         wftool = self.portal_workflow
-        logger = logging.getLogger('WAeUPTool.mass_edit_verdict')
+        logger = logging.getLogger('WAeUPImport.VerdictImport.create')
         students_folder = self.portal_url.getPortalObject().campus.students
         student_id = mapping.get('id',None)
@@ -1310,5 +1310,5 @@
         "edit student verdicts"
         wftool = self.portal_workflow
-        logger = logging.getLogger('WAeUPTool.mass_edit_verdict')
+        logger = logging.getLogger('WAeUPImport.VerdictImport.edit')
         students_folder = self.portal_url.getPortalObject().campus.students
         student_id = mapping.get('id',None)
@@ -1389,98 +1389,64 @@
     ###)
 
-    def edit_old(self,mapping): ###(
-        "edit student verdicts"
+    
+    
+class PaymentImport(WAeUPImport):###(
+    """ PaymentImport """
+    name = "payment"
+    plural_name = "%ss" % name
+    commit_after = 1000000
+    required_modes = ('create',)
+
+    def create(self,mapping): ###(
+        "create payment object"
         wftool = self.portal_workflow
-        logger = logging.getLogger('WAeUPTool.mass_edit_verdict')
+        logger = logging.getLogger('WAeUPImport.PaymentImport.create')
         students_folder = self.portal_url.getPortalObject().campus.students
         student_id = mapping.get('id',None)
-        matric_no = mapping.get('matric_no',None)
+        order_id = key= mapping.get('order_id',None)
+        payment_type = mapping.get('type',None)
         editable_keys = mapping.keys()
         key = ''
-        while True:
-            msg = ''
-            if student_id:
-                student_record = self.students_catalog.getRecordByKey(student_id)
-                if student_record is None:
-                    #return '',"no student with id %s" % student_id
-                    msg = "no student with id %s" % student_id
+        msg = ''
+        while True:
+            result = self.findStudent('create',student_id=student_id)
+            msg = result['msg']
+            if msg:
+                break            
+            if payment_type == 'sc':
+                hyphen = order_id.rfind('-')
+                if not hyphen > -1:
+                    msg = '%s: wrong order_id of sc payment' % student_id
                     break
-                if matric_no and student_record.matric_no and matric_no != student_record.matric_no:
-                    msg = 'student %s: matric_no %s does not match %s' % (student_record.id,
-                                                                          student_record.matric_no,
-                                                                          matric_no)
-                    break
-                mapping['matric_no'] = student_record.matric_no
-            elif matric_no:
-                res = self.students_catalog(matric_no = matric_no)
-                if not res:
-                    msg = "no student with matric_no %s" % matric_no
-                    break
-                student_record = res[0]
-                editable_keys.remove('matric_no')
+                payment_object_id = 'p' + order_id[hyphen+1:]
+            elif payment_type == 'online':
+                payment_object_id = 'p' + order_id[6:]
             else:
-                msg = "no id or matric_no specified"
-                break
+                msg = '%s: no payment type defined' % student_id
+                break
+            student_record = result['student_record']
             student_id = student_record.id
+
             mapping['id'] = student_id
-            d = {}
-            #import pdb;pdb.set_trace()
-            any_change = False
-            #special treatment for StudentStudyLevel
-            current_session = d['session'] = mapping.get('current_session','')
-            if current_session and student_record.session != current_session:
-                msg = 'student %s: imported session %s does not match current_session %s' % (student_id,
-                                                                                            current_session,
-                                                                                            student_record.session)
-                break
-            current_level = mapping.get('current_level','')
-            if not current_level.isdigit():
-                msg = 'student %s: imported level is empty' % (student_id,)
-                break
-            if current_level and student_record.level != current_level:
-                msg = 'student %s: imported level %s does not match current_level %s' % (student_id,
-                                                                                        current_level,
-                                                                                        student_record.level)
-                break
-            student_review_state =  student_record.review_state
-            if student_review_state == 'deactivated':
-                msg = "student %s in review_state %s" % (student_id, student_review_state)
-                break
-            if student_review_state not in ('courses_validated','returning'):
-                msg = "student %s in wrong review_state %s" % (student_id, student_review_state)
-                break
-            student_obj = getattr(students_folder,student_id)
-            # f2t = self.field2types_student
-            study_course_obj = getattr(student_obj,'study_course',None)
-            if study_course_obj is None:
-                msg = 'student %s: no study_course object' % student_id
-                break
-            level_obj = getattr(study_course_obj,current_level,None)
-            if  level_obj is None:
-                msg = 'student %s: no study_level object for level %s' % (student_id,
-                                                                                current_level)
-                break
-            verdict = d['verdict'] = d['current_verdict']  = mapping.get('current_verdict','')
-
-            #if verdict == student_record.verdict:
-            #    msg = 'student %s: verdict already set to %s' % (student_id,
-            #                                                            verdict)
-
-            level_review_state = wftool.getInfoFor(level_obj,'review_state',None)
-            if level_review_state != "closed":
-                wftool.doActionFor(level_obj,'close')
-                # msg = 'student %s: level %s is not closed' % (student_id,
-                #                                                      current_level)
-
-            study_course_obj.getContent().edit(mapping = d)
-            level_obj.getContent().edit(mapping = d)
-            if student_review_state != "returning":
-                wftool.doActionFor(student_obj,'return')
-            # try:
-            #     wftool.doActionFor(level_obj,'close')
-            # except:
-            #     pass
-            break
-        return student_id,msg,mapping
-    ###)
+            payments_folder = getattr(getattr(students_folder,student_id),'payments',None)
+            if payments_folder is None:
+                msg = '%s: no payments folder' % student_id
+                break
+            if getattr(payments_folder,payment_object_id,False):
+                msg = '%s: payment object with id %s exists' % (student_id,payment_object_id)
+                break
+            try:
+                #import pdb;pdb.set_trace()
+                payments_folder.invokeFactory('Payment',"%s" % payment_object_id)
+                payment_obj = getattr(payments_folder,"%s" % payment_object_id)
+            except:
+                msg = '%s: payment object %s cannot be created' % (student_id,payment_object_id)
+                break
+            payment_obj.getContent().edit(mapping = mapping)
+            wftool.doActionFor(payment_obj,'close')
+            break
+        return key,msg,mapping
+    ###)
+    
+    
 ###)
Index: /WAeUP_SRP/trunk/WAeUPTables.py
===================================================================
--- /WAeUP_SRP/trunk/WAeUPTables.py	(revision 3987)
+++ /WAeUP_SRP/trunk/WAeUPTables.py	(revision 3988)
@@ -1668,5 +1668,5 @@
     ###)
     
-    def getExportRemoveAllCourses(self,student_id,export=False,remove=False): ###(
+    def exportRemoveAllCourses(self,student_id,export=False,remove=False): ###(
         ""
         query = Eq('student_id',student_id)
@@ -1797,5 +1797,5 @@
 
 
-    def getExportRemoveAllPayments(self,student_id,export=False,remove=False): ###(
+    def exportRemoveAllPayments(self,student_id,export=False,remove=False): ###(
         ""
         query = Eq('student_id',student_id)
Index: /WAeUP_SRP/trunk/WAeUPTool.py
===================================================================
--- /WAeUP_SRP/trunk/WAeUPTool.py	(revision 3987)
+++ /WAeUP_SRP/trunk/WAeUPTool.py	(revision 3988)
@@ -44,5 +44,5 @@
 from Globals import package_home,INSTANCE_HOME
 from WAeUPImport import ApplicationImport,CertificateImport,CertificateCourseImport
-from WAeUPImport import CourseImport,CourseResultImport,StudentStudyLevelImport
+from WAeUPImport import CourseImport,CourseResultImport,StudentStudyLevelImport,PaymentImport
 from WAeUPImport import DepartmentImport,FacultyImport,StudentImport,VerdictImport
 from utils import makeDigest
Index: /WAeUP_SRP/trunk/patches/PatchExtendedWidgetsCPSDateTimeWidget.py
===================================================================
--- /WAeUP_SRP/trunk/patches/PatchExtendedWidgetsCPSDateTimeWidget.py	(revision 3987)
+++ /WAeUP_SRP/trunk/patches/PatchExtendedWidgetsCPSDateTimeWidget.py	(revision 3988)
@@ -10,43 +10,63 @@
     field_id = self.fields[0]
     widget_id = self.getWidgetId()
-    if datastructure.has_key(widget_id + '_date'):
-        date = datastructure[widget_id + '_date'].strip()
-    else:
-        date = datastructure[widget_id].strip()
-    if datastructure.has_key(widget_id + '_hour'):
-        hour = datastructure[widget_id + '_hour'].strip()
-    else:
-        hour = self.time_hour_default
-    if datastructure.has_key(widget_id + '_minute'):
-        minute = datastructure[widget_id + '_minute'].strip()
-    else:
-        minute = self.time_minutes_default
-
-    if not (date):
-        if self.is_required:
-            datastructure[widget_id] = ''
-            datastructure.setError(widget_id, 'cpsschemas_err_required')
-            return 0
-        else:
-            datamodel[field_id] = None
-            return 1
-    #import pdb;pdb.set_trace()
-    if self.view_format.startswith('iso8601'):
-        if re.match(r'^[0-9]+-[0-9]{2}-[0-9]{2}', date) is not None:
-            y, m, d = date.split('-')
-        else:
+    
+    if self.view_format == 'import':
+        try:
+            dt = datastructure[widget_id].strip() 
+            date,time,dummy = dt.split()
+            y,m,d = date.split('/')
+            hour,minute,second = time.split(':')
+        except:
             datastructure.setError(widget_id, 'cpsschemas_err_date')
             return 0
+        if not (date):
+            if self.is_required:
+                datastructure[widget_id] = ''
+                datastructure.setError(widget_id, 'cpsschemas_err_required')
+                return 0
+            else:
+                datamodel[field_id] = None
+                return 1
     else:
-        if re.match(r'^[0-9]?[0-9][/,\-,\.][0-9]?[0-9][/,\-,\.][0-9]{2,4}$', date) is not None:
-            d, m, y = re.split(r'[/,\-,\.]',date) # always use d/m/y and use /,- or . as separator
-            #d, m, y = date.split('/') # always use d/m/y
-            # locale = self.translation_service.getSelectedLanguage()
-            # if False and locale in ('en', 'hu'): 
-            #     m, d, y = date.split('/')
-            # else:
+        if datastructure.has_key(widget_id + '_date'):
+            date = datastructure[widget_id + '_date'].strip()
         else:
-            datastructure.setError(widget_id, 'cpsschemas_err_date')
-            return 0
+            date = datastructure[widget_id].strip()
+        if datastructure.has_key(widget_id + '_hour'):
+            hour = datastructure[widget_id + '_hour'].strip()
+        else:
+            hour = self.time_hour_default
+        if datastructure.has_key(widget_id + '_minute'):
+            minute = datastructure[widget_id + '_minute'].strip()
+        else:
+            minute = self.time_minutes_default
+
+        if not (date):
+            if self.is_required:
+                datastructure[widget_id] = ''
+                datastructure.setError(widget_id, 'cpsschemas_err_required')
+                return 0
+            else:
+                datamodel[field_id] = None
+                return 1
+                
+        #import pdb;pdb.set_trace()
+        if self.view_format.startswith('iso8601'):
+            if re.match(r'^[0-9]+-[0-9]{2}-[0-9]{2}', date) is not None:
+                y, m, d = date.split('-')
+            else:
+                datastructure.setError(widget_id, 'cpsschemas_err_date')
+                return 0
+        else:
+            if re.match(r'^[0-9]?[0-9][/,\-,\.][0-9]?[0-9][/,\-,\.][0-9]{2,4}$', date) is not None:
+                d, m, y = re.split(r'[/,\-,\.]',date) # always use d/m/y and use /,- or . as separator
+                #d, m, y = date.split('/') # always use d/m/y
+                # locale = self.translation_service.getSelectedLanguage()
+                # if False and locale in ('en', 'hu'): 
+                #     m, d, y = date.split('/')
+                # else:
+            else:
+                datastructure.setError(widget_id, 'cpsschemas_err_date')
+                return 0
 
     try:
Index: /WAeUP_SRP/trunk/profiles/default/layouts.xml
===================================================================
--- /WAeUP_SRP/trunk/profiles/default/layouts.xml	(revision 3987)
+++ /WAeUP_SRP/trunk/profiles/default/layouts.xml	(revision 3988)
@@ -79,4 +79,5 @@
   <object name="import_verdict" meta_type="CPS Layout"/>
   <object name="import_student_study_level" meta_type="CPS Layout"/>
+  <object name="import_payment" meta_type="CPS Layout"/>
 
   <object name="department" meta_type="CPS Layout"/>
Index: /WAeUP_SRP/trunk/profiles/default/layouts/import_payment.xml
===================================================================
--- /WAeUP_SRP/trunk/profiles/default/layouts/import_payment.xml	(revision 3988)
+++ /WAeUP_SRP/trunk/profiles/default/layouts/import_payment.xml	(revision 3988)
@@ -0,0 +1,105 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/xsl" href="layout.xsl"?>
+<object name="payment" meta_type="CPS Layout">
+ <property name="layout_create_method"></property>
+ <property name="layout_edit_method"></property>
+ <property name="layout_view_method"></property>
+ <property name="style_prefix">layout_waeup_</property>
+ <property name="flexible_widgets"/>
+ <property name="validate_values_expr"></property>
+ <widget name="import_mode" meta_type="Select Widget">
+  <property name="fields">
+   <element value="import_mode"/>
+  </property>
+  <property name="is_required">True</property>
+  <property name="vocabulary">import_modes</property>
+ </widget>
+  <widget name="id" meta_type="String Widget">
+    <property name="fields">
+      <element value="id"/>
+    </property>
+    <property name="is_required">False</property>
+  </widget> 
+ <widget name="amount" meta_type="String Widget">
+  <property name="fields">
+   <element value="amount"/>
+  </property>
+ </widget>
+ <widget name="surcharge" meta_type="String Widget">
+  <property name="fields">
+   <element value="surcharge"/>
+  </property>
+ </widget>
+ <widget name="date" meta_type="DateTime Widget">
+  <property name="fields">
+   <element value="date"/>
+  </property>
+  <property name="view_format">import</property>
+ </widget>
+
+ <widget name="resp_approved_amount" meta_type="String Widget">
+  <property name="fields">
+   <element value="resp_approved_amount"/>
+  </property>
+ </widget>
+ <widget name="resp_pay_reference" meta_type="String Widget">
+  <property name="fields">
+   <element value="resp_pay_reference"/>
+  </property>
+ </widget>
+ <widget name="resp_card_num" meta_type="String Widget">
+  <property name="fields">
+   <element value="resp_card_num"/>
+  </property>
+ </widget>
+ <widget name="resp_code" meta_type="String Widget">
+  <property name="fields">
+   <element value="resp_code"/>
+  </property>
+ </widget>
+ <widget name="resp_desc" meta_type="String Widget">
+ <property name="fields">
+  <element value="resp_desc"/>
+ </property>
+ </widget>
+ <widget name="status" meta_type="Select Widget">
+  <property name="fields">
+   <element value="status"/>
+  </property>
+  <property name="vocabulary">payment_status</property>
+ </widget>
+ <widget name="category" meta_type="Select Widget">
+  <property name="fields">
+   <element value="category"/>
+  </property>
+  <property name="vocabulary">payment_categories</property>
+ </widget>
+ <widget name="item" meta_type="String Widget">
+  <property name="fields">
+   <element value="item"/>
+  </property>
+ </widget>
+ <widget name="type" meta_type="Select Widget">
+  <property name="fields">
+   <element value="type"/>
+  </property>
+  <property name="vocabulary">payment_types</property>
+ </widget>
+ <widget name="session_id" meta_type="Select Widget">
+  <property name="fields">
+   <element value="session_id"/>
+  </property>
+  <property name="vocabulary">sessions</property>
+ </widget>
+ <widget name="type_description" meta_type="String Widget">
+  <property name="fields">
+   <element value="type_description"/>
+  </property>
+  </widget>
+ <widget name="order_id" meta_type="String Widget">
+  <property name="fields">
+   <element value="order_id"/>
+  </property>
+ </widget>
+</object>
+
Index: /WAeUP_SRP/trunk/profiles/default/layouts/import_student.xml
===================================================================
--- /WAeUP_SRP/trunk/profiles/default/layouts/import_student.xml	(revision 3987)
+++ /WAeUP_SRP/trunk/profiles/default/layouts/import_student.xml	(revision 3988)
@@ -245,9 +245,10 @@
  </widget> 
  
- <widget name="app_ac_date" meta_type="String Widget">
+ <widget name="app_ac_date" meta_type="DateTime Widget">
   <property name="fields">
    <element value="app_ac_date"/>
   </property>
- </widget> 
+  <property name="view_format">import</property>
+ </widget>
  
  <widget name="app_mobile" meta_type="String Widget">
@@ -257,8 +258,9 @@
  </widget> 
  
- <widget name="request_date" meta_type="String Widget">
+ <widget name="request_date" meta_type="DateTime Widget">
   <property name="fields">
    <element value="request_date"/>
   </property>
+  <property name="view_format">import</property>
  </widget> 
  
@@ -269,8 +271,9 @@
  </widget> 
  
- <widget name="cleared_date" meta_type="String Widget">
+ <widget name="cleared_date" meta_type="DateTime Widget">
   <property name="fields">
    <element value="cleared_date"/>
   </property>
+  <property name="view_format">import</property>
  </widget> 
  
Index: /WAeUP_SRP/trunk/profiles/default/schemas.xml
===================================================================
--- /WAeUP_SRP/trunk/profiles/default/schemas.xml	(revision 3987)
+++ /WAeUP_SRP/trunk/profiles/default/schemas.xml	(revision 3988)
@@ -61,4 +61,5 @@
  <object name="import_verdict" meta_type="CPS Schema"/>
  <object name="import_student_study_level" meta_type="CPS Schema"/>
+ <object name="import_payment" meta_type="CPS Schema"/>
 
  <object name="course" meta_type="CPS Schema"/>
Index: /WAeUP_SRP/trunk/profiles/default/schemas/import_payment.xml
===================================================================
--- /WAeUP_SRP/trunk/profiles/default/schemas/import_payment.xml	(revision 3988)
+++ /WAeUP_SRP/trunk/profiles/default/schemas/import_payment.xml	(revision 3988)
@@ -0,0 +1,21 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/xsl" href="schema.xsl"?>
+<object name="import_payment" meta_type="CPS Schema">
+  <field name="import_mode" meta_type="CPS String Field"/>
+  <field name="id" meta_type="CPS String Field"/>
+  <field name="date" meta_type="CPS DateTime Field"/>
+  <field name="type_description" meta_type="CPS String Field" />
+  <field name="amount" meta_type="CPS String Field"/>
+  <field name="surcharge" meta_type="CPS String Field"/>
+  <field name="item" meta_type="CPS String Field"/>
+  <field name="type" meta_type="CPS String Field"/>
+  <field name="category" meta_type="CPS String Field"/>
+  <field name="status" meta_type="CPS String Field"/>
+  <field name="resp_pay_reference" meta_type="CPS String Field"/>
+  <field name="resp_desc" meta_type="CPS String Field" />
+  <field name="order_id" meta_type="CPS String Field"/>
+  <field name="session_id" meta_type="CPS String Field"/>
+  <field name="resp_code" meta_type="CPS String Field"/>
+  <field name="resp_card_num" meta_type="CPS String Field"/>
+  <field name="resp_approved_amount" meta_type="CPS String Field"/>
+</object>
Index: /WAeUP_SRP/trunk/profiles/default/vocabularies/import_names.xml
===================================================================
--- /WAeUP_SRP/trunk/profiles/default/vocabularies/import_names.xml	(revision 3987)
+++ /WAeUP_SRP/trunk/profiles/default/vocabularies/import_names.xml	(revision 3988)
@@ -16,3 +16,4 @@
  <item key="certificate" msgid="">Certificate Data</item>
  <item key="certificate_course" msgid="">Certificate Course Data</item>
+ <item key="payment" msgid="">Payment Data</item>
 </object>
Index: /WAeUP_SRP/trunk/skins/waeup_epayment/payment_receipt.pt
===================================================================
--- /WAeUP_SRP/trunk/skins/waeup_epayment/payment_receipt.pt	(revision 3987)
+++ /WAeUP_SRP/trunk/skins/waeup_epayment/payment_receipt.pt	(revision 3988)
@@ -112,5 +112,5 @@
         <tr>        
           <td width="220px">Transaction Date:</td> 
-          <td><span tal:content="python:pm.date.ISO()" /></td>
+          <td><span tal:content='python:pm.date.strftime("%d/%m/%y %H:%M:%S")' /></td>
         </tr>       
         <tr>
