Index: main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py
===================================================================
--- main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py	(revision 9139)
+++ main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py	(revision 9148)
@@ -1575,5 +1575,57 @@
         return
 
-    def test_postgraduate_payments(self):
+    def test_student_previous_payments(self):
+        # Login
+        self.browser.open(self.login_path)
+        self.browser.getControl(name="form.login").value = self.student_id
+        self.browser.getControl(name="form.password").value = 'spwd'
+        self.browser.getControl("Login").click()
+
+        # Students can add previous school fee payment tickets in any state.
+        IWorkflowState(self.student).setState('courses registered')
+        self.browser.open(self.payments_path)
+        self.browser.getControl("Add online payment ticket").click()
+        self.browser.getControl(name="form.p_category").value = ['schoolfee']
+        self.browser.getControl("Create ticket").click()
+
+        # Amount cannot be determined since the state is not
+        # 'cleared' or 'returning'
+        self.assertMatches('...Amount could not be determined...',
+                           self.browser.contents)
+        self.assertMatches('...Would you like to pay for a previous session?...',
+                           self.browser.contents)
+
+        # Previous session payment form is provided
+        self.browser.getControl(name="form.p_category").value = ['schoolfee']
+        self.browser.getControl(name="form.p_session").value = ['2004']
+        self.browser.getControl(name="form.p_level").value = ['300']
+        self.browser.getControl("Create ticket").click()
+        self.assertMatches('...ticket created...',
+                           self.browser.contents)
+        ctrl = self.browser.getControl(name='val_id')
+        value = ctrl.options[0]
+        self.browser.getLink(value).click()
+        self.assertMatches('...Amount Authorized...',
+                           self.browser.contents)
+        self.assertEqual(self.student['payments'][value].amount_auth, 20000.0)
+
+        # Payment session is properly set
+        self.assertEqual(self.student['payments'][value].p_session, 2004)
+        self.assertEqual(self.student['payments'][value].p_level, 300)
+
+        # We simulate the approval
+        self.browser.open(self.browser.url + '/fake_approve')
+        self.assertMatches('...Payment approved...',
+                          self.browser.contents)
+
+        # No AC has been created
+        self.assertEqual(len(self.app['accesscodes']['SFE-0'].keys()), 0)
+        self.assertTrue(self.student['payments'][value].ac is None)
+
+        # Current payment flag is set False
+        self.assertFalse(self.student['payments'][value].p_current)
+        return
+
+    def test_student_postgraduate_payments(self):
         self.certificate.study_mode = 'pg_ft'
         self.certificate.start_level = 999
Index: main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_export.py
===================================================================
--- main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_export.py	(revision 9139)
+++ main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_export.py	(revision 9148)
@@ -371,9 +371,9 @@
         self.assertEqual(
             result,
-            'ac,amount_auth,creation_date,p_category,p_id,'
+            'ac,amount_auth,creation_date,p_category,p_current,p_id,'
             'p_item,p_level,p_session,p_state,payment_date,r_amount_approved,'
             'r_code,r_desc,student_id\r\n'
 
-            ',0.0,2012-04-01 13:12:01,schoolfee,,,,,unpaid,,0.0,,,\r\n'
+            ',0.0,2012-04-01 13:12:01,schoolfee,1,,,,,unpaid,,0.0,,,\r\n'
             )
         return
@@ -389,9 +389,9 @@
         self.assertEqual(
             result,
-            'ac,amount_auth,creation_date,p_category,p_id,'
+            'ac,amount_auth,creation_date,p_category,p_current,p_id,'
             'p_item,p_level,p_session,p_state,payment_date,r_amount_approved,'
             'r_code,r_desc,student_id\r\n'
 
-            '666,0.0,2012-04-01 13:12:01,schoolfee,my-id,'
+            '666,0.0,2012-04-01 13:12:01,schoolfee,1,my-id,'
             'p-item,100,2012,unpaid,2012-04-01 14:12:01,12.12,'
             'r-code,,A111111\r\n'
@@ -408,9 +408,9 @@
         self.assertEqual(
             result,
-            'ac,amount_auth,creation_date,p_category,p_id,'
+            'ac,amount_auth,creation_date,p_category,p_current,p_id,'
             'p_item,p_level,p_session,p_state,payment_date,r_amount_approved,'
             'r_code,r_desc,student_id\r\n'
 
-            '666,0.0,2012-04-01 13:12:01,schoolfee,my-id,'
+            '666,0.0,2012-04-01 13:12:01,schoolfee,1,my-id,'
             'p-item,100,2012,unpaid,2012-04-01 14:12:01,12.12,'
             'r-code,,A111111\r\n'
@@ -427,9 +427,9 @@
         self.assertEqual(
             result,
-            'ac,amount_auth,creation_date,p_category,p_id,'
+            'ac,amount_auth,creation_date,p_category,p_current,p_id,'
             'p_item,p_level,p_session,p_state,payment_date,r_amount_approved,'
             'r_code,r_desc,student_id\r\n'
 
-            '666,0.0,2012-04-01 13:12:01,schoolfee,my-id,'
+            '666,0.0,2012-04-01 13:12:01,schoolfee,1,my-id,'
             'p-item,100,2012,unpaid,2012-04-01 14:12:01,12.12,'
             'r-code,,A111111\r\n'
