Index: /main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py
===================================================================
--- /main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py	(revision 9516)
+++ /main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py	(revision 9517)
@@ -1338,7 +1338,7 @@
         return
 
-    @action(_('Add online payment ticket'))
-    def addPaymentTicket(self, **data):
-        self.redirect(self.url(self.context, '@@addop'))
+    #@action(_('Add online payment ticket'))
+    #def addPaymentTicket(self, **data):
+    #    self.redirect(self.url(self.context, '@@addop'))
 
 class OnlinePaymentAddFormPage(KofaAddFormPage):
@@ -1378,8 +1378,4 @@
         if error is not None:
             self.flash(error)
-            if 'previous session' in error or 'Would you like' in error:
-                self.redirect(self.url(self.context) + '/@@addpp')
-                return
-            self.redirect(self.url(self.context))
             return
         self.context[payment.p_id] = payment
@@ -1402,4 +1398,11 @@
     label = _('Add previous session online payment')
     pnav = 4
+
+    def update(self):
+        if self.context.student.is_fresh:
+            self.flash(_("You can't pay for a session below your entry session."))
+            self.redirect(self.url(self.context))
+        super(PreviousPaymentAddFormPage, self).update()
+        return
 
 class OnlinePaymentDisplayFormPage(KofaDisplayFormPage):
Index: /main/waeup.kofa/trunk/src/waeup/kofa/students/student.py
===================================================================
--- /main/waeup.kofa/trunk/src/waeup/kofa/students/student.py	(revision 9516)
+++ /main/waeup.kofa/trunk/src/waeup/kofa/students/student.py	(revision 9517)
@@ -36,5 +36,6 @@
 from waeup.kofa.interfaces import (
     IObjectHistory, IUserAccount, IFileStoreNameChooser, IFileStoreHandler,
-    IKofaUtils, CLEARANCE, registration_states_vocab, IExtFileStore,)
+    IKofaUtils, registration_states_vocab, IExtFileStore,
+    CLEARANCE)
 from waeup.kofa.students.accommodation import StudentAccommodation
 from waeup.kofa.students.export import EXPORTER_NAMES
@@ -190,4 +191,12 @@
             self.get('studycourse', None), 'is_postgrad', False)
         return is_postgrad
+
+    @property
+    def is_fresh(self):
+        entry_session = getattr(
+            self.get('studycourse', None), 'entry_session', None)
+        if self.current_session == entry_session:
+            return True
+        return False
 
     def transfer(self, certificate, current_session=None,
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()
Index: /main/waeup.kofa/trunk/src/waeup/kofa/students/utils.py
===================================================================
--- /main/waeup.kofa/trunk/src/waeup/kofa/students/utils.py	(revision 9516)
+++ /main/waeup.kofa/trunk/src/waeup/kofa/students/utils.py	(revision 9517)
@@ -309,4 +309,14 @@
         amount = 0.0
         if previous_session:
+            if previous_session < student['studycourse'].entry_session:
+                return _('The previous session must not fall below '
+                         'your entry session.'), None
+            if category == 'schoolfee':
+                # School fee is always paid for the following session
+                if previous_session > student['studycourse'].current_session:
+                    return _('This is not a previous session.'), None
+            else:
+                if previous_session > student['studycourse'].current_session - 1:
+                    return _('This is not a previous session.'), None
             p_session = previous_session
             p_level = previous_level
@@ -328,9 +338,7 @@
                 return _('Study course data are incomplete.'), None
             if previous_session:
-                if previous_session < student['studycourse'].entry_session:
-                    return _('The previous session must not fall below '
-                             'your entry session.'), None
-                if previous_session > student['studycourse'].current_session - 1:
-                    return _('This is not a previous session.'), None
+                # Students can pay for previous sessions in all workflow states.
+                # Fresh students are excluded by the update method of the
+                # PreviousPaymentAddFormPage.
                 if previous_level == 100:
                     amount = getattr(certificate, 'school_fee_1', 0.0)
@@ -343,5 +351,5 @@
                     # In case of returning school fee payment the payment session
                     # and level contain the values of the session the student
-                    # has paid for.
+                    # has paid for. Payment session is always next session.
                     p_session, p_level = self.getReturningData(student)
                     amount = getattr(certificate, 'school_fee_2', 0.0)
@@ -372,6 +380,5 @@
                 p_item = trans(_('no bed allocated'), portal_language)
         if amount in (0.0, None):
-            return _('Amount could not be determined.' +
-                     ' Would you like to pay for a previous session?'), None
+            return _('Amount could not be determined.'), None
         for key in student['payments'].keys():
             ticket = student['payments'][key]
@@ -380,6 +387,5 @@
                ticket.p_item == p_item and \
                ticket.p_session == p_session:
-                  return _('This type of payment has already been made.' +
-                           ' Would you like to pay for another session?'), None
+                  return _('This type of payment has already been made.'), None
         payment = createObject(u'waeup.StudentOnlinePayment')
         timestamp = ("%d" % int(time()*10000))[1:]
Index: /main/waeup.kofa/trunk/src/waeup/kofa/students/viewlets.py
===================================================================
--- /main/waeup.kofa/trunk/src/waeup/kofa/students/viewlets.py	(revision 9516)
+++ /main/waeup.kofa/trunk/src/waeup/kofa/students/viewlets.py	(revision 9517)
@@ -43,8 +43,10 @@
     CourseTicketDisplayFormPage, OnlinePaymentDisplayFormPage,
     AccommodationManageFormPage, BedTicketDisplayFormPage,
-    StudentClearanceEditFormPage, StudentPersonalEditFormPage)
+    StudentClearanceEditFormPage, StudentPersonalEditFormPage,
+    PaymentsManageFormPage)
 from waeup.kofa.students.interfaces import (
     IStudentsContainer, IStudent, IStudentStudyCourse, IStudentAccommodation,
     IStudentStudyLevel, ICourseTicket, IStudentOnlinePayment, IBedTicket,
+    IStudentPaymentsContainer,
     )
 from waeup.kofa.utils.helpers import get_fileformat
@@ -589,4 +591,27 @@
             return self.view.url(self.view.context, self.target)
         return ''
+
+class AddPaymentActionButton(AddActionButton):
+    grok.order(1)
+    grok.context(IStudentPaymentsContainer)
+    grok.view(PaymentsManageFormPage)
+    grok.require('waeup.payStudent')
+    text = _('Add current session payment ticket')
+    target = 'addop'
+
+class AddPreviousPaymentActionButton(AddActionButton):
+    grok.order(2)
+    grok.context(IStudentPaymentsContainer)
+    grok.view(PaymentsManageFormPage)
+    grok.require('waeup.payStudent')
+    text = _('Add previous session payment ticket')
+    target = 'addpp'
+
+    @property
+    def target_url(self):
+        student = self.view.context.student
+        if student.is_fresh:
+            return ''
+        return self.view.url(self.view.context, self.target)
 
 class StudentsTab(PrimaryNavTab):
