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
Line 
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##
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        }
85
86    SELECTABLE_PAYMENT_CATEGORIES = {
87        'schoolfee': 'School Fee without additional fees',
88        'schoolfee_1': 'School Fee (1st instalment) incl. additional fees',
89        'schoolfee_2': 'School Fee (2nd instalment)',
90        'schoolfee_incl': 'School Fee incl. additional fees',
91        'clearance': 'Acceptance Fee without additional fees',
92        'clearance_incl': 'Acceptance Fee incl. additional fees',
93        'hostel_maintenance': 'Hostel Accommodation Fee',
94        #'application': 'Application Fee',
95        #'bed_allocation': 'Bed Allocation Fee',
96        #'transfer': 'Transfer Fee',
97        'transcript_local': 'Local Transcript Fee',
98        'transcript_inter': 'International Transcript Fee',
99        'late_registration': 'Late Course Registration Fee',
100        #'welfare': 'Student Welfare Assurance Fee',
101        #'union': 'Student Union Dues',
102        #'lapel': 'Lapel/File Fee',
103        #'matric_gown': 'Matriculation Gown Fee',
104        'concessional': 'Concessional Fee',
105        #'id_card': 'Student ID Card',
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',
109        'gst_text_book_3': 'Text Book Fee GST222',
110        'gst_registration_1': 'Registration Fee GST101 GST102 GST111 GST112',
111        'gst_registration_2': 'Registration Fee GST222',
112        'ent_text_book_1': 'Text Book Fee ENT201',
113        'ent_text_book_2': 'Text Book Fee ENT211',
114        'ent_text_book_0': 'Text Book Fee for ENT201 and ENT211',
115        'ent_registration_1': 'Registration Fee ENT201',
116        'ent_registration_2': 'Registration Fee ENT211',
117        'ent_registration_0': 'Registration Fee for ENT201 and ENT211',
118        'ent_combined': 'Registration and Textbook Fee for ENT201 and ENT211',
119        #'fac_dep': 'Faculty and Departmental Dues (incl. ICT/Affidavit Dues)',
120        'ict': 'ICT/Affidavit Dues',
121        #'affidavit': 'Affidavit Dues',
122        'restitution': 'Restitution Fee',
123        'sports': 'Sports Fee',
124        'library': 'UG Library Fee',
125        'library_pg': 'PG Library Fee',
126        'sports_library': 'Sports Development and Library Fee',
127        'lab_1': 'Faculty Laboratory Due (CHM102/PHY103/CSC101)',
128        'lab_2': 'Laboratory Due (BIO101/BIO111)',
129        'lms_sund': 'LMS plus Sundry Fees (new UG students only)',
130        }
131
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',
140        'late_registration': 'Late Course Registration Fee',
141        'sports': 'Sports Fee',
142        'library': 'UG Library Fee',
143        'library_pg': 'PG Library Fee',
144        'sports_library': 'Sports Development and Library Fee',
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)',
152        'sports': 'Sports Fee',
153        'library': 'UG Library Fee',
154        'library_pg': 'PG Library Fee',
155        'sports_library': 'Sports Development and Library Fee',
156        }
157
158    PT_AND_DSH_PAYMENT_CATS =  {
159        'clearance_incl': 'Acceptance Fee Plus',
160        'schoolfee_incl': 'School Fee Plus',
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',
164        'ent_registration_1': 'Registration Fee ENT201',
165        'ent_registration_2': 'Registration Fee ENT211',
166        'ent_registration_0': 'Registration Fee for ENT201 and ENT211',
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',
173        'ent_combined': 'Registration and Textbook Fee for ENT201 and ENT211',
174        'late_registration': 'Late Course Registration Fee',
175        'sports': 'Sports Fee',
176        'library': 'UG Library Fee',
177        'library_pg': 'PG Library Fee',
178        'sports_library': 'Sports Development and Library Fee',
179        'lab_1': 'Faculty Laboratory Due (CHM102/PHY103/CSC101)',
180        'lab_2': 'Laboratory Due (BIO101/BIO111)',
181        }
182
183    def selectable_payment_categories(self, student):
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
194        return self.SELECTABLE_PAYMENT_CATEGORIES
195
196    REPORTABLE_PAYMENT_CATEGORIES = {
197        'schoolfee': 'School Fee',
198        'schoolfee_incl': 'School Fee Plus',
199        'schoolfee_1': 'School Fee 1 Plus',
200        'schoolfee_2': 'School Fee 2',
201        'clearance': 'Acceptance Fee',
202        'clearance_incl': 'Acceptance Fee Plus',
203        'hostel_maintenance': 'Hostel Maintenance Fee',
204        }
205
206    BALANCE_PAYMENT_CATEGORIES = {
207        'schoolfee': 'School Fee',
208        'clearance': 'Acceptance Fee',
209        'hostel_maintenance': 'Hostel Maintenance Fee',
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',
215        'id_card': 'Student ID Card',
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',
219        'gst_registration_1': 'Registration Fee GST101 GST102 GST111 GST112',
220        'gst_registration_2': 'Registration Fee GST222',
221        'ent_text_book_1': 'Text Book Fee ENT201',
222        'ent_text_book_2': 'Text Book Fee ENT211',
223        'ent_text_book_0': 'Text Book Fee for ENT201 and ENT211',
224        'ent_registration_1': 'Registration Fee ENT201',
225        'ent_registration_2': 'Registration Fee ENT211',
226        'ent_registration_0': 'Registration Fee for ENT201 and ENT211',
227        #'fac_dep': 'Faculty and Departmental Dues (incl. ICT/Affidavit Dues)',
228        'ict': 'ICT/Affidavit Dues',
229        #'affidavit': 'Affidavit Dues',
230        'restitution': 'Restitution Fee',
231        }
232
233    PREVIOUS_PAYMENT_CATEGORIES = {
234        'schoolfee': 'School Fee',
235        'clearance': 'Acceptance Fee',
236        'late_registration': 'Late Course Registration Fee',
237        }
238
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',
246        'ptee': 'Part-Time Entrance Examination',
247        'ioe_dp': 'Institute of Education Diploma',
248        'ijmbe': 'IJMBE Preparation',
249        'bridge': 'Bridge',
250        'dsh': 'Science and Humanities',
251
252        }
253
254    STUDY_MODES_DICT = {
255        'ug_ft': 'Undergraduate Full Time',
256        'ug_pt': 'Undergraduate Part Time',
257        'de_ft': 'Direct Entry Full Time',
258        'de_pt': 'Direct Entry Part Time',
259        'dp_pt': 'Diploma Part Time',
260        'dp_ft': 'Diploma Full Time',
261        'special_pg_ft': 'Postgraduate Full Time',
262        'special_pg_pt': 'Postgraduate Part Time',
263        'found': 'Foundation',
264        'transfer': 'Transfer',
265        'transferred': 'Transferred',
266        'mug_ft': 'Undergraduate Full Time Merit List',
267        'mde_ft': 'Direct Entry Full Time Merit List',
268        'ijmbe': 'IJMBE Preparation',
269        'bridge': 'Bridge',
270        'ug_dsh': 'Undergraduate Science and Humanities',
271        'de_dsh': 'Direct Entry Science and Humanities',
272        }
273
274    ENABLE_SCORE_EDITING_GROUP_DICT = STUDY_MODES_DICT
275
276    VERDICTS_DICT = {
277        '0': 'not yet',
278        'A': 'Successful student',
279        'B': 'Student with carryover courses',
280        'C': 'Student on probation',
281        'D': 'Withdrawn from the faculty',
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',
304        'NER': 'No evidence of registration',
305        'NYV': 'Not yet verified',
306        'FRNS': 'Faculty requirements not satisfied',
307        }
308
309    DISABLE_PAYMENT_GROUP_DICT = {
310        'sf_all': 'School Fee - All Students',
311        'sf_pg': 'School Fee - Postgraduate Students',
312        'sf_ug_pt': 'School Fee - Undergraduate Part-Time Students',
313        'sf_found': 'School Fee - Foundation Students',
314        'maint_all': 'Accommodation Fee - All Students',
315        'cl_regular': 'Acceptance Fee - Regular Students',
316        }
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'),
325        'IJMBE Preparation': ('ijmbe',),
326        'Bridge': ('bridge',),
327        }
328
329    #: Maximum number of files listed in `finished` subfolder
330    MAX_FILES = 5000
331
332    def fullname(self, firstname, lastname, middlename=None):
333        """Construct fullname.
334        """
335        try:
336            lastname = lastname.upper()
337        except AttributeError:
338            pass
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:
349            givennames = '%s %s' % (firstname, middlename)
350        elif firstname:
351            givennames = firstname
352        elif middlename:
353            givennames = middlename
354        givennames = string.capwords(
355            givennames.replace('-', ' - ')).replace(' - ', '-')
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
364        if '<' in fullname:
365            return 'XXX'
366        return fullname
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.