source: main/waeup.custom/trunk/src/waeup/custom/students/utils.py @ 7926

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

Add InterswitchPage? which generates POST requests for the Interswitch CollegePAY gateway (moved from trunk).

  • Property svn:keywords set to Id
File size: 4.5 KB
Line 
1## $Id: utils.py 7879 2012-03-14 09:41:09Z 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.custom.interfaces import MessageFactory as _
23
24def get_school_fee(student, surcharge):
25    study_mode = student['studycourse'].certificate.study_mode
26    entry_mode = student['studycourse'].entry_mode
27    state = student.state
28    #lga = student.lga
29    lga = 'nothing'
30    current_level = student['studycourse'].current_level
31
32    if study_mode.endswith('_ft'):
33        # fresh
34        if state == CLEARED:
35            return 40000 - surcharge
36        # returning
37        elif state == RETURNING:
38            return 20000 - surcharge
39        else:
40            return 0
41    else:
42        return 0
43
44class StudentsUtils(StudentsUtils):
45    """A collection of customized methods.
46
47    """
48    grok.implements(IStudentsUtils)
49
50    # not yet changed
51    def setReturningData(self, student):
52        student['studycourse'].current_level += 100
53        student['studycourse'].current_session += 1
54        verdict = student['studycourse'].current_verdict
55        student['studycourse'].current_verdict = '0'
56        student['studycourse'].previous_verdict = verdict
57        return
58
59    def getPaymentDetails(self, category, student):
60        d = {}
61        d['surcharge_1'] = d['surcharge_2'] = d['surcharge_3'] = 0
62        d['p_item'] = u''
63        d['amount'] = 0
64        d['error'] = u''
65        d['p_session'] = student['studycourse'].current_session
66        session = str(d['p_session'])
67        try:
68            academic_session = grok.getSite()['configuration'][session]
69        except KeyError:
70            d['error'] = _(u'Session configuration object is not available.')
71            return d
72        if category == 'transfer':
73            d['amount'] = academic_session.transfer_fee
74        elif category == 'gown':
75            d['amount'] = academic_session.gown_fee
76        elif category == 'bed_allocation':
77            d['amount'] = academic_session.booking_fee
78        elif category == 'hostel_maintenance':
79            d['amount'] = academic_session.maint_fee
80        elif category == 'clearance':
81            d['p_item'] = student['studycourse'].certificate.code
82            d['amount'] = academic_session.clearance_fee
83        elif category == 'schoolfee':
84            d['surcharge_1'] = academic_session.surcharge_1
85            d['surcharge_2'] = academic_session.surcharge_2
86            d['amount'] = get_school_fee(student, d['surcharge_1'] + d['surcharge_2'])
87            code = student['studycourse'].certificate.code
88            d['p_item'] = code
89            d['p_session'] += 1
90        if d['amount'] == 0:
91            d['error'] = _(u'Amount could not be determined.')
92        return d
93
94    VERDICTS_DICT = {
95        '0': 'not yet',
96        'A': 'Successful student',
97        'B': 'Student with carryover courses',
98        'C': 'Student on probation',
99        'D': 'Withdrawn from the faculty',
100        'E': 'Student who were previously on probation',
101        'F': 'Medical case',
102        'G': 'Absent from examination',
103        'H': 'Withheld results',
104        'I': 'Expelled/rusticated/suspended student',
105        'J': 'Temporary withdrawn from the university',
106        'K': 'Unregistered student',
107        'L': 'Referred student',
108        'M': 'Reinstatement',
109        'N': 'Student on transfer',
110        'O': 'NCE-III repeater',
111        'Y': 'No previous verdict',
112        'X': 'New 300 level student',
113        'Z': 'Successful student (provisional)',
114        'A1': 'First Class',
115        'A2': 'Second Class Upper',
116        'A3': 'Second Class Lower',
117        'A4': 'Third Class',
118        'A5': 'Pass',
119        'A6': 'Distinction',
120        'A7': 'Credit',
121        'A8': 'Merit',
122        }
Note: See TracBrowser for help on using the repository browser.