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