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

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

Add payment category.

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