1 | import grok |
---|
2 | from waeup.sirp.students.vocabularies import academic_sessions_vocab |
---|
3 | from waeup.sirp.students.workflow import CLEARED, RETURNING |
---|
4 | from waeup.sirp.students.utils import StudentsUtils |
---|
5 | from waeup.sirp.students.interfaces import IStudentsUtils |
---|
6 | |
---|
7 | def get_school_fee(student, surcharge): |
---|
8 | study_mode = student['studycourse'].certificate.study_mode |
---|
9 | entry_mode = student['studycourse'].entry_mode |
---|
10 | state = student.state |
---|
11 | #lga = student.lga |
---|
12 | lga = 'nothing' |
---|
13 | current_level = student['studycourse'].current_level |
---|
14 | |
---|
15 | if study_mode.endswith('_ft'): |
---|
16 | # fresh |
---|
17 | if state == CLEARED: |
---|
18 | return 40000 - surcharge |
---|
19 | # returning |
---|
20 | elif state == RETURNING: |
---|
21 | return 20000 - surcharge |
---|
22 | else: |
---|
23 | return 0 |
---|
24 | else: |
---|
25 | return 0 |
---|
26 | |
---|
27 | class StudentsUtils(StudentsUtils): |
---|
28 | """A collection of customized methods. |
---|
29 | |
---|
30 | """ |
---|
31 | grok.implements(IStudentsUtils) |
---|
32 | |
---|
33 | def get_payment_details(self, category, student): |
---|
34 | d = {} |
---|
35 | d['surcharge_1'] = d['surcharge_2'] = d['surcharge_3'] = 0 |
---|
36 | d['p_item'] = u'' |
---|
37 | d['amount'] = 0 |
---|
38 | d['error'] = u'' |
---|
39 | d['p_session'] = student['studycourse'].current_session |
---|
40 | session = str(d['p_session']) |
---|
41 | try: |
---|
42 | academic_session = grok.getSite()['configuration'][session] |
---|
43 | except KeyError: |
---|
44 | d['error'] = u'Session configuration object is not available.' |
---|
45 | return d |
---|
46 | if category == 'transfer': |
---|
47 | d['amount'] = academic_session.transfer_fee |
---|
48 | elif category == 'gown': |
---|
49 | d['amount'] = academic_session.gown_fee |
---|
50 | elif category == 'bed_allocation': |
---|
51 | d['amount'] = academic_session.booking_fee |
---|
52 | elif category == 'hostel_maintenance': |
---|
53 | d['amount'] = academic_session.maint_fee |
---|
54 | elif category == 'clearance': |
---|
55 | d['p_item'] = student['studycourse'].certificate.code |
---|
56 | d['amount'] = academic_session.clearance_fee |
---|
57 | elif category == 'schoolfee': |
---|
58 | d['surcharge_1'] = academic_session.surcharge_1 |
---|
59 | d['surcharge_2'] = academic_session.surcharge_2 |
---|
60 | d['amount'] = get_school_fee(student, d['surcharge_1'] + d['surcharge_2']) |
---|
61 | code = student['studycourse'].certificate.code |
---|
62 | #session_string = academic_sessions_vocab.by_value[p_session + 1].title |
---|
63 | d['p_item'] = code |
---|
64 | d['p_session'] += 1 |
---|
65 | if d['amount'] == 0: |
---|
66 | d['error'] = u'Amount could not be determined.' |
---|
67 | return d |
---|