- Timestamp:
- 14 Dec 2016, 16:57:13 (8 years ago)
- Location:
- main/kofacustom.coewarri/trunk/src/kofacustom/coewarri/students
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
main/kofacustom.coewarri/trunk/src/kofacustom/coewarri/students/payments.py
r14340 r14344 21 21 import grok 22 22 from zope.component.interfaces import IFactory 23 from zope.schema.interfaces import ConstraintNotSatisfied 23 24 from zope.interface import implementedBy 25 from hurry.workflow.interfaces import IWorkflowInfo 24 26 from waeup.kofa.students.interfaces import IStudentNavigation 27 from waeup.kofa.students.workflow import CLEARED, RETURNING, PAID 25 28 from waeup.kofa.utils.helpers import attrs_to_fields 26 29 from kofacustom.nigeria.students.payments import ( … … 59 62 return error 60 63 self.ac = pin 61 elif self.p_category .startswith('schoolfee'):64 elif self.p_category in ('schoolfee', 'schoolfee_1') : 62 65 # Bypass activation code creation if next session 63 66 # can be started directly. -
main/kofacustom.coewarri/trunk/src/kofacustom/coewarri/students/tests/test_browser.py
r14035 r14344 42 42 layer = FunctionalLayer 43 43 44 def test_dummytest(self): 44 def test_for_instalment_payments(self): 45 46 #configuration_1 = createObject('waeup.SessionConfiguration') 47 #configuration_1.academic_session = 2015 48 #self.app['configuration'].addSessionConfiguration(configuration_1) 49 self.student['studycourse'].certificate.study_mode = 'ug_ft' 50 self.student.nationality = u'NG' 51 # Fresh student 52 IWorkflowState(self.student).setState('cleared') 53 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') 54 self.browser.open(self.payments_path + '/addop') 55 self.browser.open(self.payments_path + '/addop') 56 # Add first instalment 57 self.browser.getControl(name="form.p_category").value = ['schoolfee_1'] 58 self.browser.getControl("Create ticket").click() 59 self.assertTrue('ticket created' in self.browser.contents) 60 self.browser.open(self.payments_path) 61 ctrl = self.browser.getControl(name='val_id') 62 p_id = ctrl.options[0] 63 self.browser.open(self.payments_path + '/' + p_id + '/approve') 64 # Add the second instalment ... 65 self.browser.open(self.payments_path + '/addop') 66 self.browser.getControl(name="form.p_category").value = ['schoolfee_2'] 67 self.browser.getControl("Create ticket").click() 68 self.assertTrue('ticket created' in self.browser.contents) 69 # ... approve the second instalment ... 70 ctrl = self.browser.getControl(name='val_id') 71 p_id = ctrl.options[1] 72 self.browser.open(self.payments_path + '/' + p_id + '/approve') 73 self.assertEqual(self.student['payments'].values()[0].p_category, 'schoolfee_1') 74 self.assertEqual(self.student['payments'].values()[1].p_category, 'schoolfee_2') 75 # 79200 / 2 + 300 76 self.assertEqual(self.student['payments'].values()[0].amount_auth, 39900.0) 77 self.assertEqual(self.student['payments'].values()[1].amount_auth, 39900.0) 78 # The two payments belong to the same session and level. 79 self.assertEqual(self.student['payments'].values()[0].p_session, 2004) 80 self.assertEqual(self.student['payments'].values()[0].p_level, 100) 81 self.assertEqual(self.student['payments'].values()[1].p_session, 2004) 82 self.assertEqual(self.student['payments'].values()[1].p_level, 100) 83 84 # Returning student 85 configuration_2 = createObject('waeup.SessionConfiguration') 86 configuration_2.academic_session = 2005 87 self.app['configuration'].addSessionConfiguration(configuration_2) 88 IWorkflowState(self.student).setState('returning') 89 self.browser.open(self.payments_path + '/addop') 90 self.browser.getControl(name="form.p_category").value = ['schoolfee_1'] 91 self.browser.getControl("Create ticket").click() 92 self.browser.open(self.payments_path + '/addop') 93 self.browser.getControl(name="form.p_category").value = ['schoolfee_2'] 94 self.browser.getControl("Create ticket").click() 95 self.browser.open(self.payments_path) 96 ctrl = self.browser.getControl(name='val_id') 97 # Nothing happens if we approve the 2nd instalment for session 2005 98 self.browser.open(self.payments_path + '/' + ctrl.options[3] + '/approve') 99 self.assertEqual(self.student.state, 'returning') 100 # Workflow transition is trigered if we approve the 1st indtalment 101 self.browser.open(self.payments_path + '/' + ctrl.options[2] + '/approve') 102 self.assertEqual(self.student.state, 'school fee paid') 103 self.assertEqual(self.student.current_level, 200) 104 self.assertEqual(self.student.current_session, 2005) 105 # 63100 / 2 + 300 106 self.assertEqual(self.student['payments'].values()[2].amount_auth, 31850.0) 107 self.assertEqual(self.student['payments'].values()[3].amount_auth, 31850.0) 108 # The last two payments belong to the same session and level. 109 self.assertEqual(self.student['payments'].values()[2].p_session, 2005) 110 self.assertEqual(self.student['payments'].values()[2].p_level, 200) 111 self.assertEqual(self.student['payments'].values()[3].p_session, 2005) 112 self.assertEqual(self.student['payments'].values()[3].p_level, 200) 45 113 return -
main/kofacustom.coewarri/trunk/src/kofacustom/coewarri/students/tests/test_utils.py
r14336 r14344 27 27 self.app['configuration']['2016'].clearance_fee = 10234.0 28 28 29 error, payment = utils.setPaymentDetails('schoolfee', self.student)30 self.assertEqual(payment, None)31 self.assertEqual(error, u'Amount could not be determined.')32 IWorkflowState(self.student).setState('cleared')33 29 error, payment = utils.setPaymentDetails('schoolfee',self.student) 34 30 self.assertEqual(payment.p_level, 100) 35 31 self.assertEqual(payment.p_session, 2016) 36 32 self.assertEqual(payment.amount_auth, 79500.0) 33 self.assertEqual(payment.p_item, u'CERT1') 34 self.assertEqual(error, None) 35 36 error, payment = utils.setPaymentDetails('schoolfee_1',self.student) 37 self.assertEqual(payment.p_level, 100) 38 self.assertEqual(payment.p_session, 2016) 39 self.assertEqual(payment.amount_auth, 39900.0) 40 self.assertEqual(payment.p_item, u'CERT1') 41 self.assertEqual(error, None) 42 43 error, payment = utils.setPaymentDetails('schoolfee_2',self.student) 44 self.assertEqual(payment.p_level, 100) 45 self.assertEqual(payment.p_session, 2016) 46 self.assertEqual(payment.amount_auth, 39900.0) 37 47 self.assertEqual(payment.p_item, u'CERT1') 38 48 self.assertEqual(error, None) -
main/kofacustom.coewarri/trunk/src/kofacustom/coewarri/students/utils.py
r14336 r14344 75 75 return _(u'Session configuration object is not available.'), None 76 76 # Determine fee. 77 if category == 'schoolfee':77 if category.startswith('schoolfee'): 78 78 try: 79 79 certificate = student['studycourse'].certificate … … 88 88 return _(u'Session configuration object ' 89 89 'is not available.'), None 90 if student.state in (RETURNING, CLEARED): 91 if p_level in PAYMENT_LEVELS: 92 amount = SCHOOL_FEES.get_fee( 93 ( 94 local_nonlocal(student), 95 student.current_mode, 96 p_level) 97 ) 98 amount += GATEWAY_AMT 90 if p_level in PAYMENT_LEVELS: 91 amount = SCHOOL_FEES.get_fee( 92 ( 93 local_nonlocal(student), 94 student.current_mode, 95 p_level) 96 ) 97 if amount and category in ('schoolfee_1', 'schoolfee_2'): 98 amount /= 2 99 if amount: 100 amount += GATEWAY_AMT 99 101 elif category == 'clearance': 100 102 try:
Note: See TracChangeset for help on using the changeset viewer.