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

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

Implement ENT211 payments.

  • Property svn:keywords set to Id
File size: 14.6 KB
RevLine 
[7569]1## $Id: utils.py 16754 2022-01-25 08:25:36Z 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',
[15841]72        'fac_dep': 'Faculty and Departmental Dues (incl. ICT/Affidavit Dues)',
[16669]73        'ict': 'ICT/Affidavit Dues',
[16181]74        'affidavit': 'Affidavit Dues',
[14375]75        'restitution': 'Restitution Fee',
[15971]76        'sports': 'Sports Fee',
[16124]77        'library': 'UG Library Fee',
78        'library_pg': 'PG Library Fee',
79        'sports_library': 'Sports Development and Library Fee',
[16080]80        'lab_1': 'Faculty Laboratory Due (CHM102/PHY103/CSC101)',
81        'lab_2': 'Laboratory Due (BIO101/BIO111)',
[9755]82        }
83
84    SELECTABLE_PAYMENT_CATEGORIES = {
[13435]85        'schoolfee': 'School Fee without additional fees',
[15971]86        'schoolfee_1': 'School Fee (1st instalment) incl. additional fees',
[13512]87        'schoolfee_2': 'School Fee (2nd instalment)',
[15971]88        'schoolfee_incl': 'School Fee incl. additional fees',
[13435]89        'clearance': 'Acceptance Fee without additional fees',
[15971]90        'clearance_incl': 'Acceptance Fee incl. additional fees',
[13454]91        'hostel_maintenance': 'Hostel Accommodation Fee',
[14243]92        #'application': 'Application Fee',
[11621]93        #'bed_allocation': 'Bed Allocation Fee',
94        #'transfer': 'Transfer Fee',
[14296]95        'transcript_local': 'Local Transcript Fee',
96        'transcript_inter': 'International Transcript Fee',
[13035]97        'late_registration': 'Late Course Registration Fee',
[14243]98        #'welfare': 'Student Welfare Assurance Fee',
99        #'union': 'Student Union Dues',
100        #'lapel': 'Lapel/File Fee',
101        #'matric_gown': 'Matriculation Gown Fee',
[13374]102        'concessional': 'Concessional Fee',
[14243]103        #'id_card': 'Student ID Card',
[14355]104        'gst_text_book_0': 'Text Book Fee GST101 GST102 GST111 GST112',
105        'gst_text_book_1': 'Text Book Fee GST101 GST102',
106        'gst_text_book_2': 'Text Book Fee GST111 GST112',
[14258]107        'gst_text_book_3': 'Text Book Fee GST222',
[16754]108        'gst_registration_1': 'Registration Fee GST101 GST102 GST111 GST112',
109        'gst_registration_2': 'Registration Fee GST222',
[14621]110        'ent_text_book_1': 'Text Book Fee ENT201',
[16749]111        'ent_text_book_2': 'Text Book Fee ENT211',
[16754]112        'ent_text_book_0': 'Text Book Fee for ENT201 and ENT211',
[14620]113        'ent_registration_1': 'Registration Fee ENT201',
[16749]114        'ent_registration_2': 'Registration Fee ENT211',
[16754]115        'ent_registration_0': 'Registration Fee for ENT201 and ENT211',
[16177]116        #'fac_dep': 'Faculty and Departmental Dues (incl. ICT/Affidavit Dues)',
[16669]117        'ict': 'ICT/Affidavit Dues',
118        #'affidavit': 'Affidavit Dues',
[14375]119        'restitution': 'Restitution Fee',
[16124]120        'sports': 'Sports Fee',
121        'library': 'UG Library Fee',
122        'library_pg': 'PG Library Fee',
123        'sports_library': 'Sports Development and Library Fee',
[16080]124        'lab_1': 'Faculty Laboratory Due (CHM102/PHY103/CSC101)',
125        'lab_2': 'Laboratory Due (BIO101/BIO111)',
[9755]126        }
127
[15451]128    ALUMNI_PAYMENT_CATS =  {
129        'transcript_local': 'Transcript Fee Local',
130        'transcript_inter': 'Transcript Fee International',
131        }
132
133    REDUCED_PAYMENT_CATS =  {
134        'clearance': 'Acceptance Fee',
135        'schoolfee': 'School Fee',
[15465]136        'late_registration': 'Late Course Registration Fee',
[16124]137        'sports': 'Sports Fee',
138        'library': 'UG Library Fee',
139        'library_pg': 'PG Library Fee',
140        'sports_library': 'Sports Development and Library Fee',
[15451]141        }
142
143    IJMBE_PAYMENT_CATS =  {
144        'clearance': 'Acceptance Fee',
145        'schoolfee': 'School Fee',
146        'schoolfee_1': 'School Fee (1st instalment)',
147        'schoolfee_2': 'School Fee (2nd instalment)',
[16124]148        'sports': 'Sports Fee',
149        'library': 'UG Library Fee',
150        'library_pg': 'PG Library Fee',
151        'sports_library': 'Sports Development and Library Fee',
[15451]152        }
153
154    PT_AND_DSH_PAYMENT_CATS =  {
155        'clearance_incl': 'Acceptance Fee Plus',
156        'schoolfee_incl': 'School Fee Plus',
[16754]157        'ent_text_book_1': 'Text Book Fee ENT201',
158        'ent_text_book_2': 'Text Book Fee ENT211',
159        'ent_text_book_0': 'Text Book Fee for ENT201 and ENT211',
[15451]160        'ent_registration_1': 'Registration Fee ENT201',
[16749]161        'ent_registration_2': 'Registration Fee ENT211',
[16754]162        'ent_registration_0': 'Registration Fee for ENT201 and ENT211',
[15451]163        'gst_registration_1': 'Registration Fee GST101 GST102 GST111 GST112',
164        'gst_registration_2': 'Registration Fee GST222',
165        'gst_text_book_0': 'Text Book Fee GST101 GST102 GST111 GST112',
166        'gst_text_book_1': 'Text Book Fee GST101 GST102',
167        'gst_text_book_2': 'Text Book Fee GST111 GST112',
168        'gst_text_book_3': 'Text Book Fee GST222',
[15862]169        'late_registration': 'Late Course Registration Fee',
[16124]170        'sports': 'Sports Fee',
171        'library': 'UG Library Fee',
172        'library_pg': 'PG Library Fee',
173        'sports_library': 'Sports Development and Library Fee',
[16080]174        'lab_1': 'Faculty Laboratory Due (CHM102/PHY103/CSC101)',
175        'lab_2': 'Laboratory Due (BIO101/BIO111)',
[15451]176        }
177
[15433]178    def selectable_payment_categories(self, student):
[15451]179        if student.state in ALUMNI_STATES:
180            return self.ALUMNI_PAYMENT_CATS
181        if student.current_mode in (
182            'special_pg_ft', 'special_pg_pt', 'found', 'bridge'):
183            return self.REDUCED_PAYMENT_CATS
184        if student.current_mode in (
185            'ug_pt', 'de_pt','dp_pt', 'de_dsh', 'ug_dsh'):
186            return self.PT_AND_DSH_PAYMENT_CATS
187        if student.current_mode == 'ijmbe':
188            return self.IJMBE_PAYMENT_CATS
[15433]189        return self.SELECTABLE_PAYMENT_CATEGORIES
190
[13451]191    REPORTABLE_PAYMENT_CATEGORIES = {
192        'schoolfee': 'School Fee',
[13452]193        'schoolfee_incl': 'School Fee Plus',
[13635]194        'schoolfee_1': 'School Fee 1 Plus',
195        'schoolfee_2': 'School Fee 2',
[13451]196        'clearance': 'Acceptance Fee',
[13452]197        'clearance_incl': 'Acceptance Fee Plus',
[13451]198        'hostel_maintenance': 'Hostel Maintenance Fee',
199        }
200
[13638]201    BALANCE_PAYMENT_CATEGORIES = {
202        'schoolfee': 'School Fee',
203        'clearance': 'Acceptance Fee',
204        'hostel_maintenance': 'Hostel Maintenance Fee',
[13750]205        'late_registration': 'Late Course Registration Fee',
206        'welfare': 'Student Welfare Assurance Fee',
207        'union': 'Student Union Dues',
208        'lapel': 'Lapel/File Fee',
209        'matric_gown': 'Matriculation Gown Fee',
[14234]210        'id_card': 'Student ID Card',
[14258]211        'gst_text_book_1': 'Text Book Fee GST101 GST102',
212        'gst_text_book_2': 'Text Book Fee GST111 GST112',
213        'gst_text_book_3': 'Text Book Fee GST222',
[16754]214        'gst_registration_1': 'Registration Fee GST101 GST102 GST111 GST112',
215        'gst_registration_2': 'Registration Fee GST222',
[14621]216        'ent_text_book_1': 'Text Book Fee ENT201',
[16749]217        'ent_text_book_2': 'Text Book Fee ENT211',
[16754]218        'ent_text_book_0': 'Text Book Fee for ENT201 and ENT211',
[14620]219        'ent_registration_1': 'Registration Fee ENT201',
[16749]220        'ent_registration_2': 'Registration Fee ENT211',
[16754]221        'ent_registration_0': 'Registration Fee for ENT201 and ENT211',
[16179]222        #'fac_dep': 'Faculty and Departmental Dues (incl. ICT/Affidavit Dues)',
[16669]223        'ict': 'ICT/Affidavit Dues',
224        #'affidavit': 'Affidavit Dues',
[14375]225        'restitution': 'Restitution Fee',
[13638]226        }
227
[14544]228    PREVIOUS_PAYMENT_CATEGORIES = {
229        'schoolfee': 'School Fee',
230        'clearance': 'Acceptance Fee',
[16552]231        'late_registration': 'Late Course Registration Fee',
[14544]232        }
233
[10304]234    APP_CATS_DICT = {
235        'basic': 'PUTME, PUDE, PCE, PRENCE',
236        'no': 'No Application',
237        'pg_ft': 'Postgraduate Full-Time',
238        'pg_pt': 'Postgraduate Part-Time',
239        'cest': 'Part-Time, Diploma, Certificate',
240        'found': 'Foundation',
[10893]241        'ptee': 'Part-Time Entrance Examination',
[13568]242        'ioe_dp': 'Institute of Education Diploma',
[14339]243        'ijmbe': 'IJMBE Preparation',
[15224]244        'bridge': 'Bridge',
[15385]245        'dsh': 'Science and Humanities',
246
[10304]247        }
248
[11591]249    STUDY_MODES_DICT = {
250        'ug_ft': 'Undergraduate Full Time',
251        'ug_pt': 'Undergraduate Part Time',
[11593]252        'de_ft': 'Direct Entry Full Time',
253        'de_pt': 'Direct Entry Part Time',
[11591]254        'dp_pt': 'Diploma Part Time',
255        'dp_ft': 'Diploma Full Time',
[13524]256        'special_pg_ft': 'Postgraduate Full Time',
257        'special_pg_pt': 'Postgraduate Part Time',
[11591]258        'found': 'Foundation',
[13498]259        'transfer': 'Transfer',
[13749]260        'mug_ft': 'Undergraduate Full Time Merit List',
261        'mde_ft': 'Direct Entry Full Time Merit List',
[14339]262        'ijmbe': 'IJMBE Preparation',
[15217]263        'bridge': 'Bridge',
[15382]264        'ug_dsh': 'Undergraduate Science and Humanities',
265        'de_dsh': 'Direct Entry Science and Humanities',
[11591]266        }
267
[14700]268    ENABLE_SCORE_EDITING_GROUP_DICT = STUDY_MODES_DICT
269
[13127]270    VERDICTS_DICT = {
271        '0': 'not yet',
272        'A': 'Successful student',
273        'B': 'Student with carryover courses',
274        'C': 'Student on probation',
[14475]275        'D': 'Withdrawn from the faculty',
[13127]276        #'E': 'Student who were previously on probation',
277        #'F': 'Medical case',
278        #'G': 'Absent from examination',
279        #'H': 'Withheld results',
280        #'I': 'Expelled/rusticated/suspended student',
281        #'J': 'Temporary withdrawn from the university',
282        #'K': 'Unregistered student',
283        #'L': 'Referred student',
284        #'M': 'Reinstatement',
285        #'N': 'Student on transfer',
286        #'O': 'NCE-III repeater',
287        #'Y': 'No previous verdict',
288        #'X': 'New 300 level student',
289        'Z': 'Successful student (provisional)',
290        #'A1': 'First Class',
291        #'A2': 'Second Class Upper',
292        #'A3': 'Second Class Lower',
293        #'A4': 'Third Class',
294        #'A5': 'Pass',
295        #'A6': 'Distinction',
296        #'A7': 'Credit',
297        #'A8': 'Merit',
[14487]298        'NER': 'No evidence of registration',
299        'NYV': 'Not yet verified',
[13127]300        'FRNS': 'Faculty requirements not satisfied',
301        }
[13454]302
303    DISABLE_PAYMENT_GROUP_DICT = {
304        'sf_all': 'School Fee - All Students',
[14246]305        'sf_pg': 'School Fee - Postgraduate Students',
[14571]306        'sf_ug_pt': 'School Fee - Undergraduate Part-Time Students',
[14246]307        'sf_found': 'School Fee - Foundation Students',
[13454]308        'maint_all': 'Accommodation Fee - All Students',
[13794]309        'cl_regular': 'Acceptance Fee - Regular Students',
[13454]310        }
[13870]311
312    MODE_GROUPS = {
313        'All': ('all',),
314        'Undergraduate Full-Time': ('ug_ft', 'mde_ft', 'mug_ft', 'de_ft'),
315        'Undergraduate Part-Time': ('ug_pt', 'de_pt'),
316        'Postgraduate': ('pg_ft','special_pg_ft', 'special_pg_pt'),
317        'Foundation Programme': ('found',),
318        'Institute of Education': ('dp_ft'),
[15242]319        'IJMBE Preparation': ('ijmbe',),
320        'Bridge': ('bridge',),
[13870]321        }
[13963]322
[15431]323    #: Maximum number of files listed in `finished` subfolder
324    MAX_FILES = 5000
325
[13963]326    def fullname(self, firstname, lastname, middlename=None):
327        """Construct fullname.
328        """
329        try:
330            lastname = lastname.upper()
331        except AttributeError:
332            pass
[14594]333        # We remove single initial
334        if firstname and len(firstname) == 1:
335            firstname = ''
336        if middlename and len(middlename) == 1:
337            middlename = ''
338        if lastname and len(lastname) == 1:
339            lastname = ''
340        # We construct givennames
341        givennames = ''
342        if middlename and firstname:
[13963]343            givennames = '%s %s' % (firstname, middlename)
[14594]344        elif firstname:
345            givennames = firstname
346        elif middlename:
347            givennames = middlename
[13963]348        givennames = string.capwords(
349            givennames.replace('-', ' - ')).replace(' - ', '-')
[14594]350        # We construct fullname
351        fullname = ''
352        if lastname and givennames:
353            fullname = '%s, %s' % (lastname, givennames)
354        elif lastname:
355            fullname = lastname
356        elif givennames:
357            fullname = givennames
[13963]358        if '<' in fullname:
359            return 'XXX'
360        return fullname
[15965]361
362    def getUsers(self):
363        users = sorted(
364            grok.getSite()['users'].items(), key=lambda x: x[0])
365        for key, val in users:
366            yield(dict(name=key, val="%s - %s" % (val.name, val.title)))
Note: See TracBrowser for help on using the repository browser.