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

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

Add payment category.

  • Property svn:keywords set to Id
File size: 15.2 KB
Line 
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##
18"""Customize general helper utilities for Kofa.
19"""
20
21import string
22import grok
23from kofacustom.nigeria.utils.utils import NigeriaKofaUtils
24from waeup.kofa.students.workflow  import ALUMNI_STATES
25
26class CustomKofaUtils(NigeriaKofaUtils):
27    """A collection of methods subject to customization.
28    """
29
30    PREFERRED_LANGUAGES_DICT = {
31        }
32
33    COURSE_CATEGORY_DICT = {
34        'C':'Core Course (C)',
35        'R':'Required Courses (R)',
36        'E':'Elective Courses (E)',
37        }
38
39    PAYMENT_CATEGORIES = {
40        'schoolfee': 'School Fee',
41        'schoolfee_1': 'School Fee Plus (1st instalment)',
42        'schoolfee_2': 'School Fee (2nd instalment)',
43        'schoolfee_incl': 'School Fee Plus',
44        'clearance': 'Acceptance Fee',
45        'clearance_incl': 'Acceptance Fee Plus',
46        'hostel_maintenance': 'Hostel Accommodation Fee',
47        'application': 'Application Fee',
48        'app_balance': 'Application Fee Balance',
49        'bed_allocation': 'Bed Allocation Fee',
50        'transfer': 'Transfer Fee',
51        'transcript_local': 'Local Transcript Fee',
52        'transcript_inter': 'International Transcript Fee',
53        'late_registration': 'Late Course Registration Fee',
54        'welfare': 'Student Welfare Assurance Fee',
55        'union': 'Student Union Dues',
56        'lapel': 'Lapel/File Fee',
57        'matric_gown': 'Matriculation Gown Fee',
58        'concessional': 'Concessional Fee',
59        'id_card': 'Student ID Card',
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',
63        'gst_text_book_3': 'Text Book Fee GST222',
64        'gst_registration_1': 'Registration Fee GST101 GST102 GST111 GST112',
65        'gst_registration_2': 'Registration Fee GST222',
66        'ent_text_book_1': 'Text Book Fee ENT201',
67        'ent_text_book_2': 'Text Book Fee ENT211',
68        'ent_text_book_0': 'Text Book Fee for ENT201 and ENT211',
69        'ent_registration_1': 'Registration Fee ENT201',
70        'ent_registration_2': 'Registration Fee ENT211',
71        'ent_registration_0': 'Registration Fee for ENT201 and ENT211',
72        'ent_combined': 'Registration and Textbook Fee for ENT201 and ENT211',
73        'fac_dep': 'Faculty and Departmental Dues (incl. ICT/Affidavit Dues)',
74        'ict': 'ICT/Affidavit Dues',
75        'affidavit': 'Affidavit Dues',
76        'restitution': 'Restitution Fee',
77        'sports': 'Sports Fee',
78        'library': 'UG Library Fee',
79        'library_pg': 'PG Library Fee',
80        'sports_library': 'Sports Development and Library Fee',
81        'lab_1': 'Faculty Laboratory Due (CHM102/PHY103/CSC101)',
82        'lab_2': 'Laboratory Due (BIO101/BIO111)',
83        'lms_sund': 'LMS + Sundry Fees',
84        'exam': 'IJMBE Examination Fee',
85        'access_card': 'AAU Access Card Fee',
86        }
87
88    SELECTABLE_PAYMENT_CATEGORIES = {
89        'schoolfee': 'School Fee without additional fees',
90        'schoolfee_1': 'School Fee (1st instalment) incl. additional fees',
91        'schoolfee_2': 'School Fee (2nd instalment)',
92        'schoolfee_incl': 'School Fee incl. additional fees',
93        'clearance': 'Acceptance Fee without additional fees',
94        'clearance_incl': 'Acceptance Fee incl. additional fees',
95        'hostel_maintenance': 'Hostel Accommodation Fee',
96        #'application': 'Application Fee',
97        #'bed_allocation': 'Bed Allocation Fee',
98        #'transfer': 'Transfer Fee',
99        'transcript_local': 'Local Transcript Fee',
100        'transcript_inter': 'International Transcript Fee',
101        'late_registration': 'Late Course Registration Fee',
102        #'welfare': 'Student Welfare Assurance Fee',
103        #'union': 'Student Union Dues',
104        #'lapel': 'Lapel/File Fee',
105        #'matric_gown': 'Matriculation Gown Fee',
106        'concessional': 'Concessional Fee',
107        #'id_card': 'Student ID Card',
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',
111        'gst_text_book_3': 'Text Book Fee GST222',
112        'gst_registration_1': 'Registration Fee GST101 GST102 GST111 GST112',
113        'gst_registration_2': 'Registration Fee GST222',
114        'ent_text_book_1': 'Text Book Fee ENT201',
115        'ent_text_book_2': 'Text Book Fee ENT211',
116        'ent_text_book_0': 'Text Book Fee for ENT201 and ENT211',
117        'ent_registration_1': 'Registration Fee ENT201',
118        'ent_registration_2': 'Registration Fee ENT211',
119        'ent_registration_0': 'Registration Fee for ENT201 and ENT211',
120        'ent_combined': 'Registration and Textbook Fee for ENT201 and ENT211',
121        #'fac_dep': 'Faculty and Departmental Dues (incl. ICT/Affidavit Dues)',
122        'ict': 'ICT/Affidavit Dues',
123        #'affidavit': 'Affidavit Dues',
124        'restitution': 'Restitution Fee',
125        'sports': 'Sports Fee',
126        'library': 'UG Library Fee',
127        'library_pg': 'PG Library Fee',
128        'sports_library': 'Sports Development and Library Fee',
129        'lab_1': 'Faculty Laboratory Due (CHM102/PHY103/CSC101)',
130        'lab_2': 'Laboratory Due (BIO101/BIO111)',
131        'lms_sund': 'LMS plus Sundry Fees (new UG students only)',
132        'access_card': 'AAU Access Card Fee',
133        }
134
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',
143        'late_registration': 'Late Course Registration Fee',
144        'sports': 'Sports Fee',
145        'library': 'UG Library Fee',
146        'library_pg': 'PG Library Fee',
147        'sports_library': 'Sports Development and Library Fee',
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)',
155        'sports': 'Sports Fee',
156        'library': 'UG Library Fee',
157        'library_pg': 'PG Library Fee',
158        'sports_library': 'Sports Development and Library Fee',
159        'exam': 'IJMBE Examination Fee',
160        }
161
162    PT_AND_DSH_PAYMENT_CATS =  {
163        'clearance_incl': 'Acceptance Fee Plus',
164        'schoolfee_incl': 'School Fee Plus',
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',
168        'ent_registration_1': 'Registration Fee ENT201',
169        'ent_registration_2': 'Registration Fee ENT211',
170        'ent_registration_0': 'Registration Fee for ENT201 and ENT211',
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',
177        'ent_combined': 'Registration and Textbook Fee for ENT201 and ENT211',
178        'late_registration': 'Late Course Registration Fee',
179        'sports': 'Sports Fee',
180        'library': 'UG Library Fee',
181        'library_pg': 'PG Library Fee',
182        'sports_library': 'Sports Development and Library Fee',
183        'lab_1': 'Faculty Laboratory Due (CHM102/PHY103/CSC101)',
184        'lab_2': 'Laboratory Due (BIO101/BIO111)',
185        }
186
187    def selectable_payment_categories(self, student):
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
198        return self.SELECTABLE_PAYMENT_CATEGORIES
199
200    REPORTABLE_PAYMENT_CATEGORIES = {
201        'schoolfee': 'School Fee',
202        'schoolfee_incl': 'School Fee Plus',
203        'schoolfee_1': 'School Fee 1 Plus',
204        'schoolfee_2': 'School Fee 2',
205        'clearance': 'Acceptance Fee',
206        'clearance_incl': 'Acceptance Fee Plus',
207        'hostel_maintenance': 'Hostel Maintenance Fee',
208        }
209
210    BALANCE_PAYMENT_CATEGORIES = {
211        'schoolfee': 'School Fee',
212        'clearance': 'Acceptance Fee',
213        'hostel_maintenance': 'Hostel Maintenance Fee',
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',
219        'id_card': 'Student ID Card',
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',
223        'gst_registration_1': 'Registration Fee GST101 GST102 GST111 GST112',
224        'gst_registration_2': 'Registration Fee GST222',
225        'ent_text_book_1': 'Text Book Fee ENT201',
226        'ent_text_book_2': 'Text Book Fee ENT211',
227        'ent_text_book_0': 'Text Book Fee for ENT201 and ENT211',
228        'ent_registration_1': 'Registration Fee ENT201',
229        'ent_registration_2': 'Registration Fee ENT211',
230        'ent_registration_0': 'Registration Fee for ENT201 and ENT211',
231        #'fac_dep': 'Faculty and Departmental Dues (incl. ICT/Affidavit Dues)',
232        'ict': 'ICT/Affidavit Dues',
233        #'affidavit': 'Affidavit Dues',
234        'restitution': 'Restitution Fee',
235        }
236
237    PREVIOUS_PAYMENT_CATEGORIES = {
238        'schoolfee': 'School Fee',
239        'clearance': 'Acceptance Fee',
240        'late_registration': 'Late Course Registration Fee',
241        }
242
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',
250        'ptee': 'Part-Time Entrance Examination',
251        'ioe_dp': 'Institute of Education Diploma',
252        'ijmbe': 'IJMBE Preparation',
253        'bridge': 'Bridge',
254        'dsh': 'Science and Humanities',
255
256        }
257
258    STUDY_MODES_DICT = {
259        'ug_ft': 'Undergraduate Full Time',
260        'ug_pt': 'Undergraduate Part Time',
261        'de_ft': 'Direct Entry Full Time',
262        'de_pt': 'Direct Entry Part Time',
263        'dp_pt': 'Diploma Part Time',
264        'dp_ft': 'Diploma Full Time',
265        'special_pg_ft': 'Postgraduate Full Time',
266        'special_pg_pt': 'Postgraduate Part Time',
267        'found': 'Foundation',
268        'transfer': 'Transfer',
269        'transferred': 'Transferred',
270        'mug_ft': 'Undergraduate Full Time Merit List',
271        'mde_ft': 'Direct Entry Full Time Merit List',
272        'ijmbe': 'IJMBE Preparation',
273        'bridge': 'Bridge',
274        'ug_dsh': 'Undergraduate Science and Humanities',
275        'de_dsh': 'Direct Entry Science and Humanities',
276        }
277
278    ENABLE_SCORE_EDITING_GROUP_DICT = STUDY_MODES_DICT
279
280    VERDICTS_DICT = {
281        '0': 'not yet',
282        'A': 'Successful student',
283        'B': 'Student with carryover courses',
284        'C': 'Student on probation',
285        'D': 'Withdrawn from the faculty',
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',
308        'NER': 'No evidence of registration',
309        'NYV': 'Not yet verified',
310        'FRNS': 'Faculty requirements not satisfied',
311        }
312
313    DISABLE_PAYMENT_GROUP_DICT = {
314        'sf_all': 'School Fee - All Students',
315        'sf_pg': 'School Fee - Postgraduate Students',
316        'sf_ug_pt': 'School Fee - Undergraduate Part-Time Students',
317        'sf_found': 'School Fee - Foundation Students',
318        'maint_all': 'Accommodation Fee - All Students',
319        'cl_regular': 'Acceptance Fee - Regular Students',
320        }
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'),
329        'IJMBE Preparation': ('ijmbe',),
330        'Bridge': ('bridge',),
331        }
332
333    #: Maximum number of files listed in `finished` subfolder
334    MAX_FILES = 5000
335
336    def fullname(self, firstname, lastname, middlename=None):
337        """Construct fullname.
338        """
339        try:
340            lastname = lastname.upper()
341        except AttributeError:
342            pass
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:
353            givennames = '%s %s' % (firstname, middlename)
354        elif firstname:
355            givennames = firstname
356        elif middlename:
357            givennames = middlename
358        givennames = string.capwords(
359            givennames.replace('-', ' - ')).replace(' - ', '-')
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
368        if '<' in fullname:
369            return 'XXX'
370        return fullname
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.