Changeset 9244
- Timestamp:
- 27 Sep 2012, 10:19:14 (12 years ago)
- Location:
- main/waeup.futminna/trunk/src/waeup/futminna/students
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.futminna/trunk/src/waeup/futminna/students/tests/test_browser.py
r9155 r9244 79 79 self.assertEqual(utils.getReturningData(self.student),(2005, 100)) 80 80 return 81 82 def test_set_payment_details(self): 83 self.app['configuration']['2004'].gown_fee = 150.0 84 self.app['configuration']['2004'].transfer_fee = 90.0 85 self.app['configuration']['2004'].booking_fee = 150.0 86 self.app['configuration']['2004'].maint_fee = 180.0 87 self.app['configuration']['2004'].clearance_fee = 120.0 88 utils = getUtility(IStudentsUtils) 89 90 error, payment = utils.setPaymentDetails('schoolfee',self.student) 91 self.assertEqual(payment, None) 92 self.assertEqual(error, u'Amount could not be determined.') 93 94 self.student.nationality = u'NG' 95 96 IWorkflowState(self.student).setState('cleared') 97 error, payment = utils.setPaymentDetails('schoolfee',self.student) 98 self.assertEqual(payment.p_level, 100) 99 self.assertEqual(payment.p_session, 2004) 100 self.assertEqual(payment.amount_auth, 37000.0) 101 self.assertEqual(payment.p_item, u'CERT1') 102 self.assertEqual(error, None) 103 104 self.certificate.study_mode = 'jm_ft' 105 error, payment = utils.setPaymentDetails('schoolfee',self.student) 106 self.assertEqual(payment.amount_auth, 72700.0) 107 108 IWorkflowState(self.student).setState('returning') 109 error, payment = utils.setPaymentDetails('schoolfee',self.student) 110 self.assertEqual(payment.p_level, 100) 111 self.assertEqual(payment.p_session, 2004) 112 self.assertEqual(payment.amount_auth, 37000.0) 113 self.assertEqual(payment.p_item, u'CERT1') 114 self.assertEqual(error, None) 115 116 self.certificate.study_mode = 'ug_ft' 117 error, payment = utils.setPaymentDetails('schoolfee',self.student) 118 self.assertEqual(payment.amount_auth, 20000.0) 119 120 121 error, payment = utils.setPaymentDetails('clearance',self.student) 122 self.assertEqual(payment.p_level, 100) 123 self.assertEqual(payment.p_session, 2004) 124 self.assertEqual(payment.amount_auth, 20000.0) 125 self.assertEqual(payment.p_item, u'CERT1') 126 self.assertEqual(error, None) 127 128 error, payment = utils.setPaymentDetails('schoolfee',self.student, 2004, 100) 129 self.assertEqual(error, u'Previous session payment not yet implemented.') 130 return -
main/waeup.futminna/trunk/src/waeup/futminna/students/utils.py
r9155 r9244 54 54 55 55 """ 56 return _(u'Payment components not yet configured.'), None 56 p_item = u'' 57 amount = 0.0 58 if previous_session: 59 return _('Previous session payment not yet implemented.'), None 60 p_session = student['studycourse'].current_session 61 p_level = student['studycourse'].current_level 62 p_current = True 63 session = str(p_session) 64 try: 65 academic_session = grok.getSite()['configuration'][session] 66 except KeyError: 67 return _(u'Session configuration object is not available.'), None 68 if category == 'schoolfee': 69 try: 70 certificate = student['studycourse'].certificate 71 p_item = certificate.code 72 except (AttributeError, TypeError): 73 return _('Study course data are incomplete.'), None 74 if student.current_mode.endswith('_ft'): 75 # fresh remedial 76 if student.current_level == 10 and student.state == CLEARED: 77 if student['studycourse'].entry_mode == 'rmd_ft': 78 amount = 80200.0 79 else: 80 amount = 74200.0 81 82 # fresh 83 elif student.state == CLEARED: 84 if student.current_mode == 'jm_ft': 85 amount = 72700.0 86 elif student.is_foreigner: 87 amount = 131500.0 88 else: 89 amount = 37000.0 # School Fee reduced by 8000 90 # returning 91 elif student.state == RETURNING: 92 if student.current_mode == 'jm_ft': 93 amount = 37000.0 94 elif student.is_foreigner: 95 amount = 109500.0 96 else: 97 amount = 20000.0 98 else: 99 amount = 0.0 100 elif category == 'clearance': 101 try: 102 p_item = student['studycourse'].certificate.code 103 except (AttributeError, TypeError): 104 return _('Study course data are incomplete.'), None 105 if student.faccode in ['EET','ICT'] or student.depcode in ['ARC']: 106 amount = 25000.0 107 else: 108 amount = 20000.0 109 elif category == 'bed_allocation': 110 p_item = self.getAccommodationDetails(student)['bt'] 111 amount = academic_session.booking_fee 112 if amount in (0.0, None): 113 return _('Amount could not be determined.'), None 114 for key in student['payments'].keys(): 115 ticket = student['payments'][key] 116 if ticket.p_state == 'paid' and\ 117 ticket.p_category == category and \ 118 ticket.p_item == p_item and \ 119 ticket.p_session == p_session: 120 return _('This type of payment has already been made.'), None 121 payment = createObject(u'waeup.StudentOnlinePayment') 122 timestamp = ("%d" % int(time()*10000))[1:] 123 payment.p_id = "p%s" % timestamp 124 payment.p_category = category 125 payment.p_item = p_item 126 payment.p_session = p_session 127 payment.p_level = p_level 128 payment.p_current = p_current 129 payment.amount_auth = amount 130 return None, payment 57 131 58 132
Note: See TracChangeset for help on using the changeset viewer.