Index: /main/waeup.aaue/trunk/src/waeup/aaue/students/tests/test_browser.py
===================================================================
--- /main/waeup.aaue/trunk/src/waeup/aaue/students/tests/test_browser.py	(revision 14240)
+++ /main/waeup.aaue/trunk/src/waeup/aaue/students/tests/test_browser.py	(revision 14241)
@@ -224,8 +224,12 @@
 
     def test_for_instalment_payments(self):
+
+        configuration_1 = createObject('waeup.SessionConfiguration')
+        configuration_1.academic_session = 2015
+        self.app['configuration'].addSessionConfiguration(configuration_1)
         self.student['studycourse'].certificate.study_mode = 'ug_pt'
         self.student['studycourse'].certificate.school_fee_1 = 6666.0
-        self.app['configuration']['2004'].union_fee = 1250.0
-        self.app['configuration']['2004'].welfare_fee = 750.0
+        self.app['configuration']['2015'].union_fee = 1250.0
+        self.app['configuration']['2015'].welfare_fee = 750.0
         self.student.nationality = u'NG'
         self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
@@ -239,8 +243,9 @@
         self.browser.getControl(name="form.p_category").value = ['schoolfee_1']
         self.browser.getControl("Create ticket").click()
-        self.assertTrue(
-            'Wrong state. Only students in state \'cleared\' are allowed to pay by instalments'
+        self.assertTrue('You are not allowed to pay by instalments.'
             in self.browser.contents)
         IWorkflowState(self.student).setState('cleared')
+        self.student['studycourse'].entry_session = 2015
+        self.student['studycourse'].current_session = 2015
         self.browser.open(self.payments_path + '/addop')
         self.browser.getControl(name="form.p_category").value = ['schoolfee_1']
@@ -274,4 +279,44 @@
         # (6666-250)/2 + 250
         self.assertEqual(self.student['payments'].values()[1].amount_auth, 3458.0)
+        # The  two payments belong to the same session and level.
+        self.assertEqual(self.student['payments'].values()[0].p_session, 2015)
+        self.assertEqual(self.student['payments'].values()[0].p_level, 100)
+        self.assertEqual(self.student['payments'].values()[1].p_session, 2015)
+        self.assertEqual(self.student['payments'].values()[1].p_level, 100)
+
+        # Returning student
+        configuration_2 = createObject('waeup.SessionConfiguration')
+        configuration_2.academic_session = 2016
+        self.app['configuration'].addSessionConfiguration(configuration_2)
+        self.student['studycourse'].certificate.school_fee_2 = 5666.0
+        self.app['configuration']['2016'].union_fee = 1250.0
+        self.app['configuration']['2016'].welfare_fee = 750.0
+        self.student.father_name = u'Albert'
+        IWorkflowState(self.student).setState('returning')
+        self.browser.open(self.payments_path + '/addop')
+        self.browser.getControl(name="form.p_category").value = ['schoolfee_1']
+        self.browser.getControl("Create ticket").click()
+        self.browser.open(self.payments_path + '/addop')
+        self.browser.getControl(name="form.p_category").value = ['schoolfee_2']
+        self.browser.getControl("Create ticket").click()
+        # Student is still in the first  session.
+        self.assertTrue('This type of payment' in self.browser.contents)
+        self.browser.open(self.payments_path)
+        ctrl = self.browser.getControl(name='val_id')
+        p_id = ctrl.options[2]
+        self.browser.open(self.payments_path + '/' + p_id + '/approve')
+        self.browser.open(self.payments_path + '/addop')
+        self.browser.getControl(name="form.p_category").value = ['schoolfee_2']
+        self.browser.getControl("Create ticket").click()
+        self.assertTrue('ticket created' in self.browser.contents)
+        # (5666-250)/2 + 1250 + 750 - 500 + 250
+        self.assertEqual(self.student['payments'].values()[2].amount_auth, 4458.0)
+        # (5666-250)/2 + 250
+        self.assertEqual(self.student['payments'].values()[3].amount_auth, 2958.0)
+        # The last two payments belong to the same session and level.
+        self.assertEqual(self.student['payments'].values()[2].p_session, 2016)
+        self.assertEqual(self.student['payments'].values()[2].p_level, 200)
+        self.assertEqual(self.student['payments'].values()[3].p_session, 2016)
+        self.assertEqual(self.student['payments'].values()[3].p_level, 200)
         return
 
@@ -711,4 +756,5 @@
     def test_student_2nd_semester_course_registration(self):
         IWorkflowState(self.student).setState('school fee paid')
+        self.student['studycourse'].entry_session = 2015
         self.course.semester = 2
         self.browser.open(self.login_path)
Index: /main/waeup.aaue/trunk/src/waeup/aaue/students/utils.py
===================================================================
--- /main/waeup.aaue/trunk/src/waeup/aaue/students/utils.py	(revision 14240)
+++ /main/waeup.aaue/trunk/src/waeup/aaue/students/utils.py	(revision 14241)
@@ -262,16 +262,17 @@
                     return _("Part-time students are not allowed "
                              "to pay by instalments."), None
-                if category == 'schoolfee_1' and student.state != CLEARED:
-                    return _("Wrong state. Only students in state 'cleared' "
-                             "are allowed to pay by instalments."), None
-                if category == 'schoolfee_2' and not student.is_fresh:
-                    return _("Only new students "
-                             "are allowed to pay by instalments."), None
-            if student.state == CLEARED or category == 'schoolfee_2':
+                if student.entry_session < 2015:
+                    return _("You are not allowed "
+                             "to pay by instalments."), None
+            if student.state == CLEARED:
                 amount = getattr(certificate, 'school_fee_1', 0.0)
                 # Cut school fee by 50%
-                if category in ('schoolfee_1', 'schoolfee_2'):
-                    if amount:
-                        amount = gateway_net_amt(amount) / 2 + GATEWAY_AMT
+                if category == 'schoolfee_1' and amount:
+                    amount = gateway_net_amt(amount) / 2 + GATEWAY_AMT
+            elif student.is_fresh and category == 'schoolfee_2':
+                amount = getattr(certificate, 'school_fee_1', 0.0)
+                # Cut school fee by 50%
+                if amount:
+                    amount = gateway_net_amt(amount) / 2 + GATEWAY_AMT
             elif student.state == RETURNING:
                 if not student.father_name:
@@ -286,8 +287,16 @@
                 except KeyError:
                     return _(u'Session configuration object is not available.'), None
-                if student.entry_session == 2015:
+                if student.entry_session >= 2015:
                     amount = getattr(certificate, 'school_fee_2', 0.0)
+                    # Cut school fee by 50%
+                    if category in ('schoolfee_1', 'schoolfee_2') and amount:
+                        amount = gateway_net_amt(amount) / 2 + GATEWAY_AMT
                 else:
                     amount = getattr(certificate, 'school_fee_3', 0.0)
+            elif category == 'schoolfee_2':
+                amount = getattr(certificate, 'school_fee_2', 0.0)
+                # Cut school fee by 50%
+                if amount:
+                    amount = gateway_net_amt(amount) / 2 + GATEWAY_AMT
             else:
                 return _('Wrong state.'), None
