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

Last change on this file since 18051 was 18045, checked in by Henrik Bettermann, 6 weeks ago

Add hostel balance fee.

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