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

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

Reorganize payment customizatiom. Tests will follow.

Let also applicants pay via eTranzact. Show transaction code on display view (slip view will follow).

  • Property svn:keywords set to Id
File size: 6.0 KB
Line 
1## $Id: utils.py 8247 2012-04-22 12:56:07Z 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, surcharge):
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 - surcharge
37        # returning
38        elif state == RETURNING:
39            return 20000.0 - surcharge
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 setReturningData(self, student):
81        student['studycourse'].current_level += 100
82        student['studycourse'].current_session += 1
83        verdict = student['studycourse'].current_verdict
84        student['studycourse'].current_verdict = '0'
85        student['studycourse'].previous_verdict = verdict
86        return
87
88    def getPaymentDetails(self, category, student):
89        d = {}
90        d['surcharge_1'] = d['surcharge_2'] = d['surcharge_3'] = 0.0
91        d['p_item'] = u''
92        d['amount'] = 0.0
93        d['error'] = u''
94        d['p_session'] = student['studycourse'].current_session
95        session = str(d['p_session'])
96        try:
97            academic_session = grok.getSite()['configuration'][session]
98        except KeyError:
99            d['error'] = _(u'Session configuration object is not available.')
100            return d
101        if category == 'transfer':
102            d['amount'] = academic_session.transfer_fee
103        elif category == 'gown':
104            d['amount'] = academic_session.gown_fee
105        elif category == 'bed_allocation':
106            d['amount'] = academic_session.booking_fee
107        elif category == 'hostel_maintenance':
108            d['amount'] = academic_session.maint_fee
109        elif category == 'clearance':
110            d['p_item'] = student['studycourse'].certificate.code
111            d['amount'] = academic_session.clearance_fee
112        elif category == 'schoolfee':
113            d['surcharge_1'] = academic_session.surcharge_1
114            d['surcharge_2'] = academic_session.surcharge_2
115            d['amount'] = get_school_fee(student, d['surcharge_1'] + d['surcharge_2'])
116            code = student['studycourse'].certificate.code
117            d['p_item'] = code
118            d['p_session'] += 1
119        if d['amount'] == 0.0:
120            d['error'] = _(u'Amount could not be determined.')
121        return d
122
123    VERDICTS_DICT = {
124        '0': 'not yet',
125        'A': 'Successful student',
126        'B': 'Student with carryover courses',
127        'C': 'Student on probation',
128        'D': 'Withdrawn from the faculty',
129        'E': 'Student who were previously on probation',
130        'F': 'Medical case',
131        'G': 'Absent from examination',
132        'H': 'Withheld results',
133        'I': 'Expelled/rusticated/suspended student',
134        'J': 'Temporary withdrawn from the university',
135        'K': 'Unregistered student',
136        'L': 'Referred student',
137        'M': 'Reinstatement',
138        'N': 'Student on transfer',
139        'O': 'NCE-III repeater',
140        'Y': 'No previous verdict',
141        'X': 'New 300 level student',
142        'Z': 'Successful student (provisional)',
143        'A1': 'First Class',
144        'A2': 'Second Class Upper',
145        'A3': 'Second Class Lower',
146        'A4': 'Third Class',
147        'A5': 'Pass',
148        'A6': 'Distinction',
149        'A7': 'Credit',
150        'A8': 'Merit',
151        }
152
153    SEPARATORS_DICT = {
154        'form.fst_sit_fname': _(u'First Sitting Recod'),
155        'form.scd_sit_fname': _(u'Second Sitting Record'),
156        'form.alr_fname': _(u'Advanced Level Record'),
157        'form.hq_type': _(u'Higher Education Record'),
158        'form.hq2_type': _(u'Second Higher Education Record'),
159        'form.nysc_year': _(u'NYSC Information'),
160        'form.employer': _(u'Employment History'),
161        'form.uniben_matric': _(u'Former Uniben Student'),
162        }
Note: See TracBrowser for help on using the repository browser.