Index: main/waeup.uniben/trunk/src/waeup/uniben/students/tests/test_browser.py
===================================================================
--- main/waeup.uniben/trunk/src/waeup/uniben/students/tests/test_browser.py	(revision 8305)
+++ main/waeup.uniben/trunk/src/waeup/uniben/students/tests/test_browser.py	(revision 8306)
@@ -166,5 +166,4 @@
         ticket = self.student['payments'].items()[0][1]
         ticket.p_state = 'paid'
-        IWorkflowState(self.student).setState('returning')
         self.browser.open(self.payments_path + '/addop')
         self.browser.getControl("Create ticket").click()
@@ -206,13 +205,26 @@
         self.assertMatches('...ticket created...',
                            self.browser.contents)
-        self.certificate.study_mode = 'ug_pt'
         self.browser.open(self.payments_path + '/addop')
         self.browser.getControl(name="form.p_category").value = ['schoolfee']
         self.browser.getControl("Create ticket").click()
+        self.assertMatches('...ticket created...',
+                           self.browser.contents)
+        # In state returning we can add a new school fee ticket since
+        # p_session and p_level is different
+        IWorkflowState(self.student).setState('returning')
+        self.browser.open(self.payments_path + '/addop')
+        self.browser.getControl(name="form.p_category").value = ['schoolfee']
+        self.browser.getControl("Create ticket").click()
+        self.assertMatches('...ticket created...',
+                           self.browser.contents)
+        IWorkflowState(self.student).setState('admitted')
+        self.browser.open(self.payments_path + '/addop')
+        self.browser.getControl(name="form.p_category").value = ['schoolfee']
+        self.browser.getControl("Create ticket").click()
         self.assertMatches('...Amount could not be determined...',
                            self.browser.contents)
 
-        # If the session configuration doesn't exist and error message will
-        # be shown
+        # If the session configuration doesn't exist an error message will
+        # be shown. No other requirement is being checked.
         del self.app['configuration']['2004']
         self.browser.open(self.payments_path)
Index: main/waeup.uniben/trunk/src/waeup/uniben/students/utils.py
===================================================================
--- main/waeup.uniben/trunk/src/waeup/uniben/students/utils.py	(revision 8305)
+++ main/waeup.uniben/trunk/src/waeup/uniben/students/utils.py	(revision 8306)
@@ -17,4 +17,5 @@
 ##
 import grok
+from waeup.kofa.interfaces import CLEARED, RETURNING
 from waeup.kofa.students.workflow import CLEARED, RETURNING
 from waeup.kofa.students.utils import StudentsUtils
@@ -24,22 +25,13 @@
 
 def get_school_fee(student):
-    study_mode = student['studycourse'].certificate.study_mode
-    entry_mode = student['studycourse'].entry_mode
     state = student.state
-    #lga = student.lga
-    lga = 'nothing'
-    current_level = student['studycourse'].current_level
-
-    if study_mode.endswith('_ft'):
-        # fresh
-        if state == CLEARED:
-            return 40000.0
-        # returning
-        elif state == RETURNING:
-            return 20000.0
-        else:
-            return 0.0
-    else:
-        return 0.0
+    fee = None
+    if state == CLEARED:
+        fee = getattr(student['studycourse'].certificate,'school_fee_1')
+    elif state == RETURNING:
+        fee = getattr(student['studycourse'].certificate,'school_fee_2')
+    if fee is not None:
+        return fee
+    return 0.0
 
 def actions_after_student_payment(student, payment, view):
@@ -90,41 +82,43 @@
 
     def getPaymentDetails(self, category, student):
-        d = {}
-        d['p_item'] = u''
-        d['amount'] = 0.0
-        d['error'] = u''
-        d['p_session'] = student['studycourse'].current_session
-        session = str(d['p_session'])
-        d['p_level'] = student['studycourse'].current_level
+        details = {}
+        details['p_item'] = u''
+        details['amount'] = 0.0
+        details['error'] = u''
+        details['p_session'] = student['studycourse'].current_session
+        session = str(details['p_session'])
+        details['p_level'] = student['studycourse'].current_level
         try:
             academic_session = grok.getSite()['configuration'][session]
         except KeyError:
-            d['error'] = _(u'Session configuration object is not available.')
-            return d
+            details['error'] = _(u'Session configuration object is not available.')
+            return details
         if category == 'transfer':
-            d['amount'] = academic_session.transfer_fee
+            details['amount'] = academic_session.transfer_fee
         elif category == 'gown':
-            d['amount'] = academic_session.gown_fee
+            details['amount'] = academic_session.gown_fee
         elif category == 'bed_allocation':
-            d['amount'] = academic_session.booking_fee
+            details['amount'] = academic_session.booking_fee
         elif category == 'hostel_maintenance':
-            d['amount'] = academic_session.maint_fee
+            details['amount'] = academic_session.maint_fee
         elif category == 'clearance':
-            d['p_item'] = student['studycourse'].certificate.code
-            if d['p_item'] in ('BEDCET', 'BIOEDCET', 'CHMEDCET', 'ISEDCET',
+            details['p_item'] = student['studycourse'].certificate.code
+            if details['p_item'] in ('BEDCET', 'BIOEDCET', 'CHMEDCET', 'ISEDCET',
                 'MTHEDCET', 'PHYEDCET', 'ITECET', 'AGREDCET', 'HEEDCET'):
-                d['amount'] = 17250.0
+                details['amount'] = 17250.0
             else:
-                d['amount'] = 34250.0
+                details['amount'] = 34250.0
         elif category == 'schoolfee':
-            d['amount'] = get_school_fee(student)
+            details['amount'] = get_school_fee(student)
             code = student['studycourse'].certificate.code
-            d['p_item'] = code
-            # In case of school fee payment the payment session and level
-            # contain the values of the session the student has paid for
-            d['p_session'], d['p_level'] = self.getReturningData(student)
-        if d['amount'] == 0.0:
-            d['error'] = _(u'Amount could not be determined.')
-        return d
+            details['p_item'] = code
+            if student.state == RETURNING:
+                # In case of returning school fee payment the payment session
+                # and level contain the values of the session the student
+                # has paid for.
+                details['p_session'], details['p_level'] = self.getReturningData(student)
+        if details['amount'] == 0.0:
+            details['error'] = _(u'Amount could not be determined.')
+        return details
 
     VERDICTS_DICT = {
