Index: main/waeup.aaue/trunk/src/waeup/aaue/interswitch/browser.py
===================================================================
--- main/waeup.aaue/trunk/src/waeup/aaue/interswitch/browser.py	(revision 17433)
+++ main/waeup.aaue/trunk/src/waeup/aaue/interswitch/browser.py	(revision 17434)
@@ -182,5 +182,26 @@
             self.redirect(self.url(self.context, '@@index'))
             return
+        student = self.student
         category = self.context.p_category
+        # To guarantee that cleared students pay both acceptance fee
+        # and school fees, the page can only be accessed
+        # for school fee payments if acceptance/clearance fee has
+        # been successfully queried/paid beforehand. This
+        # requirement applies to students in state 'cleared' and
+        # entry_session greater than 2012 only.
+        if self.context.p_category.startswith('schoolfee') and \
+            student.state == CLEARED and \
+            student.entry_session > 2012:
+            acceptance_fee_paid = False
+            for ticket in student['payments'].values():
+                if ticket.p_state == 'paid' and \
+                    ticket.p_category.startswith('clearance'):
+                    acceptance_fee_paid = True
+                    break
+            if not acceptance_fee_paid:
+                self.flash(
+                    _('Please pay acceptance fee first.'), type="danger")
+                self.redirect(self.url(self.context, '@@index'))
+                return
         # Already now it becomes an Interswitch payment. We set the net amount
         # and add the gateway amount.
@@ -190,5 +211,4 @@
             self.context.gateway_amt = GATEWAY_AMT
             self.context.r_company = u'interswitch'
-        student = self.student
         xmldict = self.xmldict
         # Provider data
Index: main/waeup.aaue/trunk/src/waeup/aaue/interswitch/tests.py
===================================================================
--- main/waeup.aaue/trunk/src/waeup/aaue/interswitch/tests.py	(revision 17433)
+++ main/waeup.aaue/trunk/src/waeup/aaue/interswitch/tests.py	(revision 17434)
@@ -261,11 +261,4 @@
         self.payment_url = self.browser.url
         self.browser.getLink("Pay via Interswitch", index=0).click()
-        #self.assertTrue(
-        #    'Please pay acceptance fee first' in self.browser.contents)
-        #acc_payment = createObject('waeup.StudentOnlinePayment')
-        #acc_payment.p_state = 'paid'
-        #acc_payment.p_category = 'clearance'
-        #self.student['payments']['xyz'] = acc_payment
-        #self.browser.getLink("Pay via Interswitch", index=0).click()
         self.assertTrue('Total Amount Authorized:'
                         in self.browser.contents)
@@ -286,4 +279,11 @@
         self.assertTrue('<span>92000.0</span>' in self.browser.contents)
         self.payment_url = self.browser.url
+        self.browser.getLink("Pay via Interswitch", index=0).click()
+        self.assertTrue(
+            'Please pay acceptance fee first' in self.browser.contents)
+        acc_payment = createObject('waeup.StudentOnlinePayment')
+        acc_payment.p_state = 'paid'
+        acc_payment.p_category = 'clearance'
+        self.student['payments']['xyz'] = acc_payment
         self.browser.getLink("Pay via Interswitch", index=0).click()
         self.assertTrue(
