Index: /main/kofacustom.dspg/trunk/src/kofacustom/dspg/interswitch/browser.py
===================================================================
--- /main/kofacustom.dspg/trunk/src/kofacustom/dspg/interswitch/browser.py	(revision 14937)
+++ /main/kofacustom.dspg/trunk/src/kofacustom/dspg/interswitch/browser.py	(revision 14938)
@@ -202,21 +202,28 @@
             # amount_auth is being ignored. However, the sum of all split payments
             # must coincide with the amount_auth configured in students/utils.py
-            xmldict['amt1'] = 100 * (1000 - GATEWAY_AMT)
+            xmldict['amt1'] = 100 * 1000
             xmldict['amt2'] = 100 * 500
             xmldict['amt3'] = 100 * 900
             xmldict['amt4'] = 100 * 500
-            xmltext = """<payment_item_detail>
+
+            if student.faccode == 'SPAT':
+                xmltext = """<payment_item_detail>
+<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
+<item_detail item_id="1" item_name="Students Welfare" item_amt="%(amt2)d" bank_id="11" acct_num="0037892949" />
+<item_detail item_id="2" item_name="Anti-Cult Book" item_amt="%(amt3)d" bank_id="11" acct_num="0037892949" />
+</item_details>
+</payment_item_detail>""" % xmldict
+            else:
+                xmltext = """<payment_item_detail>
 <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
 <item_detail item_id="1" item_name="SUG" item_amt="%(amt1)d" bank_id="11" acct_num="0038079930" />
 <item_detail item_id="2" item_name="Students Welfare" item_amt="%(amt2)d" bank_id="11" acct_num="0037892949" />
 <item_detail item_id="3" item_name="Anti-Cult Book" item_amt="%(amt3)d" bank_id="11" acct_num="0037892949" />
-<item_detail item_id="4" item_name="NADESSTU " item_amt="%(amt4)d" bank_id="11" acct_num="0036375968" />
-</item_details>
-</payment_item_detail>""" % xmldict
-
+<item_detail item_id="4" item_name="NADESSTU" item_amt="%(amt4)d" bank_id="11" acct_num="0036375968" />
+</item_details>
+</payment_item_detail>""" % xmldict
         self.xml_data = """<input type="hidden" name="xml_data" value='%s'  />""" % xmltext
         self.context.provider_amt = provider_amt
         self.context.gateway_amt = GATEWAY_AMT
