source: main/waeup.fceokene/trunk/src/waeup/fceokene/students/utils.py @ 9147

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

Configure school fees. In FCEOkene we can't setup school fees in certificates.

  • Property svn:keywords set to Id
File size: 8.8 KB
Line 
1## $Id: utils.py 9143 2012-09-01 15:16:10Z 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 time import time
20from zope.component import createObject
21from waeup.kofa.interfaces import CLEARED, RETURNING, PAID
22from kofacustom.nigeria.students.utils import NigeriaStudentsUtils
23from waeup.kofa.accesscodes import create_accesscode
24from waeup.kofa.interfaces import CLEARED, RETURNING
25from waeup.fceokene.interfaces import MessageFactory as _
26
27class CustomStudentsUtils(NigeriaStudentsUtils):
28    """A collection of customized methods.
29
30    """
31
32    def getReturningData(self, student):
33        """ This method defines what happens after school fee payment
34        of returning students depending on the student's senate verdict.
35        """
36        prev_level = student['studycourse'].current_level
37        cur_verdict = student['studycourse'].current_verdict
38        if cur_verdict in ('A','B','L','M','N','Z',):
39            # Successful student
40            new_level = divmod(int(prev_level),100)[0]*100 + 100
41        elif cur_verdict == 'C':
42            # Student on probation
43            new_level = int(prev_level) + 10
44        else:
45            # Student is somehow in an undefined state.
46            # Level has to be set manually.
47            new_level = prev_level
48        new_session = student['studycourse'].current_session + 1
49        return new_session, new_level
50
51    def setPaymentDetails(self, category, student):
52        """Create Payment object and set the payment data of a student for
53        the payment category specified.
54
55        """
56        details = {}
57        p_item = u''
58        amount = 0.0
59        error = u''
60        p_session = student['studycourse'].current_session
61        p_level = student['studycourse'].current_level
62        session = str(p_session)
63        try:
64            academic_session = grok.getSite()['configuration'][session]
65        except KeyError:
66            return _(u'Session configuration object is not available.'), None
67        if category == 'transfer':
68            amount = academic_session.transfer_fee
69        elif category == 'gown':
70            amount = academic_session.gown_fee
71        elif category == 'bed_allocation':
72            amount = academic_session.booking_fee
73        elif category == 'hostel_maintenance':
74            amount = academic_session.maint_fee
75        elif category == 'clearance':
76            amount = academic_session.clearance_fee
77            try:
78                p_item = student['studycourse'].certificate.code
79            except (AttributeError, TypeError):
80                return _('Study course data are incomplete.'), None
81        elif category == 'schoolfee':
82            try:
83                certificate = student['studycourse'].certificate
84                p_item = certificate.code
85            except (AttributeError, TypeError):
86                return _('Study course data are incomplete.'), None
87
88            # Very special school fee configuration, should be moved to
89            # a seperate file.
90
91            ARTS = ('CRS','ISS','HIS','MUS','ECO','GEO','POL','SOS','CCA','ECU',
92                    'THA','GED','GSE','PES','SPC','ENG','FRE','ARB','HAU','IGB',
93                    'YOR','NCRS','NISS','NHIS','NMUS','NECO','NGEO','NPOL',
94                    'NCCA','NECU','NTHA','NGED','NGSE','NPES','NSPC','NENG',
95                    'NFRE','NARB','NHAU','NIGB','NYOR','NSOS')
96
97            #PDE Students
98            if student.current_mode == 'pd_ft':
99                amount = 35000
100            elif not student.current_mode.endswith('_sw'):
101                # PRENCE
102                if student.current_level == 10 and student.state == CLEARED:
103                    if student.depcode in ARTS:
104                        amount = 14900
105                    else:
106                        amount = 15400
107                # NCE I fresh
108                elif student.current_level == 100 and student.state == CLEARED:
109                    if student.depcode in ARTS:
110                        amount = 12020
111                    else:
112                        amount = 12495
113                # NCE II
114                elif student.current_level in (100, 110, 120) and \
115                    student.state == RETURNING:
116                    if student.depcode in ARTS:
117                        amount = 11070
118                    else:
119                        amount = 11545
120                # NCE III
121                elif student.current_level in (200, 210, 220):
122                    if student.depcode in ARTS:
123                        amount = 11070
124                    else:
125                        amount = 11545
126                # NCE III repeater
127                elif student.current_level in (300, 310, 320) and \
128                    student.current_verdict == 'O':
129                    if student.depcode in ARTS:
130                        amount = 6535
131                    else:
132                        amount = 6773
133                # NCE III spillover
134                elif student.current_level in (300, 310, 320) and \
135                    student.current_verdict == 'B':
136                    if student.depcode in ARTS:
137                        amount = 9170
138                    else:
139                        amount = 9645
140                # NCE III second spillover
141                elif student.current_level in (400, 410, 420) and \
142                    student.current_verdict == 'B':
143                    if student.depcode in ARTS:
144                        amount = 9170
145                    else:
146                        amount = 9645
147            else:
148                if student.current_level == 100 and student.state == CLEARED:
149                    if student.depcode in ARTS:
150                        amount = 21900
151                    else:
152                        amount = 22400
153                # NCE II
154                elif student.current_level in (100, 110, 120) and \
155                    student.state == RETURNING:
156                    if student.depcode in ARTS:
157                        amount = 18400
158                    else:
159                        amount = 18900
160                # NCE III
161                elif student.current_level in (200, 210, 220):
162                    if student.depcode in ARTS:
163                        amount = 20400
164                    else:
165                        amount = 20900
166                # NCE IV
167                elif student.current_level in (300, 310, 320):
168                    if student.depcode in ARTS:
169                        amount = 18400
170                    else:
171                        amount = 18900
172                # NCE V
173                elif student.current_level in (400, 410, 420):
174                    if student.depcode in ARTS:
175                        amount = 18400
176                    else:
177                        amount = 18900
178                # NCE V spillover
179                elif student.current_level in (500, 510, 520) and \
180                    student.current_verdict == 'B':
181                    if student.depcode in ARTS:
182                        amount = 16900
183                    else:
184                        amount = 17400
185                # NCE V second spillover
186                elif student.current_level in (600, 610, 620) and \
187                    student.current_verdict == 'B':
188                    if student.depcode in ARTS:
189                        amount = 16900
190                    else:
191                        amount = 17400
192
193        if amount in (0.0, None):
194            return _(u'Amount could not be determined.'), None
195        for key in student['payments'].keys():
196            ticket = student['payments'][key]
197            if ticket.p_state == 'paid' and\
198               ticket.p_category == category and \
199               ticket.p_item == p_item and \
200               ticket.p_session == p_session:
201                  return _('This type of payment has already been made.'), None
202        payment = createObject(u'waeup.StudentOnlinePayment')
203        timestamp = ("%d" % int(time()*10000))[1:]
204        payment.p_id = "p%s" % timestamp
205        payment.p_category = category
206        payment.p_item = p_item
207        payment.p_session = p_session
208        payment.p_level = p_level
209        payment.amount_auth = float(amount)
210        return None, payment
211
212    # FCEOkene prefix
213    STUDENT_ID_PREFIX = u'K'
Note: See TracBrowser for help on using the repository browser.