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

Last change on this file since 8294 was 8294, checked in by Henrik Bettermann, 12 years ago

Dynamize acceptance fee (clearance fee) payment.

  • Property svn:keywords set to Id
File size: 6.3 KB
Line 
1## $Id: utils.py 8294 2012-04-27 06:32:43Z 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.students.workflow 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    study_mode = student['studycourse'].certificate.study_mode
27    entry_mode = student['studycourse'].entry_mode
28    state = student.state
29    #lga = student.lga
30    lga = 'nothing'
31    current_level = student['studycourse'].current_level
32
33    if study_mode.endswith('_ft'):
34        # fresh
35        if state == CLEARED:
36            return 40000.0
37        # returning
38        elif state == RETURNING:
39            return 20000.0
40        else:
41            return 0.0
42    else:
43        return 0.0
44
45def actions_after_student_payment(student, payment, view):
46    if payment.p_category == 'clearance':
47        # Create CLR access code
48        pin, error = create_accesscode('CLR',0,student.student_id)
49        if error:
50            view.flash(_('Valid callback received. ${a}',
51                mapping = {'a':error}))
52            return
53        payment.ac = pin
54    elif payment.p_category == 'schoolfee':
55        # Create SFE access code
56        pin, error = create_accesscode('SFE',0,student.student_id)
57        if error:
58            view.flash(_('Valid callback received. ${a}',
59                mapping = {'a':error}))
60            return
61        payment.ac = pin
62    elif payment.p_category == 'bed_allocation':
63        # Create HOS access code
64        pin, error = create_accesscode('HOS',0,student.student_id)
65        if error:
66            view.flash(_('Valid callback received. ${a}',
67                mapping = {'a':error}))
68            return
69        payment.ac = pin
70    view.flash(_('Valid callback received.'))
71    return
72
73class CustomStudentsUtils(StudentsUtils):
74    """A collection of customized methods.
75
76    """
77    grok.implements(IStudentsUtils)
78
79    # not yet changed
80    def getReturningData(self, student):
81        """ This method defines what happens after school fee payment
82        depending on the student's senate verdict.
83
84        In the base configuration current level is always increased
85        by 100 no matter which verdict has been assigned.
86        """
87        new_level = student['studycourse'].current_level + 100
88        new_session = student['studycourse'].current_session + 1
89        return new_session, new_level
90
91    def getPaymentDetails(self, category, student):
92        d = {}
93        d['p_item'] = u''
94        d['amount'] = 0.0
95        d['error'] = u''
96        d['p_session'] = student['studycourse'].current_session
97        session = str(d['p_session'])
98        d['p_level'] = student['studycourse'].current_level
99        try:
100            academic_session = grok.getSite()['configuration'][session]
101        except KeyError:
102            d['error'] = _(u'Session configuration object is not available.')
103            return d
104        if category == 'transfer':
105            d['amount'] = academic_session.transfer_fee
106        elif category == 'gown':
107            d['amount'] = academic_session.gown_fee
108        elif category == 'bed_allocation':
109            d['amount'] = academic_session.booking_fee
110        elif category == 'hostel_maintenance':
111            d['amount'] = academic_session.maint_fee
112        elif category == 'clearance':
113            d['p_item'] = student['studycourse'].certificate.code
114            if d['p_item'] in ('BEDCET', 'BIOEDCET', 'CHMEDCET', 'ISEDCET',
115                'MTHEDCET', 'PHYEDCET', 'ITECET', 'AGREDCET', 'HEEDCET'):
116                d['amount'] = 17250.0
117            else:
118                d['amount'] = 34250.0
119        elif category == 'schoolfee':
120            d['amount'] = get_school_fee(student)
121            code = student['studycourse'].certificate.code
122            d['p_item'] = code
123            # In case of school fee payment the payment session and level
124            # contain the values of the session the student has paid for
125            d['p_session'], d['p_level'] = self.getReturningData(student)
126        if d['amount'] == 0.0:
127            d['error'] = _(u'Amount could not be determined.')
128        return d
129
130    VERDICTS_DICT = {
131        '0': 'not yet',
132        'A': 'Successful student',
133        'B': 'Student with carryover courses',
134        'C': 'Student on probation',
135        'D': 'Withdrawn from the faculty',
136        'E': 'Student who were previously on probation',
137        'F': 'Medical case',
138        'G': 'Absent from examination',
139        'H': 'Withheld results',
140        'I': 'Expelled/rusticated/suspended student',
141        'J': 'Temporary withdrawn from the university',
142        'K': 'Unregistered student',
143        'L': 'Referred student',
144        'M': 'Reinstatement',
145        'N': 'Student on transfer',
146        'O': 'NCE-III repeater',
147        'Y': 'No previous verdict',
148        'X': 'New 300 level student',
149        'Z': 'Successful student (provisional)',
150        'A1': 'First Class',
151        'A2': 'Second Class Upper',
152        'A3': 'Second Class Lower',
153        'A4': 'Third Class',
154        'A5': 'Pass',
155        'A6': 'Distinction',
156        'A7': 'Credit',
157        'A8': 'Merit',
158        }
159
160    SEPARATORS_DICT = {
161        'form.fst_sit_fname': _(u'First Sitting Record'),
162        'form.scd_sit_fname': _(u'Second Sitting Record'),
163        'form.alr_fname': _(u'Advanced Level Record'),
164        'form.hq_type': _(u'Higher Education Record'),
165        'form.hq2_type': _(u'Second Higher Education Record'),
166        'form.nysc_year': _(u'NYSC Information'),
167        'form.employer': _(u'Employment History'),
168        'form.uniben_matric': _(u'Former Uniben Student'),
169        }
Note: See TracBrowser for help on using the repository browser.