Index: main/waeup.kwarapoly/trunk/src/waeup/kwarapoly/interswitch/tests.py
===================================================================
--- main/waeup.kwarapoly/trunk/src/waeup/kwarapoly/interswitch/tests.py	(revision 10672)
+++ main/waeup.kwarapoly/trunk/src/waeup/kwarapoly/interswitch/tests.py	(revision 10675)
@@ -28,4 +28,5 @@
 from waeup.kofa.configuration import SessionConfiguration
 from waeup.kwarapoly.testing import FunctionalLayer
+from waeup.kwarapoly.students.payments import CustomStudentOnlinePayment
 
 # Also run tests that send requests to external servers?
@@ -76,4 +77,6 @@
         notify(grok.ObjectModifiedEvent(self.student))
 
+
+    def test_schoolfee_ticket_creation(self):
         self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
         self.browser.open(self.payments_path)
@@ -82,8 +85,24 @@
         self.browser.getControl(name="form.p_category").value = ['schoolfee']
         self.browser.getControl("Create ticket").click()
+        self.assertMatches('...Book and pay for accommodation first...',
+                           self.browser.contents)
+        # We add a fake maint. payment ticket to meet the condition
+        maint_payment = CustomStudentOnlinePayment()
+        self.student['payments']['any_key'] = maint_payment
+        maint_payment.p_category = 'hostel_maintenance'
+        maint_payment.p_state = 'unpaid'
+        maint_payment.p_session = 2004
+        self.browser.getControl(name="form.p_category").value = ['schoolfee']
+        self.browser.getControl("Create ticket").click()
+        self.assertMatches('...Book and pay for accommodation first...',
+                           self.browser.contents)
+        # Ticket must be paid
+        maint_payment.p_state = 'paid'
+        self.browser.getControl(name="form.p_category").value = ['schoolfee']
+        self.browser.getControl("Create ticket").click()
         self.assertMatches('...ticket created...',
                            self.browser.contents)
         ctrl = self.browser.getControl(name='val_id')
-        self.value = ctrl.options[0]
+        self.value = ctrl.options[1]
         self.browser.getLink(self.value).click()
         self.assertMatches('...Amount Authorized...',
@@ -107,4 +126,26 @@
 
     def test_interswitch_form(self):
+
+        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
+        self.browser.open(self.payments_path)
+        # In KwaraPoly only returning students can create school fee payment
+        # without haveing paid accommodation fee
+        IWorkflowState(self.student).setState('returning')
+        configuration = createObject('waeup.SessionConfiguration')
+        configuration.academic_session = 2005
+        self.app['configuration'].addSessionConfiguration(configuration)
+        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)
+        ctrl = self.browser.getControl(name='val_id')
+        self.value = ctrl.options[0]
+        self.browser.getLink(self.value).click()
+        self.assertMatches('...Amount Authorized...', self.browser.contents)
+        self.assertMatches(
+            '...<span>29500.0</span>...',
+            self.browser.contents)
+        self.payment_url = self.browser.url
+
         # Manager can access InterswitchForm
         self.assertEqual(self.student['payments'][self.value].provider_amt, 0.0)
@@ -119,8 +160,8 @@
                            self.browser.contents)
         self.assertTrue(
-            '<input type="hidden" name="amount" value="3940000.0" />' in
-            self.browser.contents)
-        self.assertTrue(
-            'item_name="School Fee" item_amt="3610000" bank_id="120" acct_num="1771180233"' in
+            '<input type="hidden" name="amount" value="2950000.0" />' in
+            self.browser.contents)
+        self.assertTrue(
+            'item_name="School Fee" item_amt="2620000" bank_id="120" acct_num="1771180233"' in
             self.browser.contents)
         self.assertTrue(
