1 | ## $Id: utils.py 7419 2011-12-21 07:59:29Z 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 | ## |
---|
18 | import grok |
---|
19 | from waeup.sirp.students.workflow import CLEARED, RETURNING |
---|
20 | from waeup.sirp.students.utils import StudentsUtils |
---|
21 | from waeup.sirp.students.interfaces import IStudentsUtils |
---|
22 | |
---|
23 | def get_school_fee(student, surcharge): |
---|
24 | study_mode = student['studycourse'].certificate.study_mode |
---|
25 | entry_mode = student['studycourse'].entry_mode |
---|
26 | state = student.state |
---|
27 | #lga = student.lga |
---|
28 | lga = 'nothing' |
---|
29 | current_level = student['studycourse'].current_level |
---|
30 | |
---|
31 | if study_mode.endswith('_ft'): |
---|
32 | # fresh |
---|
33 | if state == CLEARED: |
---|
34 | return 40000 - surcharge |
---|
35 | # returning |
---|
36 | elif state == RETURNING: |
---|
37 | return 20000 - surcharge |
---|
38 | else: |
---|
39 | return 0 |
---|
40 | else: |
---|
41 | return 0 |
---|
42 | |
---|
43 | class StudentsUtils(StudentsUtils): |
---|
44 | """A collection of customized methods. |
---|
45 | |
---|
46 | """ |
---|
47 | grok.implements(IStudentsUtils) |
---|
48 | |
---|
49 | def getPaymentDetails(self, category, student): |
---|
50 | d = {} |
---|
51 | d['surcharge_1'] = d['surcharge_2'] = d['surcharge_3'] = 0 |
---|
52 | d['p_item'] = u'' |
---|
53 | d['amount'] = 0 |
---|
54 | d['error'] = u'' |
---|
55 | d['p_session'] = student['studycourse'].current_session |
---|
56 | session = str(d['p_session']) |
---|
57 | try: |
---|
58 | academic_session = grok.getSite()['configuration'][session] |
---|
59 | except KeyError: |
---|
60 | d['error'] = u'Session configuration object is not available.' |
---|
61 | return d |
---|
62 | if category == 'transfer': |
---|
63 | d['amount'] = academic_session.transfer_fee |
---|
64 | elif category == 'gown': |
---|
65 | d['amount'] = academic_session.gown_fee |
---|
66 | elif category == 'bed_allocation': |
---|
67 | d['amount'] = academic_session.booking_fee |
---|
68 | elif category == 'hostel_maintenance': |
---|
69 | d['amount'] = academic_session.maint_fee |
---|
70 | elif category == 'clearance': |
---|
71 | d['p_item'] = student['studycourse'].certificate.code |
---|
72 | d['amount'] = academic_session.clearance_fee |
---|
73 | elif category == 'schoolfee': |
---|
74 | d['surcharge_1'] = academic_session.surcharge_1 |
---|
75 | d['surcharge_2'] = academic_session.surcharge_2 |
---|
76 | d['amount'] = get_school_fee(student, d['surcharge_1'] + d['surcharge_2']) |
---|
77 | code = student['studycourse'].certificate.code |
---|
78 | d['p_item'] = code |
---|
79 | d['p_session'] += 1 |
---|
80 | if d['amount'] == 0: |
---|
81 | d['error'] = u'Amount could not be determined.' |
---|
82 | return d |
---|