## $Id: utils.py 18337 2026-09-26 12:58:14Z 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 string
from copy import deepcopy
from kofacustom.nigeria.utils.utils import NigeriaKofaUtils

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

    PAYMENT_CATEGORIES = {
        'schoolfee': 'School Fee',
        'clearance': 'Acceptance Fee',
        'bed_allocation': 'Bed Reservation',
        'hostel_maintenance': 'Hostel Fee',
        #'transfer': 'Transfer Fee',
        #'gown': 'Gown Hire Fee',
        'application': 'Application Fee',
        #'app_balance': 'Application Fee Balance',
        'transcript': 'Transcript Fee',
        'transcript_student': 'Transcript Fee Students Copy',
        'transcript_local': 'Transcript Fee Local Copy',
        'transcript_inter': 'Transcript Fee International Copy',
        #'late_registration': 'Late Course Registration Fee',
        #'combi': 'Combi Payment',
        'med_reg':'Medical Registration Fee',
        'teaching_practice':'Teaching Practice Fee',
        'ijmb_exam':'IJMB Examination Fees',
        'union': 'Student Union Due',
        'siwes': 'SIWES',
        'trcn_nce': 'NCE TRCN Induction / License Fees',
        'trcn_degree': 'DEGREE TRCN Induction / License Fees',
        'twohundred_ced': 'CED Registration Fee (200 Level)',
        'threehundred_ced': 'CED Registration Fee (300 Level)',
        'convocation': 'Convocation Fee',
        'plagtest':   'Turnitin Plagiarism Checker',
        'plagtest_2': 'Turnitin Plagiarism Checker 2',
        'plagtest_3': 'Turnitin Plagiarism Checker 3',
        'plagtest_4': 'Turnitin Plagiarism Checker 4',
        'plagtest_5': 'Turnitin Plagiarism Checker 5',
        'plagtest_6': 'Turnitin Plagiarism Checker 6',
        'plagtest_7': 'Turnitin Plagiarism Checker 7',
        'plagtest_8': 'Turnitin Plagiarism Checker 8',
        'plagtest_9': 'Turnitin Plagiarism Checker 9',
        'plagtest_10': 'Turnitin Plagiarism Checker 10',
        'plagtest_11': 'Turnitin Plagiarism Checker 11',
        'plagtest_12': 'Turnitin Plagiarism Checker 12',
        'plagtest_13': 'Turnitin Plagiarism Checker 13',
        'plagtest_14': 'Turnitin Plagiarism Checker 14',
        'plagtest_15': 'Turnitin Plagiarism Checker 15',
        'plagtest_16': 'Turnitin Plagiarism Checker 16',
        'plagtest_17': 'Turnitin Plagiarism Checker 17',
        'plagtest_18': 'Turnitin Plagiarism Checker 18',
        'plagtest_19': 'Turnitin Plagiarism Checker 19',
        'dsb': 'Digital Skills Training Fee',
        }

    SELECTABLE_PAYMENT_CATEGORIES = {
        'schoolfee': 'School Fee',
        'clearance': 'Acceptance Fee',
        #'bed_allocation': 'Bed Reservation (free of charge)',
        'hostel_maintenance': 'Hostel Fee',
        'med_reg':'Medical Registration Fee',
        'teaching_practice':'Teaching Practice Fee',
        'ijmb_exam':'IJMB Examination Fees',
        #'transcript': 'Transcript Fee',
        'transcript_student': 'Transcript Fee Students Copy',
        'transcript_local': 'Transcript Fee Local Copy',
        'transcript_inter': 'Transcript Fee International Copy',
        'siwes': 'SIWES',
        #'union': 'Student Union Due',
        'trcn_nce': 'NCE TRCN Induction / License Fees',
        'trcn_degree': 'DEGREE TRCN Induction / License Fees',
        'twohundred_ced': 'CED Registration Fee (200 Level)',
        'threehundred_ced': 'CED Registration Fee (300 Level)',
        'convocation': 'Convocation Fee',
        'plagtest':   'Turnitin Plagiarism Checker',
        'dsb': 'Digital Skills Training Fee',
        }

    def selectable_payment_categories(self, student):
        return self.SELECTABLE_PAYMENT_CATEGORIES

    PREVIOUS_PAYMENT_CATEGORIES = deepcopy(SELECTABLE_PAYMENT_CATEGORIES)

    DISABLE_PAYMENT_GROUP_DICT = {
        'sf_all':    'School Fee - All',
        'sf_ugft':   'School Fee - Undergraduate Full-Time',
        }

    COURSE_CATEGORY_DICT = {
        'C':'Core Course (C)',
        'R':'Required Courses (R)',
        'E':'Elective Courses (E)',
        }
        
    STUDY_MODES_DICT = {
        'ug_ft': 'Undergraduate Full-Time',
        'ug_pt': 'Undergraduate Part-Time',
        'found': 'Foundation',
        'dp_ft': 'Full-Time Diploma Programmes',
        'dp_pt': 'Part-Time Diploma Programmes',
        'de_ft': 'Direct Entry Full-Time Programmes',
        'nce_ft': 'NCE Full-Time',
        'nce_pt': 'NCE Part-Time',
        'pde': 'Professional Diploma in Education Programmes',
        'trc': 'TRCN Programmes',
        'dsb': 'Digital Skill Boulevard Certificate Programmes',
        'pg_ft': 'Postgraduate Full-Time',
        'pg_pt': 'Postgraduate Part-Time',
        }

    ENABLE_SCORE_EDITING_GROUP_DICT = STUDY_MODES_DICT

    APP_CATS_DICT = {
        'basic': 'UAS, PUTME, PCE, PRENCE',
        'basic_de': 'UAS, PUTME, PUDE, PCE, PRENCE',
        'no': 'No Application',
        'pre': 'Pre-Degree Programmes',
        'jupeb': 'JUPEB Pre-Degree (Foundation) Programmes',
        'ijmb': 'IJMB Foundation School Programmes',
        'dp_ft': 'Full-Time Diploma Programmes',
        'dp_pt': 'Part-Time Diploma Programmes',
        'ug_pt': 'Undergraduate Part-Time Programmes',
        'df': 'Digital Forensic for Professionals and Academia',
        'law': 'Certificate in Law Programme',
        'pde': 'Professional Diploma in Education Programmes',
        'trcdeg': 'TRCN Degree Programmes',
        'trcnce': 'TRCN NCE Programmes',
        'dsb': 'Digital Skill Boulevard Certificate Programmes',
        'pg_ft': 'Full-Time Postgraduate Programmes',
        'pg_pt': 'Part-Time Postgraduate Programmes',
        }

    SPECIAL_HANDLING_DICT = {
        'regular': 'Regular Hostel',
        'blocked': 'Blocked Hostel',
        'oyibu': 'Owa-Oyibu Campus Hostel',
        'alero': 'Owa-Alero Campus Hostel',
        }

    def fullname(self, firstname, lastname, middlename=None):
        """Construct fullname.
        """
        try:
            lastname = lastname.upper()
        except AttributeError:
            pass
        # We remove single initial
        if firstname and len(firstname) == 1:
            firstname = ''
        if middlename and len(middlename) == 1:
            middlename = ''
        if lastname and len(lastname) == 1:
            lastname = ''
        # We construct givennames
        givennames = ''
        if middlename and firstname:
            givennames = '%s %s' % (firstname, middlename)
        elif firstname:
            givennames = firstname
        elif middlename:
            givennames = middlename
        givennames = string.capwords(
            givennames.replace('-', ' - ')).replace(' - ', '-')
        # We construct fullname
        fullname = ''
        if lastname and givennames:
            fullname = '%s, %s' % (lastname, givennames)
        elif lastname:
            fullname = lastname
        elif givennames:
            fullname = givennames
        if '<' in fullname:
            return 'XXX'
        return fullname