Index: main/waeup.aaue/trunk/src/waeup/aaue/etranzact/browser.py
===================================================================
--- main/waeup.aaue/trunk/src/waeup/aaue/etranzact/browser.py	(revision 11626)
+++ main/waeup.aaue/trunk/src/waeup/aaue/etranzact/browser.py	(revision 11627)
@@ -275,4 +275,17 @@
     placeholder = _('Confirmation Number (PIN)')
 
+    def update(self):
+        super(EtranzactEnterPinPageStudent, self).update()
+        if self.context.p_category != 'schoolfee':
+            return
+        student = self.context.student
+        for ticket in student['payments'].values():
+            if ticket.p_state == 'paid' and \
+                ticket.p_category == 'clearance':
+                return
+        self.flash(_('Please pay acceptance fee first.'), type="danger")
+        self.redirect(self.url(self.context, '@@index'))
+        return
+
 class EtranzactEnterPinPageApplicant(EtranzactEnterPinPageStudent):
     """
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 11626)
+++ main/waeup.aaue/trunk/src/waeup/aaue/students/tests/test_browser.py	(revision 11627)
@@ -135,15 +135,15 @@
                            self.browser.contents)
         self.app['configuration']['2004'].school_fee_1 = 6666.0
-        self.browser.getControl(name="form.p_category").value = ['schoolfee']
+        #self.browser.getControl(name="form.p_category").value = ['schoolfee']
         # Accepotance fee must be paid first
-        self.browser.getControl("Create ticket").click()
-        self.assertMatches('...Please pay acceptance fee first...',
-                           self.browser.contents)
+        #self.browser.getControl("Create ticket").click()
+        #self.assertMatches('...Please pay acceptance fee first...',
+        #                   self.browser.contents)
         self.app['configuration']['2004'].clearance_fee = 666.0
         self.browser.getControl(name="form.p_category").value = ['clearance']
         self.browser.getControl("Create ticket").click()
         ctrl = self.browser.getControl(name='val_id')
-        value = ctrl.options[0]
-        self.student['payments'][value].approveStudentPayment()
+        cpt_value = ctrl.options[0]
+        # School fee payment ticket can be added ...
         self.browser.open(self.payments_path + '/addop')
         self.browser.getControl(name="form.p_category").value = ['schoolfee']
@@ -151,15 +151,26 @@
         self.assertMatches('...ticket created...',
                            self.browser.contents)
+        # ... but not paid through the query_history page.
         ctrl = self.browser.getControl(name='val_id')
-        value = ctrl.options[1]
-        self.browser.getLink(value).click()
-        self.assertMatches('...Amount Authorized...',
-                           self.browser.contents)
+        sfpt_value = ctrl.options[1]
+        self.browser.open(self.payments_path + '/' + sfpt_value)
+        self.browser.getLink("Query eTranzact History").click()
+        self.assertMatches('...alert-danger">Please pay acceptance fee first...',
+                           self.browser.contents)
+        # If clearance/acceptance fee is paid ...
+        self.student['payments'][cpt_value].approveStudentPayment()
+        self.browser.getLink("Query eTranzact History").click()
+        # ... query_history page is accessible.
+        self.assertMatches(
+            '...<h1 class="kofa-content-label">Requery eTranzact History</h1>...',
+            self.browser.contents)
         # Managers can open school fee payment slip
+        self.browser.open(self.payments_path + '/' + sfpt_value)
         self.browser.getLink("Download payment slip").click()
         self.assertEqual(self.browser.headers['Status'], '200 Ok')
         self.assertEqual(self.browser.headers['Content-Type'], 'application/pdf')
-        # Set ticket paid
-        ticket = self.student['payments'][value].approveStudentPayment()
+        # If school fee ticket is paid ...
+        ticket = self.student['payments'][sfpt_value].approveStudentPayment()
+        # ... no further school fee ticket can be added.
         self.browser.open(self.payments_path + '/addop')
         self.browser.getControl(name="form.p_category").value = ['schoolfee']
@@ -167,5 +178,4 @@
         self.assertMatches('...This type of payment has already been made...',
                            self.browser.contents)
-
 
     def deactivated_test_for_instalment_payments(self):
Index: main/waeup.aaue/trunk/src/waeup/aaue/students/tests/test_utils.py
===================================================================
--- main/waeup.aaue/trunk/src/waeup/aaue/students/tests/test_utils.py	(revision 11626)
+++ main/waeup.aaue/trunk/src/waeup/aaue/students/tests/test_utils.py	(revision 11627)
@@ -37,4 +37,12 @@
         return
 
+    def test_no_clearance_ac_code_created(self):
+        payment = createObject('waeup.StudentOnlinePayment')
+        payment.p_category = 'clearance'
+        self.student['payments']['any_id'] = payment
+        payment.approveStudentPayment()
+        # No activation code created.
+        self.assertEqual(payment.ac, None)
+
     def test_set_payment_details(self):
         self.app['configuration']['2004'].gown_fee = 150.0
@@ -54,15 +62,5 @@
         self.assertEqual(payment, None)
         self.assertEqual(error, u'Wrong state.')
-
         IWorkflowState(self.student).setState('cleared')
-        error, payment = utils.setPaymentDetails('schoolfee',self.student)
-        # Acceptance fee must be paid first.
-        self.assertEqual(error, 'Please pay acceptance fee first.')
-        payment = createObject('waeup.StudentOnlinePayment')
-        payment.p_category = 'clearance'
-        self.student['payments']['any_id'] = payment
-        payment.approveStudentPayment()
-        # No activation code created.
-        self.assertEqual(payment.ac, None)
         # School fee can be set.
         error, payment = utils.setPaymentDetails('schoolfee',self.student)
@@ -72,5 +70,4 @@
         self.assertEqual(payment.p_item, u'CERT1')
         self.assertEqual(error, None)
-
         # Add penalty fee ...
         # ... for cleared
Index: main/waeup.aaue/trunk/src/waeup/aaue/students/utils.py
===================================================================
--- main/waeup.aaue/trunk/src/waeup/aaue/students/utils.py	(revision 11626)
+++ main/waeup.aaue/trunk/src/waeup/aaue/students/utils.py	(revision 11627)
@@ -109,12 +109,4 @@
         new_session = student['studycourse'].current_session + 1
         return new_session, new_level
-
-    def _acceptanceFeePaid(self, student):
-        if len(student['payments']):
-            for ticket in student['payments'].values():
-                if ticket.p_state == 'paid' and \
-                    ticket.p_category == 'clearance':
-                    return True
-        return False
 
     def setPaymentDetails(self, category, student,
@@ -159,6 +151,4 @@
                 return _('Study course data are incomplete.'), None
             if student.state == CLEARED:
-                if not self._acceptanceFeePaid(student):
-                    return _('Please pay acceptance fee first.'), None
                 if student.faccode == 'FP':
                     amount = 84000.0
