source: main/waeup.aaue/trunk/src/waeup/aaue/students/utils.py @ 8499

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

Take clearance_fee from session configuration object.

  • Property svn:keywords set to Id
File size: 5.9 KB
Line 
1## $Id: utils.py 8499 2012-05-23 09:16:37Z 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.interfaces import CLEARED, RETURNING, PAID
20from waeup.kofa.students.utils import StudentsUtils
21from waeup.kofa.students.interfaces import IStudentsUtils
22from waeup.kofa.accesscodes import create_accesscode
23from waeup.aaue.interfaces import MessageFactory as _
24
25def get_school_fee(student):
26    state = student.state
27    fee = None
28    if state == CLEARED:
29        fee = getattr(student['studycourse'].certificate,'school_fee_1')
30    elif state == RETURNING:
31        fee = getattr(student['studycourse'].certificate,'school_fee_2')
32    if fee is not None:
33        return fee
34    return 0.0
35
36class CustomStudentsUtils(StudentsUtils):
37    """A collection of customized methods.
38
39    """
40    grok.implements(IStudentsUtils)
41
42    def getReturningData(self, student):
43        """ This method defines what happens after school fee payment
44        of returning students depending on the student's senate verdict.
45        """
46        prev_level = student['studycourse'].current_level
47        cur_verdict = student['studycourse'].current_verdict
48        if cur_verdict in ('A','B','L','M','N','Z',):
49            # Successful student
50            new_level = divmod(int(prev_level),100)[0]*100 + 100
51        elif cur_verdict == 'C':
52            # Student on probation
53            new_level = int(prev_level) + 10
54        else:
55            # Student is somehow in an undefined state.
56            # Level has to be set manually.
57            new_level = prev_level
58        new_session = student['studycourse'].current_session + 1
59        return new_session, new_level
60
61    def getPaymentDetails(self, category, student):
62        details = {}
63        details['p_item'] = u''
64        details['amount'] = 0.0
65        details['error'] = u''
66        details['p_session'] = student['studycourse'].current_session
67        session = str(details['p_session'])
68        details['p_level'] = student['studycourse'].current_level
69        try:
70            academic_session = grok.getSite()['configuration'][session]
71        except KeyError:
72            details['error'] = _(u'Session configuration object is not available.')
73            return details
74        if category == 'transfer':
75            details['amount'] = academic_session.transfer_fee
76        elif category == 'gown':
77            details['amount'] = academic_session.gown_fee
78        elif category == 'bed_allocation':
79            details['amount'] = academic_session.booking_fee
80        elif category == 'hostel_maintenance':
81            details['amount'] = academic_session.maint_fee
82        elif category == 'clearance':
83            details['amount'] = academic_session.clearance_fee
84        elif category == 'schoolfee':
85            details['amount'] = get_school_fee(student)
86            code = student['studycourse'].certificate.code
87            details['p_item'] = code
88            if student.state == RETURNING:
89                # In case of returning school fee payment the payment session
90                # and level contain the values of the session the student
91                # has paid for.
92                details['p_session'], details['p_level'] = self.getReturningData(student)
93            elif student.current_mode.startswith('pg') and student.state == PAID:
94                # Returning postgraduate students also pay for the next session
95                # but their level always remains the same.
96                details['p_session'] += 1
97                details['amount'] = getattr(
98                    student['studycourse'].certificate,'school_fee_2')
99        if details['amount'] in (0.0, None):
100            details['error'] = _(u'Amount could not be determined.')
101        return details
102
103    VERDICTS_DICT = {
104        '0': 'not yet',
105        'A': 'Successful student',
106        'B': 'Student with carryover courses',
107        'C': 'Student on probation',
108        'D': 'Withdrawn from the faculty',
109        'E': 'Student who were previously on probation',
110        'F': 'Medical case',
111        'G': 'Absent from examination',
112        'H': 'Withheld results',
113        'I': 'Expelled/rusticated/suspended student',
114        'J': 'Temporary withdrawn from the university',
115        'K': 'Unregistered student',
116        'L': 'Referred student',
117        'M': 'Reinstatement',
118        'N': 'Student on transfer',
119        'O': 'NCE-III repeater',
120        'Y': 'No previous verdict',
121        'X': 'New 300 level student',
122        'Z': 'Successful student (provisional)',
123        'A1': 'First Class',
124        'A2': 'Second Class Upper',
125        'A3': 'Second Class Lower',
126        'A4': 'Third Class',
127        'A5': 'Pass',
128        'A6': 'Distinction',
129        'A7': 'Credit',
130        'A8': 'Merit',
131        }
132
133    # AAUE separators
134    SEPARATORS_DICT = {
135        'form.fst_sit_fname': _(u'First Sitting Record'),
136        'form.scd_sit_fname': _(u'Second Sitting Record'),
137        'form.alr_fname': _(u'Advanced Level Record'),
138        'form.hq_type': _(u'Higher Education Record'),
139        'form.hq2_type': _(u'Second Higher Education Record'),
140        'form.nysc_year': _(u'NYSC Information'),
141        'form.employer': _(u'Employment History'),
142        'form.former_matric': _(u'Former AAUE Student'),
143        }
144
145    # AAUE prefix
146    STUDENT_ID_PREFIX = u'E'
Note: See TracBrowser for help on using the repository browser.