-
         hashargs = (
             self.context.p_id +
Index: /main/kofacustom.dspg/trunk/src/kofacustom/dspg/interswitch/tests.py
===================================================================
--- /main/kofacustom.dspg/trunk/src/kofacustom/dspg/interswitch/tests.py	(revision 14937)
+++ /main/kofacustom.dspg/trunk/src/kofacustom/dspg/interswitch/tests.py	(revision 14938)
@@ -67,8 +67,19 @@
         self.browser.getControl(name="form.p_category").value = ['schoolfee']
         self.browser.getControl("Create ticket").click()
+        self.assertTrue('You have to pay NADESU/SA/SUG Dues first'
+            in self.browser.contents)
+        payment = createObject('waeup.StudentOnlinePayment')
+        payment.p_category = u'dep_sug'
+        payment.p_session = self.student.current_session
+        payment.p_id = u'anyid'
+        payment.p_state = u'paid'
+        self.student['payments']['anykey'] = payment
+        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.value = ctrl.options[1]
         self.browser.getLink(self.value).click()
         self.assertTrue('<span>30000.0</span>'  in self.browser.contents)
@@ -88,18 +99,14 @@
         self.browser.getControl(name="form.p_category").value = ['clearance']
         self.browser.getControl("Create ticket").click()
-        self.assertMatches('...ticket created...',
-                           self.browser.contents)
-        ctrl = self.browser.getControl(name='val_id')
-        self.value = ctrl.options[1]
-        self.browser.getLink(self.value).click()
-        self.assertMatches('...Amount Authorized...',
-                           self.browser.contents)
-        self.assertMatches(
-            '...<span>12345.0</span>...',
-            self.browser.contents)
-        self.payment_url = self.browser.url
-        self.browser.getLink("CollegePAY", index=0).click()
-        self.assertTrue('<input type="hidden" name="pay_item_id" value="103" />' in
-                           self.browser.contents)
+        self.assertTrue('ticket created' in self.browser.contents)
+        ctrl = self.browser.getControl(name='val_id')
+        self.value = ctrl.options[2]
+        self.browser.getLink(self.value).click()
+        self.assertTrue('Amount Authorized' in self.browser.contents)
+        self.assertTrue('<span>12345.0</span>' in self.browser.contents)
+        self.payment_url = self.browser.url
+        self.browser.getLink("CollegePAY", index=0).click()
+        self.assertTrue('<input type="hidden" name="pay_item_id" value="103" />'
+                           in self.browser.contents)
         self.assertTrue(
             '<input type="hidden" name="amount" value="1234500" />' in
@@ -142,5 +149,5 @@
                            self.browser.contents)
 
-    def test_interswitch_form_pt_payments(self):
+    def test_pt_payments(self):
         # Add SPAT certificate
         certificate = createObject('waeup.Certificate')
@@ -165,4 +172,21 @@
         self.certificate.study_mode = 'nd_ft'
         self.certificate.school_fee_3 = 30000.0
+        # Add dep_sug ticket
+        self.browser.open(self.payments_path + '/addop')
+        self.browser.getControl(name="form.p_category").value = ['dep_sug']
+        self.browser.getControl("Create ticket").click()
+        self.assertMatches('...ticket created...', self.browser.contents)
+        ctrl = self.browser.getControl(name='val_id')
+        dep_sug_pid = ctrl.options[0]
+        self.assertTrue(self.student['payments'][dep_sug_pid].amount_auth == 1650)
+        
+        self.browser.getLink(dep_sug_pid).click()
+        self.browser.getLink("CollegePAY", index=0).click()
+        self.student['payments'][dep_sug_pid].p_state = 'paid'
+        self.assertTrue(
+            '<item_detail item_id="1" item_name="Students Welfare" '
+            'item_amt="50000" bank_id="11" acct_num="0037892949" />'
+            in self.browser.contents)
+        # Add school fee ticket
         self.browser.open(self.payments_path + '/addop')
         self.browser.getControl(name="form.p_category").value = ['schoolfee']
@@ -170,5 +194,5 @@
         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.assertTrue('<span>30000.0</span>'  in self.browser.contents)
@@ -194,8 +218,8 @@
         self.value = ctrl.options[0]
         self.browser.getLink(self.value).click()
-        self.assertTrue('<span>2900.0</span>'  in self.browser.contents)
-        self.payment_url = self.browser.url
-        self.browser.getLink("CollegePAY", index=0).click()
-        self.assertTrue('<item_detail item_id="1" item_name="SUG" item_amt="75000" bank_id="11" acct_num="0038079930" />'
+        self.assertTrue('<span>3150.0</span>'  in self.browser.contents)
+        self.payment_url = self.browser.url
+        self.browser.getLink("CollegePAY", index=0).click()
+        self.assertTrue('<item_detail item_id="1" item_name="SUG" item_amt="100000" bank_id="11" acct_num="0038079930" />'
             in self.browser.contents)
         self.assertTrue('<item_detail item_id="2" item_name="Students Welfare" item_amt="50000" bank_id="11" acct_num="0037892949" />'
@@ -203,5 +227,5 @@
         self.assertTrue('<item_detail item_id="3" item_name="Anti-Cult Book" item_amt="90000" bank_id="11" acct_num="0037892949" />'
             in self.browser.contents)
-        self.assertTrue('<item_detail item_id="4" item_name="NADESSTU " item_amt="50000" bank_id="11" acct_num="0036375968" />'
+        self.assertTrue('<item_detail item_id="4" item_name="NADESSTU" item_amt="50000" bank_id="11" acct_num="0036375968" />'
             in self.browser.contents)
 
Index: /main/kofacustom.dspg/trunk/src/kofacustom/dspg/students/utils.py
===================================================================
--- /main/kofacustom.dspg/trunk/src/kofacustom/dspg/students/utils.py	(revision 14937)
+++ /main/kofacustom.dspg/trunk/src/kofacustom/dspg/students/utils.py	(revision 14938)
@@ -36,4 +36,13 @@
     # prefix
     STUDENT_ID_PREFIX = u'P'
+
+    def _dep_sug_paymentMade(self, student, session):
+        if len(student['payments']):
+            for ticket in student['payments'].values():
+                if ticket.p_state == 'paid' and \
+                    ticket.p_category == 'dep_sug' and \
+                    ticket.p_session == session:
+                    return True
+        return False
 
     def setPaymentDetails(self, category, student,
@@ -87,4 +96,9 @@
                         amount = getattr(certificate, 'school_fee_4', 0.0)
             else:
+                # Students are only allowed to pay school fee 
+                # if current session dep_sug payment has been made.
+                if not self._dep_sug_paymentMade(student,
+                    student.current_session):
+                    return _('You have to pay NADESU/SA/SUG Dues first.'), None
                 if student.state == CLEARED:
                     if local(student):
@@ -164,5 +178,7 @@
             amount = 13000.0
         elif category == 'dep_sug':
-            amount = 2900.0
+            amount = 3150.0 # includes GATEWAY_AMT
+            if student.faccode == 'SPAT':
+                amount = 1650.0 # includes GATEWAY_AMT
         else:
             fee_name = category + '_fee'
