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

Last change on this file since 17397 was 17099, checked in by Henrik Bettermann, 2 years ago

Add payment category.

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