Index: /main/kofacustom.coewarri/trunk/src/kofacustom/coewarri/students/utils.py
===================================================================
--- /main/kofacustom.coewarri/trunk/src/kofacustom/coewarri/students/utils.py	(revision 14332)
+++ /main/kofacustom.coewarri/trunk/src/kofacustom/coewarri/students/utils.py	(revision 14333)
@@ -23,8 +23,130 @@
 from kofacustom.coewarri.interfaces import MessageFactory as _
 
+
+def local_nonlocal(student):
+    lga = getattr(student, 'lga')
+    if lga and lga.startswith('delta'):
+        return 'local'
+    else:
+        return 'non-local'
+
 class CustomStudentsUtils(NigeriaStudentsUtils):
     """A collection of customized methods.
 
     """
+
+    def setPaymentDetails(self, category, student,
+            previous_session, previous_level):
+        """Create a payment ticket and set the payment data of a
+        student for the payment category specified.
+        """
+        p_item = u''
+        amount = 0.0
+        if previous_session:
+            if previous_session < student['studycourse'].entry_session:
+                return _('The previous session must not fall below '
+                         'your entry session.'), None
+            if category == 'schoolfee':
+                # School fee is always paid for the following session
+                if previous_session > student['studycourse'].current_session:
+                    return _('This is not a previous session.'), None
+            else:
+                if previous_session > student['studycourse'].current_session - 1:
+                    return _('This is not a previous session.'), None
+            p_session = previous_session
+            p_level = previous_level
+            p_current = False
+        else:
+            p_session = student['studycourse'].current_session
+            p_level = student['studycourse'].current_level
+            p_current = True
+        academic_session = self._getSessionConfiguration(p_session)
+        if academic_session == None:
+            return _(u'Session configuration object is not available.'), None
+        # Determine fee.
+        if category == 'schoolfee':
+            try:
+                certificate = student['studycourse'].certificate
+                p_item = certificate.code
+            except (AttributeError, TypeError):
+                return _('Study course data are incomplete.'), None
+            if previous_session:
+                # Students can pay for previous sessions in all
+                # workflow states.  Fresh students are excluded by the
+                # update method of the PreviousPaymentAddFormPage.
+                if previous_level == 100:
+                    amount = getattr(certificate, 'school_fee_1', 0.0)
+                else:
+                    amount = getattr(certificate, 'school_fee_2', 0.0)
+            else:
+                if student.state == CLEARED:
+                    amount = getattr(certificate, 'school_fee_1', 0.0)
+                elif student.state == RETURNING:
+                    # In case of returning school fee payment the
+                    # payment session and level contain the values of
+                    # the session the student has paid for. Payment
+                    # session is always next session.
+                    p_session, p_level = self.getReturningData(student)
+                    academic_session = self._getSessionConfiguration(p_session)
+                    if academic_session == None:
+                        return _(
+                            u'Session configuration object is not available.'
+                            ), None
+                    amount = getattr(certificate, 'school_fee_2', 0.0)
+                elif student.is_postgrad and student.state == PAID:
+                    # Returning postgraduate students also pay for the
+                    # next session but their level always remains the
+                    # same.
+                    p_session += 1
+                    academic_session = self._getSessionConfiguration(p_session)
+                    if academic_session == None:
+                        return _(
+                            u'Session configuration object is not available.'
+                            ), None
+                    amount = getattr(certificate, 'school_fee_2', 0.0)
+        elif category == 'clearance':
+            try:
+                p_item = student['studycourse'].certificate.code
+            except (AttributeError, TypeError):
+                return _('Study course data are incomplete.'), None
+            amount = academic_session.clearance_fee
+        elif category == 'bed_allocation':
+            p_item = self.getAccommodationDetails(student)['bt']
+            amount = academic_session.booking_fee
+        elif category == 'hostel_maintenance':
+            amount = 0.0
+            bedticket = student['accommodation'].get(
+                str(student.current_session), None)
+            if bedticket is not None and bedticket.bed is not None:
+                p_item = bedticket.bed_coordinates
+                if bedticket.bed.__parent__.maint_fee > 0:
+                    amount = bedticket.bed.__parent__.maint_fee
+                else:
+                    # fallback
+                    amount = academic_session.maint_fee
+            else:
+                return _(u'No bed allocated.'), None
+        elif category == 'transcript':
+            amount = academic_session.transcript_fee
+        elif category == 'transfer':
+            amount = academic_session.transfer_fee
+        elif category == 'late_registration':
+            amount = academic_session.late_registration_fee
+        if amount in (0.0, None):
+            return _('Amount could not be determined.'), None
+        if self.samePaymentMade(student, category, p_item, p_session):
+            return _('This type of payment has already been made.'), None
+        if self._isPaymentDisabled(p_session, category, student):
+            return _('This category of payments has been disabled.'), 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
 
     # prefix
Index: /main/kofacustom.coewarri/trunk/src/kofacustom/coewarri/utils/utils.py
===================================================================
--- /main/kofacustom.coewarri/trunk/src/kofacustom/coewarri/utils/utils.py	(revision 14332)
+++ /main/kofacustom.coewarri/trunk/src/kofacustom/coewarri/utils/utils.py	(revision 14333)
@@ -32,2 +32,40 @@
         'prence': 'Pre-NCE Programme',
         }
+
+    STUDY_MODES_DICT = {
+        'ume_ft': 'UME Full Time',
+        'ug_ft': 'Undergraduate Full Time',
+        'ug_pt': 'Undergraduate Part Time',
+        'dp_pt': 'Diploma Part Time',
+        'ct_ft': 'Certificate Full Time',
+        'dp_ft': 'Diploma Full Time',
+        'de_ft': 'Direct Entry Full Time',
+        'de_pt': 'Direct Entry Part Time',
+        'nd_ft': 'National Diploma Full Time',
+        'nd_pt': 'National Diploma Part Time',
+        'hnd_ft': 'Higher National Diploma Full Time',
+        'hnd_pt': 'Higher National Diploma Part Time',
+        'pg_ft': 'Postgraduate Full Time',
+        'pg_pt': 'Postgraduate Part Time',
+        'pgd_ft': 'Postgraduate Diploma Full Time',
+        'pgd_pt': 'Postgraduate Diploma Part Time',
+        'special_pg_pt': 'Special Postgraduate Part Time',
+        'nce_ft': 'NCE Full Time',
+        'nce_pt': 'NCE Part Time',
+        'ug_sw': 'Undergraduate Sandwich',
+        'nce_sw': 'NCE Sandwich',
+        'jm_ft': 'Joint Matriculation Full Time',
+        'ph_ft': 'Post Higher Education Full Time',
+        'transfer_pt': 'Transfer Part Time',
+        'transfer_ft': 'Transfer Full Time',
+        'ct_pt': 'Certificate Part Time',
+        'rmd_ft': 'Remedial with deficiencies',
+        'rm_ft': 'Remedial',
+        'transfer': 'Transfer',
+        'prence': 'Pre-NCE',
+        'prend': 'Pre-ND',
+        'pce': 'PCE',
+        'pd_ft': 'Professional Diploma in Education',
+        'found': 'Foundation',
+        'no': 'no application',
+        }
