import grok from waeup.sirp.students.vocabularies import academic_sessions_vocab from waeup.sirp.students.workflow import CLEARED, RETURNING from waeup.sirp.students.utils import StudentsUtils from waeup.sirp.students.interfaces import IStudentsUtils def get_school_fee(student, surcharge): study_mode = student['studycourse'].certificate.study_mode entry_mode = student['studycourse'].entry_mode state = student.state #lga = student.lga lga = 'nothing' current_level = student['studycourse'].current_level if study_mode.endswith('_ft'): # fresh if state == CLEARED: return 40000 - surcharge # returning elif state == RETURNING: return 20000 - surcharge else: return 0 else: return 0 class StudentsUtils(StudentsUtils): """A collection of customized methods. """ grok.implements(IStudentsUtils) def get_payment_details(self, category, student): d = {} d['surcharge_1'] = d['surcharge_2'] = d['surcharge_3'] = 0 d['p_item'] = u'' d['amount'] = 0 d['error'] = u'' d['p_session'] = student['studycourse'].current_session session = str(d['p_session']) try: academic_session = grok.getSite()['configuration'][session] except KeyError: d['error'] = u'Session configuration object is not available.' return d if category == 'transfer': d['amount'] = academic_session.transfer_fee elif category == 'gown': d['amount'] = academic_session.gown_fee elif category == 'bed_allocation': d['amount'] = academic_session.booking_fee elif category == 'hostel_maintenance': d['amount'] = academic_session.maint_fee elif category == 'clearance': d['p_item'] = student['studycourse'].certificate.code d['amount'] = academic_session.clearance_fee elif category == 'schoolfee': d['surcharge_1'] = academic_session.surcharge_1 d['surcharge_2'] = academic_session.surcharge_2 d['amount'] = get_school_fee(student, d['surcharge_1'] + d['surcharge_2']) code = student['studycourse'].certificate.code #session_string = academic_sessions_vocab.by_value[p_session + 1].title d['p_item'] = code d['p_session'] += 1 if d['amount'] == 0: d['error'] = u'Amount could not be determined.' return d