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 9516)
+++ main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py	(revision 9517)
@@ -760,5 +760,5 @@
         self.browser.open(self.payments_path)
         IWorkflowState(self.student).setState('cleared')
-        self.browser.getControl("Add online payment ticket").click()
+        self.browser.getLink("Add current session payment ticket").click()
         self.browser.getControl(name="form.p_category").value = ['schoolfee']
         self.browser.getControl("Create ticket").click()
@@ -781,5 +781,5 @@
         # can be initialized a second time if the former ticket is not yet paid.
         self.browser.open(self.payments_path)
-        self.browser.getControl("Add online payment ticket").click()
+        self.browser.getLink("Add current session payment ticket").click()
         self.browser.getControl(name="form.p_category").value = ['schoolfee']
         self.browser.getControl("Create ticket").click()
@@ -827,5 +827,5 @@
         # (with same p_item, p_session and p_category) can be added
         self.browser.open(self.payments_path)
-        self.browser.getControl("Add online payment ticket").click()
+        self.browser.getLink("Add current session payment ticket").click()
         self.browser.getControl(name="form.p_category").value = ['schoolfee']
         self.browser.getControl("Create ticket").click()
@@ -833,6 +833,4 @@
             '...This type of payment has already been made...',
             self.browser.contents)
-        # The PreviousPaymentAddFormPage opens
-        self.assertEqual(self.browser.url, self.payments_path + '/@@addpp')
 
         # Managers can open the pdf payment slip
@@ -887,5 +885,5 @@
         self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
         self.browser.open(self.payments_path)
-        self.browser.getControl("Add online payment ticket").click()
+        self.browser.getLink("Add current session payment ticket").click()
         self.browser.getControl(name="form.p_category").value = ['bed_allocation']
         # If student is not in accommodation session, payment cannot be processed
@@ -895,5 +893,5 @@
                            self.browser.contents)
         self.app['hostels'].accommodation_session = 2004
-        self.browser.getControl("Add online payment ticket").click()
+        self.browser.getLink("Add current session payment ticket").click()
         self.browser.getControl(name="form.p_category").value = ['bed_allocation']
         self.browser.getControl("Create ticket").click()
@@ -2046,5 +2044,5 @@
         self.assertRaises(
             LookupError, self.browser.getControl, name='val_id')
-        self.browser.getControl("Add online payment ticket").click()
+        self.browser.getLink("Add current session payment ticket").click()
         self.browser.getControl(name="form.p_category").value = ['schoolfee']
         self.browser.getControl("Create ticket").click()
@@ -2136,5 +2134,9 @@
         configuration2.booking_fee = 123.4
         self.app['configuration'].addSessionConfiguration(configuration2)
-
+        configuration3 = createObject('waeup.SessionConfiguration')
+        configuration3.academic_session = 2005
+        configuration3.clearance_fee = 3456.0
+        configuration3.booking_fee = 123.4
+        self.app['configuration'].addSessionConfiguration(configuration3)
         self.student['studycourse'].entry_session = 2002
 
@@ -2148,16 +2150,8 @@
         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)
+        self.browser.getLink("Add previous session payment ticket").click()
 
         # Previous session payment form is provided
+        self.assertEqual(self.student.current_session, 2004)
         self.browser.getControl(name="form.p_category").value = ['schoolfee']
         self.browser.getControl(name="form.p_session").value = ['2000']
@@ -2167,11 +2161,12 @@
                            self.browser.contents)
         self.browser.getControl(name="form.p_category").value = ['schoolfee']
-        self.browser.getControl(name="form.p_session").value = ['2004']
+        self.browser.getControl(name="form.p_session").value = ['2005']
         self.browser.getControl(name="form.p_level").value = ['300']
         self.browser.getControl("Create ticket").click()
         self.assertMatches('...This is not a previous session...',
                            self.browser.contents)
+        # Students can pay current session school fee.
         self.browser.getControl(name="form.p_category").value = ['schoolfee']
-        self.browser.getControl(name="form.p_session").value = ['2003']
+        self.browser.getControl(name="form.p_session").value = ['2004']
         self.browser.getControl(name="form.p_level").value = ['300']
         self.browser.getControl("Create ticket").click()
@@ -2186,5 +2181,5 @@
 
         # Payment session is properly set
-        self.assertEqual(self.student['payments'][value].p_session, 2003)
+        self.assertEqual(self.student['payments'][value].p_session, 2004)
         self.assertEqual(self.student['payments'][value].p_level, 300)
 
@@ -2200,4 +2195,14 @@
         # Current payment flag is set False
         self.assertFalse(self.student['payments'][value].p_current)
+
+        # Button and form are not available for fresh students
+        self.student['studycourse'].entry_session = 2004
+        self.browser.open(self.payments_path)
+        self.assertFalse(
+            "Add previous session payment ticket" in self.browser.contents)
+        self.browser.open(self.payments_path + '/addpp')
+        self.assertTrue(
+            "You can't pay for a session below your entry session" in
+            self.browser.contents)
         return
 
@@ -2215,5 +2220,5 @@
         IWorkflowState(self.student).setState('cleared')
         self.browser.open(self.payments_path)
-        self.browser.getControl("Add online payment ticket").click()
+        self.browser.getLink("Add current session payment ticket").click()
         self.browser.getControl(name="form.p_category").value = ['schoolfee']
         self.browser.getControl("Create ticket").click()
@@ -2255,5 +2260,5 @@
         # Remove first payment to be sure that we access the right ticket
         del self.student['payments'][value]
-        self.browser.getControl("Add online payment ticket").click()
+        self.browser.getLink("Add current session payment ticket").click()
         self.browser.getControl(name="form.p_category").value = ['schoolfee']
         self.browser.getControl("Create ticket").click()
@@ -2301,5 +2306,5 @@
         # callback view (see test_manage_payments)
         self.browser.getLink("Payments").click()
-        self.browser.getControl("Add online payment ticket").click()
+        self.browser.getLink("Add current session payment ticket").click()
         self.browser.getControl(name="form.p_category").value = ['bed_allocation']
         self.browser.getControl("Create ticket").click()
