source: main/waeup.uniben/trunk/src/waeup/uniben/students/utils.py @ 8440

Last change on this file since 8440 was 8430, checked in by Henrik Bettermann, 13 years ago

Make waeup.uniben in line with base package. Fortunately we can now use the payment methods used in the base package and do no longer need the actions_after functions in w.u.students.utils and w.u.applicants.utils.

Interswitch and etranzact modules have not been tested with live gateways. The query functions and approval methods may fail.

  • Property svn:keywords set to Id
File size: 5.7 KB
Line 
1## $Id: utils.py 8430 2012-05-12 08:43:51Z henrik $
2##
3## Copyright (C) 2011 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##
18import grok
19from waeup.kofa.interfaces import CLEARED, RETURNING
20from waeup.kofa.students.utils import StudentsUtils
21from waeup.kofa.students.interfaces import IStudentsUtils
22from waeup.kofa.accesscodes import create_accesscode
23from waeup.uniben.interfaces import MessageFactory as _
24
25def get_school_fee(student):
26    state = student.state
27    fee = None
28    if state == CLEARED:
29        fee = getattr(student['studycourse'].certificate,'school_fee_1')
30    elif state == RETURNING:
31        fee = getattr(student['studycourse'].certificate,'school_fee_2')
32    if fee is not None:
33        return fee
34    return 0.0
35
36class CustomStudentsUtils(StudentsUtils):
37    """A collection of customized methods.
38
39    """
40    grok.implements(IStudentsUtils)
41
42    def getReturningData(self, student):
43        """ This method defines what happens after school fee payment
44        of returning students depending on the student's senate verdict.
45        """
46        prev_level = student['studycourse'].current_level
47        cur_verdict = student['studycourse'].current_verdict
48        if cur_verdict in ('A','B','L','M','N','Z',):
49            # Successful student
50            new_level = divmod(int(prev_level),100)[0]*100 + 100
51        elif cur_verdict == 'C':
52            # Student on probation
53            new_level = int(prev_level) + 10
54        else:
55            # Student is somehow in an undefined state.
56            # Level has to be set manually.
57            new_level = prev_level
58        new_session = student['studycourse'].current_session + 1
59        return new_session, new_level
60
61    def getPaymentDetails(self, category, student):
62        details = {}
63        details['p_item'] = u''
64        details['amount'] = 0.0
65        details['error'] = u''
66        details['p_session'] = student['studycourse'].current_session
67        session = str(details['p_session'])
68        details['p_level'] = student['studycourse'].current_level
69        try:
70            academic_session = grok.getSite()['configuration'][session]
71        except KeyError:
72            details['error'] = _(u'Session configuration object is not available.')
73            return details
74        if category == 'transfer':
75            details['amount'] = academic_session.transfer_fee
76        elif category == 'gown':
77            details['amount'] = academic_session.gown_fee
78        elif category == 'bed_allocation':
79            details['amount'] = academic_session.booking_fee
80        elif category == 'hostel_maintenance':
81            details['amount'] = academic_session.maint_fee
82        elif category == 'clearance':
83            details['p_item'] = student['studycourse'].certificate.code
84            if details['p_item'] in ('BEDCET', 'BIOEDCET', 'CHMEDCET', 'ISEDCET',
85                'MTHEDCET', 'PHYEDCET', 'ITECET', 'AGREDCET', 'HEEDCET'):
86                details['amount'] = 17250.0
87            else:
88                details['amount'] = 34250.0
89        elif category == 'schoolfee':
90            details['amount'] = get_school_fee(student)
91            code = student['studycourse'].certificate.code
92            details['p_item'] = code
93            if student.state == RETURNING:
94                # In case of returning school fee payment the payment session
95                # and level contain the values of the session the student
96                # has paid for.
97                details['p_session'], details['p_level'] = self.getReturningData(student)
98        if details['amount'] in (0.0, None):
99            details['error'] = _(u'Amount could not be determined.')
100        return details
101
102    VERDICTS_DICT = {
103        '0': 'not yet',
104        'A': 'Successful student',
105        'B': 'Student with carryover courses',
106        'C': 'Student on probation',
107        'D': 'Withdrawn from the faculty',
108        'E': 'Student who were previously on probation',
109        'F': 'Medical case',
110        'G': 'Absent from examination',
111        'H': 'Withheld results',
112        'I': 'Expelled/rusticated/suspended student',
113        'J': 'Temporary withdrawn from the university',
114        'K': 'Unregistered student',
115        'L': 'Referred student',
116        'M': 'Reinstatement',
117        'N': 'Student on transfer',
118        'O': 'NCE-III repeater',
119        'Y': 'No previous verdict',
120        'X': 'New 300 level student',
121        'Z': 'Successful student (provisional)',
122        'A1': 'First Class',
123        'A2': 'Second Class Upper',
124        'A3': 'Second Class Lower',
125        'A4': 'Third Class',
126        'A5': 'Pass',
127        'A6': 'Distinction',
128        'A7': 'Credit',
129        'A8': 'Merit',
130        }
131
132    SEPARATORS_DICT = {
133        'form.fst_sit_fname': _(u'First Sitting Record'),
134        'form.scd_sit_fname': _(u'Second Sitting Record'),
135        'form.alr_fname': _(u'Advanced Level Record'),
136        'form.hq_type': _(u'Higher Education Record'),
137        'form.hq2_type': _(u'Second Higher Education Record'),
138        'form.nysc_year': _(u'NYSC Information'),
139        'form.employer': _(u'Employment History'),
140        'form.uniben_matric': _(u'Former Uniben Student'),
141        }
142
143    STUDENT_ID_PREFIX = u'B'
Note: See TracBrowser for help on using the repository browser.