source: main/waeup.aaue/trunk/src/waeup/aaue/utils/utils.py @ 16932

Last change on this file since 16932 was 16929, checked in by Henrik Bettermann, 3 years ago

Add payment category.

  • Property svn:keywords set to Id
File size: 15.0 KB
RevLine 
[7569]1## $Id: utils.py 16929 2022-04-20 06:20:10Z henrik $
2##
3## Copyright (C) 2012 Uli Fouquet & Henrik Bettermann
4## This program is free software; you can redistribute it and/or modify
5## it under the terms of the GNU General Public License as published by
6## the Free Software Foundation; either version 2 of the License, or
7## (at your option) any later version.
8##
9## This program is distributed in the hope that it will be useful,
10## but WITHOUT ANY WARRANTY; without even the implied warranty of
11## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12## GNU General Public License for more details.
13##
14## You should have received a copy of the GNU General Public License
15## along with this program; if not, write to the Free Software
16## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17##
[7822]18"""Customize general helper utilities for Kofa.
[7569]19"""
[13963]20
21import string
[15965]22import grok
[8823]23from kofacustom.nigeria.utils.utils import NigeriaKofaUtils
[15451]24from waeup.kofa.students.workflow  import ALUMNI_STATES
[7569]25
[8823]26class CustomKofaUtils(NigeriaKofaUtils):
[7569]27    """A collection of methods subject to customization.
28    """
[7845]29
30    PREFERRED_LANGUAGES_DICT = {
[9755]31        }
32
[14650]33    COURSE_CATEGORY_DICT = {
34        'C':'Core Course (C)',
35        'R':'Required Courses (R)',
36        'E':'Elective Courses (E)',
37        }
38
[9755]39    PAYMENT_CATEGORIES = {
40        'schoolfee': 'School Fee',
[13512]41        'schoolfee_1': 'School Fee Plus (1st instalment)',
42        'schoolfee_2': 'School Fee (2nd instalment)',
[13410]43        'schoolfee_incl': 'School Fee Plus',
[9755]44        'clearance': 'Acceptance Fee',
[13410]45        'clearance_incl': 'Acceptance Fee Plus',
[13424]46        'hostel_maintenance': 'Hostel Accommodation Fee',
[9755]47        'application': 'Application Fee',
[15555]48        'app_balance': 'Application Fee Balance',
[9755]49        'bed_allocation': 'Bed Allocation Fee',
50        'transfer': 'Transfer Fee',
[14296]51        'transcript_local': 'Local Transcript Fee',
52        'transcript_inter': 'International Transcript Fee',
[13035]53        'late_registration': 'Late Course Registration Fee',
[13402]54        'welfare': 'Student Welfare Assurance Fee',
[13463]55        'union': 'Student Union Dues',
[13402]56        'lapel': 'Lapel/File Fee',
[13374]57        'matric_gown': 'Matriculation Gown Fee',
58        'concessional': 'Concessional Fee',
[14234]59        'id_card': 'Student ID Card',
[14355]60        'gst_text_book_0': 'Text Book Fee GST101 GST102 GST111 GST112',
61        'gst_text_book_1': 'Text Book Fee GST101 GST102',
62        'gst_text_book_2': 'Text Book Fee GST111 GST112',
[14258]63        'gst_text_book_3': 'Text Book Fee GST222',
[16754]64        'gst_registration_1': 'Registration Fee GST101 GST102 GST111 GST112',
65        'gst_registration_2': 'Registration Fee GST222',
[14621]66        'ent_text_book_1': 'Text Book Fee ENT201',
[16749]67        'ent_text_book_2': 'Text Book Fee ENT211',
[16754]68        'ent_text_book_0': 'Text Book Fee for ENT201 and ENT211',
[14620]69        'ent_registration_1': 'Registration Fee ENT201',
[16749]70        'ent_registration_2': 'Registration Fee ENT211',
[16754]71        'ent_registration_0': 'Registration Fee for ENT201 and ENT211',
[16805]72        'ent_combined': 'Registration and Textbook Fee for ENT201 and ENT211',
[15841]73        'fac_dep': 'Faculty and Departmental Dues (incl. ICT/Affidavit Dues)',
[16669]74        'ict': 'ICT/Affidavit Dues',
[16181]75        'affidavit': 'Affidavit Dues',
[14375]76        'restitution': 'Restitution Fee',
[15971]77        'sports': 'Sports Fee',
[16124]78        'library': 'UG Library Fee',
79        'library_pg': 'PG Library Fee',
80        'sports_library': 'Sports Development and Library Fee',
[16080]81        'lab_1': 'Faculty Laboratory Due (CHM102/PHY103/CSC101)',
82        'lab_2': 'Laboratory Due (BIO101/BIO111)',
[16929]83        'lms_sund': 'LMS + Sundry Fees',
[9755]84        }
85
86    SELECTABLE_PAYMENT_CATEGORIES = {
[13435]87        'schoolfee': 'School Fee without additional fees',
[15971]88        'schoolfee_1': 'School Fee (1st instalment) incl. additional fees',
[13512]89        'schoolfee_2': 'School Fee (2nd instalment)',
[15971]90        'schoolfee_incl': 'School Fee incl. additional fees',
[13435]91        'clearance': 'Acceptance Fee without additional fees',
[15971]92        'clearance_incl': 'Acceptance Fee incl. additional fees',
[13454]93        'hostel_maintenance': 'Hostel Accommodation Fee',
[14243]94        #'application': 'Application Fee',
[11621]95        #'bed_allocation': 'Bed Allocation Fee',
96        #'transfer': 'Transfer Fee',
[14296]97        'transcript_local': 'Local Transcript Fee',
98        'transcript_inter': 'International Transcript Fee',
[13035]99        'late_registration': 'Late Course Registration Fee',
[14243]100        #'welfare': 'Student Welfare Assurance Fee',
101        #'union': 'Student Union Dues',
102        #'lapel': 'Lapel/File Fee',
103        #'matric_gown': 'Matriculation Gown Fee',
[13374]104        'concessional': 'Concessional Fee',
[14243]105        #'id_card': 'Student ID Card',
[14355]106        'gst_text_book_0': 'Text Book Fee GST101 GST102 GST111 GST112',
107        'gst_text_book_1': 'Text Book Fee GST101 GST102',
108        'gst_text_book_2': 'Text Book Fee GST111 GST112',
[14258]109        'gst_text_book_3': 'Text Book Fee GST222',
[16754]110        'gst_registration_1': 'Registration Fee GST101 GST102 GST111 GST112',
111        'gst_registration_2': 'Registration Fee GST222',
[14621]112        'ent_text_book_1': 'Text Book Fee ENT201',
[16749]113        'ent_text_book_2': 'Text Book Fee ENT211',
[16754]114        'ent_text_book_0': 'Text Book Fee for ENT201 and ENT211',
[14620]115        'ent_registration_1': 'Registration Fee ENT201',
[16749]116        'ent_registration_2': 'Registration Fee ENT211',
[16754]117        'ent_registration_0': 'Registration Fee for ENT201 and ENT211',
[16805]118        'ent_combined': 'Registration and Textbook Fee for ENT201 and ENT211',
[16177]119        #'fac_dep': 'Faculty and Departmental Dues (incl. ICT/Affidavit Dues)',
[16669]120        'ict': 'ICT/Affidavit Dues',
121        #'affidavit': 'Affidavit Dues',
[14375]122        'restitution': 'Restitution Fee',
[16124]123        'sports': 'Sports Fee',
124        'library': 'UG Library Fee',
125        'library_pg': 'PG Library Fee',
126        'sports_library': 'Sports Development and Library Fee',
[16080]127        'lab_1': 'Faculty Laboratory Due (CHM102/PHY103/CSC101)',
128        'lab_2': 'Laboratory Due (BIO101/BIO111)',
[16929]129        'lms_sund': 'LMS plus Sundry Fees (new UG students only)',
[9755]130        }
131
[15451]132    ALUMNI_PAYMENT_CATS =  {
133        'transcript_local': 'Transcript Fee Local',
134        'transcript_inter': 'Transcript Fee International',
135        }
136
137    REDUCED_PAYMENT_CATS =  {
138        'clearance': 'Acceptance Fee',
139        'schoolfee': 'School Fee',
[15465]140        'late_registration': 'Late Course Registration Fee',
[16124]141        'sports': 'Sports Fee',
142        'library': 'UG Library Fee',
143        'library_pg': 'PG Library Fee',
144        'sports_library': 'Sports Development and Library Fee',
[15451]145        }
146
147    IJMBE_PAYMENT_CATS =  {
148        'clearance': 'Acceptance Fee',
149        'schoolfee': 'School Fee',
150        'schoolfee_1': 'School Fee (1st instalment)',
151        'schoolfee_2': 'School Fee (2nd instalment)',
[16124]152        'sports': 'Sports Fee',
153        'library': 'UG Library Fee',
154        'library_pg': 'PG Library Fee',
155        'sports_library': 'Sports Development and Library Fee',
[15451]156        }
157
158    PT_AND_DSH_PAYMENT_CATS =  {
159        'clearance_incl': 'Acceptance Fee Plus',
160        'schoolfee_incl': 'School Fee Plus',
[16754]161        'ent_text_book_1': 'Text Book Fee ENT201',
162        'ent_text_book_2': 'Text Book Fee ENT211',
163        'ent_text_book_0': 'Text Book Fee for ENT201 and ENT211',
[15451]164        'ent_registration_1': 'Registration Fee ENT201',
[16749]165        'ent_registration_2': 'Registration Fee ENT211',
[16754]166        'ent_registration_0': 'Registration Fee for ENT201 and ENT211',
[15451]167        'gst_registration_1': 'Registration Fee GST101 GST102 GST111 GST112',
168        'gst_registration_2': 'Registration Fee GST222',
169        'gst_text_book_0': 'Text Book Fee GST101 GST102 GST111 GST112',
170        'gst_text_book_1': 'Text Book Fee GST101 GST102',
171        'gst_text_book_2': 'Text Book Fee GST111 GST112',
172        'gst_text_book_3': 'Text Book Fee GST222',
[16805]173        'ent_combined': 'Registration and Textbook Fee for ENT201 and ENT211',
[15862]174        'late_registration': 'Late Course Registration Fee',
[16124]175        'sports': 'Sports Fee',
176        'library': 'UG Library Fee',
177        'library_pg': 'PG Library Fee',
178        'sports_library': 'Sports Development and Library Fee',
[16080]179        'lab_1': 'Faculty Laboratory Due (CHM102/PHY103/CSC101)',
180        'lab_2': 'Laboratory Due (BIO101/BIO111)',
[15451]181        }
182
[15433]183    def selectable_payment_categories(self, student):
[15451]184        if student.state in ALUMNI_STATES:
185            return self.ALUMNI_PAYMENT_CATS
186        if student.current_mode in (
187            'special_pg_ft', 'special_pg_pt', 'found', 'bridge'):
188            return self.REDUCED_PAYMENT_CATS
189        if student.current_mode in (
190            'ug_pt', 'de_pt','dp_pt', 'de_dsh', 'ug_dsh'):
191            return self.PT_AND_DSH_PAYMENT_CATS
192        if student.current_mode == 'ijmbe':
193            return self.IJMBE_PAYMENT_CATS
[15433]194        return self.SELECTABLE_PAYMENT_CATEGORIES
195
[13451]196    REPORTABLE_PAYMENT_CATEGORIES = {
197        'schoolfee': 'School Fee',
[13452]198        'schoolfee_incl': 'School Fee Plus',
[13635]199        'schoolfee_1': 'School Fee 1 Plus',
200        'schoolfee_2': 'School Fee 2',
[13451]201        'clearance': 'Acceptance Fee',
[13452]202        'clearance_incl': 'Acceptance Fee Plus',
[13451]203        'hostel_maintenance': 'Hostel Maintenance Fee',
204        }
205
[13638]206    BALANCE_PAYMENT_CATEGORIES = {
207        'schoolfee': 'School Fee',
208        'clearance': 'Acceptance Fee',
209        'hostel_maintenance': 'Hostel Maintenance Fee',
[13750]210        'late_registration': 'Late Course Registration Fee',
211        'welfare': 'Student Welfare Assurance Fee',
212        'union': 'Student Union Dues',
213        'lapel': 'Lapel/File Fee',
214        'matric_gown': 'Matriculation Gown Fee',
[14234]215        'id_card': 'Student ID Card',
[14258]216        'gst_text_book_1': 'Text Book Fee GST101 GST102',
217        'gst_text_book_2': 'Text Book Fee GST111 GST112',
218        'gst_text_book_3': 'Text Book Fee GST222',
[16754]219        'gst_registration_1': 'Registration Fee GST101 GST102 GST111 GST112',
220        'gst_registration_2': 'Registration Fee GST222',
[14621]221        'ent_text_book_1': 'Text Book Fee ENT201',
[16749]222        'ent_text_book_2': 'Text Book Fee ENT211',
[16754]223        'ent_text_book_0': 'Text Book Fee for ENT201 and ENT211',
[14620]224        'ent_registration_1': 'Registration Fee ENT201',
[16749]225        'ent_registration_2': 'Registration Fee ENT211',
[16754]226        'ent_registration_0': 'Registration Fee for ENT201 and ENT211',
[16179]227        #'fac_dep': 'Faculty and Departmental Dues (incl. ICT/Affidavit Dues)',
[16669]228        'ict': 'ICT/Affidavit Dues',
229        #'affidavit': 'Affidavit Dues',
[14375]230        'restitution': 'Restitution Fee',
[13638]231        }
232
[14544]233    PREVIOUS_PAYMENT_CATEGORIES = {
234        'schoolfee': 'School Fee',
235        'clearance': 'Acceptance Fee',
[16552]236        'late_registration': 'Late Course Registration Fee',
[14544]237        }
238
[10304]239    APP_CATS_DICT = {
240        'basic': 'PUTME, PUDE, PCE, PRENCE',
241        'no': 'No Application',
242        'pg_ft': 'Postgraduate Full-Time',
243        'pg_pt': 'Postgraduate Part-Time',
244        'cest': 'Part-Time, Diploma, Certificate',
245        'found': 'Foundation',
[10893]246        'ptee': 'Part-Time Entrance Examination',
[13568]247        'ioe_dp': 'Institute of Education Diploma',
[14339]248        'ijmbe': 'IJMBE Preparation',
[15224]249        'bridge': 'Bridge',
[15385]250        'dsh': 'Science and Humanities',
251
[10304]252        }
253
[11591]254    STUDY_MODES_DICT = {
255        'ug_ft': 'Undergraduate Full Time',
256        'ug_pt': 'Undergraduate Part Time',
[11593]257        'de_ft': 'Direct Entry Full Time',
258        'de_pt': 'Direct Entry Part Time',
[11591]259        'dp_pt': 'Diploma Part Time',
260        'dp_ft': 'Diploma Full Time',
[13524]261        'special_pg_ft': 'Postgraduate Full Time',
262        'special_pg_pt': 'Postgraduate Part Time',
[11591]263        'found': 'Foundation',
[13498]264        'transfer': 'Transfer',
[16830]265        'transferred': 'Transferred',
[13749]266        'mug_ft': 'Undergraduate Full Time Merit List',
267        'mde_ft': 'Direct Entry Full Time Merit List',
[14339]268        'ijmbe': 'IJMBE Preparation',
[15217]269        'bridge': 'Bridge',
[15382]270        'ug_dsh': 'Undergraduate Science and Humanities',
271        'de_dsh': 'Direct Entry Science and Humanities',
[11591]272        }
273
[14700]274    ENABLE_SCORE_EDITING_GROUP_DICT = STUDY_MODES_DICT
275
[13127]276    VERDICTS_DICT = {
277        '0': 'not yet',
278        'A': 'Successful student',
279        'B': 'Student with carryover courses',
280        'C': 'Student on probation',
[14475]281        'D': 'Withdrawn from the faculty',
[13127]282        #'E': 'Student who were previously on probation',
283        #'F': 'Medical case',
284        #'G': 'Absent from examination',
285        #'H': 'Withheld results',
286        #'I': 'Expelled/rusticated/suspended student',
287        #'J': 'Temporary withdrawn from the university',
288        #'K': 'Unregistered student',
289        #'L': 'Referred student',
290        #'M': 'Reinstatement',
291        #'N': 'Student on transfer',
292        #'O': 'NCE-III repeater',
293        #'Y': 'No previous verdict',
294        #'X': 'New 300 level student',
295        'Z': 'Successful student (provisional)',
296        #'A1': 'First Class',
297        #'A2': 'Second Class Upper',
298        #'A3': 'Second Class Lower',
299        #'A4': 'Third Class',
300        #'A5': 'Pass',
301        #'A6': 'Distinction',
302        #'A7': 'Credit',
303        #'A8': 'Merit',
[14487]304        'NER': 'No evidence of registration',
305        'NYV': 'Not yet verified',
[13127]306        'FRNS': 'Faculty requirements not satisfied',
307        }
[13454]308
309    DISABLE_PAYMENT_GROUP_DICT = {
310        'sf_all': 'School Fee - All Students',
[14246]311        'sf_pg': 'School Fee - Postgraduate Students',
[14571]312        'sf_ug_pt': 'School Fee - Undergraduate Part-Time Students',
[14246]313        'sf_found': 'School Fee - Foundation Students',
[13454]314        'maint_all': 'Accommodation Fee - All Students',
[13794]315        'cl_regular': 'Acceptance Fee - Regular Students',
[13454]316        }
[13870]317
318    MODE_GROUPS = {
319        'All': ('all',),
320        'Undergraduate Full-Time': ('ug_ft', 'mde_ft', 'mug_ft', 'de_ft'),
321        'Undergraduate Part-Time': ('ug_pt', 'de_pt'),
322        'Postgraduate': ('pg_ft','special_pg_ft', 'special_pg_pt'),
323        'Foundation Programme': ('found',),
324        'Institute of Education': ('dp_ft'),
[15242]325        'IJMBE Preparation': ('ijmbe',),
326        'Bridge': ('bridge',),
[13870]327        }
[13963]328
[15431]329    #: Maximum number of files listed in `finished` subfolder
330    MAX_FILES = 5000
331
[13963]332    def fullname(self, firstname, lastname, middlename=None):
333        """Construct fullname.
334        """
335        try:
336            lastname = lastname.upper()
337        except AttributeError:
338            pass
[14594]339        # We remove single initial
340        if firstname and len(firstname) == 1:
341            firstname = ''
342        if middlename and len(middlename) == 1:
343            middlename = ''
344        if lastname and len(lastname) == 1:
345            lastname = ''
346        # We construct givennames
347        givennames = ''
348        if middlename and firstname:
[13963]349            givennames = '%s %s' % (firstname, middlename)
[14594]350        elif firstname:
351            givennames = firstname
352        elif middlename:
353            givennames = middlename
[13963]354        givennames = string.capwords(
355            givennames.replace('-', ' - ')).replace(' - ', '-')
[14594]356        # We construct fullname
357        fullname = ''
358        if lastname and givennames:
359            fullname = '%s, %s' % (lastname, givennames)
360        elif lastname:
361            fullname = lastname
362        elif givennames:
363            fullname = givennames
[13963]364        if '<' in fullname:
365            return 'XXX'
366        return fullname
[15965]367
368    def getUsers(self):
369        users = sorted(
370            grok.getSite()['users'].items(), key=lambda x: x[0])
371        for key, val in users:
372            yield(dict(name=key, val="%s - %s" % (val.name, val.title)))
Note: See TracBrowser for help on using the repository browser.