[7419] | 1 | ## $Id: utils.py 7928 2012-03-20 14:37:35Z 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 | ## |
---|
[7151] | 18 | import grok |
---|
[7822] | 19 | from waeup.kofa.students.workflow import CLEARED, RETURNING |
---|
| 20 | from waeup.kofa.students.utils import StudentsUtils |
---|
| 21 | from waeup.kofa.students.interfaces import IStudentsUtils |
---|
[7879] | 22 | from waeup.custom.interfaces import MessageFactory as _ |
---|
[6902] | 23 | |
---|
[7152] | 24 | def 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: |
---|
[7928] | 35 | return 40000.0 - surcharge |
---|
[7152] | 36 | # returning |
---|
| 37 | elif state == RETURNING: |
---|
[7928] | 38 | return 20000.0 - surcharge |
---|
[7152] | 39 | else: |
---|
[7928] | 40 | return 0.0 |
---|
[7152] | 41 | else: |
---|
[7928] | 42 | return 0.0 |
---|
[7152] | 43 | |
---|
[7151] | 44 | class StudentsUtils(StudentsUtils): |
---|
| 45 | """A collection of customized methods. |
---|
| 46 | |
---|
| 47 | """ |
---|
| 48 | grok.implements(IStudentsUtils) |
---|
| 49 | |
---|
[7621] | 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 | |
---|
[7419] | 59 | def getPaymentDetails(self, category, student): |
---|
[7151] | 60 | d = {} |
---|
[7928] | 61 | d['surcharge_1'] = d['surcharge_2'] = d['surcharge_3'] = 0.0 |
---|
[7151] | 62 | d['p_item'] = u'' |
---|
[7928] | 63 | d['amount'] = 0.0 |
---|
[7151] | 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: |
---|
[7879] | 70 | d['error'] = _(u'Session configuration object is not available.') |
---|
[7151] | 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 |
---|
[7152] | 86 | d['amount'] = get_school_fee(student, d['surcharge_1'] + d['surcharge_2']) |
---|
[7151] | 87 | code = student['studycourse'].certificate.code |
---|
| 88 | d['p_item'] = code |
---|
| 89 | d['p_session'] += 1 |
---|
[7928] | 90 | if d['amount'] == 0.0: |
---|
[7879] | 91 | d['error'] = _(u'Amount could not be determined.') |
---|
[7021] | 92 | return d |
---|
[7621] | 93 | |
---|
[7845] | 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 | } |
---|