## $Id: utils.py 18140 2025-07-23 08:16:47Z henrik $
##
## Copyright (C) 2012 Uli Fouquet & Henrik Bettermann
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software
## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
##
"""Customize general helper utilities for Kofa.
"""

import grok
from copy import deepcopy
from kofacustom.nigeria.utils.utils import NigeriaKofaUtils

class CustomKofaUtils(NigeriaKofaUtils):
    """A collection of methods subject to customization.
    """

    PAYMENT_CATEGORIES = {
        'schoolfee': 'Tuition Plus (total amount)',
        'schoolfee40': 'Tuition Plus (40% - 1st instalment)',
        'secondinstal': 'Tuition Plus (60% - 2nd instalment)',
        'clearance': 'Acceptance Fee',
        'grad_clearance': 'Clearance Fee',
        'registration': 'Registration Fee',
        'registration_fresh': 'Registration Fee (Fresh)',
        'registration_return': 'Registration Fee (Returning)',
        #'bed_allocation': 'Bed Allocation Fee',
        #'hostel_maintenance': 'Accommodation',
        #'transfer': 'Transfer Fee',
        #'gown': 'Gown Hire Fee',
        'application': 'Application Fee',
        'pg_application': 'PG Application Fee',
        'app_balance': 'Application Fee Balance',
        'transcript': 'Transcript Fee',
        'transcript_local': 'Transcript Fee Local',
        'transcript_overseas': 'Transcript Fee Oversea',
        'late_registration': 'Late Registration Fee',
        'science': 'Science Bench Fee',
        'clinical': 'Clinical Fee (Medical Students)',
        'develop': 'Development Fee',
        'municipal_fresh': 'Municipal Fee (Fresh Students)',
        'municipal_returning': 'Municipal Fee (Returning Students)',
        'alumni': 'Alumni Fee',
        'conv': 'Convocation Fee',
        'matric': 'Matriculation Fee',
        'waecneco': 'WAEC/NECO Verification',
        'jambver': 'JAMB Verification',
        'book': 'Book Deposit',
        'parentsconsult': 'Parents Consultative Forum (PCF) Fee',
        'pharmlab': 'Pharmacy Lab Support Fee',
        'lo_ident': 'Letter of Identification Fee',
        'change_course': 'Change of Course Fee',
        'make_up': 'Make-up Fee',
        'iuits': 'IUITS Fee',
        'fine': 'Fine',
        'combi': 'Combi Payment',
        'resit1': '1 Make-Up Examination Course',
        'resit2': '2 Make-Up Examination Courses',
        'resit3': '3 Make-Up Examination Courses',
        'resit4': '4 Make-Up Examination Courses',
        'resit5': '5 Make-Up Examination Courses',
        'resit6': '6 Make-Up Examination Courses',
        'resit7': '7 Make-Up Examination Courses',
        'resit8': '8 Make-Up Examination Courses',
        'resit9': '9 Make-Up Examination Courses',
        'makeup_admin': 'Make-Up Registration Fee',
        'id_card': 'Student ID Card',
        'required_combi': 'Total Sundry Charges',
        'pg_other': 'PG Other Charges',
        'jupeb_form':'JUPEB Form Fee',
        'jupeb_acc':'JUPEB Acceptance Fee',
        'jupeb_reg':'JUPEB Administrative Fee',
        'jupeb_sci':'JUPEB Tuition (Science)',
        'jupeb_arts':'JUPEB Tuition (Arts)',
        'jupeb_hostel':'JUPEB Accommodation (optional)',
        'brought_fwd': 'Balance Brought Forward',
        'health_insurance': 'Student Health Insurance',
        # CDL Portal Fees only
        'medical':'Medical Services',
        'library':'Library',
        'ict':'ICT Fees',
        'orientation':'Orientation Fee',
        'examination':'Examination Fee',
        'medical_screening':'Medical Screening Fees',
        'cdlcourse1': ' 1 Course',
        'cdlcourse2': ' 2 Courses',
        'cdlcourse3': ' 3 Courses',
        'cdlcourse4': ' 4 Courses',
        'cdlcourse5': ' 5 Courses',
        'cdlcourse6': ' 6 Courses',
        'cdlcourse7': ' 7 Courses',
        'cdlcourse8': ' 8 Courses',
        'cdlcourse9': ' 9 Courses',
        'cdlcourse10': '10 Courses',
        'cdlcourse11': '11 Courses',
        'cdlcourse12': '12 Courses',
        'cdlcourse13': '13 Courses',
        'cdlcourse14': '14 Courses',
        'cdlcourse15': '15 Courses',
        }

    SELECTABLE_PAYMENT_CATEGORIES = {
        'schoolfee': 'Tuition Plus (total amount)',
        'schoolfee40': 'Tuition Plus (40% - 1st instalment)',
        'secondinstal': 'Tuition Plus (60% - 2nd instalment)',
        'clearance': 'Acceptance Fee',
        #'registration': 'Registration Fee',
        #'bed_allocation': 'Bed Allocation Fee',
        #'hostel_maintenance': 'Accommodation',
        #'transfer': 'Transfer Fee',
        #'gown': 'Gown Hire Fee',
        #'app_balance': 'Application Fee Balance',
        #'make_up': 'Make-up Fee',
        'application': 'Application Fee',
        'pg_application': 'PG Application Fee',
        'transcript_local': 'Transcript Fee (Local Students)',
        'transcript_overseas': 'Transcript Fee (Oversea Students)',
        'late_registration': 'Late Registration Fee',
        'clinical': 'Clinical Fee (Medical Students)',
        'lo_ident': 'Letter of Identification Fee',
        'change_course': 'Change of Course Fee',
        'iuits': 'IUITS Fee',
        'fine': 'Fine',
        #'combi': 'Combi Payment',
        #'resit1': '1 Make-Up Examination Course',
        #'resit2': '2 Make-Up Examination Courses',
        #'resit3': '3 Make-Up Examination Courses',
        #'resit4': '4 Make-Up Examination Courses',
        #'resit5': '5 Make-Up Examination Courses',
        #'resit6': '6 Make-Up Examination Courses',
        #'resit7': '7 Make-Up Examination Courses',
        #'resit8': '8 Make-Up Examination Courses',
        #'resit9': '9 Make-Up Examination Courses',
        'makeup_admin': 'Make-Up Registration Fee',
        'required_combi': 'Total Sundry Charges',
        'pg_other': 'PG Other Charges',
        #'jupeb_form':'JUPEB Form Fee',
        #'jupeb_acc':'JUPEB Acceptance Fee',
        #'jupeb_reg':'JUPEB Administrative Fee',
        'jupeb_sci':'JUPEB Tuition (Science)',
        'jupeb_arts':'JUPEB Tuition (Arts)',
        'jupeb_hostel':'JUPEB Accommodation (optional)',

        ## sundry: 'registration_fresh': 'Registration Fee (Fresh)',
        ## sundry: 'registration_return': 'Registration Fee (Returning)',
        ## sundry: 'grad_clearance': 'Clearance Fee',
        ## sundry: 'science': 'Science Bench Fee',
        ## sundry: 'medical_screening':'Medical Screening Fees',
        ## sundry: 'municipal_fresh': 'Municipal Fee (Fresh Students)',
        ## sundry: 'municipal_returning': 'Municipal Fee (Returning Students)',
        ## sundry: 'alumni': 'Alumni Fee',
        ## sundry: 'conv': 'Convocation Fee',
        ## sundry: 'matric': 'Matriculation Fee',
        ## sundry: 'waecneco': 'WAEC/NECO Verification',
        ## sundry: 'jambver': 'JAMB Verification',
        ## sundry: 'book': 'Book Deposit',
        ## sundry: 'parentsconsult': 'Parents Consultative Forum (PCF) Fee',
        ## sundry: 'id_card': 'Student ID Card',
        ## sundry: 'develop': 'Development Fee',
        ## sundry: 'health_insurance': 'Student Health Insurance',
        ## sundry: 'pharmlab': 'Pharmacy Lab Support Fee',
        }

    CDLPORTAL_PAYMENT_CATEGORIES = {
        'schoolfee': 'School Fees',
        'clearance': 'Acceptance Fee',
        'id_card': 'Student ID Card',
        'waecneco': 'WAEC/NECO Verification',
        # CDL Portal fees only
        'medical':'Medical Services',
        'library':'Library',
        'ict':'ICT Fees',
        'orientation':'Orientation Fee',
        'examination':'Examination Fee',
        'cdlcourse1': ' 1 Course',
        'cdlcourse2': ' 2 Courses',
        'cdlcourse3': ' 3 Courses',
        'cdlcourse4': ' 4 Courses',
        'cdlcourse5': ' 5 Courses',
        'cdlcourse6': ' 6 Courses',
        'cdlcourse7': ' 7 Courses',
        'cdlcourse8': ' 8 Courses',
        'cdlcourse9': ' 9 Courses',
        'cdlcourse10': '10 Courses',
        'cdlcourse11': '11 Courses',
        'cdlcourse12': '12 Courses',
        'cdlcourse13': '13 Courses',
        'cdlcourse14': '14 Courses',
        'cdlcourse15': '15 Courses',
        'combi': 'Combi Payment',
        }

    def selectable_payment_categories(self, student):
        if grok.getSite().__name__ == 'iuokada-cdl':
            spc = deepcopy(self.CDLPORTAL_PAYMENT_CATEGORIES)
            return spc
        spc = deepcopy(self.SELECTABLE_PAYMENT_CATEGORIES)
        if student.depcode == 'BMS':
            del spc['schoolfee40']
            del spc['secondinstal']
        return spc

    PREVIOUS_PAYMENT_CATEGORIES = {
        'schoolfee': 'Tuition, Accommodation, Adm. Charges',
        #'registration': 'Registration Fee',
        'registration_fresh': 'Registration Fee (Fresh)',
        'registration_return': 'Registration Fee (Returning)',
        'clearance': 'Acceptance Fee',
        'grad_clearance': 'Clearance Fee',
        'application': 'Application Fee',
        'late_registration': 'Late Registration Fee',
        'science': 'Science Bench Fee',
        'clinical': 'Clinical Fee (Medical Students)',
        'medical_screening':'Medical Screening Fees',
        'develop': 'Development Fee',
        'municipal_fresh': 'Municipal Fee (Fresh Students)',
        'municipal_returning': 'Municipal Fee (Returning Students)',
        'alumni': 'Alumni Fee',
        'conv': 'Convocation Fee',
        'matric': 'Matriculation Fee',
        'waecneco': 'WAEC/NECO Verification',
        'jambver': 'JAMB Verification',
        'book': 'Book Deposit',
        'parentsconsult': 'Parents Consultative Forum (PCF) Fee',
        'pharmlab': 'Pharmacy Lab Support Fee',
        'lo_ident': 'Letter of Identification Fee',
        'change_course': 'Change of Course Fee',
        'make_up': 'Make-up Fee',
        'iuits': 'IUITS Fee',
        'fine': 'Fine',
        'id_card': 'Student ID Card',
        #'required_combi': 'Total  Sundry Charges',
        'pg_other': 'PG Other Charges',
        #'jupeb_form':'JUPEB Form Fee',
        #'jupeb_acc':'JUPEB Acceptance Fee',
        #'jupeb_reg':'JUPEB Administrative Fee',
        'jupeb_sci':'JUPEB Tuition (Science)',
        'jupeb_arts':'JUPEB Tuition (Arts)',
        'jupeb_hostel':'JUPEB Accommodation (optional)',
        'health_insurance': 'Student Health Insurance',
        }

    @property
    def COMBI_PAYMENT_CATEGORIES(self):
        if grok.getSite().__name__ == 'iuokada-cdl':
            return self.CDLPORTAL_COMBI_PAYMENT_CATEGORIES
        return self._COMBI_PAYMENT_CATEGORIES

    CDLPORTAL_COMBI_PAYMENT_CATEGORIES = {
        'clearance': 'Acceptance Fee',
        'id_card': 'Student ID Card',
        'waecneco': 'WAEC/NECO Verification',
        # CDL Portal fees only
        'medical':'Medical Services',
        'library':'Library',
        'ict':'ICT Fees',
        'orientation':'Orientation Fee',
        'examination':'Examination Fee',
        'cdlcourse1': ' 1 Course',
        'cdlcourse2': ' 2 Courses',
        'cdlcourse3': ' 3 Courses',
        'cdlcourse4': ' 4 Courses',
        'cdlcourse5': ' 5 Courses',
        'cdlcourse6': ' 6 Courses',
        'cdlcourse7': ' 7 Courses',
        'cdlcourse8': ' 8 Courses',
        'cdlcourse9': ' 9 Courses',
        'cdlcourse10': '10 Courses',
        'cdlcourse11': '11 Courses',
        'cdlcourse12': '12 Courses',
        'cdlcourse13': '13 Courses',
        'cdlcourse14': '14 Courses',
        'cdlcourse15': '15 Courses',
        }

    _COMBI_PAYMENT_CATEGORIES = {
        #'registration': 'Registration Fee',
        ## sundry: 'registration_fresh': 'Registration Fee (Fresh)',
        ## sundry: 'registration_return': 'Registration Fee (Returning)',
        ## sundry: 'grad_clearance': 'Clearance Fee',
        ## sundry: 'science': 'Science Bench Fee',
        ## sundry: 'medical_screening':'Medical Screening Fees',
        ## sundry: 'municipal_fresh': 'Municipal Fee (Fresh Students)',
        ## sundry: 'municipal_returning': 'Municipal Fee (Returning Students)',
        ## sundry: 'alumni': 'Alumni Fee',
        ## sundry: 'conv': 'Convocation Fee',
        ## sundry: 'matric': 'Matriculation Fee',
        ## sundry: 'waecneco': 'WAEC/NECO Verification',
        ## sundry: 'jambver': 'JAMB Verification',
        ## sundry: 'book': 'Book Deposit',
        ## sundry: 'parentsconsult': 'Parents Consultative Forum (PCF) Fee',
        ## sundry: 'id_card': 'Student ID Card',
        ## sundry: 'develop': 'Development Fee',
        ## sundry: 'health_insurance': 'Student Health Insurance',
        ## sundry: 'pharmlab': 'Pharmacy Lab Support Fee',
        'clinical': 'Clinical Fee (Medical Students)',
        'late_registration': 'Late Registration Fee',
        'lo_ident': 'Letter of Identification Fee',
        'change_course': 'Change of Course Fee',
        'make_up': 'Make-up Fee',
        'iuits': 'IUITS Fee',
        'fine': 'Fine',
        'pg_other': 'PG Other Charges',
        'jupeb_form':'JUPEB Form Fee',
        'jupeb_acc':'JUPEB Acceptance Fee',
        'jupeb_reg':'JUPEB Administrative Fee',
        'jupeb_sci':'JUPEB Tuition (Science)',
        'jupeb_arts':'JUPEB Tuition (Arts)',
        'jupeb_hostel':'JUPEB Accommodation (optional)',
        }

    BALANCE_PAYMENT_CATEGORIES = {
        'schoolfee': 'Tuition, Accommodation, Adm. Charges',
        }

    @property
    def PAYMENT_OPTIONS(self):
        if grok.getSite().__name__ == 'iuokada-cdl':
            return dict()
        return self._PAYMENT_OPTIONS

    _PAYMENT_OPTIONS = {
        'first': 'First Bank Debit Card',
        'access': 'Access Bank Debit Card',
        'zenith': 'Zenith Bank Debit Card',
        'other': 'Other Bank Debit Card',
        }

    APP_CATS_DICT = {
        'basic': 'UAS, PUTME, PUDE, PCE, PRENCE',
        'no': 'No Application',
        'pg': 'Postgraduate Programmes',
        'pg2': 'Postgraduate Programmes 2',
        'pgphd': 'Postgraduate PhD/MPhil',
        'pre': 'Pre-Degree Studies',
        'pt': 'Part-Time Degree Programmes',
        'ut': 'Undergraduate Programmes',
        'conv': 'HND to BSc Conversion',
        'odl': 'Open & Distant Learning',
        }

    STUDY_MODES_DICT = {
        'ug_ft': 'Undergraduate Full Time',
        'ug_pt': 'Undergraduate Part Time',
        'pg_ft': 'Postgraduate Full Time',
        'pg_pt': 'Postgraduate Part Time',
        'pgphd': 'Postgraduate PhD/MPhil',
        'odl': 'Open & Distant Learning',
        'found': 'Foundation',
        'no': 'no application',
        'transfer': 'Transfer',
        'transferred': 'Transferred',
        'de': 'Direct Entry',
        'jupeb': 'JUPEB',
        }

    #: Maximum size in Bytes of passport images in the applicants and
    #: students section
    MAX_PASSPORT_SIZE = 250 * 1024
