Index: /main/waeup.futminna/trunk/src/waeup/futminna/students/tests/test_browser.py
===================================================================
--- /main/waeup.futminna/trunk/src/waeup/futminna/students/tests/test_browser.py	(revision 9243)
+++ /main/waeup.futminna/trunk/src/waeup/futminna/students/tests/test_browser.py	(revision 9244)
@@ -79,2 +79,52 @@
         self.assertEqual(utils.getReturningData(self.student),(2005, 100))
         return
+
+    def test_set_payment_details(self):
+        self.app['configuration']['2004'].gown_fee = 150.0
+        self.app['configuration']['2004'].transfer_fee = 90.0
+        self.app['configuration']['2004'].booking_fee = 150.0
+        self.app['configuration']['2004'].maint_fee = 180.0
+        self.app['configuration']['2004'].clearance_fee = 120.0
+        utils = getUtility(IStudentsUtils)
+
+        error, payment = utils.setPaymentDetails('schoolfee',self.student)
+        self.assertEqual(payment, None)
+        self.assertEqual(error, u'Amount could not be determined.')
+
+        self.student.nationality = u'NG'
+
+        IWorkflowState(self.student).setState('cleared')
+        error, payment = utils.setPaymentDetails('schoolfee',self.student)
+        self.assertEqual(payment.p_level, 100)
+        self.assertEqual(payment.p_session, 2004)
+        self.assertEqual(payment.amount_auth, 37000.0)
+        self.assertEqual(payment.p_item, u'CERT1')
+        self.assertEqual(error, None)
+
+        self.certificate.study_mode = 'jm_ft'
+        error, payment = utils.setPaymentDetails('schoolfee',self.student)
+        self.assertEqual(payment.amount_auth, 72700.0)
+
+        IWorkflowState(self.student).setState('returning')
+        error, payment = utils.setPaymentDetails('schoolfee',self.student)
+        self.assertEqual(payment.p_level, 100)
+        self.assertEqual(payment.p_session, 2004)
+        self.assertEqual(payment.amount_auth, 37000.0)
+        self.assertEqual(payment.p_item, u'CERT1')
+        self.assertEqual(error, None)
+
+        self.certificate.study_mode = 'ug_ft'
+        error, payment = utils.setPaymentDetails('schoolfee',self.student)
+        self.assertEqual(payment.amount_auth, 20000.0)
+
+
+        error, payment = utils.setPaymentDetails('clearance',self.student)
+        self.assertEqual(payment.p_level, 100)
+        self.assertEqual(payment.p_session, 2004)
+        self.assertEqual(payment.amount_auth, 20000.0)
+        self.assertEqual(payment.p_item, u'CERT1')
+        self.assertEqual(error, None)
+
+        error, payment = utils.setPaymentDetails('schoolfee',self.student, 2004, 100)
+        self.assertEqual(error, u'Previous session payment not yet implemented.')
+        return
Index: /main/waeup.futminna/trunk/src/waeup/futminna/students/utils.py
===================================================================
--- /main/waeup.futminna/trunk/src/waeup/futminna/students/utils.py	(revision 9243)
+++ /main/waeup.futminna/trunk/src/waeup/futminna/students/utils.py	(revision 9244)
@@ -54,5 +54,79 @@
 
         """
-        return _(u'Payment components not yet configured.'), None
+        p_item = u''
+        amount = 0.0
+        if previous_session:
+            return _('Previous session payment not yet implemented.'), None
+        p_session = student['studycourse'].current_session
+        p_level = student['studycourse'].current_level
+        p_current = True
+        session = str(p_session)
+        try:
+            academic_session = grok.getSite()['configuration'][session]
+        except KeyError:
+            return _(u'Session configuration object is not available.'), None
+        if category == 'schoolfee':
+            try:
+                certificate = student['studycourse'].certificate
+                p_item = certificate.code
+            except (AttributeError, TypeError):
+                return _('Study course data are incomplete.'), None
+            if student.current_mode.endswith('_ft'):
+                # fresh remedial
+                if student.current_level == 10 and student.state == CLEARED:
+                    if student['studycourse'].entry_mode == 'rmd_ft':
+                        amount = 80200.0
+                    else:
+                        amount = 74200.0
+
+                # fresh
+                elif student.state == CLEARED:
+                    if student.current_mode == 'jm_ft':
+                        amount = 72700.0
+                    elif student.is_foreigner:
+                        amount = 131500.0
+                    else:
+                        amount = 37000.0 # School Fee reduced by 8000
+                # returning
+                elif student.state == RETURNING:
+                    if student.current_mode == 'jm_ft':
+                        amount = 37000.0
+                    elif student.is_foreigner:
+                        amount = 109500.0
+                    else:
+                        amount = 20000.0
+                else:
+                    amount = 0.0
+        elif category == 'clearance':
+            try:
+                p_item = student['studycourse'].certificate.code
+            except (AttributeError, TypeError):
+                return _('Study course data are incomplete.'), None
+            if student.faccode in ['EET','ICT'] or student.depcode in ['ARC']:
+                amount = 25000.0
+            else:
+                amount = 20000.0
+        elif category == 'bed_allocation':
+            p_item = self.getAccommodationDetails(student)['bt']
+            amount = academic_session.booking_fee
+        if amount in (0.0, None):
+            return _('Amount could not be determined.'), None
+        for key in student['payments'].keys():
+            ticket = student['payments'][key]
+            if ticket.p_state == 'paid' and\
+               ticket.p_category == category and \
+               ticket.p_item == p_item and \
+               ticket.p_session == p_session:
+                  return _('This type of payment has already been made.'), None
+        payment = createObject(u'waeup.StudentOnlinePayment')
+        timestamp = ("%d" % int(time()*10000))[1:]
+        payment.p_id = "p%s" % timestamp
+        payment.p_category = category
+        payment.p_item = p_item
+        payment.p_session = p_session
+        payment.p_level = p_level
+        payment.p_current = p_current
+        payment.amount_auth = amount
+        return None, payment
 
 
